scordi-extension 1.16.2 → 1.16.4
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 +61 -29
- package/dist/blocks/AiParseDataBlock.d.ts.map +1 -1
- package/dist/blocks/EventClickBlock.d.ts.map +1 -1
- package/dist/blocks/ExportDataBlock.d.ts.map +1 -1
- package/dist/blocks/KeypressBlock.d.ts.map +1 -1
- package/dist/blocks/NetworkCatchBlock.d.ts.map +1 -1
- package/dist/blocks/WaitForConditionBlock.d.ts.map +1 -1
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/sdk/EightGClient.d.ts +9 -6
- package/dist/sdk/EightGClient.d.ts.map +1 -1
- package/dist/sdk/index.cjs +4 -4
- package/dist/sdk/index.js +175 -160
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/types/internal-messages.d.ts.map +1 -1
- package/dist/workflow/context/execution-context/binding.d.ts.map +1 -1
- package/dist/workflow/context/execution-context/condition.d.ts.map +1 -1
- package/dist/workflow/context/execution-context/index.d.ts +3 -3
- package/dist/workflow/context/execution-context/index.d.ts.map +1 -1
- package/dist/workflow/context/execution-context/resolver.d.ts.map +1 -1
- package/dist/workflow/context/loop-context/index.d.ts +1 -1
- package/dist/workflow/context/loop-context/index.d.ts.map +1 -1
- package/dist/workflow/context/loop-context/loop-context.d.ts.map +1 -1
- package/dist/workflow/context/loop-context/resolver.d.ts.map +1 -1
- package/dist/workflow/context/step-context/index.d.ts +1 -1
- package/dist/workflow/context/step-context/index.d.ts.map +1 -1
- package/dist/workflow/context/step-context/resolver.d.ts.map +1 -1
- package/dist/workflow/context/step-context/step-context.d.ts.map +1 -1
- package/dist/workflow/context/var-context/index.d.ts +1 -1
- package/dist/workflow/context/var-context/index.d.ts.map +1 -1
- package/dist/workflow/context/var-context/resolver.d.ts.map +1 -1
- package/dist/workflow/context/var-context/var-context.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/.vite/manifest.json +0 -75
- package/dist/assets/index-B45Q7XiR.js +0 -49
- package/dist/assets/index-BqQ8JinV.js +0 -1
- package/dist/assets/index-CVzjlC_s.js +0 -1
- package/dist/assets/index-CYVwV_2L.js +0 -1
- package/dist/assets/index-DkFIvNAm.css +0 -1
- package/dist/assets/index-DxZcS402.js +0 -1
- package/dist/assets/index-tW55lo_h.js +0 -4
- package/dist/assets/index.html-DZ7AUTQZ.js +0 -1
- package/dist/assets/index.ts-2nFLTUkL.js +0 -238
- package/dist/assets/index.ts-BRPHoTRl.js +0 -256
- package/dist/assets/index.ts-C2f2hGoV.js +0 -158
- package/dist/assets/index.ts-CD2jVezi.js +0 -256
- package/dist/assets/index.ts-COMnxBfB.js +0 -238
- package/dist/assets/index.ts-mAOhzdZJ.js +0 -238
- package/dist/assets/internal-messages-BMRA0i8A.js +0 -1
- package/dist/assets/internal-messages-BS1uEgeS.js +0 -1
- package/dist/assets/internal-messages-CP1ANEcL.js +0 -1
- package/dist/assets/internal-messages-Drf0Gb9U.js +0 -1
- package/dist/assets/loading-page-1924caaa.js +0 -51
- package/dist/assets/main.tsx-CHn9k-P7.js +0 -38
- package/dist/assets/main.tsx-DnGNeWWr.js +0 -38
- package/dist/assets/main.tsx-DtStYr-r.js +0 -2
- package/dist/assets/main.tsx-UFslEqbd.js +0 -38
- package/dist/assets/main.tsx-loader-6Ftbg0YS.js +0 -13
- package/dist/assets/main.tsx-loader-ByFSLdJ4.js +0 -13
- package/dist/assets/main.tsx-loader-CuF0J02t.js +0 -13
- package/dist/assets/main.tsx-loader-sjxNXQPw.js +0 -13
- package/dist/assets/types-BId3CBm7.js +0 -1
- package/dist/assets/types-CeXfY5Yv.js +0 -4
- package/dist/assets/types-Dzn4eD9c.js +0 -22
- package/dist/assets/types-q2_wITfk.js +0 -4
- package/dist/blocks/CaptureNetworkBlock.d.ts +0 -75
- package/dist/blocks/CaptureNetworkBlock.d.ts.map +0 -1
- package/dist/blocks/DataExtractBlock.d.ts +0 -23
- package/dist/blocks/DataExtractBlock.d.ts.map +0 -1
- package/dist/blocks/index.cjs +0 -4
- package/dist/blocks/index.js +0 -7839
- package/dist/blocks/logo.png +0 -0
- package/dist/logo.png +0 -0
- package/dist/manifest.json +0 -55
- package/dist/public/logo.png +0 -0
- package/dist/service-worker-loader.js +0 -3
- package/dist/src/blocks/AiParseDataBlock.ts.js +0 -111
- package/dist/src/blocks/CaptureNetworkBlock.ts.js +0 -55
- package/dist/src/blocks/ClearValueFormBlock.ts.js +0 -55
- package/dist/src/blocks/DataExtractBlock.ts.js +0 -28
- package/dist/src/blocks/ElementExistsBlock.ts.js +0 -26
- package/dist/src/blocks/EventClickBlock.ts.js +0 -143
- package/dist/src/blocks/ExportDataBlock.ts.js +0 -47
- package/dist/src/blocks/FetchApiBlock.ts.js +0 -50
- package/dist/src/blocks/GetAttributeValueBlock.ts.js +0 -33
- package/dist/src/blocks/GetElementDataBlock.ts.js +0 -114
- package/dist/src/blocks/GetTextBlock.ts.js +0 -152
- package/dist/src/blocks/GetValueFormBlock.ts.js +0 -52
- package/dist/src/blocks/KeypressBlock.ts.js +0 -89
- package/dist/src/blocks/NavigateBlock.ts.js +0 -48
- package/dist/src/blocks/NetworkCatchBlock.ts.js +0 -61
- package/dist/src/blocks/SaveAssetsBlock.ts.js +0 -35
- package/dist/src/blocks/ScrollBlock.ts.js +0 -111
- package/dist/src/blocks/SetValueFormBlock.ts.js +0 -56
- package/dist/src/blocks/TransformDataBlock.ts.js +0 -42
- package/dist/src/blocks/WaitBlock.ts.js +0 -24
- package/dist/src/blocks/WaitForConditionBlock.ts.js +0 -187
- package/dist/src/blocks/index.ts.js +0 -198
- package/dist/src/blocks/types.ts.js +0 -11
- package/dist/src/content/components/ConfirmationUI.tsx.js +0 -244
- package/dist/src/content/components/ExecutionStatusUI.tsx.js +0 -223
- package/dist/src/content/elements/finders/CssSelector.ts.js +0 -51
- package/dist/src/content/elements/finders/ElementSelector.ts.js +0 -20
- package/dist/src/content/elements/finders/IframeSelector.ts.js +0 -32
- package/dist/src/content/elements/finders/ShadowDOMSelector.ts.js +0 -38
- package/dist/src/content/elements/finders/XPathFinder.ts.js +0 -32
- package/dist/src/content/elements/index.ts.js +0 -26
- package/dist/src/content/elements/utils/CSSSelectorGenerator.ts.js +0 -72
- package/dist/src/content/elements/utils/XPathGenerator.ts.js +0 -62
- package/dist/src/content/handler/ExternalMessageHandler.ts.js +0 -78
- package/dist/src/content/handler/InternalMessageHandler.ts.js +0 -40
- package/dist/src/content/kernel/MessageKernel.ts.js +0 -83
- package/dist/src/content/main.tsx-loader.js +0 -22
- package/dist/src/content/main.tsx.js +0 -50
- package/dist/src/content/utils/index.ts.js +0 -1
- package/dist/src/content/utils/synchronizedLock.ts.js +0 -35
- package/dist/src/popup/index.html +0 -12
- package/dist/src/sdk/types.ts.js +0 -150
- package/dist/src/types/internal-messages.ts.js +0 -27
- package/dist/src/workflow/context/execution-context/types.ts.js +0 -0
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--29d58732.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--34285d49.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--36a0c079.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--7cce5f32.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--8598b0e0.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--9054997c.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--a79cb78d.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--af906259.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--e041f26d.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--e1405dc4.js +0 -45
- package/dist/vendor/.vite-deps-chunk-2TUXWMP5.js__v--e2a1f584.js +0 -45
- package/dist/vendor/.vite-deps-chunk-DC5AMYBS.js__v--87b685c1.js +0 -38
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--29d58732.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--34285d49.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--36a0c079.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--7cce5f32.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--8598b0e0.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--a79cb78d.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--af906259.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--e041f26d.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--e1405dc4.js +0 -975
- package/dist/vendor/.vite-deps-chunk-EL3BNLGW.js__v--e2a1f584.js +0 -975
- package/dist/vendor/.vite-deps-chunk-KDMJ4XM7.js__v--87b685c1.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-MANNBT4V.js__v--87b685c1.js +0 -280
- package/dist/vendor/.vite-deps-chunk-NZP3G7XT.js__v--87b685c1.js +0 -975
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--36a0c079.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--8598b0e0.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--9054997c.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--a79cb78d.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--e041f26d.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-QIBDMRD4.js__v--e2a1f584.js +0 -4158
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--29d58732.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--34285d49.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--7cce5f32.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--af906259.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-UW5CEYRC.js__v--e1405dc4.js +0 -4154
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--29d58732.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--34285d49.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--36a0c079.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--7cce5f32.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--8598b0e0.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--a79cb78d.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--af906259.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--e041f26d.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--e1405dc4.js +0 -280
- package/dist/vendor/.vite-deps-chunk-XHY3JSIG.js__v--e2a1f584.js +0 -280
- package/dist/vendor/.vite-deps-jsonata.js__v--1f855851.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--34285d49.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--370b8ffe.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--7496ecd5.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--7cce5f32.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--8598b0e0.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--989ee283.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--aa4cf553.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--af906259.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--d602c657.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--e041f26d.js +0 -5761
- package/dist/vendor/.vite-deps-jsonata.js__v--e2a1f584.js +0 -5761
- package/dist/vendor/.vite-deps-react-dom.js__v--1217aa43.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--34285d49.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--36c31e85.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--7cce5f32.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--8313ef2c.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--8598b0e0.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--87af57af.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--9967e564.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--af906259.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--e041f26d.js +0 -6
- package/dist/vendor/.vite-deps-react-dom.js__v--e2a1f584.js +0 -6
- package/dist/vendor/.vite-deps-react-dom_client.js__v--05e7db8c.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--34285d49.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--7cce5f32.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--8598b0e0.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--8ec6d0f4.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--a69c8f91.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--aaaed31d.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--af906259.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--e041f26d.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--e2a1f584.js +0 -18108
- package/dist/vendor/.vite-deps-react-dom_client.js__v--f80719e9.js +0 -18108
- package/dist/vendor/.vite-deps-react.js__v--1217aa43.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--34285d49.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--36c31e85.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--7cce5f32.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--8313ef2c.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--8598b0e0.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--87af57af.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--9967e564.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--af906259.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--e041f26d.js +0 -5
- package/dist/vendor/.vite-deps-react.js__v--e2a1f584.js +0 -5
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--1217aa43.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--34285d49.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--36c31e85.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--7cce5f32.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--8313ef2c.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--8598b0e0.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--87af57af.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--9967e564.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--af906259.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--e041f26d.js +0 -281
- package/dist/vendor/.vite-deps-react_jsx-dev-runtime.js__v--e2a1f584.js +0 -281
- package/dist/vendor/.vite-deps-zod.js__v--34285d49.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--6548a37a.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--706a718e.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--7cce5f32.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--8598b0e0.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--9e0f4cc1.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--af906259.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--b73c580c.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--dc9842e6.js +0 -222
- package/dist/vendor/.vite-deps-zod.js__v--e041f26d.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--e2a1f584.js +0 -219
- package/dist/vendor/.vite-deps-zod.js__v--e4714212.js +0 -222
- package/dist/vendor/crx-client-port.js +0 -66
- package/dist/vendor/crx-client-preamble.js +0 -4
- package/dist/vendor/react-refresh.js +0 -670
- package/dist/vendor/vite-client.js +0 -1134
- package/dist/vendor/vite-dist-client-env.mjs.js +0 -24
- package/dist/vendor/webcomponents-custom-elements.js +0 -47
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var Ur=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function an(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ve;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const i={};for(const c of s)i[c]=c;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(f=>typeof s[s[f]]!="number"),c={};for(const f of i)c[f]=s[f];return t.objectValues(c)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const c in s)Object.prototype.hasOwnProperty.call(s,c)&&i.push(c);return i},t.find=(s,i)=>{for(const c of s)if(i(c))return c},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function a(s,i=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(i)}t.joinValues=a,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(ve||(ve={}));var Or;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Or||(Or={}));const z=ve.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wt=t=>{switch(typeof t){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(t)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(t)?z.array:t===null?z.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?z.promise:typeof Map<"u"&&t instanceof Map?z.map:typeof Set<"u"&&t instanceof Set?z.set:typeof Date<"u"&&t instanceof Date?z.date:z.object;default:return z.unknown}},P=ve.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),sn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class rt extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(i){return i.message},a={_errors:[]},s=i=>{for(const c of i.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)a._errors.push(r(c));else{let f=a,w=0;for(;w<c.path.length;){const E=c.path[w];w===c.path.length-1?(f[E]=f[E]||{_errors:[]},f[E]._errors.push(r(c))):f[E]=f[E]||{_errors:[]},f=f[E],w++}}};return s(this),a}static assert(e){if(!(e instanceof rt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ve.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},a=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else a.push(e(s));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}}rt.create=t=>new rt(t);const Bt=(t,e)=>{let r;switch(t.code){case P.invalid_type:t.received===z.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case P.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ve.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:r=`Unrecognized key(s) in object: ${ve.joinValues(t.keys,", ")}`;break;case P.invalid_union:r="Invalid input";break;case P.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ve.joinValues(t.options)}`;break;case P.invalid_enum_value:r=`Invalid enum value. Expected ${ve.joinValues(t.options)}, received '${t.received}'`;break;case P.invalid_arguments:r="Invalid function arguments";break;case P.invalid_return_type:r="Invalid function return type";break;case P.invalid_date:r="Invalid date";break;case P.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:ve.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case P.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case P.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case P.custom:r="Invalid input";break;case P.invalid_intersection_types:r="Intersection results could not be merged";break;case P.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case P.not_finite:r="Number must be finite";break;default:r=e.defaultError,ve.assertNever(t)}return{message:r}};let qr=Bt;function on(t){qr=t}function yr(){return qr}const gr=t=>{const{data:e,path:r,errorMaps:a,issueData:s}=t,i=[...r,...s.path||[]],c={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let f="";const w=a.filter(E=>!!E).slice().reverse();for(const E of w)f=E(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},cn=[];function U(t,e){const r=yr(),a=gr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Bt?void 0:Bt].filter(s=>!!s)});t.common.issues.push(a)}class Ye{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const a=[];for(const s of r){if(s.status==="aborted")return ee;s.status==="dirty"&&e.dirty(),a.push(s.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,r){const a=[];for(const s of r){const i=await s.key,c=await s.value;a.push({key:i,value:c})}return Ye.mergeObjectSync(e,a)}static mergeObjectSync(e,r){const a={};for(const s of r){const{key:i,value:c}=s;if(i.status==="aborted"||c.status==="aborted")return ee;i.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(a[i.value]=c.value)}return{status:e.value,value:a}}}const ee=Object.freeze({status:"aborted"}),Lt=t=>({status:"dirty",value:t}),Ge=t=>({status:"valid",value:t}),Pr=t=>t.status==="aborted",Nr=t=>t.status==="dirty",Ct=t=>t.status==="valid",Gt=t=>typeof Promise<"u"&&t instanceof Promise;var G;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(G||(G={}));class pt{constructor(e,r,a,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=a,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Lr=(t,e)=>{if(Ct(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new rt(t.common.issues);return this._error=r,this._error}}};function ie(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:a,description:s}=t;if(e&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,f)=>{const{message:w}=t;return c.code==="invalid_enum_value"?{message:w??f.defaultError}:typeof f.data>"u"?{message:w??a??f.defaultError}:c.code!=="invalid_type"?{message:f.defaultError}:{message:w??r??f.defaultError}},description:s}}class ce{get description(){return this._def.description}_getType(e){return wt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:wt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ye,ctx:{common:e.parent.common,data:e.data,parsedType:wt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Gt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const a=this.safeParse(e,r);if(a.success)return a.data;throw a.error}safeParse(e,r){const a={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)},s=this._parseSync({data:e,path:a.path,parent:a});return Lr(a,s)}"~validate"(e){var a,s;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return Ct(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(s=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>Ct(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){const a=await this.safeParseAsync(e,r);if(a.success)return a.data;throw a.error}async safeParseAsync(e,r){const a={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)},s=this._parse({data:e,path:a.path,parent:a}),i=await(Gt(s)?s:Promise.resolve(s));return Lr(a,i)}refine(e,r){const a=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{const c=e(s),f=()=>i.addIssue({code:P.custom,...a(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(w=>w?!0:(f(),!1)):c?!0:(f(),!1)})}refinement(e,r){return this._refinement((a,s)=>e(a)?!0:(s.addIssue(typeof r=="function"?r(a,s):r),!1))}_refinement(e){return new lt({schema:this,typeName:re.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){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"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return ht.create(this,this._def)}nullable(){return Dt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ut.create(this)}promise(){return Vt.create(this,this._def)}or(e){return Qt.create([this,e],this._def)}and(e){return er.create(this,e,this._def)}transform(e){return new lt({...ie(this._def),schema:this,typeName:re.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new sr({...ie(this._def),innerType:this,defaultValue:r,typeName:re.ZodDefault})}brand(){return new Mr({typeName:re.ZodBranded,type:this,...ie(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new ir({...ie(this._def),innerType:this,catchValue:r,typeName:re.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return cr.create(this,e)}readonly(){return or.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const un=/^c[^\s-]{8,}$/i,ln=/^[0-9a-z]+$/,fn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,dn=/^[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,hn=/^[a-z0-9_-]{21}$/i,pn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,mn=/^[-+]?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)?)??$/,yn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ar;const vn=/^(?:(?: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])$/,wn=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,_n=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Wr="((\\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])))",En=new RegExp(`^${Wr}$`);function Hr(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Tn(t){return new RegExp(`^${Hr(t)}$`)}function Yr(t){let e=`${Wr}T${Hr(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function An(t,e){return!!((e==="v4"||!e)&&vn.test(t)||(e==="v6"||!e)&&wn.test(t))}function Sn(t,e){if(!pn.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(a));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Dn(t,e){return!!((e==="v4"||!e)&&bn.test(t)||(e==="v6"||!e)&&kn.test(t))}class ct extends ce{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_type,expected:z.string,received:i.parsedType}),ee}const a=new Ye;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const c=e.data.length>i.value,f=e.data.length<i.value;(c||f)&&(s=this._getOrReturnCtx(e,s),c?U(s,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):f&&U(s,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")yn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"email",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Ar||(Ar=new RegExp(gn,"u")),Ar.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"emoji",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")dn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"uuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")hn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"nanoid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")un.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")ln.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid2",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")fn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ulid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),U(s,{validation:"url",code:P.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"regex",code:P.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?Yr(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?En.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?Tn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?mn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"duration",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?An(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ip",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?Sn(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"jwt",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?Dn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cidr",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?xn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?_n.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64url",code:P.invalid_string,message:i.message}),a.dirty()):ve.assertNever(i);return{status:a.value,value:e.data}}_regex(e,r,a){return this.refinement(s=>e.test(s),{validation:r,code:P.invalid_string,...G.errToObj(a)})}_addCheck(e){return new ct({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...G.errToObj(e)})}url(e){return this._addCheck({kind:"url",...G.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...G.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...G.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...G.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...G.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...G.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...G.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...G.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...G.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...G.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...G.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...G.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...G.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...G.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...G.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...G.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...G.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...G.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...G.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...G.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...G.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...G.errToObj(r)})}nonempty(e){return this.min(1,G.errToObj(e))}trim(){return new ct({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ct({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ct({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}ct.create=t=>new ct({checks:[],typeName:re.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...ie(t)});function On(t,e){const r=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,s=r>a?r:a,i=Number.parseInt(t.toFixed(s).replace(".","")),c=Number.parseInt(e.toFixed(s).replace(".",""));return i%c/10**s}class Tt extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_type,expected:z.number,received:i.parsedType}),ee}let a;const s=new Ye;for(const i of this._def.checks)i.kind==="int"?ve.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:P.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?On(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:P.not_finite,message:i.message}),s.dirty()):ve.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,G.toString(r))}gt(e,r){return this.setLimit("min",e,!1,G.toString(r))}lte(e,r){return this.setLimit("max",e,!0,G.toString(r))}lt(e,r){return this.setLimit("max",e,!1,G.toString(r))}setLimit(e,r,a,s){return new Tt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:G.toString(s)}]})}_addCheck(e){return new Tt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:G.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:G.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:G.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:G.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:G.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:G.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ve.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Tt.create=t=>new Tt({checks:[],typeName:re.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...ie(t)});class At extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==z.bigint)return this._getInvalidInput(e);let a;const s=new Ye;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),U(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):ve.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return U(r,{code:P.invalid_type,expected:z.bigint,received:r.parsedType}),ee}gte(e,r){return this.setLimit("min",e,!0,G.toString(r))}gt(e,r){return this.setLimit("min",e,!1,G.toString(r))}lte(e,r){return this.setLimit("max",e,!0,G.toString(r))}lt(e,r){return this.setLimit("max",e,!1,G.toString(r))}setLimit(e,r,a,s){return new At({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:G.toString(s)}]})}_addCheck(e){return new At({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:G.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:G.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}At.create=t=>new At({checks:[],typeName:re.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...ie(t)});class Kt extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:z.boolean,received:a.parsedType}),ee}return Ge(e.data)}}Kt.create=t=>new Kt({typeName:re.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...ie(t)});class Rt extends ce{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_type,expected:z.date,received:i.parsedType}),ee}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_date}),ee}const a=new Ye;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):ve.assertNever(i);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Rt({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:G.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:G.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Rt.create=t=>new Rt({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:re.ZodDate,...ie(t)});class vr extends ce{_parse(e){if(this._getType(e)!==z.symbol){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:z.symbol,received:a.parsedType}),ee}return Ge(e.data)}}vr.create=t=>new vr({typeName:re.ZodSymbol,...ie(t)});class Jt extends ce{_parse(e){if(this._getType(e)!==z.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:z.undefined,received:a.parsedType}),ee}return Ge(e.data)}}Jt.create=t=>new Jt({typeName:re.ZodUndefined,...ie(t)});class Xt extends ce{_parse(e){if(this._getType(e)!==z.null){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:z.null,received:a.parsedType}),ee}return Ge(e.data)}}Xt.create=t=>new Xt({typeName:re.ZodNull,...ie(t)});class zt extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return Ge(e.data)}}zt.create=t=>new zt({typeName:re.ZodAny,...ie(t)});class Nt extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ge(e.data)}}Nt.create=t=>new Nt({typeName:re.ZodUnknown,...ie(t)});class kt extends ce{_parse(e){const r=this._getOrReturnCtx(e);return U(r,{code:P.invalid_type,expected:z.never,received:r.parsedType}),ee}}kt.create=t=>new kt({typeName:re.ZodNever,...ie(t)});class br extends ce{_parse(e){if(this._getType(e)!==z.undefined){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:z.void,received:a.parsedType}),ee}return Ge(e.data)}}br.create=t=>new br({typeName:re.ZodVoid,...ie(t)});class ut extends ce{_parse(e){const{ctx:r,status:a}=this._processInputParams(e),s=this._def;if(r.parsedType!==z.array)return U(r,{code:P.invalid_type,expected:z.array,received:r.parsedType}),ee;if(s.exactLength!==null){const c=r.data.length>s.exactLength.value,f=r.data.length<s.exactLength.value;(c||f)&&(U(r,{code:c?P.too_big:P.too_small,minimum:f?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(U(r,{code:P.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(U(r,{code:P.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((c,f)=>s.type._parseAsync(new pt(r,c,r.path,f)))).then(c=>Ye.mergeArray(a,c));const i=[...r.data].map((c,f)=>s.type._parseSync(new pt(r,c,r.path,f)));return Ye.mergeArray(a,i)}get element(){return this._def.type}min(e,r){return new ut({...this._def,minLength:{value:e,message:G.toString(r)}})}max(e,r){return new ut({...this._def,maxLength:{value:e,message:G.toString(r)}})}length(e,r){return new ut({...this._def,exactLength:{value:e,message:G.toString(r)}})}nonempty(e){return this.min(1,e)}}ut.create=(t,e)=>new ut({type:t,minLength:null,maxLength:null,exactLength:null,typeName:re.ZodArray,...ie(e)});function Ut(t){if(t instanceof Me){const e={};for(const r in t.shape){const a=t.shape[r];e[r]=ht.create(Ut(a))}return new Me({...t._def,shape:()=>e})}else return t instanceof ut?new ut({...t._def,type:Ut(t.element)}):t instanceof ht?ht.create(Ut(t.unwrap())):t instanceof Dt?Dt.create(Ut(t.unwrap())):t instanceof mt?mt.create(t.items.map(e=>Ut(e))):t}class Me extends ce{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=ve.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==z.object){const E=this._getOrReturnCtx(e);return U(E,{code:P.invalid_type,expected:z.object,received:E.parsedType}),ee}const{status:a,ctx:s}=this._processInputParams(e),{shape:i,keys:c}=this._getCached(),f=[];if(!(this._def.catchall instanceof kt&&this._def.unknownKeys==="strip"))for(const E in s.data)c.includes(E)||f.push(E);const w=[];for(const E of c){const M=i[E],S=s.data[E];w.push({key:{status:"valid",value:E},value:M._parse(new pt(s,S,s.path,E)),alwaysSet:E in s.data})}if(this._def.catchall instanceof kt){const E=this._def.unknownKeys;if(E==="passthrough")for(const M of f)w.push({key:{status:"valid",value:M},value:{status:"valid",value:s.data[M]}});else if(E==="strict")f.length>0&&(U(s,{code:P.unrecognized_keys,keys:f}),a.dirty());else if(E!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const E=this._def.catchall;for(const M of f){const S=s.data[M];w.push({key:{status:"valid",value:M},value:E._parse(new pt(s,S,s.path,M)),alwaysSet:M in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const E=[];for(const M of w){const S=await M.key,k=await M.value;E.push({key:S,value:k,alwaysSet:M.alwaysSet})}return E}).then(E=>Ye.mergeObjectSync(a,E)):Ye.mergeObjectSync(a,w)}get shape(){return this._def.shape()}strict(e){return G.errToObj,new Me({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,a)=>{var i,c;const s=((c=(i=this._def).errorMap)==null?void 0:c.call(i,r,a).message)??a.defaultError;return r.code==="unrecognized_keys"?{message:G.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Me({...this._def,unknownKeys:"strip"})}passthrough(){return new Me({...this._def,unknownKeys:"passthrough"})}extend(e){return new Me({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Me({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:re.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Me({...this._def,catchall:e})}pick(e){const r={};for(const a of ve.objectKeys(e))e[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new Me({...this._def,shape:()=>r})}omit(e){const r={};for(const a of ve.objectKeys(this.shape))e[a]||(r[a]=this.shape[a]);return new Me({...this._def,shape:()=>r})}deepPartial(){return Ut(this)}partial(e){const r={};for(const a of ve.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?r[a]=s:r[a]=s.optional()}return new Me({...this._def,shape:()=>r})}required(e){const r={};for(const a of ve.objectKeys(this.shape))if(e&&!e[a])r[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof ht;)i=i._def.innerType;r[a]=i}return new Me({...this._def,shape:()=>r})}keyof(){return Gr(ve.objectKeys(this.shape))}}Me.create=(t,e)=>new Me({shape:()=>t,unknownKeys:"strip",catchall:kt.create(),typeName:re.ZodObject,...ie(e)});Me.strictCreate=(t,e)=>new Me({shape:()=>t,unknownKeys:"strict",catchall:kt.create(),typeName:re.ZodObject,...ie(e)});Me.lazycreate=(t,e)=>new Me({shape:t,unknownKeys:"strip",catchall:kt.create(),typeName:re.ZodObject,...ie(e)});class Qt extends ce{_parse(e){const{ctx:r}=this._processInputParams(e),a=this._def.options;function s(i){for(const f of i)if(f.result.status==="valid")return f.result;for(const f of i)if(f.result.status==="dirty")return r.common.issues.push(...f.ctx.common.issues),f.result;const c=i.map(f=>new rt(f.ctx.common.issues));return U(r,{code:P.invalid_union,unionErrors:c}),ee}if(r.common.async)return Promise.all(a.map(async i=>{const c={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:c}),ctx:c}})).then(s);{let i;const c=[];for(const w of a){const E={...r,common:{...r.common,issues:[]},parent:null},M=w._parseSync({data:r.data,path:r.path,parent:E});if(M.status==="valid")return M;M.status==="dirty"&&!i&&(i={result:M,ctx:E}),E.common.issues.length&&c.push(E.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const f=c.map(w=>new rt(w));return U(r,{code:P.invalid_union,unionErrors:f}),ee}}get options(){return this._def.options}}Qt.create=(t,e)=>new Qt({options:t,typeName:re.ZodUnion,...ie(e)});const bt=t=>t instanceof rr?bt(t.schema):t instanceof lt?bt(t.innerType()):t instanceof nr?[t.value]:t instanceof St?t.options:t instanceof ar?ve.objectValues(t.enum):t instanceof sr?bt(t._def.innerType):t instanceof Jt?[void 0]:t instanceof Xt?[null]:t instanceof ht?[void 0,...bt(t.unwrap())]:t instanceof Dt?[null,...bt(t.unwrap())]:t instanceof Mr||t instanceof or?bt(t.unwrap()):t instanceof ir?bt(t._def.innerType):[];class Er extends ce{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.object)return U(r,{code:P.invalid_type,expected:z.object,received:r.parsedType}),ee;const a=this.discriminator,s=r.data[a],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(U(r,{code:P.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),ee)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,a){const s=new Map;for(const i of r){const c=bt(i.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const f of c){if(s.has(f))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(f)}`);s.set(f,i)}}return new Er({typeName:re.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...ie(a)})}}function Cr(t,e){const r=wt(t),a=wt(e);if(t===e)return{valid:!0,data:t};if(r===z.object&&a===z.object){const s=ve.objectKeys(e),i=ve.objectKeys(t).filter(f=>s.indexOf(f)!==-1),c={...t,...e};for(const f of i){const w=Cr(t[f],e[f]);if(!w.valid)return{valid:!1};c[f]=w.data}return{valid:!0,data:c}}else if(r===z.array&&a===z.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const c=t[i],f=e[i],w=Cr(c,f);if(!w.valid)return{valid:!1};s.push(w.data)}return{valid:!0,data:s}}else return r===z.date&&a===z.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class er extends ce{_parse(e){const{status:r,ctx:a}=this._processInputParams(e),s=(i,c)=>{if(Pr(i)||Pr(c))return ee;const f=Cr(i.value,c.value);return f.valid?((Nr(i)||Nr(c))&&r.dirty(),{status:r.value,value:f.data}):(U(a,{code:P.invalid_intersection_types}),ee)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,c])=>s(i,c)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}er.create=(t,e,r)=>new er({left:t,right:e,typeName:re.ZodIntersection,...ie(r)});class mt extends ce{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.array)return U(a,{code:P.invalid_type,expected:z.array,received:a.parsedType}),ee;if(a.data.length<this._def.items.length)return U(a,{code:P.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&a.data.length>this._def.items.length&&(U(a,{code:P.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...a.data].map((c,f)=>{const w=this._def.items[f]||this._def.rest;return w?w._parse(new pt(a,c,a.path,f)):null}).filter(c=>!!c);return a.common.async?Promise.all(i).then(c=>Ye.mergeArray(r,c)):Ye.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new mt({...this._def,rest:e})}}mt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new mt({items:t,typeName:re.ZodTuple,rest:null,...ie(e)})};class tr extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.object)return U(a,{code:P.invalid_type,expected:z.object,received:a.parsedType}),ee;const s=[],i=this._def.keyType,c=this._def.valueType;for(const f in a.data)s.push({key:i._parse(new pt(a,f,a.path,f)),value:c._parse(new pt(a,a.data[f],a.path,f)),alwaysSet:f in a.data});return a.common.async?Ye.mergeObjectAsync(r,s):Ye.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,a){return r instanceof ce?new tr({keyType:e,valueType:r,typeName:re.ZodRecord,...ie(a)}):new tr({keyType:ct.create(),valueType:e,typeName:re.ZodRecord,...ie(r)})}}class wr extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.map)return U(a,{code:P.invalid_type,expected:z.map,received:a.parsedType}),ee;const s=this._def.keyType,i=this._def.valueType,c=[...a.data.entries()].map(([f,w],E)=>({key:s._parse(new pt(a,f,a.path,[E,"key"])),value:i._parse(new pt(a,w,a.path,[E,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const w of c){const E=await w.key,M=await w.value;if(E.status==="aborted"||M.status==="aborted")return ee;(E.status==="dirty"||M.status==="dirty")&&r.dirty(),f.set(E.value,M.value)}return{status:r.value,value:f}})}else{const f=new Map;for(const w of c){const E=w.key,M=w.value;if(E.status==="aborted"||M.status==="aborted")return ee;(E.status==="dirty"||M.status==="dirty")&&r.dirty(),f.set(E.value,M.value)}return{status:r.value,value:f}}}}wr.create=(t,e,r)=>new wr({valueType:e,keyType:t,typeName:re.ZodMap,...ie(r)});class Mt extends ce{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==z.set)return U(a,{code:P.invalid_type,expected:z.set,received:a.parsedType}),ee;const s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(U(a,{code:P.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&a.data.size>s.maxSize.value&&(U(a,{code:P.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const i=this._def.valueType;function c(w){const E=new Set;for(const M of w){if(M.status==="aborted")return ee;M.status==="dirty"&&r.dirty(),E.add(M.value)}return{status:r.value,value:E}}const f=[...a.data.values()].map((w,E)=>i._parse(new pt(a,w,a.path,E)));return a.common.async?Promise.all(f).then(w=>c(w)):c(f)}min(e,r){return new Mt({...this._def,minSize:{value:e,message:G.toString(r)}})}max(e,r){return new Mt({...this._def,maxSize:{value:e,message:G.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Mt.create=(t,e)=>new Mt({valueType:t,minSize:null,maxSize:null,typeName:re.ZodSet,...ie(e)});class Zt extends ce{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.function)return U(r,{code:P.invalid_type,expected:z.function,received:r.parsedType}),ee;function a(f,w){return gr({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yr(),Bt].filter(E=>!!E),issueData:{code:P.invalid_arguments,argumentsError:w}})}function s(f,w){return gr({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yr(),Bt].filter(E=>!!E),issueData:{code:P.invalid_return_type,returnTypeError:w}})}const i={errorMap:r.common.contextualErrorMap},c=r.data;if(this._def.returns instanceof Vt){const f=this;return Ge(async function(...w){const E=new rt([]),M=await f._def.args.parseAsync(w,i).catch(A=>{throw E.addIssue(a(w,A)),E}),S=await Reflect.apply(c,this,M);return await f._def.returns._def.type.parseAsync(S,i).catch(A=>{throw E.addIssue(s(S,A)),E})})}else{const f=this;return Ge(function(...w){const E=f._def.args.safeParse(w,i);if(!E.success)throw new rt([a(w,E.error)]);const M=Reflect.apply(c,this,E.data),S=f._def.returns.safeParse(M,i);if(!S.success)throw new rt([s(M,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Zt({...this._def,args:mt.create(e).rest(Nt.create())})}returns(e){return new Zt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,a){return new Zt({args:e||mt.create([]).rest(Nt.create()),returns:r||Nt.create(),typeName:re.ZodFunction,...ie(a)})}}class rr extends ce{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}rr.create=(t,e)=>new rr({getter:t,typeName:re.ZodLazy,...ie(e)});class nr extends ce{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return U(r,{received:r.data,code:P.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:e.data}}get value(){return this._def.value}}nr.create=(t,e)=>new nr({value:t,typeName:re.ZodLiteral,...ie(e)});function Gr(t,e){return new St({values:t,typeName:re.ZodEnum,...ie(e)})}class St extends ce{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),a=this._def.values;return U(r,{expected:ve.joinValues(a),received:r.parsedType,code:P.invalid_type}),ee}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),a=this._def.values;return U(r,{received:r.data,code:P.invalid_enum_value,options:a}),ee}return Ge(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return St.create(e,{...this._def,...r})}exclude(e,r=this._def){return St.create(this.options.filter(a=>!e.includes(a)),{...this._def,...r})}}St.create=Gr;class ar extends ce{_parse(e){const r=ve.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==z.string&&a.parsedType!==z.number){const s=ve.objectValues(r);return U(a,{expected:ve.joinValues(s),received:a.parsedType,code:P.invalid_type}),ee}if(this._cache||(this._cache=new Set(ve.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=ve.objectValues(r);return U(a,{received:a.data,code:P.invalid_enum_value,options:s}),ee}return Ge(e.data)}get enum(){return this._def.values}}ar.create=(t,e)=>new ar({values:t,typeName:re.ZodNativeEnum,...ie(e)});class Vt extends ce{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.promise&&r.common.async===!1)return U(r,{code:P.invalid_type,expected:z.promise,received:r.parsedType}),ee;const a=r.parsedType===z.promise?r.data:Promise.resolve(r.data);return Ge(a.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Vt.create=(t,e)=>new Vt({type:t,typeName:re.ZodPromise,...ie(e)});class lt extends ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===re.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:a}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:c=>{U(a,c),c.fatal?r.abort():r.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const c=s.transform(a.data,i);if(a.common.async)return Promise.resolve(c).then(async f=>{if(r.value==="aborted")return ee;const w=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return w.status==="aborted"?ee:w.status==="dirty"||r.value==="dirty"?Lt(w.value):w});{if(r.value==="aborted")return ee;const f=this._def.schema._parseSync({data:c,path:a.path,parent:a});return f.status==="aborted"?ee:f.status==="dirty"||r.value==="dirty"?Lt(f.value):f}}if(s.type==="refinement"){const c=f=>{const w=s.refinement(f,i);if(a.common.async)return Promise.resolve(w);if(w instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(a.common.async===!1){const f=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return f.status==="aborted"?ee:(f.status==="dirty"&&r.dirty(),c(f.value),{status:r.value,value:f.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(f=>f.status==="aborted"?ee:(f.status==="dirty"&&r.dirty(),c(f.value).then(()=>({status:r.value,value:f.value}))))}if(s.type==="transform")if(a.common.async===!1){const c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Ct(c))return ee;const f=s.transform(c.value,i);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:f}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>Ct(c)?Promise.resolve(s.transform(c.value,i)).then(f=>({status:r.value,value:f})):ee);ve.assertNever(s)}}lt.create=(t,e,r)=>new lt({schema:t,typeName:re.ZodEffects,effect:e,...ie(r)});lt.createWithPreprocess=(t,e,r)=>new lt({schema:e,effect:{type:"preprocess",transform:t},typeName:re.ZodEffects,...ie(r)});class ht extends ce{_parse(e){return this._getType(e)===z.undefined?Ge(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ht.create=(t,e)=>new ht({innerType:t,typeName:re.ZodOptional,...ie(e)});class Dt extends ce{_parse(e){return this._getType(e)===z.null?Ge(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Dt.create=(t,e)=>new Dt({innerType:t,typeName:re.ZodNullable,...ie(e)});class sr extends ce{_parse(e){const{ctx:r}=this._processInputParams(e);let a=r.data;return r.parsedType===z.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}sr.create=(t,e)=>new sr({innerType:t,typeName:re.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class ir extends ce{_parse(e){const{ctx:r}=this._processInputParams(e),a={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Gt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new rt(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new rt(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}ir.create=(t,e)=>new ir({innerType:t,typeName:re.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class kr extends ce{_parse(e){if(this._getType(e)!==z.nan){const a=this._getOrReturnCtx(e);return U(a,{code:P.invalid_type,expected:z.nan,received:a.parsedType}),ee}return{status:"valid",value:e.data}}}kr.create=t=>new kr({typeName:re.ZodNaN,...ie(t)});const Pn=Symbol("zod_brand");class Mr extends ce{_parse(e){const{ctx:r}=this._processInputParams(e),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}}class cr extends ce{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?ee:i.status==="dirty"?(r.dirty(),Lt(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?ee:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}static create(e,r){return new cr({in:e,out:r,typeName:re.ZodPipeline})}}class or extends ce{_parse(e){const r=this._def.innerType._parse(e),a=s=>(Ct(s)&&(s.value=Object.freeze(s.value)),s);return Gt(r)?r.then(s=>a(s)):a(r)}unwrap(){return this._def.innerType}}or.create=(t,e)=>new or({innerType:t,typeName:re.ZodReadonly,...ie(e)});function Zr(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Kr(t,e={},r){return t?zt.create().superRefine((a,s)=>{const i=t(a);if(i instanceof Promise)return i.then(c=>{if(!c){const f=Zr(e,a),w=f.fatal??r??!0;s.addIssue({code:"custom",...f,fatal:w})}});if(!i){const c=Zr(e,a),f=c.fatal??r??!0;s.addIssue({code:"custom",...c,fatal:f})}}):zt.create()}const Nn={object:Me.lazycreate};var re;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(re||(re={}));const Cn=(t,e={message:`Input not instance of ${t.name}`})=>Kr(r=>r instanceof t,e),xr=ct.create,jr=Tt.create,Rn=kr.create,Mn=At.create,_r=Kt.create,jn=Rt.create,In=vr.create,Fn=Jt.create,$n=Xt.create,Un=zt.create,Ln=Nt.create,Zn=kt.create,Bn=br.create,zn=ut.create,Rr=Me.create,Vn=Me.strictCreate,qn=Qt.create,Wn=Er.create,Hn=er.create,Yn=mt.create,Gn=tr.create,Kn=wr.create,Jn=Mt.create,Xn=Zt.create,Qn=rr.create,ea=nr.create,Jr=St.create,ta=ar.create,ra=Vt.create,Br=lt.create,na=ht.create,aa=Dt.create,sa=lt.createWithPreprocess,ia=cr.create,oa=()=>xr().optional(),ca=()=>jr().optional(),ua=()=>_r().optional(),la={string:(t=>ct.create({...t,coerce:!0})),number:(t=>Tt.create({...t,coerce:!0})),boolean:(t=>Kt.create({...t,coerce:!0})),bigint:(t=>At.create({...t,coerce:!0})),date:(t=>Rt.create({...t,coerce:!0}))},fa=ee,D=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Pn,DIRTY:Lt,EMPTY_PATH:cn,INVALID:ee,NEVER:fa,OK:Ge,ParseStatus:Ye,Schema:ce,ZodAny:zt,ZodArray:ut,ZodBigInt:At,ZodBoolean:Kt,ZodBranded:Mr,ZodCatch:ir,ZodDate:Rt,ZodDefault:sr,ZodDiscriminatedUnion:Er,ZodEffects:lt,ZodEnum:St,ZodError:rt,get ZodFirstPartyTypeKind(){return re},ZodFunction:Zt,ZodIntersection:er,ZodIssueCode:P,ZodLazy:rr,ZodLiteral:nr,ZodMap:wr,ZodNaN:kr,ZodNativeEnum:ar,ZodNever:kt,ZodNull:Xt,ZodNullable:Dt,ZodNumber:Tt,ZodObject:Me,ZodOptional:ht,ZodParsedType:z,ZodPipeline:cr,ZodPromise:Vt,ZodReadonly:or,ZodRecord:tr,ZodSchema:ce,ZodSet:Mt,ZodString:ct,ZodSymbol:vr,ZodTransformer:lt,ZodTuple:mt,ZodType:ce,ZodUndefined:Jt,ZodUnion:Qt,ZodUnknown:Nt,ZodVoid:br,addIssueToContext:U,any:Un,array:zn,bigint:Mn,boolean:_r,coerce:la,custom:Kr,date:jn,datetimeRegex:Yr,defaultErrorMap:Bt,discriminatedUnion:Wn,effect:Br,enum:Jr,function:Xn,getErrorMap:yr,getParsedType:wt,instanceof:Cn,intersection:Hn,isAborted:Pr,isAsync:Gt,isDirty:Nr,isValid:Ct,late:Nn,lazy:Qn,literal:ea,makeIssue:gr,map:Kn,nan:Rn,nativeEnum:ta,never:Zn,null:$n,nullable:aa,number:jr,object:Rr,get objectUtil(){return Or},oboolean:ua,onumber:ca,optional:na,ostring:oa,pipeline:ia,preprocess:sa,promise:ra,quotelessJson:sn,record:Gn,set:Jn,setErrorMap:on,strictObject:Vn,string:xr,symbol:In,transformer:Br,tuple:Yn,undefined:Fn,union:qn,unknown:Ln,get util(){return ve},void:Bn},Symbol.toStringTag,{value:"Module"})),yt=Rr({name:xr(),selector:xr(),findBy:Jr(["cssSelector","xpath"]),option:Rr({waitForSelector:_r().optional(),waitSelectorTimeout:jr().optional(),multiple:_r().optional()})}),da=D.object({type:D.literal("object"),shape:D.record(D.string(),D.any())}),ha=D.object({type:D.literal("array"),items:D.any()}),pa=D.discriminatedUnion("type",[da,ha]),ma=D.object({name:D.literal("ai-parse-data"),sourceData:D.any().optional(),schemaDefinition:pa,prompt:D.string().optional(),model:D.string().optional(),apiKey:D.string().min(1,"AI API key is required"),provider:D.enum(["openai","anthropic"])});function rs(t){return ma.parse(t)}async function ns(t){try{const{sourceData:e,schemaDefinition:r,prompt:a,model:s,apiKey:i,provider:c}=t;if(e==null)throw new Error("sourceData is required for ai-parse-data block");if(!i||i.trim()==="")throw new Error("apiKey is required for ai-parse-data block");const f=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:r,prompt:a,model:s,apiKey:i,provider:c}});if(f.$isError)throw new Error(f.message||"AI parsing failed");return{data:f.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}class Tr{async waitForElement(e,r,a){return new Promise(s=>{const i=Date.now(),c=async()=>{const f=await this.find(e,r);if(f&&(!Array.isArray(f)||f.length>0)){s(f);return}if(Date.now()-i>=a){s(null);return}setTimeout(c,100)};c()})}}class ya extends Tr{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=this.processCustomPseudoSelectors(a,r);return i?Array.from(r.querySelectorAll(c)):r.querySelector(c)}catch(c){return console.error("CSS Selector error:",c),null}}processCustomPseudoSelectors(e,r){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-contains="${c}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-equal="${c}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const s=((i=a.textContent)==null?void 0:i.trim())||"";if(s){a.setAttribute("data-contains",s);const f=Array.from(a.childNodes).filter(w=>w.nodeType===Node.TEXT_NODE).map(w=>{var E;return((E=w.textContent)==null?void 0:E.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class ga extends Tr{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split("|>").map(E=>E.trim());if(c.length!==2)return null;const f=c[0],w=c[1];if(!f||!w)return null;try{const E=r.querySelector(f);if(!E||!E.contentDocument)return null;const M=E.contentDocument;return i?Array.from(M.querySelectorAll(w)):M.querySelector(w)}catch(E){return console.error("Iframe Selector error:",E),null}}}class va extends Tr{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split(">>").map(w=>w.trim());let f=r;try{for(let w=0;w<c.length;w++){const E=c[w],M=w===c.length-1;if(!E)return null;if(M&&i)return Array.from(f.querySelectorAll(E));const S=f.querySelector(E);if(!S)return null;if(M)return S;if(S.shadowRoot)f=S.shadowRoot;else return null}}catch(w){return console.error("Shadow DOM Selector error:",w),null}return null}}class ba extends Tr{async find(e,r=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=r.evaluate(a,r,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const f=[];for(let w=0;w<c.snapshotLength;w++){const E=c.snapshotItem(w);E&&E.nodeType===Node.ELEMENT_NODE&&f.push(E)}return Promise.resolve(f.length>0?f:null)}else{const f=c.singleNodeValue;return f&&f.nodeType===Node.ELEMENT_NODE?f:null}}catch(c){return console.error("XPath error:",c),null}}}class wa{static generate(e){const r=["data-testid","aria-label","title","alt","role"];for(const i of r){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const a=e.tagName.toLowerCase(),s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${c})`}if(s){const i=this.generateParentSelector(s);if(i)return`${i} > ${a}:nth-child(${Array.from(s.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const r=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${r}:nth-child(${c})`}return r}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/].some(a=>a.test(e))}}async function ft(t,e=document){const{selector:r,findBy:a="cssSelector",option:s}=t,{waitForSelector:i=!1,waitSelectorTimeout:c=5e3}=s||{},f=ka(r,a);return i?f.waitForElement(t,e,c):f.find(t,e)}function ka(t,e){return e==="xpath"?new ba:t.includes(">>")?new va:t.includes("|>")?new ga:new ya}const xa=yt.extend({name:D.literal("get-text"),includeTags:D.boolean().optional(),useTextContent:D.boolean().optional(),regex:D.string().optional(),prefixText:D.string().optional(),suffixText:D.string().optional(),filterEmpty:D.boolean().optional(),scrollToCollect:D.boolean().optional(),scrollDistance:D.number().optional(),scrollWaitMs:D.number().optional(),maxScrollAttempts:D.number().optional()});function as(t){return xa.parse(t)}async function ss(t){try{const{selector:e="",includeTags:r=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:w,filterEmpty:E=!0,scrollToCollect:M=!1,scrollDistance:S=500,scrollWaitMs:k=300,maxScrollAttempts:A=100}=t;if(!e)throw new Error("Selector is required for get-text block");if(M&&(w!=null&&w.multiple))return await _a({selector:e,findBy:f,option:w,includeTags:r,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:E,scrollDistance:S,scrollWaitMs:k,maxScrollAttempts:A});const j=await ft({selector:e,findBy:f,option:w});if(!j)return{data:""};const se=Xr(r,a,s,i,c);if(Array.isArray(j)){const pe=j.map(se);return{data:E?pe.filter(H=>H.trim()!==""):pe}}else return{data:se(j)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function _a(t){const{selector:e,findBy:r,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:w,filterEmpty:E,scrollDistance:M,scrollWaitMs:S,maxScrollAttempts:k}=t,A=Xr(s,i,c,f,w),j=new Set;let se=0,pe=0;const ye=5;for(;se<k;){const H=await ft({selector:e,findBy:r,option:a});if(H&&Array.isArray(H)){const Z=j.size;if(H.forEach(L=>{const V=A(L);(!E||V.trim()!=="")&&j.add(V)}),j.size===Z){if(pe++,pe>=ye)break}else pe=0}const C=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:M,behavior:"auto"}),await new Promise(Z=>setTimeout(Z,S)),(window.pageYOffset||document.documentElement.scrollTop)===C)break;se++}return{data:Array.from(j)}}function Xr(t,e,r,a="",s=""){return i=>{let c="";if(t?c=i.innerHTML:c=e?i.textContent||"":i.innerText||"",r){const f=new RegExp(r,"g"),w=c.match(f);c=w?w.join(" "):""}return c.trim()&&(c=a+c.trim()+s),c}}const Ea=yt.extend({name:D.literal("attribute-value"),attributeName:D.string()});function is(t){return Ea.parse(t)}async function os(t){try{const{selector:e="",attributeName:r,findBy:a="cssSelector",option:s}=t;if(!e)throw new Error("Selector is required for attribute-value block");if(!r)throw new Error("Attribute name is required for attribute-value block");const i=await ft({selector:e,findBy:a,option:s});return i?{data:Array.isArray(i)?i.map(f=>f.getAttribute(r)).filter(f=>f!==null):i.getAttribute(r)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const Ta=yt.extend({name:D.literal("get-value-form"),type:D.enum(["text-field","select","checkbox"]).optional()});function cs(t){return Ta.parse(t)}async function us(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for get-value-form block");const s=await ft({selector:e,findBy:a,option:t.option});if(!s)throw new Error("Form element not found");return{data:Aa(s,r)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function Aa(t,e){switch(e){case"text-field":if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)return t.value;break;case"select":if(t instanceof HTMLSelectElement)return t.value;break;case"checkbox":if(t instanceof HTMLInputElement&&t.type==="checkbox")return t.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const Sa=yt.extend({name:D.literal("set-value-form"),setValue:D.string(),type:D.enum(["text-field","select","checkbox"]).optional()});function ls(t){return Sa.parse(t)}async function fs(t){try{const{selector:e="",setValue:r,type:a="text-field",findBy:s="cssSelector"}=t;if(!e)throw new Error("Selector is required for set-value-form block");const i=await ft({selector:e,findBy:s,option:t.option});if(!i)throw new Error("Form element not found");return Da(i,r,a),{data:"Form element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-value-form handler",data:null}}}function Da(t,e,r){switch(r){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.value=e,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=e==="true"||e==="checked",t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${r}`)}}const Oa=yt.extend({name:D.literal("clear-value-form"),type:D.enum(["text-field","select","checkbox"]).optional()});function ds(t){return Oa.parse(t)}async function hs(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for clear-value-form block");const s=await ft({selector:e,findBy:a,option:t.option});if(!s)throw new Error("Form element not found");return Pa(s,r),{data:"Form element cleared successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in clear-value-form handler",data:null}}}function Pa(t,e){switch(e){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value="",t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.selectedIndex=0,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=!1,t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Na=yt.extend({name:D.literal("element-exists")});function ps(t){return Na.parse(t)}async function ms(t){try{const{selector:e="",findBy:r="cssSelector",option:a}=t;if(!e)throw new Error("Selector is required for element-exists block");return{data:await ft({selector:e,findBy:r,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Ca=yt.extend({name:D.literal("event-click"),textFilter:D.object({text:D.union([D.string(),D.array(D.string())]),mode:D.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function ys(t){return Ca.parse(t)}async function gs(t){try{const{selector:e="",findBy:r="cssSelector",option:a,textFilter:s}=t;if(!e)throw new Error("Selector is required for event-click block");const i=await ft({selector:e,findBy:r,option:a});if(!i)throw new Error("Element not found for clicking");let c;if(Array.isArray(i))if(s){const f=Ra(i,s.text,s.mode);if(!f){const w=Array.isArray(s.text)?s.text.join(", "):s.text;throw new Error(`No element found with text filter: "${w}" (mode: ${s.mode})`)}c=f}else c=i[0];else c=i;return await ja(c),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in event-click handler",data:!1}}}function Ra(t,e,r){for(const a of t){const s=Ma(a),i=Array.isArray(e)?e:[e];for(const c of i){let f=!1;switch(r){case"exact":f=s===c;break;case"contains":f=s.includes(c);break;case"startsWith":f=s.startsWith(c);break;case"endsWith":f=s.endsWith(c);break;case"regex":try{f=new RegExp(c).test(s)}catch{console.warn("Invalid regex pattern:",c);continue}break}if(f)return a}}return null}function Ma(t){if(t.innerText)return t.innerText.trim();if(t.textContent)return t.textContent.trim();if(t instanceof HTMLInputElement&&t.value)return t.value.trim();const e=t.getAttribute("placeholder");if(e)return e.trim();const r=t.getAttribute("title");if(r)return r.trim();const a=t.getAttribute("aria-label");return a?a.trim():""}async function ja(t){t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(s=>setTimeout(s,50)),t.focus&&t.focus();const e=t.getBoundingClientRect(),r=e.left+e.width/2,a=e.top+e.height/2;try{const s=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:r,y:a}});if(s&&!s.$isError)console.log("[EventClick] CDP click successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP click failed")}catch(s){console.error("[EventClick] CDP click failed, falling back to native click:",s),t.click&&t.click()}await new Promise(s=>setTimeout(s,50))}const Ia=D.object({name:D.literal("keypress"),key:D.string(),code:D.string().optional(),keyCode:D.number().optional(),modifiers:D.array(D.enum(["Alt","Control","Meta","Shift"])).optional()});function vs(t){return Ia.parse(t)}async function bs(t){try{const{key:e,code:r,keyCode:a,modifiers:s=[]}=t;return await Fa(e,r,a,s),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in keypress handler",data:!1}}}async function Fa(t,e,r,a=[]){try{const s=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:t,code:e||t,keyCode:r||Sr(t),modifiers:a}});if(s&&!s.$isError)console.log("[Keypress] CDP keypress successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP keypress failed")}catch(s){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",s);const i=new KeyboardEvent("keydown",{key:t,code:e||t,keyCode:r||Sr(t),bubbles:!0,cancelable:!0,...zr(a)}),c=new KeyboardEvent("keyup",{key:t,code:e||t,keyCode:r||Sr(t),bubbles:!0,cancelable:!0,...zr(a)});document.dispatchEvent(i),await new Promise(f=>setTimeout(f,10)),document.dispatchEvent(c)}await new Promise(s=>setTimeout(s,50))}function Sr(t){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[t]||0}function zr(t){return{altKey:t.includes("Alt"),ctrlKey:t.includes("Control"),metaKey:t.includes("Meta"),shiftKey:t.includes("Shift")}}const $a=D.object({name:D.literal("wait"),duration:D.number().min(0)});function ws(t){return $a.parse(t)}async function ks(t){try{const{duration:e}=t;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(r=>setTimeout(r,e)),console.log(`[Wait] Wait completed after ${e}ms`),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait handler",data:!1}}}const Ua=D.object({name:D.literal("wait-for-condition"),conditions:D.object({urlPattern:D.string().optional(),elementExists:D.object({selector:D.string(),findBy:D.enum(["cssSelector","xpath"])}).optional(),cookieExists:D.string().optional(),storageKey:D.object({type:D.enum(["localStorage","sessionStorage"]),key:D.string()}).optional(),userConfirmation:D.boolean().optional(),message:D.string().optional(),buttonText:D.string().optional()}).refine(t=>t.urlPattern!==void 0||t.elementExists!==void 0||t.cookieExists!==void 0||t.storageKey!==void 0||t.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:D.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:D.number().min(100).optional(),timeoutMs:D.number().min(1e3).optional(),position:D.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function xs(t){return Ua.parse(t)}async function _s(t){try{const{conditions:e,mode:r="auto-or-manual",pollingIntervalMs:a=1e3,timeoutMs:s=3e5,position:i="bottom-right"}=t;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",r,"Timeout:",s);const c=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),f=e.userConfirmation===!0;let w=null,E=null;(r==="manual"||r==="auto-or-manual")&&f&&(w=new Promise(S=>{E=S}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:E}})));const M=async()=>{if(e.urlPattern)try{if(new RegExp(e.urlPattern).test(window.location.href))return{success:!0,reason:"urlPattern",message:`URL matches pattern: ${e.urlPattern}`}}catch(S){console.warn("[WaitForCondition] Invalid URL pattern:",S)}if(e.elementExists){const{selector:S,findBy:k}=e.elementExists;let A=null;if(k==="cssSelector"?A=document.querySelector(S):k==="xpath"&&(A=document.evaluate(S,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),A)return{success:!0,reason:"elementExists",message:`Element found: ${S}`}}if(e.cookieExists&&document.cookie.split(";").some(A=>{const[j]=A.trim().split("=");return j===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:S,key:k}=e.storageKey;if((S==="localStorage"?window.localStorage:window.sessionStorage).getItem(k)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${S}.${k}`}}return null};return new Promise(S=>{let k=null,A=!1;const j=()=>{k&&(clearInterval(k),k=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},se=ye=>{A||(A=!0,j(),console.log("[WaitForCondition] Resolved with:",ye),S({data:ye}))},pe=setTimeout(()=>{se({success:!1,reason:"timeout",message:`Timeout after ${s}ms`})},s);(r==="auto"||r==="auto-or-manual")&&c&&(k=setInterval(async()=>{const ye=await M();ye&&(clearTimeout(pe),se(ye))},a)),(r==="manual"||r==="auto-or-manual")&&w&&w.then(()=>{clearTimeout(pe),se({success:!0,reason:"userConfirmation",message:"User confirmed completion"})})})}catch(e){return console.error("[WaitForCondition] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait-for-condition handler",data:{success:!1,message:e instanceof Error?e.message:"Unknown error"}}}}const La=D.object({name:D.literal("navigate"),url:D.string().url("Valid URL is required"),waitForLoad:D.boolean().optional(),timeout:D.number().min(0).optional()});function Es(t){return La.parse(t)}async function Ts(t){try{const{url:e,waitForLoad:r=!0,timeout:a=3e4}=t;return console.log(`[Navigate] Navigating to: ${e}`),r?new Promise((s,i)=>{const c=setTimeout(()=>{i(new Error(`Navigation timeout after ${a}ms`))},a),f=()=>{clearTimeout(c),window.removeEventListener("load",f),console.log(`[Navigate] Page loaded: ${e}`),s({data:!0})};document.readyState==="complete"?(clearTimeout(c),console.log(`[Navigate] Page already loaded: ${e}`),s({data:!0})):window.addEventListener("load",f),window.location.href=e}):(window.location.href=e,console.log(`[Navigate] Navigation initiated (no wait): ${e}`),{data:!0})}catch(e){return console.error("[Navigate] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in navigate handler",data:!1}}}const Za=yt.extend({name:D.literal("save-assets")});function As(t){return Za.parse(t)}async function Ss(t){try{const{selector:e="img, audio, video, source",findBy:r="cssSelector",option:a}=t,s=await ft({selector:e,findBy:r,option:a});if(!s||!Array.isArray(s))return{data:[]};const i=[];return s.forEach(c=>{let f="";(c instanceof HTMLImageElement||c instanceof HTMLAudioElement||c instanceof HTMLVideoElement||c instanceof HTMLSourceElement)&&(f=c.src),f&&!i.includes(f)&&i.push(f)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class Ba{static generate(e){var s;const r=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let i=a.tagName.toLowerCase();const c=Array.from(((s=a.parentElement)==null?void 0:s.children)||[]).filter(w=>w.tagName===a.tagName);if(c.length>1){const w=c.indexOf(a)+1;i+=`[${w}]`}const f=this.getStableAttributes(a);f.length>0&&(i+=`[@${f.join(" and @")}]`),r.unshift(i),a=a.parentElement}return"/"+r.join("/")}static getStableAttributes(e){const r=[],a=["data-testid","aria-label","title","alt","role"];for(const s of a){const i=e.getAttribute(s);i&&!this.isDynamicValue(i)&&r.push(`${s}="${i}"`)}return r}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/,/^[a-zA-Z0-9]+_[a-zA-Z0-9]+$/].some(a=>a.test(e))}}const za=yt.extend({name:D.literal("get-element-data"),includeText:D.boolean().optional(),includeTags:D.boolean().optional(),useTextContent:D.boolean().optional(),regex:D.string().optional(),prefixText:D.string().optional(),suffixText:D.string().optional(),attributes:D.array(D.string()).optional(),includeSelector:D.boolean().optional(),includeXPath:D.boolean().optional()});function Ds(t){return za.parse(t)}async function Os(t){try{const{selector:e="",includeText:r=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:w=[],includeSelector:E=!1,includeXPath:M=!1,findBy:S="cssSelector",option:k}=t;if(!e)throw new Error("Selector is required for get-element-data block");if(!r&&w.length===0)throw new Error("Either includeText must be true or attributes must be provided");const A=await ft({selector:e,findBy:S,option:k});if(!A)return{data:Array.isArray(A)?[]:{}};const j=Va(r,a,s,i,c,f,w,E,M);return Array.isArray(A)?{data:A.map(j)}:{data:j(A)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function Va(t,e,r,a,s="",i="",c=[],f=!1,w=!1){return E=>{const M={};if(t){let S="";if(e?S=E.innerHTML:S=r?E.textContent||"":E.innerText||"",a){const k=new RegExp(a,"g"),A=S.match(k);S=A?A.join(" "):""}S.trim()&&(S=s+S.trim()+i),M.text=S}return c.length>0&&(M.attributes={},c.forEach(S=>{let k=E.getAttribute(S);if(k===null){const A=E.querySelector(`[${S}]`);A&&(k=A.getAttribute(S))}M.attributes[S]=k})),f&&(M.selector=wa.generate(E)),w&&(M.xpath=Ba.generate(E)),M}}const qa=yt.extend({name:D.literal("scroll"),scrollType:D.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:D.number().optional(),behavior:D.enum(["auto","smooth"]).optional(),maxScrolls:D.number().optional(),waitAfterScroll:D.number().optional()});function Ps(t){return qa.parse(t)}async function Ns(t){try{const{selector:e="",scrollType:r="toBottom",distance:a=500,behavior:s="smooth",maxScrolls:i=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:w}=t;switch(r){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await Wa(e,f,w,s);case"toBottom":return await Ha(s,c);case"byDistance":return await Ya(a,s);case"untilLoaded":return await Ga(i,a,s,c);default:throw new Error(`Unknown scroll type: ${r}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function Wa(t,e,r,a){const s=await ft({selector:t,findBy:e,option:r});return s?((Array.isArray(s)?s[0]:s).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function Ha(t,e){let r=document.body.scrollHeight,a=0;const s=50;for(;a<s;){window.scrollTo({top:document.body.scrollHeight,behavior:t}),await new Promise(c=>setTimeout(c,e));const i=document.body.scrollHeight;if(i===r)break;r=i,a++}return{data:!0}}async function Ya(t,e){return window.scrollBy({top:t,behavior:e}),{data:!0}}async function Ga(t,e,r,a){let s=0,i=document.body.scrollHeight;for(;s<t;){window.scrollBy({top:e,behavior:r}),await new Promise(E=>setTimeout(E,a));const c=document.body.scrollHeight,f=window.pageYOffset||document.documentElement.scrollTop,w=window.innerHeight;if(f+w>=c-10&&c===i)break;i=c,s++}return{data:!0}}const Ka=D.object({name:D.literal("fetch-api"),url:D.string(),method:D.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:D.record(D.string(),D.string()).optional(),body:D.record(D.string(),D.any()).optional(),timeout:D.number().min(0).optional(),parseJson:D.boolean().optional(),returnHeaders:D.boolean().optional()});function Cs(t){return Ka.parse(t)}async function Rs(t){try{console.log("[FetchApiBlock] Sending API request to background:",t.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:t.url,method:t.method||"GET",headers:t.headers||{},body:t.body,timeout:t.timeout||3e4,parseJson:t.parseJson??!0,returnHeaders:t.returnHeaders??!1}});return e.$isError?{hasError:!0,message:e.message||"API request failed",data:void 0}:(console.log("[FetchApiBlock] API request successful"),{data:e.data})}catch(e){return console.error("[FetchApiBlock] API request error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in API request",data:void 0}}}function mr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Dr={exports:{}},Vr;function Ja(){return Vr||(Vr=1,(function(t,e){(function(r){t.exports=r()})(function(){return(function(){function r(a,s,i){function c(E,M){if(!s[E]){if(!a[E]){var S=typeof mr=="function"&&mr;if(!M&&S)return S(E,!0);if(f)return f(E,!0);var k=new Error("Cannot find module '"+E+"'");throw k.code="MODULE_NOT_FOUND",k}var A=s[E]={exports:{}};a[E][0].call(A.exports,function(j){var se=a[E][1][j];return c(se||j)},A,A.exports,r,a,s,i)}return s[E].exports}for(var f=typeof mr=="function"&&mr,w=0;w<i.length;w++)c(i[w]);return c}return r})()({1:[function(r,a,s){const i=r("./utils"),c=(function(){const f=i.stringToArray,w=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],E=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],M=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],S=["Thousand","Million","Billion","Trillion"];function k(v,T){var b=function($,I,O){var F="";if($<=19)F=(I?" and ":"")+(O?E[$]:w[$]);else if($<100){const me=Math.floor($/10),be=$%10;F=(I?" and ":"")+M[me-2],be>0?F+="-"+b(be,!1,O):O&&(F=F.substring(0,F.length-1)+"ieth")}else if($<1e3){const me=Math.floor($/100),be=$%100;F=(I?", ":"")+w[me]+" Hundred",be>0?F+=b(be,!0,O):O&&(F+="th")}else{var J=Math.floor(Math.log10($)/3);J>S.length&&(J=S.length);const me=Math.pow(10,J*3),be=Math.floor($/me),K=$-be*me;F=(I?", ":"")+b(be,!1,!1)+" "+S[J-1],K>0?F+=b(K,!0,O):O&&(F+="th")}return F},N=b(v,!1,T);return N}const A={};w.forEach(function(v,T){A[v.toLowerCase()]=T}),E.forEach(function(v,T){A[v.toLowerCase()]=T}),M.forEach(function(v,T){const b=v.toLowerCase();A[b]=(T+2)*10,A[b.substring(0,v.length-1)+"ieth"]=A[b]}),A.hundredth=100,S.forEach(function(v,T){const b=v.toLowerCase(),N=Math.pow(10,(T+1)*3);A[b]=N,A[b+"th"]=N});function j(v){const b=v.split(/,\s|\sand\s|[\s\\-]/).map(I=>A[I]);let N=[0];return b.forEach(I=>{if(I<100){let O=N.pop();O>=1e3&&(N.push(O),O=0),N.push(O+I)}else N.push(N.pop()*I)}),N.reduce((I,O)=>I+O,0)}const se=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],pe={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function ye(v){for(var T=0;T<se.length;T++){const b=se[T];if(v>=b[0])return b[1]+ye(v-b[0])}return""}function H(v){for(var T=0,b=1,N=v.length-1;N>=0;N--){const $=v[N],I=pe[$];I<b?T-=I:(b=I,T+=I)}return T}function C(v,T){for(var b=[],N=T.charCodeAt(0);v>0;)b.unshift(String.fromCharCode((v-1)%26+N)),v=Math.floor((v-1)/26);return b.join("")}function ne(v,T){for(var b=T.charCodeAt(0),N=0,$=0;$<v.length;$++)N+=(v.charCodeAt(v.length-$-1)-b+1)*Math.pow(26,$);return N}function Z(v,T){if(typeof v>"u")return;v=Math.floor(v);const b=ke(T);return V(v,b)}const _={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},L={UPPER:"upper",LOWER:"lower",TITLE:"title"};function V(v,T){let b;const N=v<0;switch(v=Math.abs(v),T.primary){case _.LETTERS:b=C(v,T.case===L.UPPER?"A":"a");break;case _.ROMAN:b=ye(v),T.case===L.UPPER&&(b=b.toUpperCase());break;case _.WORDS:b=k(v,T.ordinal),T.case===L.UPPER?b=b.toUpperCase():T.case===L.LOWER&&(b=b.toLowerCase());break;case _.DECIMAL:b=""+v;var $=T.mandatoryDigits-b.length;if($>0){var I=new Array($+1).join("0");b=I+b}if(T.zeroCode!==48&&(b=f(b).map(me=>String.fromCodePoint(me.codePointAt(0)+T.zeroCode-48)).join("")),T.regular){const me=Math.floor((b.length-1)/T.groupingSeparators.position);for(let be=me;be>0;be--){const K=b.length-be*T.groupingSeparators.position;b=b.substr(0,K)+T.groupingSeparators.character+b.substr(K)}}else T.groupingSeparators.reverse().forEach(me=>{const be=b.length-me.position;b=b.substr(0,be)+me.character+b.substr(be)});if(T.ordinal){var O={1:"st",2:"nd",3:"rd"},F=b[b.length-1],J=O[F];(!J||b.length>1&&b[b.length-2]==="1")&&(J="th"),b=b+J}break;case _.SEQUENCE:throw{code:"D3130",value:T.token}}return N&&(b="-"+b),b}const fe=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function ke(v){const T={type:"integer",primary:_.DECIMAL,case:L.LOWER,ordinal:!1};let b,N;const $=v.lastIndexOf(";");switch($===-1?b=v:(b=v.substring(0,$),N=v.substring($+1),N[0]==="o"&&(T.ordinal=!0)),b){case"A":T.case=L.UPPER;case"a":T.primary=_.LETTERS;break;case"I":T.case=L.UPPER;case"i":T.primary=_.ROMAN;break;case"W":T.case=L.UPPER,T.primary=_.WORDS;break;case"Ww":T.case=L.TITLE,T.primary=_.WORDS;break;case"w":T.primary=_.WORDS;break;default:{let I=null,O=0,F=0,J=[],me=0;if(f(b).map(K=>K.codePointAt(0)).reverse().forEach(K=>{let Q=!1;for(let de=0;de<fe.length;de++){const Y=fe[de];if(K>=Y&&K<=Y+9){if(Q=!0,O++,me++,I===null)I=Y;else if(Y!==I)throw{code:"D3131"};break}}Q||(K===35?(me++,F++):J.push({position:me,character:String.fromCodePoint(K)}))}),O>0){T.primary=_.DECIMAL,T.zeroCode=I,T.mandatoryDigits=O,T.optionalDigits=F;const Q=function(de){if(de.length===0)return 0;const Y=de[0].character;for(let $e=1;$e<de.length;$e++)if(de[$e].character!==Y)return 0;const Le=de.map($e=>$e.position),at=function($e,qe){return qe===0?$e:at(qe,$e%qe)},Ve=Le.reduce(at);for(let $e=1;$e<=Le.length;$e++)if(Le.indexOf($e*Ve)===-1)return 0;return Ve}(J);Q>0?(T.regular=!0,T.groupingSeparators={position:Q,character:J[0].character}):(T.regular=!1,T.groupingSeparators=J)}else T.primary=_.SEQUENCE,T.token=b}}return T}const Ee={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function Te(v){var T=[];const b={type:"datetime",parts:T},N=function(Q,de){if(de>Q){let Y=v.substring(Q,de);Y=Y.split("]]").join("]"),T.push({type:"literal",value:Y})}};for(var $=0,I=0;I<v.length;){if(v.charAt(I)==="["){if(v.charAt(I+1)==="["){N($,I),T.push({type:"literal",value:"["}),I+=2,$=I;continue}if(N($,I),$=I,I=v.indexOf("]",$),I===-1)throw{code:"D3135"};let Q=v.substring($+1,I);Q=Q.split(/\s+/).join("");var O={type:"marker",component:Q.charAt(0)},F=Q.lastIndexOf(","),J;if(F!==-1){const de=Q.substring(F+1),Y=de.indexOf("-");let Le,at;const Ve=function(qe){if(!(typeof qe>"u"||qe==="*"))return parseInt(qe)};Y===-1?Le=de:(Le=de.substring(0,Y),at=de.substring(Y+1));const $e={min:Ve(Le),max:Ve(at)};O.width=$e,J=Q.substring(1,F)}else J=Q.substring(1);if(J.length===1)O.presentation1=J;else if(J.length>1){var me=J.charAt(J.length-1);"atco".indexOf(me)!==-1?(O.presentation2=me,me==="o"&&(O.ordinal=!0),O.presentation1=J.substring(0,J.length-1)):O.presentation1=J}else O.presentation1=Ee[O.component];if(typeof O.presentation1>"u")throw{code:"D3132",value:O.component};if(O.presentation1[0]==="n")O.names=L.LOWER;else if(O.presentation1[0]==="N")O.presentation1[1]==="n"?O.names=L.TITLE:O.names=L.UPPER;else if("YMDdFWwXxHhmsf".indexOf(O.component)!==-1){var be=O.presentation1;if(O.presentation2&&(be+=";"+O.presentation2),O.integerFormat=ke(be),O.width&&O.width.min!==void 0&&O.integerFormat.mandatoryDigits<O.width.min&&(O.integerFormat.mandatoryDigits=O.width.min),O.component==="Y")if(O.n=-1,O.width&&O.width.max!==void 0)O.n=O.width.max,O.integerFormat.mandatoryDigits=O.n;else{var K=O.integerFormat.mandatoryDigits+O.integerFormat.optionalDigits;K>=2&&(O.n=K)}const de=T[T.length-1];de&&de.integerFormat&&(de.integerFormat.parseWidth=de.integerFormat.mandatoryDigits)}(O.component==="Z"||O.component==="z")&&(O.integerFormat=ke(O.presentation1)),T.push(O),$=I+1}I++}return N($,I),b}const ge=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Ce=["January","February","March","April","May","June","July","August","September","October","November","December"],Xe=1e3*60*60*24,xe=function(v){const T=Date.UTC(v.year,v.month);var b=new Date(T).getUTCDay();return b===0&&(b=7),b>4?T+(8-b)*Xe:T-(b-1)*Xe},ue=function(v,T){return{year:v,month:T,nextMonth:function(){return T===11?ue(v+1,0):ue(v,T+1)},previousMonth:function(){return T===0?ue(v-1,11):ue(v,T-1)},nextYear:function(){return ue(v+1,T)},previousYear:function(){return ue(v-1,T)}}},Qe=function(v,T){return(T-v)/(Xe*7)+1},ae=(v,T)=>{let b;switch(T){case"Y":b=v.getUTCFullYear();break;case"M":b=v.getUTCMonth()+1;break;case"D":b=v.getUTCDate();break;case"d":{const N=Date.UTC(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),$=Date.UTC(v.getUTCFullYear(),0);b=(N-$)/Xe+1;break}case"F":b=v.getUTCDay(),b===0&&(b=7);break;case"W":{const N=ue(v.getUTCFullYear(),0),$=xe(N),I=Date.UTC(N.year,v.getUTCMonth(),v.getUTCDate());let O=Qe($,I);if(O>52){const F=xe(N.nextYear());I>=F&&(O=1)}else if(O<1){const F=xe(N.previousYear());O=Qe(F,I)}b=Math.floor(O);break}case"w":{const N=ue(v.getUTCFullYear(),v.getUTCMonth()),$=xe(N),I=Date.UTC(N.year,N.month,v.getUTCDate());let O=Qe($,I);if(O>4){const F=xe(N.nextMonth());I>=F&&(O=1)}else if(O<1){const F=xe(N.previousMonth());O=Qe(F,I)}b=Math.floor(O);break}case"X":{const N=ue(v.getUTCFullYear(),0),$=xe(N),I=xe(N.nextYear()),O=v.getTime();O<$?b=N.year-1:O>=I?b=N.year+1:b=N.year;break}case"x":{const N=ue(v.getUTCFullYear(),v.getUTCMonth()),$=xe(N),I=N.nextMonth(),O=xe(I),F=v.getTime();F<$?b=N.previousMonth().month+1:F>=O?b=I.month+1:b=N.month+1;break}case"H":b=v.getUTCHours();break;case"h":b=v.getUTCHours(),b=b%12,b===0&&(b=12);break;case"P":b=v.getUTCHours()>=12?"pm":"am";break;case"m":b=v.getUTCMinutes();break;case"s":b=v.getUTCSeconds();break;case"f":b=v.getUTCMilliseconds();break;case"Z":case"z":break;case"C":b="ISO";break;case"E":b="ISO";break}return b};let Ie=null;function nt(v,T,b){var N=0,$=0;if(typeof b<"u"){const be=parseInt(b);N=Math.floor(be/100),$=be%100}var I=function(be,K){var Q=ae(be,K.component);if("YMDdFWwXxHhms".indexOf(K.component)!==-1)if(K.component==="Y"&&K.n!==-1&&(Q=Q%Math.pow(10,K.n)),K.names){if(K.component==="M"||K.component==="x")Q=Ce[Q-1];else if(K.component==="F")Q=ge[Q];else throw{code:"D3133",value:K.component};K.names===L.UPPER?Q=Q.toUpperCase():K.names===L.LOWER&&(Q=Q.toLowerCase()),K.width&&Q.length>K.width.max&&(Q=Q.substring(0,K.width.max))}else Q=V(Q,K.integerFormat);else if(K.component==="f")Q=V(Q,K.integerFormat);else if(K.component==="Z"||K.component==="z"){const de=N*100+$;if(K.integerFormat.regular)Q=V(de,K.integerFormat);else{const Y=K.integerFormat.mandatoryDigits;if(Y===1||Y===2)Q=V(N,K.integerFormat),$!==0&&(Q+=":"+Z($,"00"));else if(Y===3||Y===4)Q=V(de,K.integerFormat);else throw{code:"D3134",value:Y}}de>=0&&(Q="+"+Q),K.component==="z"&&(Q="GMT"+Q),de===0&&K.presentation2==="t"&&(Q="Z")}else K.component==="P"&&K.names===L.UPPER&&(Q=Q.toUpperCase());return Q};let O;typeof T>"u"?(Ie===null&&(Ie=Te("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),O=Ie):O=Te(T);const F=(60*N+$)*60*1e3,J=new Date(v+F);let me="";return O.parts.forEach(function(be){be.type==="literal"?me+=be.value:me+=I(J,be)}),me}function d(v){var T={};if(v.type==="datetime")T.type="datetime",T.parts=v.parts.map(function(b){var N={};if(b.type==="literal")N.regex=b.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(b.component==="Z"||b.component==="z"){let I;Array.isArray(b.integerFormat.groupingSeparators)||(I=b.integerFormat.groupingSeparators),N.regex="",b.component==="z"&&(N.regex="GMT"),N.regex+="[-+][0-9]+",I&&(N.regex+=I.character+"[0-9]+"),N.parse=function(O){b.component==="z"&&(O=O.substring(3));let F=0,J=0;return I?(F=Number.parseInt(O.substring(0,O.indexOf(I.character))),J=Number.parseInt(O.substring(O.indexOf(I.character)+1))):O.length-1<=2?F=Number.parseInt(O):(F=Number.parseInt(O.substring(0,3)),J=Number.parseInt(O.substring(3))),F*60+J}}else if(b.integerFormat)N=d(b.integerFormat);else{N.regex="[a-zA-Z]+";var $={};if(b.component==="M"||b.component==="x")Ce.forEach(function(I,O){b.width&&b.width.max?$[I.substring(0,b.width.max)]=O+1:$[I]=O+1});else if(b.component==="F")ge.forEach(function(I,O){O>0&&(b.width&&b.width.max?$[I.substring(0,b.width.max)]=O:$[I]=O)});else if(b.component==="P")$={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:b.component};N.parse=function(I){return $[I]}}return N.component=b.component,N});else{T.type="integer";const b=v.case===L.UPPER;switch(v.primary){case _.LETTERS:T.regex=b?"[A-Z]+":"[a-z]+",T.parse=function(N){return ne(N,b?"A":"a")};break;case _.ROMAN:T.regex=b?"[MDCLXVI]+":"[mdclxvi]+",T.parse=function(N){return H(b?N:N.toUpperCase())};break;case _.WORDS:T.regex="(?:"+Object.keys(A).concat("and","[\\-, ]").join("|")+")+",T.parse=function(N){return j(N.toLowerCase())};break;case _.DECIMAL:T.regex="[0-9]",v.parseWidth?T.regex+=`{${v.parseWidth}}`:T.regex+="+",v.ordinal&&(T.regex+="(?:th|st|nd|rd)"),T.parse=function(N){let $=N;return v.ordinal&&($=N.substring(0,N.length-2)),v.regular?$=$.split(",").join(""):v.groupingSeparators.forEach(I=>{$=$.split(I.character).join("")}),v.zeroCode!==48&&($=$.split("").map(I=>String.fromCodePoint(I.codePointAt(0)-v.zeroCode+48)).join("")),parseInt($)};break;case _.SEQUENCE:throw{code:"D3130",value:v.token}}}return T}function m(v,T){if(typeof v>"u")return;const b=ke(T);return d(b).parse(v)}function q(v,T){const b=Te(T),N=d(b),$="^"+N.parts.map(J=>"("+J.regex+")").join("")+"$";var O=new RegExp($,"i").exec(v);if(O!==null){const Y={};for(let Se=1;Se<O.length;Se++){const u=N.parts[Se-1];u.parse&&(Y[u.component]=u.parse(O[Se]))}if(Object.getOwnPropertyNames(Y).length===0)return;let Le=0;const at=Se=>{Le<<=1,Le+=Se?1:0},Ve=Se=>!(~Se&Le)&&!!(Se&Le);"YXMxWwdD".split("").forEach(Se=>at(Y[Se]));const qe=!Ve(161)&&Ve(130),gt=Ve(84),xt=!gt&&Ve(72);Le=0,"PHhmsf".split("").forEach(Se=>at(Y[Se]));const _t=!Ve(23)&&Ve(47),qt=(qe?"YD":gt?"XxwF":xt?"XWF":"YMD")+(_t?"Phmsf":"Hmsf"),it=this.environment.timestamp;let jt=!1,dt=!1;if(qt.split("").forEach(Se=>{if(typeof Y[Se]>"u")jt?(Y[Se]="MDd".indexOf(Se)!==-1?1:0,dt=!0):Y[Se]=ae(it,Se);else if(jt=!0,dt)throw{code:"D3136"}}),Y.M>0?Y.M-=1:Y.M=0,qe){const Se=Date.UTC(Y.Y,0),u=(Y.d-1)*1e3*60*60*24,h=new Date(Se+u);Y.M=h.getUTCMonth(),Y.D=h.getUTCDate()}if(gt)throw{code:"D3136"};if(xt)throw{code:"D3136"};_t&&(Y.H=Y.h===12?0:Y.h,Y.P===1&&(Y.H+=12));var F=Date.UTC(Y.Y,Y.M,Y.D,Y.H,Y.m,Y.s,Y.f);return(Y.Z||Y.z)&&(F-=(Y.Z||Y.z)*60*1e3),F}}var le=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function Oe(v,T){if(!(typeof v>"u"))if(typeof T>"u"){if(!le.test(v))throw{stack:new Error().stack,code:"D3110",value:v};return Date.parse(v)}else return q.call(this,v,T)}function _e(v,T,b){if(!(typeof v>"u"))return nt.call(this,v,T,b)}return{formatInteger:Z,parseInteger:m,fromMillis:_e,toMillis:Oe}})();a.exports=c},{"./utils":6}],2:[function(r,a,s){(function(i){(function(){var c=r("./utils");const f=(()=>{var w=c.isNumeric,E=c.isArrayOfStrings,M=c.isArrayOfNumbers,S=c.createSequence,k=c.isSequence,A=c.isFunction,j=c.isLambda,se=c.isPromise,pe=c.getFunctionArity,ye=c.isDeepEqual,H=c.stringToArray;function C(n){if(!(typeof n>"u")){var o=0;return n.forEach(function(l){o+=l}),o}}function ne(n){return typeof n>"u"?0:n.length}function Z(n){if(!(typeof n>"u"||n.length===0))return Math.max.apply(Math,n)}function _(n){if(!(typeof n>"u"||n.length===0))return Math.min.apply(Math,n)}function L(n){if(!(typeof n>"u"||n.length===0)){var o=0;return n.forEach(function(l){o+=l}),o/n.length}}function V(n,o=!1){if(!(typeof n>"u")){var l;if(typeof n=="string")l=n;else if(A(n))l="";else{if(typeof n=="number"&&!isFinite(n))throw{code:"D3001",value:n,stack:new Error().stack};var g=o?2:0;Array.isArray(n)&&n.outerWrapper&&(n=n[0]),l=JSON.stringify(n,function(p,x){return typeof x<"u"&&x!==null&&x.toPrecision&&w(x)?Number(x.toPrecision(15)):x&&A(x)?"":x},g)}return l}}function fe(n,o,l){if(!(typeof n>"u")){var g=H(n),p=g.length;if(p+o<0&&(o=0),typeof l<"u"){if(l<=0)return"";var x=o>=0?o+l:p+o+l;return g.slice(o,x).join("")}return g.slice(o).join("")}}function ke(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(0,l):n}}function Ee(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(l+o.length):n}}function Te(n){if(!(typeof n>"u"))return n.toLowerCase()}function ge(n){if(!(typeof n>"u"))return n.toUpperCase()}function Ce(n){if(!(typeof n>"u"))return H(n).length}function Xe(n){if(!(typeof n>"u")){var o=n.replace(/[ \t\n\r]+/gm," ");return o.charAt(0)===" "&&(o=o.substring(1)),o.charAt(o.length-1)===" "&&(o=o.substring(0,o.length-1)),o}}function xe(n,o,l){if(!(typeof n>"u")){(typeof l>"u"||l.length===0)&&(l=" ");var g;o=Math.trunc(o);var p=Math.abs(o)-Ce(n);if(p>0){var x=new Array(p+1).join(l);l.length>1&&(x=fe(x,0,p)),o>0?g=n+x:g=x+n}else g=n;return g}}async function ue(n,o){var l=n.apply(this,[o]);if(se(l)&&(l=await l),l&&!(typeof l.start=="number"||l.end==="number"||Array.isArray(l.groups)||A(l.next)))throw{code:"T1010",stack:new Error().stack};return l}async function Qe(n,o){if(!(typeof n>"u")){var l;if(typeof o=="string")l=n.indexOf(o)!==-1;else{var g=await ue(o,n);l=typeof g<"u"}return l}}async function ae(n,o,l){if(!(typeof n>"u")){if(l<0)throw{stack:new Error().stack,value:l,code:"D3040",index:3};var g=S();if(typeof l>"u"||l>0){var p=0,x=await ue(o,n);if(typeof x<"u")for(;typeof x<"u"&&(typeof l>"u"||p<l);)g.push({match:x.match,index:x.start,groups:x.groups}),x=await ue(x.next),p++}return g}}async function Ie(n,o,l,g){if(!(typeof n>"u")){var p=this;if(o==="")throw{code:"D3010",stack:new Error().stack,value:o,index:2};if(g<0)throw{code:"D3011",stack:new Error().stack,value:g,index:4};var x;typeof l=="string"?x=function(Ae){for(var Ze="",we=0,je=l.indexOf("$",we);je!==-1&&we<l.length;){Ze+=l.substring(we,je),we=je+1;var st=l.charAt(we);if(st==="$")Ze+="$",we++;else if(st==="0")Ze+=Ae.match,we++;else{var Be;if(Ae.groups.length===0?Be=1:Be=Math.floor(Math.log(Ae.groups.length)*Math.LOG10E)+1,je=parseInt(l.substring(we,we+Be),10),Be>1&&je>Ae.groups.length&&(je=parseInt(l.substring(we,we+Be-1),10)),isNaN(je))Ze+="$";else{if(Ae.groups.length>0){var It=Ae.groups[je-1];typeof It<"u"&&(Ze+=It)}we+=je.toString().length}}je=l.indexOf("$",we)}return Ze+=l.substring(we),Ze}:x=l;var R="",W=0;if(typeof g>"u"||g>0){var X=0;if(typeof o=="string"){for(var De=n.indexOf(o,W);De!==-1&&(typeof g>"u"||X<g);)R+=n.substring(W,De),R+=l,W=De+o.length,X++,De=n.indexOf(o,W);R+=n.substring(W)}else{var he=await ue(o,n);if(typeof he<"u"){for(;typeof he<"u"&&(typeof g>"u"||X<g);){R+=n.substring(W,he.start);var Pe=x.apply(p,[he]);if(se(Pe)&&(Pe=await Pe),typeof Pe=="string")R+=Pe;else throw{code:"D3012",stack:new Error().stack,value:Pe};W=he.start+he.match.length,X++,he=await ue(he.next)}R+=n.substring(W)}else R=n}}else R=n;return R}}function nt(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.btoa:function(l){return new i.Buffer.from(l,"binary").toString("base64")};return o(n)}}function d(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.atob:function(l){return new i.Buffer.from(l,"base64").toString("binary")};return o(n)}}function m(n){if(!(typeof n>"u")){var o;try{o=encodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrlComponent"}}return o}}function q(n){if(!(typeof n>"u")){var o;try{o=encodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrl"}}return o}}function le(n){if(!(typeof n>"u")){var o;try{o=decodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrlComponent"}}return o}}function Oe(n){if(!(typeof n>"u")){var o;try{o=decodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrl"}}return o}}async function _e(n,o,l){if(!(typeof n>"u")){if(l<0)throw{code:"D3020",stack:new Error().stack,value:l,index:3};var g=[];if(typeof l>"u"||l>0)if(typeof o=="string")g=n.split(o,l);else{var p=0,x=await ue(o,n);if(typeof x<"u"){for(var R=0;typeof x<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(R,x.start)),R=x.end,x=await ue(x.next),p++;(typeof l>"u"||p<l)&&g.push(n.substring(R))}else g.push(n)}return g}}function v(n,o){if(!(typeof n>"u"))return typeof o>"u"&&(o=""),n.join(o)}function T(n,o,l){if(!(typeof n>"u")){var g={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},p=g;typeof l<"u"&&Object.keys(l).forEach(function(te){p[te]=l[te]});for(var x=[],R=p["zero-digit"].charCodeAt(0),W=R;W<R+10;W++)x.push(String.fromCharCode(W));var X=x.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),De=o.split(p["pattern-separator"]);if(De.length>2)throw{code:"D3080",stack:new Error().stack};var he=function(te){var Re=(function(){for(var Ue,tt=0;tt<te.length;tt++)if(Ue=te.charAt(tt),X.indexOf(Ue)!==-1&&Ue!==p["exponent-separator"])return te.substring(0,tt)})(),He=(function(){for(var Ue,tt=te.length-1;tt>=0;tt--)if(Ue=te.charAt(tt),X.indexOf(Ue)!==-1&&Ue!==p["exponent-separator"])return te.substring(tt+1)})(),Ne=te.substring(Re.length,te.length-He.length),Ke,Et,Je,Pt,et=te.indexOf(p["exponent-separator"],Re.length);et===-1||et>te.length-He.length?(Ke=Ne,Et=void 0):(Ke=Ne.substring(0,et),Et=Ne.substring(et+1));var ot=Ke.indexOf(p["decimal-separator"]);return ot===-1?(Je=Ke,Pt=He):(Je=Ke.substring(0,ot),Pt=Ke.substring(ot+1)),{prefix:Re,suffix:He,activePart:Ne,mantissaPart:Ke,exponentPart:Et,integerPart:Je,fractionalPart:Pt,subpicture:te}},Pe=function(te){var Re,He,Ne=te.subpicture,Ke=Ne.indexOf(p["decimal-separator"]);Ke!==Ne.lastIndexOf(p["decimal-separator"])&&(Re="D3081"),Ne.indexOf(p.percent)!==Ne.lastIndexOf(p.percent)&&(Re="D3082"),Ne.indexOf(p["per-mille"])!==Ne.lastIndexOf(p["per-mille"])&&(Re="D3083"),Ne.indexOf(p.percent)!==-1&&Ne.indexOf(p["per-mille"])!==-1&&(Re="D3084");var Et=!1;for(He=0;He<te.mantissaPart.length;He++){var Je=te.mantissaPart.charAt(He);if(x.indexOf(Je)!==-1||Je===p.digit){Et=!0;break}}Et||(Re="D3085");var Pt=te.activePart.split("").map(function(Ue){return X.indexOf(Ue)===-1?"p":"a"}).join("");Pt.indexOf("p")!==-1&&(Re="D3086"),Ke!==-1?(Ne.charAt(Ke-1)===p["grouping-separator"]||Ne.charAt(Ke+1)===p["grouping-separator"])&&(Re="D3087"):te.integerPart.charAt(te.integerPart.length-1)===p["grouping-separator"]&&(Re="D3088"),Ne.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Re="D3089");var et=te.integerPart.indexOf(p.digit);et!==-1&&te.integerPart.substring(0,et).split("").filter(function(Ue){return x.indexOf(Ue)>-1}).length>0&&(Re="D3090"),et=te.fractionalPart.lastIndexOf(p.digit),et!==-1&&te.fractionalPart.substring(et).split("").filter(function(Ue){return x.indexOf(Ue)>-1}).length>0&&(Re="D3091");var ot=typeof te.exponentPart=="string";if(ot&&te.exponentPart.length>0&&(Ne.indexOf(p.percent)!==-1||Ne.indexOf(p["per-mille"])!==-1)&&(Re="D3092"),ot&&(te.exponentPart.length===0||te.exponentPart.split("").filter(function(Ue){return x.indexOf(Ue)===-1}).length>0)&&(Re="D3093"),Re)throw{code:Re,stack:new Error().stack}},Ae=function(te){var Re=function(ze,hr){for(var Yt=[],vt=ze.indexOf(p["grouping-separator"]);vt!==-1;){var pr=(hr?ze.substring(0,vt):ze.substring(vt)).split("").filter(function($t){return x.indexOf($t)!==-1||$t===p.digit}).length;Yt.push(pr),vt=te.integerPart.indexOf(p["grouping-separator"],vt+1)}return Yt},He=Re(te.integerPart),Ne=function(ze){if(ze.length===0)return 0;for(var hr=function(pr,$t){return $t===0?pr:hr($t,pr%$t)},Yt=ze.reduce(hr),vt=1;vt<=ze.length;vt++)if(ze.indexOf(vt*Yt)===-1)return 0;return Yt},Ke=Ne(He),Et=Re(te.fractionalPart,!0),Je=te.integerPart.split("").filter(function(ze){return x.indexOf(ze)!==-1}).length,Pt=Je,et=te.fractionalPart.split(""),ot=et.filter(function(ze){return x.indexOf(ze)!==-1}).length,Ue=et.filter(function(ze){return x.indexOf(ze)!==-1||ze===p.digit}).length,tt=typeof te.exponentPart=="string";Je===0&&Ue===0&&(tt?(ot=1,Ue=1):Je=1),tt&&Je===0&&te.integerPart.indexOf(p.digit)!==-1&&(Je=1),Je===0&&ot===0&&(ot=1);var $r=0;return tt&&($r=te.exponentPart.split("").filter(function(ze){return x.indexOf(ze)!==-1}).length),{integerPartGroupingPositions:He,regularGrouping:Ke,minimumIntegerPartSize:Je,scalingFactor:Pt,prefix:te.prefix,fractionalPartGroupingPositions:Et,minimumFactionalPartSize:ot,maximumFactionalPartSize:Ue,minimumExponentSize:$r,suffix:te.suffix,picture:te.subpicture}},Ze=De.map(he);Ze.forEach(Pe);var we=Ze.map(Ae),je=p["minus-sign"],st=p["zero-digit"],Be=p["decimal-separator"],It=p["grouping-separator"];we.length===1&&(we.push(JSON.parse(JSON.stringify(we[0]))),we[1].prefix=je+we[1].prefix);var Fe;n>=0?Fe=we[0]:Fe=we[1];var Wt;Fe.picture.indexOf(p.percent)!==-1?Wt=n*100:Fe.picture.indexOf(p["per-mille"])!==-1?Wt=n*1e3:Wt=n;var Ot,Ft;if(Fe.minimumExponentSize===0)Ot=Wt;else{var en=Math.pow(10,Fe.scalingFactor),tn=Math.pow(10,Fe.scalingFactor-1);for(Ot=Wt,Ft=0;Ot<tn;)Ot*=10,Ft-=1;for(;Ot>en;)Ot/=10,Ft+=1}var rn=F(Ot,Fe.maximumFactionalPartSize),Ir=function(te,Re){var He=Math.abs(te).toFixed(Re);return st!=="0"&&(He=He.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?x[Ne.charCodeAt(0)-48]:Ne}).join("")),He},oe=Ir(rn,Fe.maximumFactionalPartSize),We=oe.indexOf(".");for(We===-1?oe=oe+Be:oe=oe.replace(".",Be);oe.charAt(0)===st;)oe=oe.substring(1);for(;oe.charAt(oe.length-1)===st;)oe=oe.substring(0,oe.length-1);We=oe.indexOf(Be);var Ht=Fe.minimumIntegerPartSize-We,Fr=Fe.minimumFactionalPartSize-(oe.length-We-1);if(oe=(Ht>0?new Array(Ht+1).join(st):"")+oe,oe=oe+(Fr>0?new Array(Fr+1).join(st):""),We=oe.indexOf(Be),Fe.regularGrouping>0)for(var nn=Math.floor((We-1)/Fe.regularGrouping),fr=1;fr<=nn;fr++)oe=[oe.slice(0,We-fr*Fe.regularGrouping),It,oe.slice(We-fr*Fe.regularGrouping)].join("");else Fe.integerPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,We-te),It,oe.slice(We-te)].join(""),We++});if(We=oe.indexOf(Be),Fe.fractionalPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,te+We+1),It,oe.slice(te+We+1)].join("")}),We=oe.indexOf(Be),(Fe.picture.indexOf(Be)===-1||We===oe.length-1)&&(oe=oe.substring(0,oe.length-1)),typeof Ft<"u"){var dr=Ir(Ft,0);Ht=Fe.minimumExponentSize-dr.length,Ht>0&&(dr=new Array(Ht+1).join(st)+dr),oe=oe+p["exponent-separator"]+(Ft<0?je:"")+dr}return oe=Fe.prefix+oe+Fe.suffix,oe}}function b(n,o){if(!(typeof n>"u")){if(n=F(n),typeof o>"u"?o=10:o=F(o),o<2||o>36)throw{code:"D3100",stack:new Error().stack,value:o};var l=n.toString(o);return l}}function N(n){var o;if(!(typeof n>"u")){if(typeof n=="number")o=n;else if(typeof n=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(n)&&!isNaN(parseFloat(n))&&isFinite(n))o=parseFloat(n);else if(typeof n=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(n))o=Number(n);else if(n===!0)o=1;else if(n===!1)o=0;else throw{code:"D3030",value:n,stack:new Error().stack,index:1};return o}}function $(n){var o;if(!(typeof n>"u"))return o=Math.abs(n),o}function I(n){var o;if(!(typeof n>"u"))return o=Math.floor(n),o}function O(n){var o;if(!(typeof n>"u"))return o=Math.ceil(n),o}function F(n,o){var l;if(!(typeof n>"u")){if(o){var g=n.toString().split("e");n=+(g[0]+"e"+(g[1]?+g[1]+o:o))}l=Math.round(n);var p=l-n;return Math.abs(p)===.5&&Math.abs(l%2)===1&&(l=l-1),o&&(g=l.toString().split("e"),l=+(g[0]+"e"+(g[1]?+g[1]-o:-o))),Object.is(l,-0)&&(l=0),l}}function J(n){var o;if(!(typeof n>"u")){if(n<0)throw{stack:new Error().stack,code:"D3060",index:1,value:n};return o=Math.sqrt(n),o}}function me(n,o){var l;if(!(typeof n>"u")){if(l=Math.pow(n,o),!isFinite(l))throw{stack:new Error().stack,code:"D3061",index:1,value:n,exp:o};return l}}function be(){return Math.random()}function K(n){if(!(typeof n>"u")){var o=!1;if(Array.isArray(n)){if(n.length===1)o=K(n[0]);else if(n.length>1){var l=n.filter(function(g){return K(g)});o=l.length>0}}else typeof n=="string"?n.length>0&&(o=!0):w(n)?n!==0&&(o=!0):n!==null&&typeof n=="object"&&!A(n)?Object.keys(n).length>0&&(o=!0):typeof n=="boolean"&&n===!0&&(o=!0);return o}}function Q(n){if(!(typeof n>"u"))return!K(n)}function de(n,o,l,g){var p=[o],x=pe(n);return x>=2&&p.push(l),x>=3&&p.push(g),p}async function Y(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=de(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}}async function Le(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=n[g],x=de(o,p,g,n),R=await o.apply(this,x);K(R)&&l.push(p)}return l}}async function at(n,o){if(!(typeof n>"u")){for(var l=!1,g,p=0;p<n.length;p++){var x=n[p],R=!0;if(typeof o<"u"){var W=de(o,x,p,n),X=await o.apply(this,W);R=K(X)}if(R)if(!l)g=x,l=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!l)throw{stack:new Error().stack,code:"D3139"};return g}}function Ve(){for(var n=[],o=Array.prototype.slice.call(arguments),l=Math.min.apply(Math,o.map(function(x){return Array.isArray(x)?x.length:0})),g=0;g<l;g++){var p=o.map(x=>x[g]);n.push(p)}return n}async function $e(n,o,l){if(!(typeof n>"u")){var g,p=pe(o);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var x;for(typeof l>"u"&&n.length>0?(g=n[0],x=1):(g=l,x=0);x<n.length;){var R=[g,n[x]];p>=3&&R.push(x),p>=4&&R.push(n),g=await o.apply(this,R),x++}return g}}function qe(n){var o=S();if(Array.isArray(n)){var l={};n.forEach(function(g){var p=qe(g);p.forEach(function(x){l[x]=!0})}),o=qe(l)}else n!==null&&typeof n=="object"&&!A(n)&&Object.keys(n).forEach(g=>o.push(g));return o}function gt(n,o){var l;if(Array.isArray(n)){l=S();for(var g=0;g<n.length;g++){var p=gt(n[g],o);typeof p<"u"&&(Array.isArray(p)?p.forEach(x=>l.push(x)):l.push(p))}}else n!==null&&typeof n=="object"&&!A(n)&&(l=n[o]);return l}function xt(n,o){return typeof n>"u"?o:typeof o>"u"?n:(Array.isArray(n)||(n=S(n)),Array.isArray(o)||(o=[o]),n.concat(o))}function ur(n){return!(typeof n>"u")}function _t(n){var o=S();if(Array.isArray(n))n.forEach(function(p){o=xt(o,_t(p))});else if(n!==null&&typeof n=="object"&&!j(n))for(var l in n){var g={};g[l]=n[l],o.push(g)}else o=n;return o}function B(n){if(!(typeof n>"u")){var o={};return n.forEach(function(l){for(var g in l)o[g]=l[g]}),o}}function lr(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=n.length,l=new Array(o),g=0;g<o;g++)l[o-g-1]=n[g];return l}}async function qt(n,o){var l=S();for(var g in n){var p=de(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}function it(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function jt(n,o){if(!n)throw{code:"D3141",stack:new Error().stack,message:o||"$assert() statement failed"}}function dt(n){if(n!==void 0)return n===null?"null":w(n)?"number":typeof n=="string"?"string":typeof n=="boolean"?"boolean":Array.isArray(n)?"array":A(n)?"function":"object"}async function Se(n,o){if(!(typeof n>"u")){if(n.length<=1)return n;var l;if(typeof o>"u"){if(!M(n)&&!E(n))throw{stack:new Error().stack,code:"D3070",index:1};l=async function(R,W){return R>W}}else l=o;var g=async function(R,W){var X=async function(he,Pe,Ae){Pe.length===0?Array.prototype.push.apply(he,Ae):Ae.length===0?Array.prototype.push.apply(he,Pe):await l(Pe[0],Ae[0])?(he.push(Ae[0]),await X(he,Pe,Ae.slice(1))):(he.push(Pe[0]),await X(he,Pe.slice(1),Ae))},De=[];return await X(De,R,W),De},p=async function(R){if(!Array.isArray(R)||R.length<=1)return R;var W=Math.floor(R.length/2),X=R.slice(0,W),De=R.slice(W);return X=await p(X),De=await p(De),await g(X,De)},x=await p(n);return x}}function u(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=new Array(n.length),l=0;l<n.length;l++){var g=Math.floor(Math.random()*(l+1));l!==g&&(o[l]=o[g]),o[g]=n[l]}return o}}function h(n){if(!(typeof n>"u")){if(!Array.isArray(n)||n.length<=1)return n;for(var o=k(n)?S():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,x=0;x<o.length;x++)if(ye(g,o[x])){p=!0;break}p||o.push(g)}return o}}async function y(n,o){var l={};for(var g in n){var p=n[g],x=de(o,p,g,n),R=await o.apply(this,x);K(R)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:C,count:ne,max:Z,min:_,average:L,string:V,substring:fe,substringBefore:ke,substringAfter:Ee,lowercase:Te,uppercase:ge,length:Ce,trim:Xe,pad:xe,match:ae,contains:Qe,replace:Ie,split:_e,join:v,formatNumber:T,formatBase:b,number:N,floor:I,ceil:O,round:F,abs:$,sqrt:J,power:me,random:be,boolean:K,not:Q,map:Y,zip:Ve,filter:Le,single:at,foldLeft:$e,sift:y,keys:qe,lookup:gt,append:xt,exists:ur,spread:_t,merge:B,reverse:lr,each:qt,error:it,assert:jt,type:dt,sort:Se,shuffle:u,distinct:h,base64encode:nt,base64decode:d,encodeUrlComponent:m,encodeUrl:q,decodeUrlComponent:le,decodeUrl:Oe}})();a.exports=f}).call(this)}).call(this,typeof Ur<"u"?Ur:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(r,a,s){var i=r("./datetime"),c=r("./functions"),f=r("./utils"),w=r("./parser"),E=r("./signature"),M=(function(){var S=f.isNumeric,k=f.isArrayOfStrings,A=f.isArrayOfNumbers,j=f.createSequence,se=f.isSequence,pe=f.isFunction,ye=f.isLambda,H=f.isIterable,C=f.isPromise,ne=f.getFunctionArity,Z=f.isDeepEqual,_=it(null);async function L(u,h,y){var n,o=y.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(o&&await o(u,h,y),u.type){case"path":n=await V(u,h,y);break;case"binary":n=await Ce(u,h,y);break;case"unary":n=await Xe(u,h,y);break;case"name":n=xe(u,h);break;case"string":case"number":case"value":n=ue(u);break;case"wildcard":n=Qe(u,h);break;case"descendant":n=Ie(u,h);break;case"parent":n=y.lookup(u.slot.label);break;case"condition":n=await I(u,h,y);break;case"block":n=await O(u,h,y);break;case"bind":n=await $(u,h,y);break;case"regex":n=F(u);break;case"function":n=await de(u,h,y);break;case"variable":n=J(u,h,y);break;case"lambda":n=at(u,h,y);break;case"partial":n=await Ve(u,h,y);break;case"apply":n=await Q(u,h,y);break;case"transform":n=be(u,h,y);break}if(Object.prototype.hasOwnProperty.call(u,"predicate"))for(var l=0;l<u.predicate.length;l++)n=await ge(u.predicate[l].expr,n,y);u.type!=="path"&&Object.prototype.hasOwnProperty.call(u,"group")&&(n=await T(u.group,n,y));var g=y.lookup(Symbol.for("jsonata.__evaluate_exit"));return g&&await g(u,h,y,n),n&&se(n)&&!n.tupleStream&&(u.keepArray&&(n.keepSingleton=!0),n.length===0?n=void 0:n.length===1&&(n=n.keepSingleton?n:n[0])),n}async function V(u,h,y){var n;Array.isArray(h)&&u.steps[0].type!=="variable"?n=h:n=j(h);for(var o,l=!1,g=void 0,p=0;p<u.steps.length;p++){var x=u.steps[p];if(x.tuple&&(l=!0),p===0&&x.consarray?o=await L(x,n,y):l?g=await Te(x,n,g,y):o=await ke(x,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof x.focus>"u"&&(n=o)}if(l)if(u.tuple)o=g;else for(o=j(),p=0;p<g.length;p++)o.push(g[p]["@"]);return u.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=j(o)),o.keepSingleton=!0),u.hasOwnProperty("group")&&(o=await T(u.group,l?g:o,y)),o}function fe(u,h){var y=it(u);for(const n in h)y.bind(n,h[n]);return y}async function ke(u,h,y,n){var o;if(u.type==="sort")return o=await me(u,h,y),u.stages&&(o=await Ee(u.stages,o,y)),o;o=j();for(var l=0;l<h.length;l++){var g=await L(u,h[l],y);if(u.stages)for(var p=0;p<u.stages.length;p++)g=await ge(u.stages[p].expr,g,y);typeof g<"u"&&o.push(g)}var x=j();return n&&o.length===1&&Array.isArray(o[0])&&!se(o[0])?x=o[0]:o.forEach(function(R){!Array.isArray(R)||R.cons?x.push(R):R.forEach(W=>x.push(W))}),x}async function Ee(u,h,y){for(var n=h,o=0;o<u.length;o++){var l=u[o];switch(l.type){case"filter":n=await ge(l.expr,n,y);break;case"index":for(var g=0;g<n.length;g++){var p=n[g];p[l.value]=g}break}}return n}async function Te(u,h,y,n){var o;if(u.type==="sort"){if(y)o=await me(u,y,n);else{var l=await me(u,h,n);o=j(),o.tupleStream=!0;for(var g=0;g<l.length;g++){var p={"@":l[g]};p[u.index]=g,o.push(p)}}return u.stages&&(o=await Ee(u.stages,o,n)),o}o=j(),o.tupleStream=!0;var x=n;y===void 0&&(y=h.map(De=>({"@":De})));for(var R=0;R<y.length;R++){x=fe(n,y[R]);var W=await L(u,y[R]["@"],x);if(typeof W<"u"){Array.isArray(W)||(W=[W]);for(var X=0;X<W.length;X++)p={},Object.assign(p,y[R]),W.tupleStream?Object.assign(p,W[X]):(u.focus?(p[u.focus]=W[X],p["@"]=y[R]["@"]):p["@"]=W[X],u.index&&(p[u.index]=X),u.ancestor&&(p[u.ancestor.label]=y[R]["@"])),o.push(p)}}return u.stages&&(o=await Ee(u.stages,o,n)),o}async function ge(u,h,y){var n=j();if(h&&h.tupleStream&&(n.tupleStream=!0),Array.isArray(h)||(h=j(h)),u.type==="number"){var o=Math.floor(u.value);o<0&&(o=h.length+o);var l=await h[o];typeof l<"u"&&(Array.isArray(l)?n=l:n.push(l))}else for(o=0;o<h.length;o++){var l=h[o],g=l,p=y;h.tupleStream&&(g=l["@"],p=fe(y,l));var x=await L(u,g,p);S(x)&&(x=[x]),A(x)?x.forEach(function(W){var X=Math.floor(W);X<0&&(X=h.length+X),X===o&&n.push(l)}):c.boolean(x)&&n.push(l)}return n}async function Ce(u,h,y){var n,o=await L(u.lhs,h,y),l=u.value,g=async()=>await L(u.rhs,h,y);if(l==="and"||l==="or")try{return await Oe(o,g,l)}catch(x){throw x.position=u.position,x.token=l,x}var p=await g();try{switch(l){case"+":case"-":case"*":case"/":case"%":n=d(o,p,l);break;case"=":case"!=":n=m(o,p,l);break;case"<":case"<=":case">":case">=":n=q(o,p,l);break;case"&":n=v(o,p);break;case"..":n=N(o,p);break;case"in":n=le(o,p);break}}catch(x){throw x.position=u.position,x.token=l,x}return n}async function Xe(u,h,y){var n;switch(u.value){case"-":if(n=await L(u.expression,h,y),typeof n>"u")n=void 0;else if(S(n))n=-n;else throw{code:"D1002",stack:new Error().stack,position:u.position,token:u.value,value:n};break;case"[":n=[];let g=await Promise.all(u.expressions.map(async(p,x)=>(y.isParallelCall=x>0,[p,await L(p,h,y)])));for(let p of g){var[o,l]=p;typeof l<"u"&&(o.value==="["?n.push(l):n=c.append(n,l))}u.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":n=await T(u,h,y);break}return n}function xe(u,h,y){return c.lookup(h,u.value)}function ue(u){return u.value}function Qe(u,h){var y=j();return Array.isArray(h)&&h.outerWrapper&&h.length>0&&(h=h[0]),h!==null&&typeof h=="object"&&Object.keys(h).forEach(function(n){var o=h[n];Array.isArray(o)?(o=ae(o),y=c.append(y,o)):y.push(o)}),y}function ae(u,h){return typeof h>"u"&&(h=[]),Array.isArray(u)?u.forEach(function(y){ae(y,h)}):h.push(u),h}function Ie(u,h){var y,n=j();return typeof h<"u"&&(nt(h,n),n.length===1?y=n[0]:y=n),y}function nt(u,h){Array.isArray(u)||h.push(u),Array.isArray(u)?u.forEach(function(y){nt(y,h)}):u!==null&&typeof u=="object"&&Object.keys(u).forEach(function(y){nt(u[y],h)})}function d(u,h,y){var n;if(typeof u<"u"&&!S(u))throw{code:"T2001",stack:new Error().stack,value:u};if(typeof h<"u"&&!S(h))throw{code:"T2002",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u")return n;switch(y){case"+":n=u+h;break;case"-":n=u-h;break;case"*":n=u*h;break;case"/":n=u/h;break;case"%":n=u%h;break}return n}function m(u,h,y){var n,o=typeof u,l=typeof h;if(o==="undefined"||l==="undefined")return!1;switch(y){case"=":n=Z(u,h);break;case"!=":n=!Z(u,h);break}return n}function q(u,h,y){var n,o=typeof u,l=typeof h,g=o==="undefined"||o==="string"||o==="number",p=l==="undefined"||l==="string"||l==="number";if(!g||!p)throw{code:"T2010",stack:new Error().stack,value:o==="string"||o==="number"?h:u};if(!(o==="undefined"||l==="undefined")){if(o!==l)throw{code:"T2009",stack:new Error().stack,value:u,value2:h};switch(y){case"<":n=u<h;break;case"<=":n=u<=h;break;case">":n=u>h;break;case">=":n=u>=h;break}return n}}function le(u,h){var y=!1;if(typeof u>"u"||typeof h>"u")return!1;Array.isArray(h)||(h=[h]);for(var n=0;n<h.length;n++)if(h[n]===u){y=!0;break}return y}async function Oe(u,h,y){var n,o=_e(u);switch(y){case"and":n=o&&_e(await h());break;case"or":n=o||_e(await h());break}return n}function _e(u){var h=c.boolean(u);return typeof h>"u"?!1:h}function v(u,h){var y,n="",o="";return typeof u<"u"&&(n=c.string(u)),typeof h<"u"&&(o=c.string(h)),y=n.concat(o),y}async function T(u,h,y){var n={},o={},l=!!(h&&h.tupleStream);Array.isArray(h)||(h=j(h)),h.length===0&&h.push(void 0);for(var g=0;g<h.length;g++)for(var p=h[g],x=l?fe(y,p):y,R=0;R<u.lhs.length;R++){var W=u.lhs[R],X=await L(W[0],l?p["@"]:p,x);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:X};if(X!==void 0){var De={data:p,exprIndex:R};if(o.hasOwnProperty(X)){if(o[X].exprIndex!==R)throw{code:"D1009",stack:new Error().stack,position:u.position,value:X};o[X].data=c.append(o[X].data,p)}else o[X]=De}}let he=await Promise.all(Object.keys(o).map(async(Ae,Ze)=>{let we=o[Ae];var je=we.data,st=y;if(l){var Be=b(we.data);je=Be["@"],delete Be["@"],st=fe(y,Be)}return y.isParallelCall=Ze>0,[Ae,await L(u.lhs[we.exprIndex][1],je,st)]}));for(let Ae of he){var[X,Pe]=await Ae;typeof Pe<"u"&&(n[X]=Pe)}return n}function b(u){if(!Array.isArray(u))return u;var h={};Object.assign(h,u[0]);for(var y=1;y<u.length;y++)for(const n in u[y])h[n]=c.append(h[n],u[y][n]);return h}function N(u,h){var y;if(typeof u<"u"&&!Number.isInteger(u))throw{code:"T2003",stack:new Error().stack,value:u};if(typeof h<"u"&&!Number.isInteger(h))throw{code:"T2004",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u"||u>h)return y;var n=h-u+1;if(n>1e7)throw{code:"D2014",stack:new Error().stack,value:n};y=new Array(n);for(var o=u,l=0;o<=h;o++,l++)y[l]=o;return y.sequence=!0,y}async function $(u,h,y){var n=await L(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function I(u,h,y){var n,o=await L(u.condition,h,y);return c.boolean(o)?n=await L(u.then,h,y):typeof u.else<"u"&&(n=await L(u.else,h,y)),n}async function O(u,h,y){for(var n,o=it(y),l=0;l<u.expressions.length;l++)n=await L(u.expressions[l],h,o);return n}function F(u){var h=new Se.RegexEngine(u.value),y=function(n,o){var l;h.lastIndex=o||0;var g=h.exec(n);if(g!==null){if(l={match:g[0],start:g.index,end:g.index+g[0].length,groups:[]},g.length>1)for(var p=1;p<g.length;p++)l.groups.push(g[p]);l.next=function(){if(!(h.lastIndex>=n.length)){var x=y(n,h.lastIndex);if(x&&x.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return x}}}return l};return y}function J(u,h,y){var n;return u.value===""?n=h&&h.outerWrapper?h[0]:h:n=y.lookup(u.value),n}async function me(u,h,y){var n,o=h,l=!!h.tupleStream,g=async function(x,R){for(var W=0,X=0;W===0&&X<u.terms.length;X++){var De=u.terms[X],he=x,Pe=y;l&&(he=x["@"],Pe=fe(y,x));var Ae=await L(De.expression,he,Pe);he=R,Pe=y,l&&(he=R["@"],Pe=fe(y,R));var Ze=await L(De.expression,he,Pe),we=typeof Ae,je=typeof Ze;if(we==="undefined"){W=je==="undefined"?0:1;continue}if(je==="undefined"){W=-1;continue}if(!(we==="string"||we==="number")||!(je==="string"||je==="number"))throw{code:"T2008",stack:new Error().stack,position:u.position,value:we==="string"||we==="number"?Ze:Ae};if(we!==je)throw{code:"T2007",stack:new Error().stack,position:u.position,value:Ae,value2:Ze};Ae!==Ze&&(Ae<Ze?W=-1:W=1,De.descending===!0&&(W=-W))}return W===1},p={environment:y,input:h};return n=await c.sort.apply(p,[o,g]),n}function be(u,h,y){var n=async function(o){if(!(typeof o>"u")){var l=y.lookup("clone");if(!pe(l))throw{code:"T2013",stack:new Error().stack,position:u.position};var g=await Y(l,[o],null,y),p=await L(u.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var x=0;x<p.length;x++){var R=p[x];if(R&&(R.isPrototypeOf(g)||R instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var W=await L(u.update,R,y),X=typeof W;if(X!=="undefined"){if(X!=="object"||W===null||Array.isArray(W))throw{code:"T2011",stack:new Error().stack,position:u.update.position,value:W};for(var De in W)R[De]=W[De]}if(typeof u.delete<"u"){var he=await L(u.delete,R,y);if(typeof he<"u"){var Pe=he;if(Array.isArray(he)||(he=[he]),!k(he))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Pe};for(var Ae=0;Ae<he.length;Ae++)typeof R=="object"&&R!==null&&delete R[he[Ae]]}}}}return g}};return B(n,"<(oa):o>")}var K=w("function($f, $g) { function($x){ $g($f($x)) } }");async function Q(u,h,y){var n,o=await L(u.lhs,h,y);if(u.rhs.type==="function")n=await de(u.rhs,h,y,{context:o});else{var l=await L(u.rhs,h,y);if(!pe(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(pe(o)){var g=await L(K,null,y);n=await Y(g,[o,l],null,y)}else n=await Y(l,[o],null,y)}return n}async function de(u,h,y,n){var o,l=await L(u.procedure,h,y);if(typeof l>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};var g=[];typeof n<"u"&&g.push(n.context);for(var p=0;p<u.arguments.length;p++){const R=await L(u.arguments[p],h,y);if(pe(R)){const W=async function(...X){return await Y(R,X,null,y)};W.arity=ne(R),g.push(W)}else g.push(R)}var x=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=x,l.position=u.position),o=await Y(l,g,h,y)}catch(R){throw R.position||(R.position=u.position),R.token||(R.token=x),R}return o}async function Y(u,h,y,n){var o;for(o=await Le(u,h,y,n);ye(o)&&o.thunk===!0;){var l=await L(o.body.procedure,o.input,o.environment);o.body.procedure.type==="variable"&&(l.token=o.body.procedure.value),l.position=o.body.procedure.position;for(var g=[],p=0;p<o.body.arguments.length;p++)g.push(await L(o.body.arguments[p],o.input,o.environment));o=await Le(l,g,y,n)}return o}async function Le(u,h,y,n){var o;try{var l=h;if(u&&(l=$e(u.signature,h,y)),ye(u))o=await qe(u,l);else if(u&&u._jsonata_function===!0){var g={environment:n,input:y};o=u.implementation.apply(g,l),H(o)&&(o=o.next().value),C(o)&&(o=await o)}else if(typeof u=="function")o=u.apply(y,l),C(o)&&(o=await o);else throw{code:"T1006",stack:new Error().stack}}catch(p){throw u&&(typeof p.token>"u"&&typeof u.token<"u"&&(p.token=u.token),p.position=u.position||p.position),p}return o}function at(u,h,y){var n={_jsonata_lambda:!0,input:h,environment:y,arguments:u.arguments,signature:u.signature,body:u.body};return u.thunk===!0&&(n.thunk=!0),n.apply=async function(o,l){return await Y(n,l,h,o?o.environment:y)},n}async function Ve(u,h,y){for(var n,o=[],l=0;l<u.arguments.length;l++){var g=u.arguments[l];g.type==="operator"&&g.value==="?"?o.push(g):o.push(await L(g,h,y))}var p=await L(u.procedure,h,y);if(typeof p>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};if(ye(p))n=gt(p,o);else if(p&&p._jsonata_function===!0)n=xt(p.implementation,o);else if(typeof p=="function")n=xt(p,o);else throw{code:"T1008",stack:new Error().stack,position:u.position,token:u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value};return n}function $e(u,h,y){if(typeof u>"u")return h;var n=u.validate(h,y);return n}async function qe(u,h){var y,n=it(u.environment);return u.arguments.forEach(function(o,l){n.bind(o.value,h[l])}),typeof u.body=="function"?y=await ur(u.body,n):y=await L(u.body,u.input,n),y}function gt(u,h){var y=it(u.environment),n=[];u.arguments.forEach(function(l,g){var p=h[g];p&&p.type==="operator"&&p.value==="?"?n.push(l):y.bind(l.value,p)});var o={_jsonata_lambda:!0,input:u.input,environment:y,arguments:n,body:u.body};return o}function xt(u,h){var y=_t(u);y=y.map(function(g){return"$"+g.trim()});var n="function("+y.join(", ")+"){ _ }",o=w(n);o.body=u;var l=gt(o,h);return l}async function ur(u,h){var y=_t(u),n=y.map(function(g){return h.lookup(g.trim())}),o={environment:h},l=u.apply(o,n);return C(l)&&(l=await l),l}function _t(u){var h=u.toString(),y=/\(([^)]*)\)/.exec(h)[1],n=y.split(",");return n}function B(u,h){var y={_jsonata_function:!0,implementation:u};return typeof h<"u"&&(y.signature=E(h)),y}async function lr(u,h){if(!(typeof u>"u")){var y=this.input;typeof h<"u"&&(y=h,Array.isArray(y)&&!se(y)&&(y=j(y),y.outerWrapper=!0));try{var n=w(u,!1)}catch(l){throw dt(l),{stack:new Error().stack,code:"D3120",value:l.message,error:l}}try{var o=await L(n,y,this.environment)}catch(l){throw dt(l),{stack:new Error().stack,code:"D3121",value:l.message,error:l}}return o}}function qt(u){if(!(typeof u>"u"))return JSON.parse(c.string(u))}function it(u){var h={};const y={bind:function(o,l){h[o]=l},lookup:function(o){var l;return h.hasOwnProperty(o)?l=h[o]:u&&(l=u.lookup(o)),l},timestamp:u?u.timestamp:null,async:u?u.async:!1,isParallelCall:u?u.isParallelCall:!1,global:u?u.global:{ancestry:[null]}};if(u){var n=u.lookup(Symbol.for("jsonata.__createFrame_push"));n&&n(u,y)}return y}_.bind("sum",B(c.sum,"<a<n>:n>")),_.bind("count",B(c.count,"<a:n>")),_.bind("max",B(c.max,"<a<n>:n>")),_.bind("min",B(c.min,"<a<n>:n>")),_.bind("average",B(c.average,"<a<n>:n>")),_.bind("string",B(c.string,"<x-b?:s>")),_.bind("substring",B(c.substring,"<s-nn?:s>")),_.bind("substringBefore",B(c.substringBefore,"<s-s:s>")),_.bind("substringAfter",B(c.substringAfter,"<s-s:s>")),_.bind("lowercase",B(c.lowercase,"<s-:s>")),_.bind("uppercase",B(c.uppercase,"<s-:s>")),_.bind("length",B(c.length,"<s-:n>")),_.bind("trim",B(c.trim,"<s-:s>")),_.bind("pad",B(c.pad,"<s-ns?:s>")),_.bind("match",B(c.match,"<s-f<s:o>n?:a<o>>")),_.bind("contains",B(c.contains,"<s-(sf):b>")),_.bind("replace",B(c.replace,"<s-(sf)(sf)n?:s>")),_.bind("split",B(c.split,"<s-(sf)n?:a<s>>")),_.bind("join",B(c.join,"<a<s>s?:s>")),_.bind("formatNumber",B(c.formatNumber,"<n-so?:s>")),_.bind("formatBase",B(c.formatBase,"<n-n?:s>")),_.bind("formatInteger",B(i.formatInteger,"<n-s:s>")),_.bind("parseInteger",B(i.parseInteger,"<s-s:n>")),_.bind("number",B(c.number,"<(nsb)-:n>")),_.bind("floor",B(c.floor,"<n-:n>")),_.bind("ceil",B(c.ceil,"<n-:n>")),_.bind("round",B(c.round,"<n-n?:n>")),_.bind("abs",B(c.abs,"<n-:n>")),_.bind("sqrt",B(c.sqrt,"<n-:n>")),_.bind("power",B(c.power,"<n-n:n>")),_.bind("random",B(c.random,"<:n>")),_.bind("boolean",B(c.boolean,"<x-:b>")),_.bind("not",B(c.not,"<x-:b>")),_.bind("map",B(c.map,"<af>")),_.bind("zip",B(c.zip,"<a+>")),_.bind("filter",B(c.filter,"<af>")),_.bind("single",B(c.single,"<af?>")),_.bind("reduce",B(c.foldLeft,"<afj?:j>")),_.bind("sift",B(c.sift,"<o-f?:o>")),_.bind("keys",B(c.keys,"<x-:a<s>>")),_.bind("lookup",B(c.lookup,"<x-s:x>")),_.bind("append",B(c.append,"<xx:a>")),_.bind("exists",B(c.exists,"<x:b>")),_.bind("spread",B(c.spread,"<x-:a<o>>")),_.bind("merge",B(c.merge,"<a<o>:o>")),_.bind("reverse",B(c.reverse,"<a:a>")),_.bind("each",B(c.each,"<o-f:a>")),_.bind("error",B(c.error,"<s?:x>")),_.bind("assert",B(c.assert,"<bs?:x>")),_.bind("type",B(c.type,"<x:s>")),_.bind("sort",B(c.sort,"<af?:a>")),_.bind("shuffle",B(c.shuffle,"<a:a>")),_.bind("distinct",B(c.distinct,"<x:x>")),_.bind("base64encode",B(c.base64encode,"<s-:s>")),_.bind("base64decode",B(c.base64decode,"<s-:s>")),_.bind("encodeUrlComponent",B(c.encodeUrlComponent,"<s-:s>")),_.bind("encodeUrl",B(c.encodeUrl,"<s-:s>")),_.bind("decodeUrlComponent",B(c.decodeUrlComponent,"<s-:s>")),_.bind("decodeUrl",B(c.decodeUrl,"<s-:s>")),_.bind("eval",B(lr,"<sx?:x>")),_.bind("toMillis",B(i.toMillis,"<s-s?:n>")),_.bind("fromMillis",B(i.fromMillis,"<n-s?s?:s>")),_.bind("clone",B(qt,"<(oa)-:o>"));var jt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function dt(u){var h=jt[u.code];if(typeof h<"u"){var y=h.replace(/\{\{\{([^}]+)}}}/g,function(){return u[arguments[1]]});y=y.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(u[arguments[1]])}),u.message=y}}function Se(u,h){var y,n;try{y=w(u,h&&h.recover),n=y.errors,delete y.errors}catch(g){throw dt(g),g}var o=it(_),l=new Date;return o.bind("now",B(function(g,p){return i.fromMillis(l.getTime(),g,p)},"<s?s?:s>")),o.bind("millis",B(function(){return l.getTime()},"<:n>")),h&&h.RegexEngine?Se.RegexEngine=h.RegexEngine:Se.RegexEngine=RegExp,{evaluate:async function(g,p,x){if(typeof n<"u"){var R={code:"S0500",position:0};throw dt(R),R}if(typeof p<"u"){var W;W=it(o);for(var X in p)W.bind(X,p[X])}else W=o;W.bind("$",g),l=new Date,W.timestamp=l,Array.isArray(g)&&!se(g)&&(g=j(g),g.outerWrapper=!0);var De;try{return De=await L(y,g,W),typeof x=="function"&&x(null,De),De}catch(he){throw dt(he),he}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,x){var R=B(p,x);o.bind(g,R)},ast:function(){return y},errors:function(){return n}}}return Se.parser=w,Se})();a.exports=M},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(r,a,s){var i=r("./signature");const c=(()=>{var f={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},w={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
|
-
`,r:"\r",t:" "},E=function(S){var k=0,A=S.length,j=function(ye,H){var C={type:ye,value:H,position:k};return C},se=function(){for(var ye=k,H=0,C,ne,Z=function(L){if(S.charAt(L)==="/"&&H===0){for(var V=0;S.charAt(L-(V+1))==="\\";)V++;if(V%2===0)return!0}return!1};k<A;){var _=S.charAt(k);if(Z(k)){if(C=S.substring(ye,k),C==="")throw{code:"S0301",stack:new Error().stack,position:k};for(k++,_=S.charAt(k),ye=k;_==="i"||_==="m";)k++,_=S.charAt(k);return ne=S.substring(ye,k)+"g",new RegExp(C,ne)}(_==="("||_==="["||_==="{")&&S.charAt(k-1)!=="\\"&&H++,(_===")"||_==="]"||_==="}")&&S.charAt(k-1)!=="\\"&&H--,k++}throw{code:"S0302",stack:new Error().stack,position:k}},pe=function(ye){if(k>=A)return null;for(var H=S.charAt(k);k<A&&`
|
|
3
|
-
\r\v`.indexOf(H)>-1;)k++,H=S.charAt(k);if(H==="/"&&S.charAt(k+1)==="*"){var C=k;for(k+=2,H=S.charAt(k);!(H==="*"&&S.charAt(k+1)==="/");)if(H=S.charAt(++k),k>=A)throw{code:"S0106",stack:new Error().stack,position:C};return k+=2,H=S.charAt(k),pe(ye)}if(ye!==!0&&H==="/")return k++,j("regex",se());if(H==="."&&S.charAt(k+1)===".")return k+=2,j("operator","..");if(H===":"&&S.charAt(k+1)==="=")return k+=2,j("operator",":=");if(H==="!"&&S.charAt(k+1)==="=")return k+=2,j("operator","!=");if(H===">"&&S.charAt(k+1)==="=")return k+=2,j("operator",">=");if(H==="<"&&S.charAt(k+1)==="=")return k+=2,j("operator","<=");if(H==="*"&&S.charAt(k+1)==="*")return k+=2,j("operator","**");if(H==="~"&&S.charAt(k+1)===">")return k+=2,j("operator","~>");if(H==="?"&&S.charAt(k+1)===":")return k+=2,j("operator","?:");if(H==="?"&&S.charAt(k+1)==="?")return k+=2,j("operator","??");if(Object.prototype.hasOwnProperty.call(f,H))return k++,j("operator",H);if(H==='"'||H==="'"){var ne=H;k++;for(var Z="";k<A;){if(H=S.charAt(k),H==="\\")if(k++,H=S.charAt(k),Object.prototype.hasOwnProperty.call(w,H))Z+=w[H];else if(H==="u"){var _=S.substr(k+1,4);if(/^[0-9a-fA-F]+$/.test(_)){var L=parseInt(_,16);Z+=String.fromCharCode(L),k+=4}else throw{code:"S0104",stack:new Error().stack,position:k}}else throw{code:"S0103",stack:new Error().stack,position:k,token:H};else{if(H===ne)return k++,j("string",Z);Z+=H}k++}throw{code:"S0101",stack:new Error().stack,position:k}}var V=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,fe=V.exec(S.substring(k));if(fe!==null){var ke=parseFloat(fe[0]);if(!isNaN(ke)&&isFinite(ke))return k+=fe[0].length,j("number",ke);throw{code:"S0102",stack:new Error().stack,position:k,token:fe[0]}}var Ee;if(H==="`"){k++;var Te=S.indexOf("`",k);if(Te!==-1)return Ee=S.substring(k,Te),k=Te+1,j("name",Ee);throw k=A,{code:"S0105",stack:new Error().stack,position:k}}for(var ge=k,Ce;;)if(Ce=S.charAt(ge),ge===A||`
|
|
4
|
-
\r\v`.indexOf(Ce)>-1||Object.prototype.hasOwnProperty.call(f,Ce)){if(S.charAt(k)==="$")return Ee=S.substring(k+1,ge),k=ge,j("variable",Ee);switch(Ee=S.substring(k,ge),k=ge,Ee){case"or":case"in":case"and":return j("operator",Ee);case"true":return j("value",!0);case"false":return j("value",!1);case"null":return j("value",null);default:return k===A&&Ee===""?null:j("name",Ee)}}else ge++};return pe},M=function(S,k){var A,j,se={},pe=[],ye=function(){var d=[];A.id!=="(end)"&&d.push({type:A.type,value:A.value,position:A.position});for(var m=j();m!==null;)d.push(m),m=j();return d},H={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(k)return d.remaining=ye(),d.type="error",pe.push(d),d;throw d.stack=new Error().stack,d}},C=function(d,m){var q=se[d];return m=m||0,q?m>=q.lbp&&(q.lbp=m):(q=Object.create(H),q.id=q.value=d,q.lbp=m,se[d]=q),q},ne=function(d){if(k){d.remaining=ye(),pe.push(d);var m=se["(error)"];return A=Object.create(m),A.error=d,A.type="(error)",A}else throw d.stack=new Error().stack,d},Z=function(d,m){if(d&&A.id!==d){var q;A.id==="(end)"?q="S0203":q="S0202";var le={code:q,position:A.position,token:A.value,value:d};return ne(le)}var Oe=j(m);if(Oe===null)return A=se["(end)"],A.position=S.length,A;var _e=Oe.value,v=Oe.type,T;switch(v){case"name":case"variable":T=se["(name)"];break;case"operator":if(T=se[_e],!T)return ne({code:"S0204",stack:new Error().stack,position:Oe.position,token:_e});break;case"string":case"number":case"value":T=se["(literal)"];break;case"regex":v="regex",T=se["(regex)"];break;default:return ne({code:"S0205",stack:new Error().stack,position:Oe.position,token:_e})}return A=Object.create(T),A.value=_e,A.type=v,A.position=Oe.position,A},_=function(d){var m,q=A;for(Z(null,!0),m=q.nud();d<A.lbp;)q=A,Z(),m=q.led(m);return m},L=function(d){var m=C(d,0);m.nud=function(){return this}},V=function(d,m,q){var le=m||f[d],Oe=C(d,le);return Oe.led=q||function(_e){return this.lhs=_e,this.rhs=_(le),this.type="binary",this},Oe},fe=function(d,m,q){var le=C(d,m);return le.led=q,le},ke=function(d,m){var q=C(d);return q.nud=m||function(){return this.expression=_(70),this.type="unary",this},q};L("(end)"),L("(name)"),L("(literal)"),L("(regex)"),C(":"),C(";"),C(","),C(")"),C("]"),C("}"),C(".."),V("."),V("+"),V("-"),V("*"),V("/"),V("%"),V("="),V("<"),V(">"),V("!="),V("<="),V(">="),V("&"),V("and"),V("or"),V("in"),L("and"),L("or"),L("in"),ke("-"),V("~>"),V("??",f["??"],function(d){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[d]},this.then=d,this.else=_(0),this}),fe("(error)",10,function(d){return this.lhs=d,this.error=A.error,this.remaining=ye(),this.type="error",this}),ke("*",function(){return this.type="wildcard",this}),ke("**",function(){return this.type="descendant",this}),ke("%",function(){return this.type="parent",this}),V("(",f["("],function(d){if(this.procedure=d,this.type="function",this.arguments=[],A.id!==")")for(;A.type==="operator"&&A.id==="?"?(this.type="partial",this.arguments.push(A),Z("?")):this.arguments.push(_(0)),A.id===",";)Z(",");if(Z(")",!0),d.type==="name"&&(d.value==="function"||d.value==="λ")){if(this.arguments.forEach(function(_e,v){if(_e.type!=="variable")return ne({code:"S0208",stack:new Error().stack,position:_e.position,token:_e.value,value:v+1})}),this.type="lambda",A.id==="<"){for(var m=A.position,q=1,le="<";q>0&&A.id!=="{"&&A.id!=="(end)";){var Oe=Z();Oe.id===">"?q--:Oe.id==="<"&&q++,le+=Oe.value}Z(">");try{this.signature=i(le)}catch(_e){return _e.position=m+_e.offset,ne(_e)}}Z("{"),this.body=_(0),Z("}")}return this}),ke("(",function(){for(var d=[];A.id!==")"&&(d.push(_(0)),A.id===";");)Z(";");return Z(")",!0),this.type="block",this.expressions=d,this}),ke("[",function(){var d=[];if(A.id!=="]")for(;;){var m=_(0);if(A.id===".."){var q={type:"binary",value:"..",position:A.position,lhs:m};Z(".."),q.rhs=_(0),m=q}if(d.push(m),A.id!==",")break;Z(",")}return Z("]",!0),this.expressions=d,this.type="unary",this}),V("[",f["["],function(d){if(A.id==="]"){for(var m=d;m&&m.type==="binary"&&m.value==="[";)m=m.lhs;return m.keepArray=!0,Z("]"),d}else return this.lhs=d,this.rhs=_(f["]"]),this.type="binary",Z("]",!0),this}),V("^",f["^"],function(d){Z("(");for(var m=[];;){var q={descending:!1};if(A.id==="<"?Z("<"):A.id===">"&&(q.descending=!0,Z(">")),q.expression=_(0),m.push(q),A.id!==",")break;Z(",")}return Z(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Ee=function(d){var m=[];if(A.id!=="}")for(;;){var q=_(0);Z(":");var le=_(0);if(m.push([q,le]),A.id!==",")break;Z(",")}return Z("}",!0),typeof d>"u"?(this.lhs=m,this.type="unary"):(this.lhs=d,this.rhs=m,this.type="binary"),this};ke("{",Ee),V("{",f["{"],Ee),fe(":=",f[":="],function(d){return d.type!=="variable"?ne({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=_(f[":="]-1),this.type="binary",this)}),V("@",f["@"],function(d){return this.lhs=d,this.rhs=_(f["@"]),this.rhs.type!=="variable"?ne({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),V("#",f["#"],function(d){return this.lhs=d,this.rhs=_(f["#"]),this.rhs.type!=="variable"?ne({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),V("?",f["?"],function(d){return this.type="condition",this.condition=d,this.then=_(0),A.id===":"&&(Z(":"),this.else=_(0)),this}),V("?:",f["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=_(0),this}),ke("|",function(){return this.type="transform",this.pattern=_(0),Z("|"),this.update=_(0),A.id===","&&(Z(","),this.delete=_(0)),Z("|"),this});var Te=function(d){var m;if(d.type==="function"&&!d.predicate){var q={type:"lambda",thunk:!0,arguments:[],position:d.position};q.body=d,m=q}else if(d.type==="condition")d.then=Te(d.then),typeof d.else<"u"&&(d.else=Te(d.else)),m=d;else if(d.type==="block"){var le=d.expressions.length;le>0&&(d.expressions[le-1]=Te(d.expressions[le-1])),m=d}else m=d;return m},ge=0,Ce=0,Xe=[],xe=function(d,m){switch(d.type){case"name":case"wildcard":m.level--,m.level===0&&(typeof d.ancestor>"u"||(Xe[m.index].slot.label=d.ancestor.label),d.ancestor=m,d.tuple=!0);break;case"parent":m.level++;break;case"block":d.expressions.length>0&&(d.tuple=!0,m=xe(d.expressions[d.expressions.length-1],m));break;case"path":d.tuple=!0;var q=d.steps.length-1;for(m=xe(d.steps[q--],m);m.level>0&&q>=0;)m=xe(d.steps[q--],m);break;default:throw{code:"S0217",token:d.type,position:d.position}}return m},ue=function(d,m){if(typeof m.seekingParent<"u"||m.type==="parent"){var q=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&q.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=q:Array.prototype.push.apply(d.seekingParent,q)}},Qe=function(d){var m=d.steps.length-1,q=d.steps[m],le=typeof q.seekingParent<"u"?q.seekingParent:[];q.type==="parent"&&le.push(q.slot);for(var Oe=0;Oe<le.length;Oe++){var _e=le[Oe];for(m=d.steps.length-2;_e.level>0;){if(m<0){typeof d.seekingParent>"u"?d.seekingParent=[_e]:d.seekingParent.push(_e);break}for(var v=d.steps[m--];m>=0&&v.focus&&d.steps[m].focus;)v=d.steps[m--];_e=xe(v,_e)}}},ae=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var q=ae(d.lhs);q.type==="path"?m=q:m={type:"path",steps:[q]},q.type==="parent"&&(m.seekingParent=[q.slot]);var le=ae(d.rhs);le.type==="function"&&le.procedure.type==="path"&&le.procedure.steps.length===1&&le.procedure.steps[0].type==="name"&&m.steps[m.steps.length-1].type==="function"&&(m.steps[m.steps.length-1].nextFunction=le.procedure.steps[0].value),le.type==="path"?Array.prototype.push.apply(m.steps,le.steps):(typeof le.predicate<"u"&&(le.stages=le.predicate,delete le.predicate),m.steps.push(le)),m.steps.filter(function(F){if(F.type==="number"||F.type==="value")throw{code:"S0213",stack:new Error().stack,position:F.position,value:F.value};return F.type==="string"}).forEach(function(F){F.type="name"}),m.steps.filter(function(F){return F.keepArray===!0}).length>0&&(m.keepSingletonArray=!0);var Oe=m.steps[0];Oe.type==="unary"&&Oe.value==="["&&(Oe.consarray=!0);var _e=m.steps[m.steps.length-1];_e.type==="unary"&&_e.value==="["&&(_e.consarray=!0),Qe(m);break;case"[":m=ae(d.lhs);var v=m,T="predicate";if(m.type==="path"&&(v=m.steps[m.steps.length-1],T="stages"),typeof v.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof v[T]>"u"&&(v[T]=[]);var b=ae(d.rhs);typeof b.seekingParent<"u"&&(b.seekingParent.forEach(F=>{F.level===1?xe(v,F):F.level--}),ue(v,b)),v[T].push({type:"filter",expr:b,position:d.position});break;case"{":if(m=ae(d.lhs),typeof m.group<"u")throw{code:"S0210",stack:new Error().stack,position:d.position};m.group={lhs:d.rhs.map(function(F){return[ae(F[0]),ae(F[1])]}),position:d.position};break;case"^":m=ae(d.lhs),m.type!=="path"&&(m={type:"path",steps:[m]});var N={type:"sort",position:d.position};N.terms=d.rhs.map(function(F){var J=ae(F.expression);return ue(N,J),{descending:F.descending,expression:J}}),m.steps.push(N),Qe(m);break;case":=":m={type:"bind",value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),ue(m,m.rhs);break;case"@":if(m=ae(d.lhs),v=m,m.type==="path"&&(v=m.steps[m.steps.length-1]),typeof v.stages<"u"||typeof v.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:d.position};if(v.type==="sort")throw{code:"S0216",stack:new Error().stack,position:d.position};d.keepArray&&(v.keepArray=!0),v.focus=d.rhs.value,v.tuple=!0;break;case"#":m=ae(d.lhs),v=m,m.type==="path"?v=m.steps[m.steps.length-1]:(m={type:"path",steps:[m]},typeof v.predicate<"u"&&(v.stages=v.predicate,delete v.predicate)),typeof v.stages>"u"?v.index=d.rhs.value:v.stages.push({type:"index",value:d.rhs.value,position:d.position}),v.tuple=!0;break;case"~>":m={type:"apply",value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),m.keepArray=m.lhs.keepArray||m.rhs.keepArray;break;default:m={type:d.type,value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),ue(m,m.lhs),ue(m,m.rhs)}break;case"unary":m={type:d.type,value:d.value,position:d.position},d.value==="["?m.expressions=d.expressions.map(function(F){var J=ae(F);return ue(m,J),J}):d.value==="{"?m.lhs=d.lhs.map(function(F){var J=ae(F[0]);ue(m,J);var me=ae(F[1]);return ue(m,me),[J,me]}):(m.expression=ae(d.expression),d.value==="-"&&m.expression.type==="number"?(m=m.expression,m.value=-m.value):ue(m,m.expression));break;case"function":case"partial":m={type:d.type,name:d.name,value:d.value,position:d.position},m.arguments=d.arguments.map(function(F){var J=ae(F);return ue(m,J),J}),m.procedure=ae(d.procedure);break;case"lambda":m={type:d.type,arguments:d.arguments,signature:d.signature,position:d.position};var $=ae(d.body);m.body=Te($);break;case"condition":m={type:d.type,position:d.position},m.condition=ae(d.condition),ue(m,m.condition),m.then=ae(d.then),ue(m,m.then),typeof d.else<"u"&&(m.else=ae(d.else),ue(m,m.else));break;case"transform":m={type:d.type,position:d.position},m.pattern=ae(d.pattern),m.update=ae(d.update),typeof d.delete<"u"&&(m.delete=ae(d.delete));break;case"block":m={type:d.type,position:d.position},m.expressions=d.expressions.map(function(F){var J=ae(F);return ue(m,J),(J.consarray||J.type==="path"&&J.steps[0].consarray)&&(m.consarray=!0),J});break;case"name":m={type:"path",steps:[d]},d.keepArray&&(m.keepSingletonArray=!0);break;case"parent":m={type:"parent",slot:{label:"!"+ge++,level:1,index:Ce++}},Xe.push(m);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":m=d;break;case"operator":if(d.value==="and"||d.value==="or"||d.value==="in")d.type="name",m=ae(d);else if(d.value==="?")m=d;else throw{code:"S0201",stack:new Error().stack,position:d.position,token:d.value};break;case"error":m=d,d.lhs&&(m=ae(d.lhs));break;default:var I="S0206";d.id==="(end)"&&(I="S0207");var O={code:I,position:d.position,token:d.value};if(k)return pe.push(O),{type:"error",error:O};throw O.stack=new Error().stack,O}return d.keepArray&&(m.keepArray=!0),m};j=E(S),Z();var Ie=_(0);if(A.id!=="(end)"){var nt={code:"S0201",position:A.position,token:A.value};ne(nt)}if(Ie=ae(Ie),Ie.type==="parent"||typeof Ie.seekingParent<"u")throw{code:"S0217",token:Ie.type,position:Ie.position};return pe.length>0&&(Ie.errors=pe),Ie};return M})();a.exports=c},{"./signature":5}],5:[function(r,a,s){var i=r("./utils");const c=(()=>{var f={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function w(E){for(var M=1,S=[],k={},A=k;M<E.length;){var j=E.charAt(M);if(j===":")break;var se=function(){S.push(k),A=k,k={}},pe=function(V,fe,ke,Ee){for(var Te=1,ge=fe;ge<V.length;)if(ge++,j=V.charAt(ge),j===Ee){if(Te--,Te===0)break}else j===ke&&Te++;return ge};switch(j){case"s":case"n":case"b":case"l":case"o":k.regex="["+j+"m]",k.type=j,se();break;case"a":k.regex="[asnblfom]",k.type=j,k.array=!0,se();break;case"f":k.regex="f",k.type=j,se();break;case"j":k.regex="[asnblom]",k.type=j,se();break;case"x":k.regex="[asnblfom]",k.type=j,se();break;case"-":A.context=!0,A.contextRegex=new RegExp(A.regex),A.regex+="?";break;case"?":case"+":A.regex+=j;break;case"(":var ye=pe(E,M,"(",")"),H=E.substring(M+1,ye);if(H.indexOf("<")===-1)k.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:M};k.type="("+H+")",M=ye,se();break;case"<":if(A.type==="a"||A.type==="f"){var C=pe(E,M,"<",">");A.subtype=E.substring(M+1,C),M=C}else throw{code:"S0401",stack:new Error().stack,value:A.type,offset:M};break}M++}var ne="^"+S.map(function(V){return"("+V.regex+")"}).join("")+"$",Z=new RegExp(ne),_=function(V){var fe;if(i.isFunction(V))fe="f";else{var ke=typeof V;switch(ke){case"string":fe="s";break;case"number":fe="n";break;case"boolean":fe="b";break;case"object":V===null?fe="l":Array.isArray(V)?fe="a":fe="o";break;case"undefined":default:fe="m"}}return fe},L=function(V,fe){for(var ke="^",Ee=0,Te=0;Te<S.length;Te++){ke+=S[Te].regex;var ge=fe.match(ke);if(ge===null)throw{code:"T0410",stack:new Error().stack,value:V[Ee],index:Ee+1};Ee=ge[0].length}throw{code:"T0410",stack:new Error().stack,value:V[Ee],index:Ee+1}};return{definition:E,validate:function(V,fe){var ke="";V.forEach(function(Ce){ke+=_(Ce)});var Ee=Z.exec(ke);if(Ee){var Te=[],ge=0;return S.forEach(function(Ce,Xe){var xe=V[ge],ue=Ee[Xe+1];if(ue==="")if(Ce.context&&Ce.contextRegex){var Qe=_(fe);if(Ce.contextRegex.test(Qe))Te.push(fe);else throw{code:"T0411",stack:new Error().stack,value:fe,index:ge+1}}else Te.push(xe),ge++;else ue.split("").forEach(function(ae){if(Ce.type==="a"){if(ae==="m")xe=void 0;else{xe=V[ge];var Ie=!0;if(typeof Ce.subtype<"u"){if(ae!=="a"&&ue!==Ce.subtype)Ie=!1;else if(ae==="a"&&xe.length>0){var nt=_(xe[0]);if(nt!==Ce.subtype.charAt(0))Ie=!1;else{var d=xe.filter(function(m){return _(m)!==nt});Ie=d.length===0}}}if(!Ie)throw{code:"T0412",stack:new Error().stack,value:xe,index:ge+1,type:f[Ce.subtype]};ae!=="a"&&(xe=[xe])}Te.push(xe),ge++}else Te.push(xe),ge++})}),Te}L(V,ke)}}}return w})();a.exports=c},{"./utils":6}],6:[function(r,a,s){const i=(()=>{function c(C){var ne=!1;if(typeof C=="number"&&(ne=!isNaN(C),ne&&!isFinite(C)))throw{code:"D1001",value:C,stack:new Error().stack};return ne}function f(C){var ne=!1;return Array.isArray(C)&&(ne=C.filter(function(Z){return typeof Z!="string"}).length===0),ne}function w(C){var ne=!1;return Array.isArray(C)&&(ne=C.filter(function(Z){return!c(Z)}).length===0),ne}function E(){var C=[];return C.sequence=!0,arguments.length===1&&C.push(arguments[0]),C}function M(C){return C.sequence===!0&&Array.isArray(C)}function S(C){return C&&(C._jsonata_function===!0||C._jsonata_lambda===!0)||typeof C=="function"}function k(C){var ne=typeof C.arity=="number"?C.arity:typeof C.implementation=="function"?C.implementation.length:typeof C.length=="number"?C.length:C.arguments.length;return ne}function A(C){return C&&C._jsonata_lambda===!0}var j=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function se(C){return typeof C=="object"&&C!==null&&j in C&&"next"in C&&typeof C.next=="function"}function pe(C,ne){if(C===ne)return!0;if(typeof C=="object"&&typeof ne=="object"&&C!==null&&ne!==null){if(Array.isArray(C)&&Array.isArray(ne)){if(C.length!==ne.length)return!1;for(var Z=0;Z<C.length;Z++)if(!pe(C[Z],ne[Z]))return!1;return!0}var _=Object.getOwnPropertyNames(C),L=Object.getOwnPropertyNames(ne);if(_.length!==L.length)return!1;for(_=_.sort(),L=L.sort(),Z=0;Z<_.length;Z++)if(_[Z]!==L[Z])return!1;for(Z=0;Z<_.length;Z++){var V=_[Z];if(!pe(C[V],ne[V]))return!1}return!0}return!1}function ye(C){return typeof C=="object"&&C!==null&&"then"in C&&typeof C.then=="function"}function H(C){var ne=[];for(let Z of C)ne.push(Z);return ne}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:w,createSequence:E,isSequence:M,isFunction:S,isLambda:A,isIterable:se,getFunctionArity:k,isDeepEqual:pe,stringToArray:H,isPromise:ye}})();a.exports=i},{}]},{},[3])(3)})})(Dr)),Dr.exports}var Xa=Ja();const Qa=an(Xa),es=D.object({name:D.literal("data-extract"),code:D.string(),inputData:D.any().optional()});function Ms(t){return es.parse(t)}async function js(t){try{console.log("[DataExtractBlock] Executing JSONata query:",t.code);const r=await Qa(t.code).evaluate(t.inputData);return console.log("[DataExtractBlock] Data extraction successful"),{data:r}}catch(e){return console.error("[DataExtractBlock] Data extraction error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in data extraction",data:void 0}}}const ts=D.object({name:D.literal("capture-network"),targetUrl:D.string().url(),waitForLoadComplete:D.boolean().optional(),timeout:D.number().min(0).optional(),includeRequestHeaders:D.boolean().optional(),includeResponseHeaders:D.boolean().optional(),includeResponseBody:D.boolean().optional(),urlFilter:D.string().optional(),resourceTypes:D.array(D.string()).optional()});function Is(t){return ts.parse(t)}async function Fs(t){try{console.log("[CaptureNetworkBlock] Capturing network requests for URL:",t.targetUrl);const e=await chrome.runtime.sendMessage({type:"CDP_CAPTURE_NETWORK",data:{targetUrl:t.targetUrl,waitForLoadComplete:t.waitForLoadComplete??!0,timeout:t.timeout||3e4,includeRequestHeaders:t.includeRequestHeaders??!1,includeResponseHeaders:t.includeResponseHeaders??!1,includeResponseBody:t.includeResponseBody??!1,urlFilter:t.urlFilter,resourceTypes:t.resourceTypes}});return e.$isError?{hasError:!0,message:e.message||"Network capture failed",data:void 0}:(console.log("[CaptureNetworkBlock] Network capture successful, captured:",e.data.summary.totalRequests,"requests"),{data:e.data})}catch(e){return console.error("[CaptureNetworkBlock] Network capture error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in network capture",data:void 0}}}var Qr=(t=>(t.USD="USD",t.KRW="KRW",t.EUR="EUR",t.GBP="GBP",t.CAD="CAD",t.CNY="CNY",t.JPY="JPY",t.VND="VND",t.ARS="ARS",t.INR="INR",t.TWD="TWD",t.AUD="AUD",t.HKD="HKD",t.IDR="IDR",t.MXN="MXN",t.NZD="NZD",t.SGD="SGD",t.CHF="CHF",t.THB="THB",t.BRL="BRL",t.TRY="TRY",t.RUB="RUB",t.NOK="NOK",t.DKK="DKK",t.SEK="SEK",t.ILS="ILS",t.ZAR="ZAR",t.PLN="PLN",t.PHP="PHP",t.CZK="CZK",t.CLP="CLP",t.COP="COP",t.EGP="EGP",t.MYR="MYR",t.HUF="HUF",t.AED="AED",t.SAR="SAR",t.RON="RON",t.BGN="BGN",t))(Qr||{});const $s={code:{enum:Object.values(Qr)},symbol:{enum:["$","₩","€","£","¥","₫","₹","NT$","Rp","₣","฿","R$","₺","₽","kr","₪","R","zł","₱","Kč","E£","RM","Ft","د.إ","﷼","L","лв"]},format:{enum:["%s%u","%s%n","%u%s","%n%s","%s %u","%s %n","%u %s","%n %s"]}};export{Oa as $,xs as A,_s as B,$s as C,ws as D,ks as E,vs as F,bs as G,ys as H,gs as I,ps as J,ms as K,ds as L,hs as M,ls as N,fs as O,cs as P,us as Q,is as R,os as S,as as T,ss as U,yt as V,xa as W,Ea as X,Ta as Y,re as Z,Sa as _,Un as a,Na as a0,Ca as a1,Ia as a2,$a as a3,Ua as a4,La as a5,Za as a6,za as a7,qa as a8,ma as a9,Ka as aa,es as ab,ts as ac,zn as b,_r as c,Ms as d,Jr as e,js as f,an as g,Fs as h,Cs as i,Rs as j,rs as k,ea as l,ns as m,jr as n,Rr as o,Ps as p,Ns as q,Ds as r,xr as s,Os as t,qn as u,Is as v,As as w,Ss as x,Es as y,Ts as z};
|