├── .github └── FUNDING.yml ├── .gitignore ├── .idea ├── directus-operation-slugify.iml ├── modules.xml ├── vcs.xml └── workspace.xml ├── .releaser.json ├── LICENSE ├── README.md ├── dist ├── api.js └── app.js ├── media ├── flow.png ├── options.png └── verify.png ├── package.json ├── pnpm-lock.yaml ├── src ├── api.ts ├── app.ts └── shims.d.ts └── tsconfig.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: muratgozel # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: #muratgozel 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | 93 | # Gatsby files 94 | .cache/ 95 | # Comment in the public line in if your project uses Gatsby and not Next.js 96 | # https://nextjs.org/blog/next-9-1#public-directory-support 97 | # public 98 | 99 | # vuepress build output 100 | .vuepress/dist 101 | 102 | # vuepress v2.x temp and cache directory 103 | .temp 104 | .cache 105 | 106 | # Docusaurus cache and generated files 107 | .docusaurus 108 | 109 | # Serverless directories 110 | .serverless/ 111 | 112 | # FuseBox cache 113 | .fusebox/ 114 | 115 | # DynamoDB Local files 116 | .dynamodb/ 117 | 118 | # TernJS port file 119 | .tern-port 120 | 121 | # Stores VSCode versions used for testing VSCode extensions 122 | .vscode-test 123 | 124 | # yarn v2 125 | .yarn/cache 126 | .yarn/unplugged 127 | .yarn/build-state.yml 128 | .yarn/install-state.gz 129 | .pnp.* -------------------------------------------------------------------------------- /.idea/directus-operation-slugify.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 18 | { 19 | "lastFilter": { 20 | "state": "OPEN", 21 | "assignee": "muratgozel" 22 | } 23 | } 24 | { 25 | "selectedUrlAndAccountId": { 26 | "url": "https://github.com/muratgozel/directus-operation-slugify.git", 27 | "accountId": "4fc87a2a-ec0f-4b37-8c05-ca22f17067f4" 28 | } 29 | } 30 | 31 | 32 | 33 | 34 | 35 | 37 | { 38 | "associatedIndex": 8 39 | } 40 | 41 | 42 | 46 | { 47 | "keyToString": { 48 | "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", 49 | "RunOnceActivity.OpenProjectViewOnStart": "true", 50 | "RunOnceActivity.ShowReadmeOnStart": "true", 51 | "git-widget-placeholder": "main", 52 | "last_opened_file_path": "/Users/muratgozel/workspace/personal/directus-operation-slugify", 53 | "node.js.detected.package.eslint": "true", 54 | "node.js.detected.package.tslint": "true", 55 | "node.js.selected.package.eslint": "(autodetect)", 56 | "node.js.selected.package.tslint": "(autodetect)", 57 | "nodejs_package_manager_path": "npm", 58 | "settings.editor.selected.configurable": "reference.settings.ide.settings.new.ui", 59 | "ts.external.directory.path": "/Users/muratgozel/workspace/personal/directus-operation-slugify/node_modules/typescript/lib", 60 | "vue.rearranger.settings.migration": "true" 61 | } 62 | } 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 1706915648974 83 | 98 | 99 | 100 | 101 | 103 | 104 | 108 | -------------------------------------------------------------------------------- /.releaser.json: -------------------------------------------------------------------------------- 1 | { 2 | "versioningScheme": "semver", 3 | "versioningPrefix": "v", 4 | "npmUpdatePackageVersion": true, 5 | "npmPublishPackage": true, 6 | "githubRelease": true, 7 | "location": ".releaser.json", 8 | "npmPublishPackageArgs": [], 9 | "gitlabRelease": false, 10 | "dockerBuildPath": ".", 11 | "dockerBuildArgs": [], 12 | "dockerPushArgs": [] 13 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Murat Gözel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # directus-operation-slugify 2 | Directus operation extension to generate language aware slugs. 3 | 4 | ## Install 5 | This extension is a standard directus operation extension. Refer to the official docs if you don't know how to install extensions: 6 | 7 | https://docs.directus.io/extensions/installing-extensions.html 8 | 9 | The extension also available as an npm package: 10 | ```sh 11 | npm i @muratgozel/directus-operation-slugify 12 | ``` 13 | 14 | If you still not sure, check `npm run up` and `npm run up-dev` commands. Those are the ones I use for installing this extension. 15 | 16 | ### Note on Directus Marketplace 17 | Directus recently released their marketplace for extensions which makes installing a lot easier. Unfortunately this feature is still in beta and because of the limitations it brang for this kind of extension, I decided to wait and not publish this extension in the marketplace. Still, you'r able install it by setting `MARKETPLACE_TRUST=all` env var in your Directus instance, that's what they said. I'll update this section and the package itself once the feature reaches satisfying kind of stability. 18 | 19 | After installing, verify it by checking Settings - Extensions screen. The extension should be there with correct version number. 20 | 21 | ![Directus Operation Slugify Verify Installation](media/verify.png?raw=true) 22 | 23 | ## Usage 24 | 1. **Create a Flow with Event Hook trigger.** The trigger should be configured as blocking, scoped to items.create and items.update, filtered to a collections of your choice and return Data of Last Operation. 25 | 26 | ![Directus Operation Slugify Setup](media/flow.png?raw=true) 27 | 28 | 2. **Add Slugify operation to the flow.** The options are: 29 | - Name of the field to generate the slug from: `title` for example if you have a collection with `title` field and want to generate slugs based on that field. 30 | - Path to the language code or 2 letter language code: 31 | - If you specify a dotted path such as `languages_code.code`, it will be transformed to a chain of property names as to be resolved in item's payload to find the language of the payload. 32 | - If you don't have a language code in your collection, you can just type a 2 letter language code here such as `en` but be aware that it might effect the generated slugs. 33 | - Name of the slug field: The name of the field in your collection to save the generated slug under. `slug` for example. 34 | 35 | ![Directus Operation Slugify Setup](media/options.png?raw=true) 36 | 37 | That's all. 38 | 39 | From now on, the extension will generate a slug: 40 | 1. on creating new items on relevant collections and 41 | 2. on updating items on relevant collections only if the slug field is empty. 42 | 43 | --- 44 | 45 | Version management of this repository done by [releaser](https://github.com/muratgozel/node-releaser) 🚀 46 | 47 | --- 48 | 49 | Thanks for watching 🐬 50 | 51 | [![Support me on Patreon](https://cdn.muratgozel.com.tr/support-me-on-patreon.v1.png)](https://patreon.com/muratgozel?utm_medium=organic&utm_source=github_repo&utm_campaign=github&utm_content=join_link) 52 | -------------------------------------------------------------------------------- /dist/api.js: -------------------------------------------------------------------------------- 1 | var e,t,a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const a of e)t[a]=a;return t},e.getValidEnumValues=t=>{const a=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),n={};for(const e of a)n[e]=t[e];return e.objectValues(n)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.push(a);return t},e.find=(e,t)=>{for(const a of e)if(t(a))return a},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(e||(e={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(t||(t={}));const s=e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),r=e=>{switch(typeof e){case"undefined":return s.undefined;case"string":return s.string;case"number":return isNaN(e)?s.nan:s.number;case"boolean":return s.boolean;case"function":return s.function;case"bigint":return s.bigint;case"symbol":return s.symbol;case"object":return Array.isArray(e)?s.array:null===e?s.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?s.promise:"undefined"!=typeof Map&&e instanceof Map?s.map:"undefined"!=typeof Set&&e instanceof Set?s.set:"undefined"!=typeof Date&&e instanceof Date?s.date:s.object;default:return s.unknown}},i=e.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"]);class o extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},a={_errors:[]},n=e=>{for(const s of e.issues)if("invalid_union"===s.code)s.unionErrors.map(n);else if("invalid_return_type"===s.code)n(s.returnTypeError);else if("invalid_arguments"===s.code)n(s.argumentsError);else if(0===s.path.length)a._errors.push(t(s));else{let e=a,n=0;for(;ne.message)){const t={},a=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):a.push(e(n));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}o.create=e=>new o(e);const d=(t,a)=>{let n;switch(t.code){case i.invalid_type:n=t.received===s.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case i.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:n=`Unrecognized key(s) in object: ${e.joinValues(t.keys,", ")}`;break;case i.invalid_union:n="Invalid input";break;case i.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case i.invalid_enum_value:n=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case i.invalid_arguments:n="Invalid function arguments";break;case i.invalid_return_type:n="Invalid function return type";break;case i.invalid_date:n="Invalid date";break;case i.invalid_string:"object"==typeof t.validation?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,"number"==typeof t.validation.position&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):n="regex"!==t.validation?`Invalid ${t.validation}`:"Invalid";break;case i.too_small:n="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:"date"===t.type?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case i.too_big:n="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"bigint"===t.type?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"date"===t.type?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case i.custom:n="Invalid input";break;case i.invalid_intersection_types:n="Intersection results could not be merged";break;case i.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case i.not_finite:n="Number must be finite";break;default:n=a.defaultError,e.assertNever(t)}return{message:n}};let u=d;function c(){return u}const l=e=>{const{data:t,path:a,errorMaps:n,issueData:s}=e,r=[...a,...s.path||[]],i={...s,path:r};if(void 0!==s.message)return{...s,path:r,message:s.message};let o="";const d=n.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...s,path:r,message:o}};function h(e,t){const a=c(),n=l({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,a,a===d?void 0:d].filter((e=>!!e))});e.common.issues.push(n)}class p{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const n of t){if("aborted"===n.status)return m;"dirty"===n.status&&e.dirty(),a.push(n.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const e of t){const t=await e.key,n=await e.value;a.push({key:t,value:n})}return p.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const n of t){const{key:t,value:s}=n;if("aborted"===t.status)return m;if("aborted"===s.status)return m;"dirty"===t.status&&e.dirty(),"dirty"===s.status&&e.dirty(),"__proto__"===t.value||void 0===s.value&&!n.alwaysSet||(a[t.value]=s.value)}return{status:e.value,value:a}}}const m=Object.freeze({status:"aborted"}),f=e=>({status:"dirty",value:e}),y=e=>({status:"valid",value:e}),g=e=>"aborted"===e.status,v=e=>"dirty"===e.status,_=e=>"valid"===e.status,k=e=>"undefined"!=typeof Promise&&e instanceof Promise;function b(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)}function x(e,t,a,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,a):s?s.value=a:t.set(e,a),a}var w,Z,T;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(w||(w={}));class O{constructor(e,t,a,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const j=(e,t)=>{if(_(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new o(e.common.issues);return this._error=t,this._error}}};function S(e){if(!e)return{};const{errorMap:t,invalid_type_error:a,required_error:n,description:s}=e;if(t&&(a||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:s};return{errorMap:(t,s)=>{var r,i;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:s.defaultError}:void 0===s.data?{message:null!==(r=null!=o?o:n)&&void 0!==r?r:s.defaultError}:"invalid_type"!==t.code?{message:s.defaultError}:{message:null!==(i=null!=o?o:a)&&void 0!==i?i:s.defaultError}},description:s}}class 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)}get description(){return this._def.description}_getType(e){return r(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new p,ctx:{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(k(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){var a;const n={common:{issues:[],async:null!==(a=null==t?void 0:t.async)&&void 0!==a&&a,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},s=this._parseSync({data:e,path:n.path,parent:n});return j(n,s)}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},n=this._parse({data:e,path:a.path,parent:a}),s=await(k(n)?n:Promise.resolve(n));return j(a,s)}refine(e,t){const a=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,n)=>{const s=e(t),r=()=>n.addIssue({code:i.custom,...a(t)});return"undefined"!=typeof Promise&&s instanceof Promise?s.then((e=>!!e||(r(),!1))):!!s||(r(),!1)}))}refinement(e,t){return this._refinement(((a,n)=>!!e(a)||(n.addIssue("function"==typeof t?t(a,n):t),!1)))}_refinement(e){return new we({schema:this,typeName:Pe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Ze.create(this,this._def)}nullable(){return Te.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this,this._def)}promise(){return xe.create(this,this._def)}or(e){return oe.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new we({...S(this._def),schema:this,typeName:Pe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Oe({...S(this._def),innerType:this,defaultValue:t,typeName:Pe.ZodDefault})}brand(){return new Ce({typeName:Pe.ZodBranded,type:this,...S(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new je({...S(this._def),innerType:this,catchValue:t,typeName:Pe.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ne.create(this,e)}readonly(){return Ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C=/^c[^\s-]{8,}$/i,N=/^[0-9a-z]+$/,A=/^[0-9A-HJKMNP-TV-Z]{26}$/,I=/^[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,R=/^[a-z0-9_-]{21}$/i,P=/^[-+]?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)?)??$/,z=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let $;const L=/^(?:(?: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])$/,M=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,U=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,D="((\\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])))",V=new RegExp(`^${D}$`);function K(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function B(e){let t=`${D}T${K(e)}`;const a=[];return a.push(e.local?"Z?":"Z"),e.offset&&a.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${a.join("|")})`,new RegExp(`^${t}$`)}class q extends E{_parse(t){this._def.coerce&&(t.data=String(t.data));if(this._getType(t)!==s.string){const e=this._getOrReturnCtx(t);return h(e,{code:i.invalid_type,expected:s.string,received:e.parsedType}),m}const a=new p;let n;for(const s of this._def.checks)if("min"===s.kind)t.data.lengths.value&&(n=this._getOrReturnCtx(t,n),h(n,{code:i.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("length"===s.kind){const e=t.data.length>s.value,r=t.data.lengthe.test(t)),{validation:t,code:i.invalid_string,...w.errToObj(a)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}datetime(e){var t,a;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(a=null==e?void 0:e.local)&&void 0!==a&&a,...w.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...w.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...w.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.valuen?a:n;return parseInt(e.toFixed(s).replace(".",""))%parseInt(t.toFixed(s).replace(".",""))/Math.pow(10,s)}q.create=e=>{var t;return new q({checks:[],typeName:Pe.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...S(e)})};class W extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){this._def.coerce&&(t.data=Number(t.data));if(this._getType(t)!==s.number){const e=this._getOrReturnCtx(t);return h(e,{code:i.invalid_type,expected:s.number,received:e.parsedType}),m}let a;const n=new p;for(const s of this._def.checks)if("int"===s.kind)e.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:i.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty());else if("min"===s.kind){(s.inclusive?t.datas.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:i.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty())}else"multipleOf"===s.kind?0!==F(t.data,s.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:i.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):"finite"===s.kind?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:i.not_finite,message:s.message}),n.dirty()):e.assertNever(s);return{status:n.value,value:t.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,a,n){return new W({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:w.toString(n)}]})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value"int"===t.kind||"multipleOf"===t.kind&&e.isInteger(t.value)))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===t||a.value>t)&&(t=a.value):"max"===a.kind&&(null===e||a.valuenew W({checks:[],typeName:Pe.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...S(e)});class Y extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){this._def.coerce&&(t.data=BigInt(t.data));if(this._getType(t)!==s.bigint){const e=this._getOrReturnCtx(t);return h(e,{code:i.invalid_type,expected:s.bigint,received:e.parsedType}),m}let a;const n=new p;for(const s of this._def.checks)if("min"===s.kind){(s.inclusive?t.datas.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:i.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty())}else"multipleOf"===s.kind?t.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),h(a,{code:i.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):e.assertNever(s);return{status:n.value,value:t.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,a,n){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:w.toString(n)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value{var t;return new Y({checks:[],typeName:Pe.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...S(e)})};class G extends E{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==s.boolean){const t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:s.boolean,received:t.parsedType}),m}return y(e.data)}}G.create=e=>new G({typeName:Pe.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...S(e)});class H extends E{_parse(t){this._def.coerce&&(t.data=new Date(t.data));if(this._getType(t)!==s.date){const e=this._getOrReturnCtx(t);return h(e,{code:i.invalid_type,expected:s.date,received:e.parsedType}),m}if(isNaN(t.data.getTime())){return h(this._getOrReturnCtx(t),{code:i.invalid_date}),m}const a=new p;let n;for(const s of this._def.checks)"min"===s.kind?t.data.getTime()s.value&&(n=this._getOrReturnCtx(t,n),h(n,{code:i.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):e.assertNever(s);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(e){return new H({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.valuenew H({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Pe.ZodDate,...S(e)});class J extends E{_parse(e){if(this._getType(e)!==s.symbol){const t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:s.symbol,received:t.parsedType}),m}return y(e.data)}}J.create=e=>new J({typeName:Pe.ZodSymbol,...S(e)});class X extends E{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:s.undefined,received:t.parsedType}),m}return y(e.data)}}X.create=e=>new X({typeName:Pe.ZodUndefined,...S(e)});class Q extends E{_parse(e){if(this._getType(e)!==s.null){const t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:s.null,received:t.parsedType}),m}return y(e.data)}}Q.create=e=>new Q({typeName:Pe.ZodNull,...S(e)});class ee extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return y(e.data)}}ee.create=e=>new ee({typeName:Pe.ZodAny,...S(e)});class te extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return y(e.data)}}te.create=e=>new te({typeName:Pe.ZodUnknown,...S(e)});class ae extends E{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:s.never,received:t.parsedType}),m}}ae.create=e=>new ae({typeName:Pe.ZodNever,...S(e)});class ne extends E{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:s.void,received:t.parsedType}),m}return y(e.data)}}ne.create=e=>new ne({typeName:Pe.ZodVoid,...S(e)});class se extends E{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),n=this._def;if(t.parsedType!==s.array)return h(t,{code:i.invalid_type,expected:s.array,received:t.parsedType}),m;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,s=t.data.lengthn.maxLength.value&&(h(t,{code:i.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map(((e,a)=>n.type._parseAsync(new O(t,e,t.path,a))))).then((e=>p.mergeArray(a,e)));const r=[...t.data].map(((e,a)=>n.type._parseSync(new O(t,e,t.path,a))));return p.mergeArray(a,r)}get element(){return this._def.type}min(e,t){return new se({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new se({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new se({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}function re(e){if(e instanceof ie){const t={};for(const a in e.shape){const n=e.shape[a];t[a]=Ze.create(re(n))}return new ie({...e._def,shape:()=>t})}return e instanceof se?new se({...e._def,type:re(e.element)}):e instanceof Ze?Ze.create(re(e.unwrap())):e instanceof Te?Te.create(re(e.unwrap())):e instanceof he?he.create(e.items.map((e=>re(e)))):e}se.create=(e,t)=>new se({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Pe.ZodArray,...S(t)});class ie extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const t=this._def.shape(),a=e.objectKeys(t);return this._cached={shape:t,keys:a}}_parse(e){if(this._getType(e)!==s.object){const t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:s.object,received:t.parsedType}),m}const{status:t,ctx:a}=this._processInputParams(e),{shape:n,keys:r}=this._getCached(),o=[];if(!(this._def.catchall instanceof ae&&"strip"===this._def.unknownKeys))for(const e in a.data)r.includes(e)||o.push(e);const d=[];for(const e of r){const t=n[e],s=a.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new O(a,s,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof ae){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)d.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)o.length>0&&(h(a,{code:i.unrecognized_keys,keys:o}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of o){const n=a.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new O(a,n,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of d){const a=await t.key,n=await t.value;e.push({key:a,value:n,alwaysSet:t.alwaysSet})}return e})).then((e=>p.mergeObjectSync(t,e))):p.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new ie({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,a)=>{var n,s,r,i;const o=null!==(r=null===(s=(n=this._def).errorMap)||void 0===s?void 0:s.call(n,t,a).message)&&void 0!==r?r:a.defaultError;return"unrecognized_keys"===t.code?{message:null!==(i=w.errToObj(e).message)&&void 0!==i?i:o}:{message:o}}}:{}})}strip(){return new ie({...this._def,unknownKeys:"strip"})}passthrough(){return new ie({...this._def,unknownKeys:"passthrough"})}extend(e){return new ie({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ie({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Pe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ie({...this._def,catchall:e})}pick(t){const a={};return e.objectKeys(t).forEach((e=>{t[e]&&this.shape[e]&&(a[e]=this.shape[e])})),new ie({...this._def,shape:()=>a})}omit(t){const a={};return e.objectKeys(this.shape).forEach((e=>{t[e]||(a[e]=this.shape[e])})),new ie({...this._def,shape:()=>a})}deepPartial(){return re(this)}partial(t){const a={};return e.objectKeys(this.shape).forEach((e=>{const n=this.shape[e];t&&!t[e]?a[e]=n:a[e]=n.optional()})),new ie({...this._def,shape:()=>a})}required(t){const a={};return e.objectKeys(this.shape).forEach((e=>{if(t&&!t[e])a[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ze;)t=t._def.innerType;a[e]=t}})),new ie({...this._def,shape:()=>a})}keyof(){return _e(e.objectKeys(this.shape))}}ie.create=(e,t)=>new ie({shape:()=>e,unknownKeys:"strip",catchall:ae.create(),typeName:Pe.ZodObject,...S(t)}),ie.strictCreate=(e,t)=>new ie({shape:()=>e,unknownKeys:"strict",catchall:ae.create(),typeName:Pe.ZodObject,...S(t)}),ie.lazycreate=(e,t)=>new ie({shape:e,unknownKeys:"strip",catchall:ae.create(),typeName:Pe.ZodObject,...S(t)});class oe extends E{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;if(t.common.async)return Promise.all(a.map((async e=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const a of e)if("dirty"===a.result.status)return t.common.issues.push(...a.ctx.common.issues),a.result;const a=e.map((e=>new o(e.ctx.common.issues)));return h(t,{code:i.invalid_union,unionErrors:a}),m}));{let e;const n=[];for(const s of a){const a={...t,common:{...t.common,issues:[]},parent:null},r=s._parseSync({data:t.data,path:t.path,parent:a});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:a}),a.common.issues.length&&n.push(a.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const s=n.map((e=>new o(e)));return h(t,{code:i.invalid_union,unionErrors:s}),m}}get options(){return this._def.options}}oe.create=(e,t)=>new oe({options:e,typeName:Pe.ZodUnion,...S(t)});const de=t=>t instanceof ge?de(t.schema):t instanceof we?de(t.innerType()):t instanceof ve?[t.value]:t instanceof ke?t.options:t instanceof be?e.objectValues(t.enum):t instanceof Oe?de(t._def.innerType):t instanceof X?[void 0]:t instanceof Q?[null]:t instanceof Ze?[void 0,...de(t.unwrap())]:t instanceof Te?[null,...de(t.unwrap())]:t instanceof Ce||t instanceof Ae?de(t.unwrap()):t instanceof je?de(t._def.innerType):[];class ue extends E{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.object)return h(t,{code:i.invalid_type,expected:s.object,received:t.parsedType}),m;const a=this.discriminator,n=t.data[a],r=this.optionsMap.get(n);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const n=new Map;for(const a of t){const t=de(a.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const s of t){if(n.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);n.set(s,a)}}return new ue({typeName:Pe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...S(a)})}}function ce(t,a){const n=r(t),i=r(a);if(t===a)return{valid:!0,data:t};if(n===s.object&&i===s.object){const n=e.objectKeys(a),s=e.objectKeys(t).filter((e=>-1!==n.indexOf(e))),r={...t,...a};for(const e of s){const n=ce(t[e],a[e]);if(!n.valid)return{valid:!1};r[e]=n.data}return{valid:!0,data:r}}if(n===s.array&&i===s.array){if(t.length!==a.length)return{valid:!1};const e=[];for(let n=0;n{if(g(e)||g(n))return m;const s=ce(e.value,n.value);return s.valid?((v(e)||v(n))&&t.dirty(),{status:t.value,value:s.data}):(h(a,{code:i.invalid_intersection_types}),m)};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((([e,t])=>n(e,t))):n(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}le.create=(e,t,a)=>new le({left:e,right:t,typeName:Pe.ZodIntersection,...S(a)});class he extends E{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.array)return h(a,{code:i.invalid_type,expected:s.array,received:a.parsedType}),m;if(a.data.lengththis._def.items.length&&(h(a,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...a.data].map(((e,t)=>{const n=this._def.items[t]||this._def.rest;return n?n._parse(new O(a,e,a.path,t)):null})).filter((e=>!!e));return a.common.async?Promise.all(n).then((e=>p.mergeArray(t,e))):p.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new he({...this._def,rest:e})}}he.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new he({items:e,typeName:Pe.ZodTuple,rest:null,...S(t)})};class pe extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.object)return h(a,{code:i.invalid_type,expected:s.object,received:a.parsedType}),m;const n=[],r=this._def.keyType,o=this._def.valueType;for(const e in a.data)n.push({key:r._parse(new O(a,e,a.path,e)),value:o._parse(new O(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?p.mergeObjectAsync(t,n):p.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,a){return new pe(t instanceof E?{keyType:e,valueType:t,typeName:Pe.ZodRecord,...S(a)}:{keyType:q.create(),valueType:e,typeName:Pe.ZodRecord,...S(t)})}}class me extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.map)return h(a,{code:i.invalid_type,expected:s.map,received:a.parsedType}),m;const n=this._def.keyType,r=this._def.valueType,o=[...a.data.entries()].map((([e,t],s)=>({key:n._parse(new O(a,e,a.path,[s,"key"])),value:r._parse(new O(a,t,a.path,[s,"value"]))})));if(a.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const a of o){const n=await a.key,s=await a.value;if("aborted"===n.status||"aborted"===s.status)return m;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const a of o){const n=a.key,s=a.value;if("aborted"===n.status||"aborted"===s.status)return m;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}}}}me.create=(e,t,a)=>new me({valueType:t,keyType:e,typeName:Pe.ZodMap,...S(a)});class fe extends E{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.set)return h(a,{code:i.invalid_type,expected:s.set,received:a.parsedType}),m;const n=this._def;null!==n.minSize&&a.data.sizen.maxSize.value&&(h(a,{code:i.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const r=this._def.valueType;function o(e){const a=new Set;for(const n of e){if("aborted"===n.status)return m;"dirty"===n.status&&t.dirty(),a.add(n.value)}return{status:t.value,value:a}}const d=[...a.data.values()].map(((e,t)=>r._parse(new O(a,e,a.path,t))));return a.common.async?Promise.all(d).then((e=>o(e))):o(d)}min(e,t){return new fe({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new fe({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}fe.create=(e,t)=>new fe({valueType:e,minSize:null,maxSize:null,typeName:Pe.ZodSet,...S(t)});class ye extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.function)return h(t,{code:i.invalid_type,expected:s.function,received:t.parsedType}),m;function a(e,a){return l({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),d].filter((e=>!!e)),issueData:{code:i.invalid_arguments,argumentsError:a}})}function n(e,a){return l({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,c(),d].filter((e=>!!e)),issueData:{code:i.invalid_return_type,returnTypeError:a}})}const r={errorMap:t.common.contextualErrorMap},u=t.data;if(this._def.returns instanceof xe){const e=this;return y((async function(...t){const s=new o([]),i=await e._def.args.parseAsync(t,r).catch((e=>{throw s.addIssue(a(t,e)),s})),d=await Reflect.apply(u,this,i);return await e._def.returns._def.type.parseAsync(d,r).catch((e=>{throw s.addIssue(n(d,e)),s}))}))}{const e=this;return y((function(...t){const s=e._def.args.safeParse(t,r);if(!s.success)throw new o([a(t,s.error)]);const i=Reflect.apply(u,this,s.data),d=e._def.returns.safeParse(i,r);if(!d.success)throw new o([n(i,d.error)]);return d.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ye({...this._def,args:he.create(e).rest(te.create())})}returns(e){return new ye({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new ye({args:e||he.create([]).rest(te.create()),returns:t||te.create(),typeName:Pe.ZodFunction,...S(a)})}}class ge extends E{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ge.create=(e,t)=>new ge({getter:e,typeName:Pe.ZodLazy,...S(t)});class ve extends E{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}function _e(e,t){return new ke({values:e,typeName:Pe.ZodEnum,...S(t)})}ve.create=(e,t)=>new ve({value:e,typeName:Pe.ZodLiteral,...S(t)});class ke extends E{constructor(){super(...arguments),Z.set(this,void 0)}_parse(t){if("string"!=typeof t.data){const a=this._getOrReturnCtx(t),n=this._def.values;return h(a,{expected:e.joinValues(n),received:a.parsedType,code:i.invalid_type}),m}if(b(this,Z,"f")||x(this,Z,new Set(this._def.values),"f"),!b(this,Z,"f").has(t.data)){const e=this._getOrReturnCtx(t),a=this._def.values;return h(e,{received:e.data,code:i.invalid_enum_value,options:a}),m}return y(t.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ke.create(e,{...this._def,...t})}exclude(e,t=this._def){return ke.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}Z=new WeakMap,ke.create=_e;class be extends E{constructor(){super(...arguments),T.set(this,void 0)}_parse(t){const a=e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==s.string&&n.parsedType!==s.number){const t=e.objectValues(a);return h(n,{expected:e.joinValues(t),received:n.parsedType,code:i.invalid_type}),m}if(b(this,T,"f")||x(this,T,new Set(e.getValidEnumValues(this._def.values)),"f"),!b(this,T,"f").has(t.data)){const t=e.objectValues(a);return h(n,{received:n.data,code:i.invalid_enum_value,options:t}),m}return y(t.data)}get enum(){return this._def.values}}T=new WeakMap,be.create=(e,t)=>new be({values:e,typeName:Pe.ZodNativeEnum,...S(t)});class xe extends E{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.promise&&!1===t.common.async)return h(t,{code:i.invalid_type,expected:s.promise,received:t.parsedType}),m;const a=t.parsedType===s.promise?t.data:Promise.resolve(t.data);return y(a.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}xe.create=(e,t)=>new xe({type:e,typeName:Pe.ZodPromise,...S(t)});class we extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Pe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:a,ctx:n}=this._processInputParams(t),s=this._def.effect||null,r={addIssue:e=>{h(n,e),e.fatal?a.abort():a.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===s.type){const e=s.transform(n.data,r);if(n.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===a.value)return m;const t=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===t.status?m:"dirty"===t.status||"dirty"===a.value?f(t.value):t}));{if("aborted"===a.value)return m;const t=this._def.schema._parseSync({data:e,path:n.path,parent:n});return"aborted"===t.status?m:"dirty"===t.status||"dirty"===a.value?f(t.value):t}}if("refinement"===s.type){const e=e=>{const t=s.refinement(e,r);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const t=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===t.status?m:("dirty"===t.status&&a.dirty(),e(t.value),{status:a.value,value:t.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((t=>"aborted"===t.status?m:("dirty"===t.status&&a.dirty(),e(t.value).then((()=>({status:a.value,value:t.value}))))))}if("transform"===s.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!_(e))return e;const t=s.transform(e.value,r);if(t instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:a.value,value:t}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((e=>_(e)?Promise.resolve(s.transform(e.value,r)).then((e=>({status:a.value,value:e}))):e))}e.assertNever(s)}}we.create=(e,t,a)=>new we({schema:e,typeName:Pe.ZodEffects,effect:t,...S(a)}),we.createWithPreprocess=(e,t,a)=>new we({schema:t,effect:{type:"preprocess",transform:e},typeName:Pe.ZodEffects,...S(a)});class Ze extends E{_parse(e){return this._getType(e)===s.undefined?y(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ze.create=(e,t)=>new Ze({innerType:e,typeName:Pe.ZodOptional,...S(t)});class Te extends E{_parse(e){return this._getType(e)===s.null?y(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Te.create=(e,t)=>new Te({innerType:e,typeName:Pe.ZodNullable,...S(t)});class Oe extends E{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===s.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Oe.create=(e,t)=>new Oe({innerType:e,typeName:Pe.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...S(t)});class je extends E{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return k(n)?n.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new o(a.common.issues)},input:a.data})}))):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new o(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}je.create=(e,t)=>new je({innerType:e,typeName:Pe.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...S(t)});class Se extends E{_parse(e){if(this._getType(e)!==s.nan){const t=this._getOrReturnCtx(e);return h(t,{code:i.invalid_type,expected:s.nan,received:t.parsedType}),m}return{status:"valid",value:e.data}}}Se.create=e=>new Se({typeName:Pe.ZodNaN,...S(e)});const Ee=Symbol("zod_brand");class Ce extends E{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ne extends E{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?m:"dirty"===e.status?(t.dirty(),f(e.value)):this._def.out._parseAsync({data:e.value,path:a.path,parent:a})})()}{const e=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?m:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:a.path,parent:a})}}static create(e,t){return new Ne({in:e,out:t,typeName:Pe.ZodPipeline})}}class Ae extends E{_parse(e){const t=this._def.innerType._parse(e),a=e=>(_(e)&&(e.value=Object.freeze(e.value)),e);return k(t)?t.then((e=>a(e))):a(t)}unwrap(){return this._def.innerType}}function Ie(e,t={},a){return e?ee.create().superRefine(((n,s)=>{var r,i;if(!e(n)){const e="function"==typeof t?t(n):"string"==typeof t?{message:t}:t,o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:a)||void 0===i||i,d="string"==typeof e?{message:e}:e;s.addIssue({code:"custom",...d,fatal:o})}})):ee.create()}Ae.create=(e,t)=>new Ae({innerType:e,typeName:Pe.ZodReadonly,...S(t)});const Re={object:ie.lazycreate};var Pe;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Pe||(Pe={}));const ze=q.create,$e=W.create,Le=Se.create,Me=Y.create,Ue=G.create,De=H.create,Ve=J.create,Ke=X.create,Be=Q.create,qe=ee.create,Fe=te.create,We=ae.create,Ye=ne.create,Ge=se.create,He=ie.create,Je=ie.strictCreate,Xe=oe.create,Qe=ue.create,et=le.create,tt=he.create,at=pe.create,nt=me.create,st=fe.create,rt=ye.create,it=ge.create,ot=ve.create,dt=ke.create,ut=be.create,ct=xe.create,lt=we.create,ht=Ze.create,pt=Te.create,mt=we.createWithPreprocess,ft=Ne.create,yt={string:e=>q.create({...e,coerce:!0}),number:e=>W.create({...e,coerce:!0}),boolean:e=>G.create({...e,coerce:!0}),bigint:e=>Y.create({...e,coerce:!0}),date:e=>H.create({...e,coerce:!0})},gt=m;var vt=Object.freeze({__proto__:null,defaultErrorMap:d,setErrorMap:function(e){u=e},getErrorMap:c,makeIssue:l,EMPTY_PATH:[],addIssueToContext:h,ParseStatus:p,INVALID:m,DIRTY:f,OK:y,isAborted:g,isDirty:v,isValid:_,isAsync:k,get util(){return e},get objectUtil(){return t},ZodParsedType:s,getParsedType:r,ZodType:E,datetimeRegex:B,ZodString:q,ZodNumber:W,ZodBigInt:Y,ZodBoolean:G,ZodDate:H,ZodSymbol:J,ZodUndefined:X,ZodNull:Q,ZodAny:ee,ZodUnknown:te,ZodNever:ae,ZodVoid:ne,ZodArray:se,ZodObject:ie,ZodUnion:oe,ZodDiscriminatedUnion:ue,ZodIntersection:le,ZodTuple:he,ZodRecord:pe,ZodMap:me,ZodSet:fe,ZodFunction:ye,ZodLazy:ge,ZodLiteral:ve,ZodEnum:ke,ZodNativeEnum:be,ZodPromise:xe,ZodEffects:we,ZodTransformer:we,ZodOptional:Ze,ZodNullable:Te,ZodDefault:Oe,ZodCatch:je,ZodNaN:Se,BRAND:Ee,ZodBranded:Ce,ZodPipeline:Ne,ZodReadonly:Ae,custom:Ie,Schema:E,ZodSchema:E,late:Re,get ZodFirstPartyTypeKind(){return Pe},coerce:yt,any:qe,array:Ge,bigint:Me,boolean:Ue,date:De,discriminatedUnion:Qe,effect:lt,enum:dt,function:rt,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>Ie((t=>t instanceof e),t),intersection:et,lazy:it,literal:ot,map:nt,nan:Le,nativeEnum:ut,never:We,null:Be,nullable:pt,number:$e,object:He,oboolean:()=>Ue().optional(),onumber:()=>$e().optional(),optional:ht,ostring:()=>ze().optional(),pipeline:ft,preprocess:mt,promise:ct,record:at,set:st,strictObject:Je,string:ze,symbol:Ve,transformer:lt,tuple:tt,undefined:Ke,union:Xe,unknown:Fe,void:Ye,NEVER:gt,ZodIssueCode:i,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:o}),_t=["interface","display","layout","module","panel","theme"],kt=["hook","endpoint"],bt=["operation"],xt="directus:extension",wt=vt.object({app:vt.string(),api:vt.string()}),Zt=vt.object({request:vt.optional(vt.object({urls:vt.array(vt.string()),methods:vt.array(vt.union([vt.literal("GET"),vt.literal("POST"),vt.literal("PATCH"),vt.literal("PUT"),vt.literal("DELETE")]))})),log:vt.optional(vt.object({})),sleep:vt.optional(vt.object({}))}),Tt=vt.optional(vt.object({enabled:vt.boolean(),requestedScopes:Zt})),Ot=vt.union([vt.object({type:vt.enum(kt),name:vt.string(),source:vt.string()}),vt.object({type:vt.enum(_t),name:vt.string(),source:vt.string()}),vt.object({type:vt.enum(bt),name:vt.string(),source:wt})]),jt=vt.object({host:vt.string(),hidden:vt.boolean().optional()}),St=vt.object({type:vt.enum(_t),path:vt.string(),source:vt.string()}),Et=vt.object({type:vt.enum(kt),path:vt.string(),source:vt.string(),sandbox:Tt}),Ct=vt.object({type:vt.enum(bt),path:wt,source:wt,sandbox:Tt}),Nt=vt.object({type:vt.literal("bundle"),partial:vt.boolean().optional(),path:wt,entries:vt.array(Ot)});vt.array(Ot);var At=jt.and(vt.union([St,Et,Ct,Nt]));vt.object({name:vt.string(),version:vt.string(),type:vt.union([vt.literal("module"),vt.literal("commonjs")]).optional(),description:vt.string().optional(),icon:vt.string().optional(),dependencies:vt.record(vt.string()).optional(),devDependencies:vt.record(vt.string()).optional(),[xt]:At});var It,Rt={exports:{}};It=Rt,function(e){var t={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"Ae","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"Oe","Ő":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"Ue","Ű":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"ae","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"oe","ő":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"ue","ű":"u","ý":"y","þ":"th","ÿ":"y","ẞ":"SS","ا":"a","أ":"a","إ":"i","آ":"aa","ؤ":"u","ئ":"e","ء":"a","ب":"b","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ي":"y","ى":"a","ة":"h","ﻻ":"la","ﻷ":"laa","ﻹ":"lai","ﻵ":"laa","گ":"g","چ":"ch","پ":"p","ژ":"zh","ک":"k","ی":"y","َ":"a","ً":"an","ِ":"e","ٍ":"en","ُ":"u","ٌ":"on","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","က":"k","ခ":"kh","ဂ":"g","ဃ":"ga","င":"ng","စ":"s","ဆ":"sa","ဇ":"z","စျ":"za","ည":"ny","ဋ":"t","ဌ":"ta","ဍ":"d","ဎ":"da","ဏ":"na","တ":"t","ထ":"ta","ဒ":"d","ဓ":"da","န":"n","ပ":"p","ဖ":"pa","ဗ":"b","ဘ":"ba","မ":"m","ယ":"y","ရ":"ya","လ":"l","ဝ":"w","သ":"th","ဟ":"h","ဠ":"la","အ":"a","ြ":"y","ျ":"ya","ွ":"w","ြွ":"yw","ျွ":"ywa","ှ":"h","ဧ":"e","၏":"-e","ဣ":"i","ဤ":"-i","ဉ":"u","ဦ":"-u","ဩ":"aw","သြော":"aw","ဪ":"aw","၀":"0","၁":"1","၂":"2","၃":"3","၄":"4","၅":"5","၆":"6","၇":"7","၈":"8","၉":"9","္":"","့":"","း":"","č":"c","ď":"d","ě":"e","ň":"n","ř":"r","š":"s","ť":"t","ů":"u","ž":"z","Č":"C","Ď":"D","Ě":"E","Ň":"N","Ř":"R","Š":"S","Ť":"T","Ů":"U","Ž":"Z","ހ":"h","ށ":"sh","ނ":"n","ރ":"r","ބ":"b","ޅ":"lh","ކ":"k","އ":"a","ވ":"v","މ":"m","ފ":"f","ދ":"dh","ތ":"th","ލ":"l","ގ":"g","ޏ":"gn","ސ":"s","ޑ":"d","ޒ":"z","ޓ":"t","ޔ":"y","ޕ":"p","ޖ":"j","ޗ":"ch","ޘ":"tt","ޙ":"hh","ޚ":"kh","ޛ":"th","ޜ":"z","ޝ":"sh","ޞ":"s","ޟ":"d","ޠ":"t","ޡ":"z","ޢ":"a","ޣ":"gh","ޤ":"q","ޥ":"w","ަ":"a","ާ":"aa","ި":"i","ީ":"ee","ު":"u","ޫ":"oo","ެ":"e","ޭ":"ey","ޮ":"o","ޯ":"oa","ް":"","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"p","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","α":"a","β":"v","γ":"g","δ":"d","ε":"e","ζ":"z","η":"i","θ":"th","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"ks","ο":"o","π":"p","ρ":"r","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"o","ά":"a","έ":"e","ί":"i","ό":"o","ύ":"y","ή":"i","ώ":"o","ς":"s","ϊ":"i","ΰ":"y","ϋ":"y","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"I","Θ":"TH","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"KS","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"O","Ά":"A","Έ":"E","Ί":"I","Ό":"O","Ύ":"Y","Ή":"I","Ώ":"O","Ϊ":"I","Ϋ":"Y","ā":"a","ē":"e","ģ":"g","ī":"i","ķ":"k","ļ":"l","ņ":"n","ū":"u","Ā":"A","Ē":"E","Ģ":"G","Ī":"I","Ķ":"k","Ļ":"L","Ņ":"N","Ū":"U","Ќ":"Kj","ќ":"kj","Љ":"Lj","љ":"lj","Њ":"Nj","њ":"nj","Тс":"Ts","тс":"ts","ą":"a","ć":"c","ę":"e","ł":"l","ń":"n","ś":"s","ź":"z","ż":"z","Ą":"A","Ć":"C","Ę":"E","Ł":"L","Ń":"N","Ś":"S","Ź":"Z","Ż":"Z","Є":"Ye","І":"I","Ї":"Yi","Ґ":"G","є":"ye","і":"i","ї":"yi","ґ":"g","ă":"a","Ă":"A","ș":"s","Ș":"S","ț":"t","Ț":"T","ţ":"t","Ţ":"T","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ё":"yo","ж":"zh","з":"z","и":"i","й":"i","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"kh","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ё":"Yo","Ж":"Zh","З":"Z","И":"I","Й":"I","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"Kh","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","ђ":"dj","ј":"j","ћ":"c","џ":"dz","Ђ":"Dj","Ј":"j","Ћ":"C","Џ":"Dz","ľ":"l","ĺ":"l","ŕ":"r","Ľ":"L","Ĺ":"L","Ŕ":"R","ş":"s","Ş":"S","ı":"i","İ":"I","ğ":"g","Ğ":"G","ả":"a","Ả":"A","ẳ":"a","Ẳ":"A","ẩ":"a","Ẩ":"A","đ":"d","Đ":"D","ẹ":"e","Ẹ":"E","ẽ":"e","Ẽ":"E","ẻ":"e","Ẻ":"E","ế":"e","Ế":"E","ề":"e","Ề":"E","ệ":"e","Ệ":"E","ễ":"e","Ễ":"E","ể":"e","Ể":"E","ỏ":"o","ọ":"o","Ọ":"o","ố":"o","Ố":"O","ồ":"o","Ồ":"O","ổ":"o","Ổ":"O","ộ":"o","Ộ":"O","ỗ":"o","Ỗ":"O","ơ":"o","Ơ":"O","ớ":"o","Ớ":"O","ờ":"o","Ờ":"O","ợ":"o","Ợ":"O","ỡ":"o","Ỡ":"O","Ở":"o","ở":"o","ị":"i","Ị":"I","ĩ":"i","Ĩ":"I","ỉ":"i","Ỉ":"i","ủ":"u","Ủ":"U","ụ":"u","Ụ":"U","ũ":"u","Ũ":"U","ư":"u","Ư":"U","ứ":"u","Ứ":"U","ừ":"u","Ừ":"U","ự":"u","Ự":"U","ữ":"u","Ữ":"U","ử":"u","Ử":"ư","ỷ":"y","Ỷ":"y","ỳ":"y","Ỳ":"Y","ỵ":"y","Ỵ":"Y","ỹ":"y","Ỹ":"Y","ạ":"a","Ạ":"A","ấ":"a","Ấ":"A","ầ":"a","Ầ":"A","ậ":"a","Ậ":"A","ẫ":"a","Ẫ":"A","ắ":"a","Ắ":"A","ằ":"a","Ằ":"A","ặ":"a","Ặ":"A","ẵ":"a","Ẵ":"A","⓪":"0","①":"1","②":"2","③":"3","④":"4","⑤":"5","⑥":"6","⑦":"7","⑧":"8","⑨":"9","⑩":"10","⑪":"11","⑫":"12","⑬":"13","⑭":"14","⑮":"15","⑯":"16","⑰":"17","⑱":"18","⑲":"18","⑳":"18","⓵":"1","⓶":"2","⓷":"3","⓸":"4","⓹":"5","⓺":"6","⓻":"7","⓼":"8","⓽":"9","⓾":"10","⓿":"0","⓫":"11","⓬":"12","⓭":"13","⓮":"14","⓯":"15","⓰":"16","⓱":"17","⓲":"18","⓳":"19","⓴":"20","Ⓐ":"A","Ⓑ":"B","Ⓒ":"C","Ⓓ":"D","Ⓔ":"E","Ⓕ":"F","Ⓖ":"G","Ⓗ":"H","Ⓘ":"I","Ⓙ":"J","Ⓚ":"K","Ⓛ":"L","Ⓜ":"M","Ⓝ":"N","Ⓞ":"O","Ⓟ":"P","Ⓠ":"Q","Ⓡ":"R","Ⓢ":"S","Ⓣ":"T","Ⓤ":"U","Ⓥ":"V","Ⓦ":"W","Ⓧ":"X","Ⓨ":"Y","Ⓩ":"Z","ⓐ":"a","ⓑ":"b","ⓒ":"c","ⓓ":"d","ⓔ":"e","ⓕ":"f","ⓖ":"g","ⓗ":"h","ⓘ":"i","ⓙ":"j","ⓚ":"k","ⓛ":"l","ⓜ":"m","ⓝ":"n","ⓞ":"o","ⓟ":"p","ⓠ":"q","ⓡ":"r","ⓢ":"s","ⓣ":"t","ⓤ":"u","ⓦ":"v","ⓥ":"w","ⓧ":"x","ⓨ":"y","ⓩ":"z","“":'"',"”":'"',"‘":"'","’":"'","∂":"d","ƒ":"f","™":"(TM)","©":"(C)","œ":"oe","Œ":"OE","®":"(R)","†":"+","℠":"(SM)","…":"...","˚":"o","º":"o","ª":"a","•":"*","၊":",","။":".",$:"USD","€":"EUR","₢":"BRN","₣":"FRF","£":"GBP","₤":"ITL","₦":"NGN","₧":"ESP","₩":"KRW","₪":"ILS","₫":"VND","₭":"LAK","₮":"MNT","₯":"GRD","₱":"ARS","₲":"PYG","₳":"ARA","₴":"UAH","₵":"GHS","¢":"cent","¥":"CNY","元":"CNY","円":"YEN","﷼":"IRR","₠":"EWE","฿":"THB","₨":"INR","₹":"INR","₰":"PF","₺":"TRY","؋":"AFN","₼":"AZN","лв":"BGN","៛":"KHR","₡":"CRC","₸":"KZT","ден":"MKD","zł":"PLN","₽":"RUB","₾":"GEL"},a=["်","ް"],n={"ာ":"a","ါ":"a","ေ":"e","ဲ":"e","ိ":"i","ီ":"i","ို":"o","ု":"u","ူ":"u","ေါင်":"aung","ော":"aw","ော်":"aw","ေါ":"aw","ေါ်":"aw","်":"်","က်":"et","ိုက်":"aik","ောက်":"auk","င်":"in","ိုင်":"aing","ောင်":"aung","စ်":"it","ည်":"i","တ်":"at","ိတ်":"eik","ုတ်":"ok","ွတ်":"ut","ေတ်":"it","ဒ်":"d","ိုဒ်":"ok","ုဒ်":"ait","န်":"an","ာန်":"an","ိန်":"ein","ုန်":"on","ွန်":"un","ပ်":"at","ိပ်":"eik","ုပ်":"ok","ွပ်":"ut","န်ုပ်":"nub","မ်":"an","ိမ်":"ein","ုမ်":"on","ွမ်":"un","ယ်":"e","ိုလ်":"ol","ဉ်":"in","ံ":"an","ိံ":"ein","ုံ":"on","ައް":"ah","ަށް":"ah"},s={en:{},az:{"ç":"c","ə":"e","ğ":"g","ı":"i","ö":"o","ş":"s","ü":"u","Ç":"C","Ə":"E","Ğ":"G","İ":"I","Ö":"O","Ş":"S","Ü":"U"},cs:{"č":"c","ď":"d","ě":"e","ň":"n","ř":"r","š":"s","ť":"t","ů":"u","ž":"z","Č":"C","Ď":"D","Ě":"E","Ň":"N","Ř":"R","Š":"S","Ť":"T","Ů":"U","Ž":"Z"},fi:{"ä":"a","Ä":"A","ö":"o","Ö":"O"},hu:{"ä":"a","Ä":"A","ö":"o","Ö":"O","ü":"u","Ü":"U","ű":"u","Ű":"U"},lt:{"ą":"a","č":"c","ę":"e","ė":"e","į":"i","š":"s","ų":"u","ū":"u","ž":"z","Ą":"A","Č":"C","Ę":"E","Ė":"E","Į":"I","Š":"S","Ų":"U","Ū":"U"},lv:{"ā":"a","č":"c","ē":"e","ģ":"g","ī":"i","ķ":"k","ļ":"l","ņ":"n","š":"s","ū":"u","ž":"z","Ā":"A","Č":"C","Ē":"E","Ģ":"G","Ī":"i","Ķ":"k","Ļ":"L","Ņ":"N","Š":"S","Ū":"u","Ž":"Z"},pl:{"ą":"a","ć":"c","ę":"e","ł":"l","ń":"n","ó":"o","ś":"s","ź":"z","ż":"z","Ą":"A","Ć":"C","Ę":"e","Ł":"L","Ń":"N","Ó":"O","Ś":"S","Ź":"Z","Ż":"Z"},sv:{"ä":"a","Ä":"A","ö":"o","Ö":"O"},sk:{"ä":"a","Ä":"A"},sr:{"љ":"lj","њ":"nj","Љ":"Lj","Њ":"Nj","đ":"dj","Đ":"Dj"},tr:{"Ü":"U","Ö":"O","ü":"u","ö":"o"}},r={ar:{"∆":"delta","∞":"la-nihaya","♥":"hob","&":"wa","|":"aw","<":"aqal-men",">":"akbar-men","∑":"majmou","¤":"omla"},az:{},ca:{"∆":"delta","∞":"infinit","♥":"amor","&":"i","|":"o","<":"menys que",">":"mes que","∑":"suma dels","¤":"moneda"},cs:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"nebo","<":"mensi nez",">":"vetsi nez","∑":"soucet","¤":"mena"},de:{"∆":"delta","∞":"unendlich","♥":"Liebe","&":"und","|":"oder","<":"kleiner als",">":"groesser als","∑":"Summe von","¤":"Waehrung"},dv:{"∆":"delta","∞":"kolunulaa","♥":"loabi","&":"aai","|":"noonee","<":"ah vure kuda",">":"ah vure bodu","∑":"jumula","¤":"faisaa"},en:{"∆":"delta","∞":"infinity","♥":"love","&":"and","|":"or","<":"less than",">":"greater than","∑":"sum","¤":"currency"},es:{"∆":"delta","∞":"infinito","♥":"amor","&":"y","|":"u","<":"menos que",">":"mas que","∑":"suma de los","¤":"moneda"},fa:{"∆":"delta","∞":"bi-nahayat","♥":"eshgh","&":"va","|":"ya","<":"kamtar-az",">":"bishtar-az","∑":"majmooe","¤":"vahed"},fi:{"∆":"delta","∞":"aarettomyys","♥":"rakkaus","&":"ja","|":"tai","<":"pienempi kuin",">":"suurempi kuin","∑":"summa","¤":"valuutta"},fr:{"∆":"delta","∞":"infiniment","♥":"Amour","&":"et","|":"ou","<":"moins que",">":"superieure a","∑":"somme des","¤":"monnaie"},ge:{"∆":"delta","∞":"usasruloba","♥":"siqvaruli","&":"da","|":"an","<":"naklebi",">":"meti","∑":"jami","¤":"valuta"},gr:{},hu:{"∆":"delta","∞":"vegtelen","♥":"szerelem","&":"es","|":"vagy","<":"kisebb mint",">":"nagyobb mint","∑":"szumma","¤":"penznem"},it:{"∆":"delta","∞":"infinito","♥":"amore","&":"e","|":"o","<":"minore di",">":"maggiore di","∑":"somma","¤":"moneta"},lt:{"∆":"delta","∞":"begalybe","♥":"meile","&":"ir","|":"ar","<":"maziau nei",">":"daugiau nei","∑":"suma","¤":"valiuta"},lv:{"∆":"delta","∞":"bezgaliba","♥":"milestiba","&":"un","|":"vai","<":"mazak neka",">":"lielaks neka","∑":"summa","¤":"valuta"},my:{"∆":"kwahkhyaet","∞":"asaonasme","♥":"akhyait","&":"nhin","|":"tho","<":"ngethaw",">":"kyithaw","∑":"paungld","¤":"ngwekye"},mk:{},nl:{"∆":"delta","∞":"oneindig","♥":"liefde","&":"en","|":"of","<":"kleiner dan",">":"groter dan","∑":"som","¤":"valuta"},pl:{"∆":"delta","∞":"nieskonczonosc","♥":"milosc","&":"i","|":"lub","<":"mniejsze niz",">":"wieksze niz","∑":"suma","¤":"waluta"},pt:{"∆":"delta","∞":"infinito","♥":"amor","&":"e","|":"ou","<":"menor que",">":"maior que","∑":"soma","¤":"moeda"},ro:{"∆":"delta","∞":"infinit","♥":"dragoste","&":"si","|":"sau","<":"mai mic ca",">":"mai mare ca","∑":"suma","¤":"valuta"},ru:{"∆":"delta","∞":"beskonechno","♥":"lubov","&":"i","|":"ili","<":"menshe",">":"bolshe","∑":"summa","¤":"valjuta"},sk:{"∆":"delta","∞":"nekonecno","♥":"laska","&":"a","|":"alebo","<":"menej ako",">":"viac ako","∑":"sucet","¤":"mena"},sr:{},tr:{"∆":"delta","∞":"sonsuzluk","♥":"ask","&":"ve","|":"veya","<":"kucuktur",">":"buyuktur","∑":"toplam","¤":"para birimi"},uk:{"∆":"delta","∞":"bezkinechnist","♥":"lubov","&":"i","|":"abo","<":"menshe",">":"bilshe","∑":"suma","¤":"valjuta"},vn:{"∆":"delta","∞":"vo cuc","♥":"yeu","&":"va","|":"hoac","<":"nho hon",">":"lon hon","∑":"tong","¤":"tien te"}},i=[";","?",":","@","&","=","+","$",",","/"].join(""),o=[";","?",":","@","&","=","+","$",","].join(""),d=[".","!","~","*","'","(",")"].join(""),u=function(e,u){var c,p,m,f,y,g,v,_,k,b,x,w,Z,T,O="-",j="",S="",E=!0,C={},N="";if("string"!=typeof e)return"";if("string"==typeof u&&(O=u),v=r.en,_=s.en,"object"==typeof u)for(x in c=u.maintainCase||!1,C=u.custom&&"object"==typeof u.custom?u.custom:C,m=+u.truncate>1&&u.truncate||!1,f=u.uric||!1,y=u.uricNoSlash||!1,g=u.mark||!1,E=!1!==u.symbols&&!1!==u.lang,O=u.separator||O,f&&(N+=i),y&&(N+=o),g&&(N+=d),v=u.lang&&r[u.lang]&&E?r[u.lang]:E?r.en:{},_=u.lang&&s[u.lang]?s[u.lang]:!1===u.lang||!0===u.lang?{}:s.en,u.titleCase&&"number"==typeof u.titleCase.length&&Array.prototype.toString.call(u.titleCase)?(u.titleCase.forEach((function(e){C[e+""]=e+""})),p=!0):p=!!u.titleCase,u.custom&&"number"==typeof u.custom.length&&Array.prototype.toString.call(u.custom)&&u.custom.forEach((function(e){C[e+""]=e+""})),Object.keys(C).forEach((function(t){var a;a=t.length>1?new RegExp("\\b"+l(t)+"\\b","gi"):new RegExp(l(t),"gi"),e=e.replace(a,C[t])})),C)N+=x;for(N=l(N+=O),Z=!1,T=!1,b=0,w=(e=e.replace(/(^\s+|\s+$)/g,"")).length;b=0?(S+=x,x=""):!0===T?(x=n[S]+t[x],S=""):x=Z&&t[x].match(/[A-Za-z0-9]/)?" "+t[x]:t[x],Z=!1,T=!1):x in n?(S+=x,x="",b===w-1&&(x=n[S]),T=!0):!v[x]||f&&-1!==i.indexOf(x)||y&&-1!==o.indexOf(x)?(!0===T?(x=n[S]+x,S="",T=!1):Z&&(/[A-Za-z0-9]/.test(x)||j.substr(-1).match(/A-Za-z0-9]/))&&(x=" "+x),Z=!1):(x=Z||j.substr(-1).match(/[A-Za-z0-9]/)?O+v[x]:v[x],x+=void 0!==e[b+1]&&e[b+1].match(/[A-Za-z0-9]/)?O:"",Z=!0),j+=x.replace(new RegExp("[^\\w\\s"+N+"_-]","g"),O);return p&&(j=j.replace(/(\w)(\S*)/g,(function(e,t,a){var n=t.toUpperCase()+(null!==a?a:"");return Object.keys(C).indexOf(n.toLowerCase())<0?n:n.toLowerCase()}))),j=j.replace(/\s+/g,O).replace(new RegExp("\\"+O+"+","g"),O).replace(new RegExp("(^\\"+O+"+|\\"+O+"+$)","g"),""),m&&j.length>m&&(k=j.charAt(m)===O,j=j.slice(0,m),k||(j=j.slice(0,j.lastIndexOf(O)))),c||p||(j=j.toLowerCase()),j},c=function(e){return function(t){return u(t,e)}},l=function(e){return e.replace(/[-\\^$*+?.()|[\]{}\/]/g,"\\$&")},h=function(e,t){for(var a in t)if(t[a]===e)return!0};if(It.exports)It.exports=u,It.exports.createSlug=c;else try{if(e.getSlug||e.createSlug)throw"speakingurl: globals exists /(getSlug|createSlug)/";e.getSlug=u,e.createSlug=c}catch(e){}}(a);var Pt=n(Rt.exports),zt={id:"operation-slugify",handler:async({valueField:e,languageCodePath:t,slugField:a},{data:n,services:s,database:r,getSchema:i,logger:o})=>{const d=n.$trigger.payload.hasOwnProperty(e),u=function(e,t){const a=e.split(".");return 1===a.length&&2===a[0].length?a[0]:1===a.length?!!t.hasOwnProperty(a[0])&&t[a[0]].slice(0,2):2===a.length?!!t.hasOwnProperty(a[0])&&(!!t[a[0]].hasOwnProperty(a[1])&&t[a[0]][a[1]].slice(0,2)):"en"}(t,n.$trigger.payload);if(!d||!u)return n.$trigger.payload;if("update"===n.$trigger.event.split(".").slice(-1)[0]){const e=n.$trigger.event.split(".")[0],t=await i({database:r}),a=new s.ItemsService(e,{schema:t,accountability:n.accountability}),o=await a.readOne(n.$trigger.keys[0]);if(o.slug&&o.slug.length>0)return n.$trigger.payload}const c=n.$trigger.payload[e],l=Pt(c,{separator:"-",lang:u});return o.info('[operation-slugify] input: "'+c+'" slug: "'+l+'" language: "'+u+'"'),Object.assign({},n.$trigger.payload,{[a]:l})}};export{zt as default}; 2 | -------------------------------------------------------------------------------- /dist/app.js: -------------------------------------------------------------------------------- 1 | import{defineOperationApp as e}from"@directus/extensions-sdk";var t=e({id:"operation-slugify",name:"Slugify",icon:"box",description:"Generates language aware slugs.",overview:({valueField:e,slugField:t,languageCodePath:a})=>[{label:"Generates slugs based on",text:e},{label:"Name of the slug field",text:t},{label:"Language indicator",text:a}],options:[{field:"valueField",name:"Name of the field to generate the slug from",type:"string",meta:{width:"half",interface:"input"}},{field:"languageCodePath",name:"Path to the language code or 2 letter language code",type:"string",meta:{width:"half",interface:"input"}},{field:"slugField",name:"Name of the slug field",type:"string",meta:{width:"half",interface:"input"}}]});export{t as default}; 2 | -------------------------------------------------------------------------------- /media/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratgozel/directus-operation-slugify/a4fc873a2dc2e95eb2658ec0cabe8ba5bbe48699/media/flow.png -------------------------------------------------------------------------------- /media/options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratgozel/directus-operation-slugify/a4fc873a2dc2e95eb2658ec0cabe8ba5bbe48699/media/options.png -------------------------------------------------------------------------------- /media/verify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muratgozel/directus-operation-slugify/a4fc873a2dc2e95eb2658ec0cabe8ba5bbe48699/media/verify.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@muratgozel/directus-operation-slugify", 3 | "description": "Generates a language aware slug from texts.", 4 | "icon": "extension", 5 | "version": "v1.1.7", 6 | "keywords": [ 7 | "directus", 8 | "directus-extension", 9 | "directus-extension-operation", 10 | "slugify" 11 | ], 12 | "type": "module", 13 | "files": [ 14 | "dist" 15 | ], 16 | "publishConfig": { 17 | "access": "public" 18 | }, 19 | "author": "Murat Gözel ", 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/muratgozel/directus-operation-slugify.git" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/muratgozel/directus-operation-slugify/issues" 26 | }, 27 | "homepage": "https://github.com/muratgozel/directus-operation-slugify#readme", 28 | "directus:extension": { 29 | "type": "operation", 30 | "host": "^10.3.0", 31 | "path": { 32 | "app": "dist/app.js", 33 | "api": "dist/api.js" 34 | }, 35 | "source": { 36 | "app": "src/app.ts", 37 | "api": "src/api.ts" 38 | }, 39 | "sandbox": { 40 | "enabled": false, 41 | "requestedScopes": {} 42 | } 43 | }, 44 | "scripts": { 45 | "build": "directus-extension build", 46 | "dev": "directus-extension build -w --no-minify", 47 | "link": "directus-extension link", 48 | "up": "export $(grep -v '^#' .env | xargs -0) && npm run build && aws s3 sync ./ s3://$S3_BUCKET_NAME/extensions/directus-extension-operation-slugify/ --exclude '*' --include 'package.json' --include 'dist/*' --delete", 49 | "up-dev": "export $(grep -v '^#' .env | xargs -0) && npm run build && rsync -a --exclude='src' --exclude='node_modules' --include='package.json' --include='dist' --include='dist/*' --exclude='*' --delete ./* $EXTENSIONS_DIR/directus-extension-operation-slugify/" 50 | }, 51 | "license": "MIT", 52 | "funding": { 53 | "type": "patreon", 54 | "url": "https://patreon.com/muratgozel" 55 | }, 56 | "devDependencies": { 57 | "@directus/extensions-sdk": "11.0.9", 58 | "@types/node": "^20.14.9", 59 | "node-releaser": "^2.1.4", 60 | "typescript": "^5.5.3", 61 | "vue": "^3.4.31" 62 | }, 63 | "dependencies": { 64 | "@types/speakingurl": "^13.0.6", 65 | "speakingurl": "^14.0.1" 66 | } 67 | } -------------------------------------------------------------------------------- /src/api.ts: -------------------------------------------------------------------------------- 1 | import { defineOperationApi } from '@directus/extensions-sdk'; 2 | import getSlug from 'speakingurl'; 3 | 4 | type Options = { 5 | valueField: string; 6 | languageCodePath: string; 7 | slugField: string; 8 | }; 9 | type Data = Record 10 | 11 | export default defineOperationApi({ 12 | id: 'operation-slugify', 13 | handler: async ({ valueField, languageCodePath, slugField }, { data, services, database, getSchema, logger }: { data: Data }) => { 14 | const hasValueField = data.$trigger.payload.hasOwnProperty(valueField) 15 | const lang = verifyLanguage(languageCodePath, data.$trigger.payload) 16 | if (!hasValueField || !lang) { 17 | return data.$trigger.payload 18 | } 19 | 20 | // generate a slug if it's empty on any update operation 21 | const isUpdate = data.$trigger.event.split('.').slice(-1)[0] === 'update' 22 | if (isUpdate) { 23 | const collection = data.$trigger.event.split('.')[0] 24 | const schema = await getSchema({ database }) 25 | const itemsService = new services.ItemsService(collection, { 26 | schema, 27 | accountability: data.accountability 28 | }) 29 | const item = await itemsService.readOne(data.$trigger.keys[0]) 30 | // cancel if it's already filled 31 | if (item.slug && item.slug.length > 0) { 32 | return data.$trigger.payload 33 | } 34 | } 35 | 36 | // get value to generate the slug from 37 | const value = data.$trigger.payload[valueField] 38 | 39 | // generate slug 40 | const slug = getSlug(value, { 41 | separator: '-', 42 | lang 43 | }) 44 | 45 | logger.info('[operation-slugify] input: "' + value + '" slug: "' + slug + '"' + ' language: "' + lang + '"') 46 | 47 | return Object.assign({}, data.$trigger.payload, { 48 | [slugField]: slug 49 | }) 50 | }, 51 | }); 52 | 53 | function verifyLanguage (input: string, payload: Record): string | boolean { 54 | const arr: string[] = input.split('.') 55 | 56 | if (arr.length === 1 && (arr[0] as string).length === 2) { 57 | return arr[0] as string 58 | } 59 | else if (arr.length === 1) { 60 | return payload.hasOwnProperty(arr[0] as string) ? (payload[arr[0] as string]).slice(0, 2) : false 61 | } 62 | else if (arr.length === 2) { 63 | return payload.hasOwnProperty(arr[0] as string) 64 | ? payload[arr[0] as string].hasOwnProperty(arr[1] as string) 65 | ? (payload[arr[0] as string][arr[1] as string]).slice(0, 2) 66 | : false 67 | : false 68 | } 69 | else { 70 | return 'en' 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/app.ts: -------------------------------------------------------------------------------- 1 | import { defineOperationApp } from '@directus/extensions-sdk'; 2 | 3 | export default defineOperationApp({ 4 | id: 'operation-slugify', 5 | name: 'Slugify', 6 | icon: 'box', 7 | description: 'Generates language aware slugs.', 8 | overview: ({ valueField, slugField, languageCodePath }) => [ 9 | { 10 | label: 'Generates slugs based on', 11 | text: valueField, 12 | }, 13 | { 14 | label: 'Name of the slug field', 15 | text: slugField, 16 | }, 17 | { 18 | label: 'Language indicator', 19 | text: languageCodePath, 20 | }, 21 | ], 22 | options: [ 23 | { 24 | field: 'valueField', 25 | name: 'Name of the field to generate the slug from', 26 | type: 'string', 27 | meta: { 28 | width: 'half', 29 | interface: 'input', 30 | }, 31 | }, 32 | { 33 | field: 'languageCodePath', 34 | name: 'Path to the language code or 2 letter language code', 35 | type: 'string', 36 | meta: { 37 | width: 'half', 38 | interface: 'input', 39 | }, 40 | }, 41 | { 42 | field: 'slugField', 43 | name: 'Name of the slug field', 44 | type: 'string', 45 | meta: { 46 | width: 'half', 47 | interface: 'input', 48 | }, 49 | }, 50 | ], 51 | }); 52 | -------------------------------------------------------------------------------- /src/shims.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import { DefineComponent } from 'vue'; 3 | const component: DefineComponent<{}, {}, any>; 4 | export default component; 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2019", 4 | "lib": ["ES2019", "DOM"], 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "noFallthroughCasesInSwitch": true, 8 | "esModuleInterop": true, 9 | "noImplicitAny": true, 10 | "noImplicitThis": true, 11 | "noImplicitReturns": true, 12 | "noUnusedLocals": true, 13 | "noUncheckedIndexedAccess": true, 14 | "noUnusedParameters": true, 15 | "alwaysStrict": true, 16 | "strictNullChecks": true, 17 | "strictFunctionTypes": true, 18 | "strictBindCallApply": true, 19 | "strictPropertyInitialization": true, 20 | "resolveJsonModule": false, 21 | "skipLibCheck": true, 22 | "forceConsistentCasingInFileNames": true, 23 | "allowSyntheticDefaultImports": true, 24 | "isolatedModules": true, 25 | "rootDir": "./src" 26 | }, 27 | "include": ["./src/**/*.ts"] 28 | } 29 | --------------------------------------------------------------------------------