@standards/schema 1.0.0-alpha.445 → 1.0.0-alpha.446

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.
Files changed (38) hide show
  1. package/dist/all-2xry8t7d.js +4 -0
  2. package/dist/all-BWpaP2E2.mjs +4 -0
  3. package/dist/api/index.d.mts +110 -69
  4. package/dist/api/index.d.ts +110 -69
  5. package/dist/api/index.js +1 -1
  6. package/dist/api/index.mjs +1 -1
  7. package/dist/attribute-validators-CFa9B00S.mjs +11 -0
  8. package/dist/attribute-validators-Djse5LWc.js +11 -0
  9. package/dist/{exceptions-zQlC2r1F.d.mts → exceptions-BjtmXIip.d.mts} +10 -2
  10. package/dist/{exceptions-YHdKk5N8.d.ts → exceptions-CxTJ-9hJ.d.ts} +10 -2
  11. package/dist/exceptions.d.mts +1 -1
  12. package/dist/exceptions.d.ts +1 -1
  13. package/dist/exceptions.js +1 -1
  14. package/dist/exceptions.mjs +1 -1
  15. package/dist/{index-D7FwaSvK.d.ts → index-BoesrnBX.d.ts} +2199 -3091
  16. package/dist/index.d.mts +4 -4
  17. package/dist/index.d.ts +4 -4
  18. package/dist/index.js +2 -2
  19. package/dist/index.mjs +2 -2
  20. package/dist/record-operation-BBOde9mE.mjs +2 -0
  21. package/dist/record-operation-BLhz84I4.js +2 -0
  22. package/dist/{record-query-BiyWXSWA.d.mts → record-query-BMeq7JRi.d.mts} +2180 -3072
  23. package/dist/{utils-CwQlKDYz.d.ts → utils-BdmqhdNL.d.ts} +1 -1
  24. package/dist/{utils-BZMgedee.d.mts → utils-DPto28bh.d.mts} +1 -1
  25. package/dist/utils.d.mts +1 -1
  26. package/dist/utils.d.ts +1 -1
  27. package/dist/validation/all.d.mts +2 -2
  28. package/dist/validation/all.d.ts +2 -2
  29. package/dist/validation/all.js +1 -1
  30. package/dist/validation/all.mjs +1 -1
  31. package/openapi.json +193 -192
  32. package/package.json +2 -2
  33. package/dist/all-BrGOpgV8.js +0 -4
  34. package/dist/all-Df9IeCkI.mjs +0 -4
  35. package/dist/attribute-validators-BJdOkURX.mjs +0 -11
  36. package/dist/attribute-validators-rgM_bLG1.js +0 -11
  37. package/dist/record-operation-BrYpYAKR.js +0 -2
  38. package/dist/record-operation-DSjDUW-6.mjs +0 -2
@@ -1,4 +0,0 @@
1
- /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- require("./zod-locale.js");const e=require("./attribute-validators-rgM_bLG1.js"),t=require("./exceptions.js");let n=require("zod");n=e.__toESM(n);let r=require("@standards/constants"),i=require("libphonenumber-js");const a=[`text`,`number`,`boolean`,`date`,`select`,`multiselect`],o={email:`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$`,url:`^https?:\\/\\/[\\w\\-]+(\\.[\\w\\-]+)+[/#?]?.*$`,slug:`^[a-z0-9]+(?:-[a-z0-9]+)*$`};function resolveTextPattern(e){return e.pattern?e.pattern:e.format?o[e.format]:void 0}const s={required:e=>`${e.label} is required`,invalidType:(e,t)=>`${e.label} must be a ${t}`,minLength:(e,t)=>`${e.label} must be at least ${t} characters`,maxLength:(e,t)=>`${e.label} must be at most ${t} characters`,invalidPattern:e=>`${e.label} format is invalid`,minValue:(e,t)=>`${e.label} must be at least ${t}`,maxValue:(e,t)=>`${e.label} must be at most ${t}`,mustBeInteger:e=>`${e.label} must be an integer`,invalidDate:e=>`${e.label} must be a valid date`,invalidOption:(e,t)=>`${e.label} must be one of: ${t.join(`, `)}`,invalidId:e=>`${e.label} must be a valid ID`,maxItems:(e,t)=>`${e.label} must have at most ${t} item${t>1?`s`:``}`,invalidRichtext:e=>`${e.label} must be valid rich text content`,invalidPhone:e=>`${e.label} must be a valid phone number`,invalidCurrency:e=>`${e.label} must be a valid currency value`,invalidLocation:e=>`${e.label} must be a valid location`};function formatZodErrors(e){return e.issues.map(e=>({path:e.path.map(String),message:e.message}))}var LRUCache=class{constructor(e){if(!Number.isInteger(e)||e<=0)throw Error(`LRU cache capacity must be greater than 0`);this.capacity=e,this.cache=/* @__PURE__ */ new Map}get(e){if(!this.cache.has(e))return;let t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){let e=this.cache.keys().next();e.done||this.cache.delete(e.value)}this.cache.set(e,t)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}get size(){return this.cache.size}};function createRegexCache(e=100){return new LRUCache(e)}function getCachedRegex(e,t){let n=e.get(t);return n||(n=new RegExp(t),e.set(t,n)),n}const c=createRegexCache();function createTextValidator(e,t=s){let r=n.string();e.minLength!==void 0&&(r=r.min(e.minLength,t.minLength(e,e.minLength))),e.maxLength!==void 0&&(r=r.max(e.maxLength,t.maxLength(e,e.maxLength)));let i=resolveTextPattern(e);return i&&(r=r.regex(getCachedRegex(c,i),t.invalidPattern(e))),r}function createNumberValidator(e,t=s){let r=n.number();return e.min!==void 0&&(r=r.min(e.min,t.minValue(e,e.min))),e.max!==void 0&&(r=r.max(e.max,t.maxValue(e,e.max))),e.renderAs===`rating`&&(r=r.min(e.min??0),r=r.max(e.max??5)),e.unit===`percentage`&&(r=r.min(e.min??0).max(e.max??100)),e.unit===`integer`&&(r=r.int(t.mustBeInteger(e))),r}function createCheckboxValidator(e,t=s){return n.boolean()}function resolveBound(e){if(!e)return null;let t=e===`today`?(/* @__PURE__ */ new Date()).toISOString().slice(0,10):e,n=new Date(t);return Number.isNaN(n.getTime())?null:n}function floorToPrecision(e,t){return e?t===`month`?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)):t===`year`?new Date(Date.UTC(e.getUTCFullYear(),0,1)):e:null}function createDateValidator(e,t=s){let r=t.invalidDate(e),i=floorToPrecision(resolveBound(e.minDate),e.precision),a=resolveBound(e.maxDate),o=n.any().superRefine((e,t)=>{let n=new Date(e);Number.isNaN(n.getTime())?t.addIssue({code:`custom`,message:r}):(i&&n<i&&t.addIssue({code:`custom`,message:r}),a&&n>a&&t.addIssue({code:`custom`,message:r}))});if(!e.endDate)return o;let c=n.object({start:o,end:o.nullable()}).superRefine((e,t)=>{if(e.end===null)return;let n=new Date(e.start),i=new Date(e.end);!(Number.isNaN(n.getTime())||Number.isNaN(i.getTime()))&&i<n&&t.addIssue({code:`custom`,message:r,path:[`end`]})});return n.preprocess(e=>typeof e==`string`?{start:e,end:null}:e,c)}function isNullishOrEmptyString(e){return e==null||e===``}function isValuePresent(e){return e==null?!1:typeof e==`string`?e.trim()!==``:!Array.isArray(e)||e.length>0}const l={phone:[`countryCode`]};function isEmptyValue(e,t=[]){return e==null||typeof e==`string`&&e.trim()===``?!0:e instanceof Date?!1:typeof e==`object`&&!Array.isArray(e)&&Object.entries(e).filter(([e])=>!t.includes(e)).every(([,e])=>e==null||typeof e==`string`&&e.trim()===``)}function withEmptyToNull(e,t){return n.preprocess(e=>isEmptyValue(e,t)?null:e,e.nullish())}const u=n.object({placeholder:n.string().optional(),description:n.string().optional(),defaultValue:n.unknown().optional(),icon:n.string().optional(),order:n.number().int().optional(),hidden:n.boolean().optional(),archived:n.boolean().optional(),deprecated:n.boolean().optional(),metadata:n.record(n.string(),n.unknown()).optional()}),d=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`],f={icon:e.iconNameSchema.optional().describe(`Field icon from search_icons`)},p={date:[`precision`],user:[`notifiesOnAssign`,`actors`]};function wireOmittedConfigKeysFor(e){return[...d,...p[e]??[]]}function wireHiddenTypeConfigMask(e){return Object.fromEntries((p[e]??[]).map(e=>[e,!0]))}function refuseForeignKeys(e,t,n=[]){let r=new Set(n);return function refuse(n,i,a,o=[]){let s=e[n];if(s!==void 0&&i!==void 0)for(let e of Object.keys(i))s.has(e)||r.has(e)||a.addIssue({code:`custom`,path:[...o,e],message:`"${e}" is not a ${n} ${t}; keys of ${n}: ${[...s].join(`, `)}`})}}const m=n.object({value:n.string().min(1).describe(`Stored value`),label:n.string().min(1).describe(`Label people see`),description:n.string().describe(`Extra context`).optional(),inverse:n.string().describe(`Paired option's value (symmetric)`).optional(),archived:n.boolean().describe(`Hides without deleting`).optional()}),h=n.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),g=m.extend({color:e.colorIdSchema}).strict(),_=m.extend({color:e.colorIdSchema,group:h}).strict(),v=m.extend({color:n.string().optional().describe(`A color id`),group:h.optional()}).strict(),y=new Set(v.keyof().options),ee=[`options`,`targetAttributeOptions`];function withoutUnknownOptionKeys(t){let n=t;for(let r of ee){let i=t[r];if(!Array.isArray(i))continue;let a=!1,o=i.map(t=>!e.isPlainRecord(t)||Object.keys(t).every(e=>y.has(e))?t:(a=!0,Object.fromEntries(Object.entries(t).filter(([e])=>y.has(e)))));a&&(n={...n,[r]:o})}let r=t.properties;if(e.isPlainRecord(r)&&Array.isArray(r.definitions)){let t=r.definitions,i=t.map(t=>e.isPlainRecord(t)?withoutUnknownOptionKeys(t):t);i.some((e,n)=>e!==t[n])&&(n={...n,properties:{...r,definitions:i}})}return n}const b=n.array(v).min(1).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`});function writeOptionsArraySchema(t){return n.array(t).min(1).max(e.SCHEMA_LIMITS.optionsPerAttribute).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`})}const x=writeOptionsArraySchema(g),S=writeOptionsArraySchema(g),C=writeOptionsArraySchema(_),w=n.object({object:n.string().min(1).describe(`Target object`),displayTemplate:n.string().optional().describe(`Linked record label template`),filter:n.record(n.string(),n.unknown()).optional().describe(`Restricts linkable records`)}),te=n.object({object:n.string().min(1).describe(`Other side's object`),attribute:n.string().min(1).describe(`Other side's attribute`),cardinality:n.enum([`one`,`many`]).optional().describe(`Other side's cardinality`),label:n.string().min(1).optional().describe(`Other side's label`),storageOwner:n.boolean().optional().describe(`Owns the join storage`)}),T=n.object({objectName:n.string().min(1).describe(`API name of the object whose options are mirrored`),attributeName:n.string().min(1).describe(`API name of the select/status attribute to mirror options from`),attributeId:n.string().optional().describe(`Id of the source attribute, resolved by the server`)}),E=u.extend({multiline:n.boolean().describe(`Renders as a multi-line textarea`).optional(),minLength:n.number().int().min(0).describe(`Minimum character count`).optional(),maxLength:n.number().int().min(1).describe(`Maximum character count`).optional(),pattern:n.string().describe(`Regular expression the value must match`).optional(),format:n.enum([`email`,`url`,`slug`]).describe(`Validates and renders as this format`).optional()}),ne=u,D=u.extend({renderAs:n.enum([`number`,`rating`]).describe(`Plain number or a star rating`).optional(),min:n.number().describe(`Minimum allowed value`).optional(),max:n.number().describe(`Maximum allowed value`).optional(),unit:n.enum([`integer`,`decimal`,`percentage`]).describe(`How the value is stored and rendered`).optional(),decimals:n.number().int().min(0).max(10).describe(`Decimal places shown`).optional()}),O=u,k=u.extend({dateFormat:n.enum([`short`,`long`,`full`,`relative`]).describe(`How the date is rendered`).optional(),precision:n.enum([`day`,`month`,`year`]).describe(`Whether the value records a day, a month or a year`).optional(),minDate:n.string().describe(`Earliest allowed date (ISO)`).optional(),maxDate:n.string().describe(`Latest allowed date (ISO)`).optional(),includeTime:n.boolean().describe(`Also captures a time of day`).optional(),endDate:n.boolean().describe(`Paired with another date attribute as a range's end`).optional(),timeFormat:n.enum([`12h`,`24h`]).describe(`Clock format when a time is included`).optional()}),A=u.extend({defaultCountryCode:n.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),j=u.extend({defaultCurrency:n.string().length(3).describe(`ISO currency code preselected for new values`).optional(),allowedCurrencies:n.array(n.string().length(3)).describe(`ISO currency codes a value may use; any currency when omitted`).optional(),allowNegative:n.boolean().describe(`Whether a negative amount is accepted`).optional()}),M=u.extend({options:b.describe(`The workflow statuses, in order`)}),N=u.extend({granularity:n.enum([`full`,`address`,`city`,`state`,`country`,`coordinates`]).describe(`How precise a location must be captured`).optional(),defaultCountry:n.string().length(3).describe(`ISO country code preselected for new values`).optional(),allowedCountries:n.array(n.string().length(3)).describe(`ISO country codes a value may use; any country when omitted`).optional()}),P=u.extend({options:b.describe(`Options`),renderAs:n.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),F=u.extend({options:b.describe(`Options`),renderAs:n.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),I=u.extend({types:n.array(n.enum([`user`,`agent`])).min(1).optional().describe(`Which kinds of actor can be picked; both when omitted`),multiple:n.boolean().optional().describe(`Whether more than one actor can be picked`),notifiesOnAssign:n.boolean().optional().describe(`Whether each person added to the value is notified`),actors:n.boolean().optional().describe(`Whether the value holds actor ids, named by each actor's current name`)}),L={name:e.ATTRIBUTE_NAME_SCHEMA.describe(`Property API name`),label:n.string().min(1).describe(`Label people see`),required:n.boolean().describe(`Required on every edge`).optional()},R={id:n.string().optional(),objectId:n.string().optional(),system:n.boolean().optional(),unique:n.boolean().optional()},z=Object.fromEntries(d.map(e=>[e,!0])),B=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],V=[...B,`select`,`multiselect`,`status`],H={text:E,number:D,checkbox:O,date:k,phone:A,currency:j,location:N,select:P,multiselect:F,status:M},U={...H,select:P.extend({options:x.describe(`Options`)}),multiselect:F.extend({options:S.describe(`Options`)}),status:M.extend({options:C.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>U[e].omit(z).omit(wireHiddenTypeConfigMask(e)).shape,storedPropertyMember=e=>n.object({...L,...R,type:n.literal(e).describe(`Property type`),...H[e].shape}).strip(),W=n.discriminatedUnion(`type`,V.map(storedPropertyMember)),G=n.object({definitions:n.array(W).min(1).max(e.SCHEMA_LIMITS.optionsPerAttribute).describe(`Edge properties`)}).strip().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),K=refuseForeignKeys(Object.fromEntries(V.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(L),`type`]);function refuseForeignPropertyKeys(e,t){K(e.type,e,t)}const q=B.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>n.object({...L,type:e.length===1?n.literal(e[0]).describe(`Property type`):n.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),J=n.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),n.object({...L,type:n.enum(B).describe(`Property type`),...q}).strict().superRefine(refuseForeignPropertyKeys)]),Y=n.object({definitions:n.array(J).min(1).max(e.SCHEMA_LIMITS.optionsPerAttribute).describe(`Edge properties`)}).strict().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),X=u.extend({targets:n.array(w).min(1).describe(`Target object(s)`),cardinality:n.enum([`one`,`many`]).describe(`one or many`),maxItems:n.number().int().min(1).optional().describe(`Max linked records`),bilateral:te.optional().describe(`Syncs the other side's attribute`),properties:G.optional()}),re=u.extend({expression:n.string().min(1).describe(`The formula expression, compiled against this object's attributes`),returnType:n.enum(a).describe(`The formula's result type`),decimals:n.number().int().min(0).max(10).optional().describe(`Decimal places shown for a number result`),currencyCode:n.string().length(3).optional().describe(`ISO 4217 code a number result renders with; presentation only`),allowRelations:n.boolean().optional().describe(`Whether the expression may read across a relation`),optionsSource:T.optional().describe(`Mirrors an option set`)}),ie=u.extend({relationAttribute:n.string().min(1).optional().describe(`API name of the relation this rollup aggregates through`),relationPath:n.string().optional().describe(`Not supported yet — single-hop only`),targetAttribute:n.string().min(1).optional().describe(`API name of the attribute aggregated on the relation's target object; not read by count`),function:n.enum([`sum`,`avg`,`earliest`,`latest`,`count`,`countValues`,`countUniqueValues`,`countEmpty`,`percentEmpty`,`percentNotEmpty`,`original`]).describe(`The aggregation applied across the linked records`),decimals:n.number().int().min(0).max(10).optional().describe(`Decimal places shown for a numeric result`),targetAttributeType:n.string().optional().describe(`Server-set`),targetAttributeOptions:n.array(v).optional().describe(`Server-set`),targetCurrencyCode:n.string().length(3).optional().describe(`Server-set`),optionsSource:T.optional().describe(`Mirrors an option set`)});function rollupTargetIssue(e,t){if(e===`rollup`&&t.function!==`count`&&t.targetAttribute===void 0)return{path:[`targetAttribute`],message:`targetAttribute is required for a "${String(t.function)}" rollup`}}function datePrecisionIssues(t,n,r=[]){let i=[],a=n.precision;if(t===`date`&&a!==void 0&&a!==`day`)for(let e of[`includeTime`,`endDate`])n[e]===!0&&i.push({path:[...r,`precision`],message:`A "${String(a)}" precision cannot be combined with ${e}`});let o=n.properties;return e.isPlainRecord(o)&&Array.isArray(o.definitions)&&o.definitions.forEach((t,n)=>{e.isPlainRecord(t)&&i.push(...datePrecisionIssues(String(t.type),t,[...r,`properties`,`definitions`,n]))}),i}const Z={text:E,richtext:ne,number:D,checkbox:O,date:k,phone:A,currency:j,status:M,location:N,select:P,multiselect:F,user:I,relation:X,formula:re,rollup:ie,document:u.extend({properties:G.optional(),accepts:n.array(n.string().min(1)).optional().describe("MIME prefixes or globs a file must match (e.g. `image/*`, `*.pdf`)"),maxFileSize:n.number().int().min(1).optional().describe(`Maximum file size in bytes`)})};function getAttributeConfigSchema(e){let n=Z[e];if(!n)throw new t.ValidationError(`Unsupported attribute type: ${e}`,[]);return n}function parseAttributeConfig(e,t){let n=getAttributeConfigSchema(e).strip().parse(t),r=rollupTargetIssue(e,n);if(r)throw validationErrorFromIssues([r]);return n}function getAttributeConfigWriteSchema(t){let n=getAttributeConfigSchema(t).extend({icon:e.iconNameSchema.optional()});switch(t){case`select`:return n.extend({options:x.describe(`Options`)});case`multiselect`:return n.extend({options:S.describe(`Options`)});case`status`:return n.extend({options:C.describe(`Statuses`)});default:return n}}function validationErrorFromIssues(e){return t.ValidationError.fromZodErrors(e.map(e=>({path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message})))}function parseWriteSchema(e,t){let n=getAttributeConfigWriteSchema(e).strip().safeParse(t);if(!n.success)throw validationErrorFromIssues(n.error.issues);let r=rollupTargetIssue(e,n.data);if(r)throw validationErrorFromIssues([r]);let i=datePrecisionIssues(e,n.data);if(i.length>0)throw validationErrorFromIssues(i);return n.data}function parseAttributeConfigForCreate(e,t){return parseWriteSchema(e,t)}function validatePatchedIcon(n){if(!Object.prototype.hasOwnProperty.call(n,`icon`))return;let r=e.iconNameSchema.optional().safeParse(n.icon);if(!r.success)throw t.ValidationError.fromZodErrors(r.error.issues.map(e=>({path:[`icon`,...e.path.map(e=>typeof e==`symbol`?String(e):e)],message:e.message})))}function parseAttributeConfigForUpdate(t,n){let r=Object.prototype.hasOwnProperty.call(n,`options`),i=Object.prototype.hasOwnProperty.call(n,`icon`),a={...t,...n};if(validatePatchedIcon(n),r){let{icon:e,...n}=a,r=parseWriteSchema(t.type,i?a:n);return!i&&e!==void 0&&(r.icon=e),r}let o=t.options;e.isValueKindType(t.type,`options`)&&(a.options=[{value:`__legacy__`,label:`__legacy__`}]);let s=getAttributeConfigSchema(t.type).strip().safeParse(a);if(!s.success)throw validationErrorFromIssues(s.error.issues);let c=s.data,l=datePrecisionIssues(t.type,c);if(l.length>0)throw validationErrorFromIssues(l);return e.isValueKindType(t.type,`options`)&&(c.options=o),c}function createCurrencyValidator(e,t=s){let r=e.allowNegative?n.number():n.number().min(0);return n.object({code:n.string().length(3),value:r},{message:t.invalidCurrency(e)})}function createLocationValidator(e,t=s){return n.object({address:n.string().optional(),address2:n.string().optional(),city:n.string().optional(),state:n.string().optional(),postalCode:n.string().optional(),country:n.string().length(3).optional(),latitude:n.number().min(-90).max(90).optional(),longitude:n.number().min(-180).max(180).optional()},{message:t.invalidLocation(e)})}function digitsOnly(e){return e.replace(/\D/g,``)}function normalizeCountrylessPhoneNumber(e){return digitsOnly(e)}function getIso2(e){return(0,r.getCountryByIso3)(e)?.iso2}function normalizePhoneNumber(e,t){if(!e)return``;let n=getIso2(t);if(!n)return digitsOnly(e);let a=(0,i.parsePhoneNumberFromString)(e,n);if(a)return absorbDoubledCallingCode(a.nationalNumber,a.isValid(),t,n);let o=(0,r.getCountryByIso3)(t),s=digitsOnly(e);if(o){let e=o.phoneCode.replace(`+`,``),t=s.startsWith(e)?s.slice(e.length):s;return(0,r.stripTrunkPrefix)(t,o.phoneTrunkPrefix??``)}return s}function absorbDoubledCallingCode(e,t,n,a){if(t)return e;let o=(0,r.getCountryByIso3)(n)?.phoneCode.replace(`+`,``);if(o===void 0||!e.startsWith(o))return e;let s=e.slice(o.length),c=(0,i.parsePhoneNumberFromString)(`+${o}${s}`,a);return c?.isValid()?c.nationalNumber:e}function formatPhoneForDisplay(e){if(!e.phoneNumber)return``;let t=getIso2(e.countryCode),n=(0,r.getCountryByIso3)(e.countryCode)?.phoneCode??``;if(!t)return`${n} ${e.phoneNumber}`.trim();let a=`${n}${digitsOnly(e.phoneNumber)}`,o=(0,i.parsePhoneNumberFromString)(a);return o?o.formatInternational():`${n} ${e.phoneNumber}`.trim()}function createPhoneValidator(e,t=s){return n.object({countryCode:n.string().length(3),phoneNumber:n.string().min(1,{message:t.required(e)})},{message:t.invalidPhone(e)}).refine(e=>(0,r.isValidIso3)(e.countryCode),{message:`Invalid country code`}).transform(e=>({countryCode:e.countryCode,phoneNumber:normalizePhoneNumber(e.phoneNumber,e.countryCode)}))}function extractRelationId(e){return typeof e==`object`&&e&&`id`in e?e.id:e}function createSingleRelationValidator(e,t=s){let r=n.guid({message:t.invalidId(e)}),i=n.union([r,n.null()]);return n.union([i,n.object({id:r,props:n.record(n.string(),n.unknown()).optional()}).passthrough()])}function createMultiRelationValidator(e,t=s){let r=n.guid({message:t.invalidId(e)}),i=n.union([r,n.object({id:r,props:n.record(n.string(),n.unknown()).optional()}).passthrough()]),a=n.array(i);return e.maxItems!==void 0&&(a=a.max(e.maxItems,t.maxItems(e,e.maxItems))),a.refine(e=>e.every(e=>{let t=extractRelationId(e);return typeof t==`string`&&r.safeParse(t).success}),{message:t.invalidId(e)})}function createRelationValidator(e,t=s){return e.cardinality===`many`?createMultiRelationValidator(e,t):createSingleRelationValidator(e,t)}function createRichtextValidator(e,t=s){return n.string({message:t.invalidRichtext(e)})}function describeOptions(e){return e.map(e=>e.label===e.value?e.value:`${e.value} (${e.label})`)}function createSelectValidator(e,t=s){let r=e.options.map(e=>e.value);return r.length===0?n.never():n.enum(r,{message:t.invalidOption(e,describeOptions(e.options))})}function createMultiselectValidator(e,t=s){let r=e.options.map(e=>e.value);return r.length===0?n.never():n.array(n.enum(r,{message:t.invalidOption(e,describeOptions(e.options))}))}function createStatusValidator(e,t=s){let r=e.options.map(e=>e.value);return r.length===0?n.never():n.enum(r,{message:t.invalidOption(e,describeOptions(e.options))})}function createUserValidator(e,t=s){let r=n.guid({message:t.invalidId(e)});return e.multiple?n.array(r):r}function createFormulaValidator(e,t=s){return n.unknown()}function createRollupValidator(e,t=s){return n.unknown()}function createAttributeValidator(e,t=s){switch(e.type){case`text`:return createTextValidator(e,t);case`richtext`:return createRichtextValidator(e,t);case`number`:return createNumberValidator(e,t);case`checkbox`:return createCheckboxValidator(e,t);case`date`:return createDateValidator(e,t);case`phone`:return createPhoneValidator(e,t);case`currency`:return createCurrencyValidator(e,t);case`status`:return createStatusValidator(e,t);case`location`:return createLocationValidator(e,t);case`select`:return createSelectValidator(e,t);case`multiselect`:return createMultiselectValidator(e,t);case`user`:return createUserValidator(e,t);case`relation`:return createRelationValidator(e,t);case`formula`:return createFormulaValidator(e,t);case`rollup`:return createRollupValidator(e,t);default:return n.unknown()}}function createFormAttributeValidator(e,t=s){let n=createAttributeValidator(e,t);return e.required?n:withEmptyToNull(n,l[e.type])}const Q=/* @__PURE__ */ new WeakMap,$=/* @__PURE__ */ new WeakMap;function createObjectValidator(e){let t=Q.get(e);if(t)return t;let r={};for(let t of e.attributes){let e=createAttributeValidator(t);t.required?r[t.name]=e.refine(isValuePresent,{message:s.required(t)}):r[t.name]=withEmptyToNull(e,l[t.type])}let i=n.object(r).passthrough();return Q.set(e,i),i}function createDraftValidator(e){let t=$.get(e);if(t)return t;let r={};for(let t of e.attributes){let e=createAttributeValidator(t);r[t.name]=withEmptyToNull(e,l[t.type])}let i=n.object(r).passthrough();return $.set(e,i),i}function validateAttribute(e,t){let n=createAttributeValidator(e);if(!e.required&&t==null)return{success:!0,data:{[e.name]:t}};let r=n.safeParse(t);return r.success?{success:!0,data:{[e.name]:r.data}}:{success:!1,errors:formatZodErrors(r.error).map(t=>({path:[e.name,...t.path],message:t.message}))}}function validateObject(e,t){let n=createObjectValidator(e).safeParse(t);return n.success?{success:!0,data:n.data}:{success:!1,errors:formatZodErrors(n.error)}}function validateObjectOrThrow(e,n){let r=validateObject(e,n);if(!r.success){let n=r.errors??[],i=n.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
3
- `)||`Unknown validation error`;throw new t.ValidationError(`Validation failed for ${e.label}:\n${i}`,n.map(e=>({path:e.path,message:e.message})))}return r.data}function validateDraft(e,t){let n=createDraftValidator(e).safeParse(t);return n.success?{success:!0,data:n.data}:{success:!1,errors:formatZodErrors(n.error)}}function validateDraftOrThrow(e,n){let r=validateDraft(e,n);if(!r.success){let n=r.errors??[],i=n.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
4
- `)||`Unknown validation error`;throw new t.ValidationError(`Draft validation failed for ${e.label}:\n${i}`,n.map(e=>({path:e.path,message:e.message})))}return r.data}function rejectUnknownAttributesOrThrow(e,n){let r=new Set(e.attributes.map(e=>e.name)),i=Object.keys(n).filter(e=>!r.has(e));if(i.length>0)throw new t.ValidationError(`Unknown attribute${i.length>1?`s`:``} for ${e.label}: ${i.join(`, `)}`,i.map(e=>({path:[e],message:`Unknown attribute`})))}Object.defineProperty(exports,"COMPUTED_RETURN_TYPES",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"DEFAULT_VALIDATION_MESSAGES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"SIMPLE_PROPERTY_TYPES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"TEXT_FORMAT_PATTERNS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"WIRE_OFFERED_BASE_CONFIG",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"WIRE_OMITTED_CONFIG_KEYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"attributeConfigSchemas",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"createAttributeValidator",{enumerable:!0,get:function(){return createAttributeValidator}}),Object.defineProperty(exports,"createFormAttributeValidator",{enumerable:!0,get:function(){return createFormAttributeValidator}}),Object.defineProperty(exports,"createObjectValidator",{enumerable:!0,get:function(){return createObjectValidator}}),Object.defineProperty(exports,"datePrecisionIssues",{enumerable:!0,get:function(){return datePrecisionIssues}}),Object.defineProperty(exports,"formatPhoneForDisplay",{enumerable:!0,get:function(){return formatPhoneForDisplay}}),Object.defineProperty(exports,"formatZodErrors",{enumerable:!0,get:function(){return formatZodErrors}}),Object.defineProperty(exports,"getAttributeConfigSchema",{enumerable:!0,get:function(){return getAttributeConfigSchema}}),Object.defineProperty(exports,"getAttributeConfigWriteSchema",{enumerable:!0,get:function(){return getAttributeConfigWriteSchema}}),Object.defineProperty(exports,"getIso2",{enumerable:!0,get:function(){return getIso2}}),Object.defineProperty(exports,"isEmptyValue",{enumerable:!0,get:function(){return isEmptyValue}}),Object.defineProperty(exports,"isNullishOrEmptyString",{enumerable:!0,get:function(){return isNullishOrEmptyString}}),Object.defineProperty(exports,"isValuePresent",{enumerable:!0,get:function(){return isValuePresent}}),Object.defineProperty(exports,"normalizeCountrylessPhoneNumber",{enumerable:!0,get:function(){return normalizeCountrylessPhoneNumber}}),Object.defineProperty(exports,"normalizePhoneNumber",{enumerable:!0,get:function(){return normalizePhoneNumber}}),Object.defineProperty(exports,"parseAttributeConfig",{enumerable:!0,get:function(){return parseAttributeConfig}}),Object.defineProperty(exports,"parseAttributeConfigForCreate",{enumerable:!0,get:function(){return parseAttributeConfigForCreate}}),Object.defineProperty(exports,"parseAttributeConfigForUpdate",{enumerable:!0,get:function(){return parseAttributeConfigForUpdate}}),Object.defineProperty(exports,"propertyAttributeSchema",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"propertyAttributeWireSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"propertySchemaSchema",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"propertySchemaWireSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"refuseForeignKeys",{enumerable:!0,get:function(){return refuseForeignKeys}}),Object.defineProperty(exports,"rejectUnknownAttributesOrThrow",{enumerable:!0,get:function(){return rejectUnknownAttributesOrThrow}}),Object.defineProperty(exports,"resolveTextPattern",{enumerable:!0,get:function(){return resolveTextPattern}}),Object.defineProperty(exports,"selectOptionWriteSchema",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"statusGroupSchema",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"statusOptionWriteSchema",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"validateAttribute",{enumerable:!0,get:function(){return validateAttribute}}),Object.defineProperty(exports,"validateDraft",{enumerable:!0,get:function(){return validateDraft}}),Object.defineProperty(exports,"validateDraftOrThrow",{enumerable:!0,get:function(){return validateDraftOrThrow}}),Object.defineProperty(exports,"validateObject",{enumerable:!0,get:function(){return validateObject}}),Object.defineProperty(exports,"validateObjectOrThrow",{enumerable:!0,get:function(){return validateObjectOrThrow}}),Object.defineProperty(exports,"wireHiddenTypeConfigMask",{enumerable:!0,get:function(){return wireHiddenTypeConfigMask}}),Object.defineProperty(exports,"wireOmittedConfigKeysFor",{enumerable:!0,get:function(){return wireOmittedConfigKeysFor}}),Object.defineProperty(exports,"withoutUnknownOptionKeys",{enumerable:!0,get:function(){return withoutUnknownOptionKeys}});
@@ -1,4 +0,0 @@
1
- /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- import"./zod-locale.mjs";import{ATTRIBUTE_NAME_SCHEMA as e,SCHEMA_LIMITS as t,colorIdSchema as n,iconNameSchema as r,isPlainRecord as i,isValueKindType as a}from"./attribute-validators-BJdOkURX.mjs";import{ValidationError as o}from"./exceptions.mjs";import*as s from"zod";import{getCountryByIso3 as c,isValidIso3 as l,stripTrunkPrefix as u}from"@standards/constants";import{parsePhoneNumberFromString as d}from"libphonenumber-js";const f=[`text`,`number`,`boolean`,`date`,`select`,`multiselect`],p={email:`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$`,url:`^https?:\\/\\/[\\w\\-]+(\\.[\\w\\-]+)+[/#?]?.*$`,slug:`^[a-z0-9]+(?:-[a-z0-9]+)*$`};function resolveTextPattern(e){return e.pattern?e.pattern:e.format?p[e.format]:void 0}const m={required:e=>`${e.label} is required`,invalidType:(e,t)=>`${e.label} must be a ${t}`,minLength:(e,t)=>`${e.label} must be at least ${t} characters`,maxLength:(e,t)=>`${e.label} must be at most ${t} characters`,invalidPattern:e=>`${e.label} format is invalid`,minValue:(e,t)=>`${e.label} must be at least ${t}`,maxValue:(e,t)=>`${e.label} must be at most ${t}`,mustBeInteger:e=>`${e.label} must be an integer`,invalidDate:e=>`${e.label} must be a valid date`,invalidOption:(e,t)=>`${e.label} must be one of: ${t.join(`, `)}`,invalidId:e=>`${e.label} must be a valid ID`,maxItems:(e,t)=>`${e.label} must have at most ${t} item${t>1?`s`:``}`,invalidRichtext:e=>`${e.label} must be valid rich text content`,invalidPhone:e=>`${e.label} must be a valid phone number`,invalidCurrency:e=>`${e.label} must be a valid currency value`,invalidLocation:e=>`${e.label} must be a valid location`};function formatZodErrors(e){return e.issues.map(e=>({path:e.path.map(String),message:e.message}))}var LRUCache=class{constructor(e){if(!Number.isInteger(e)||e<=0)throw Error(`LRU cache capacity must be greater than 0`);this.capacity=e,this.cache=/* @__PURE__ */ new Map}get(e){if(!this.cache.has(e))return;let t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){let e=this.cache.keys().next();e.done||this.cache.delete(e.value)}this.cache.set(e,t)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}get size(){return this.cache.size}};function createRegexCache(e=100){return new LRUCache(e)}function getCachedRegex(e,t){let n=e.get(t);return n||(n=new RegExp(t),e.set(t,n)),n}const ee=createRegexCache();function createTextValidator(e,t=m){let n=s.string();e.minLength!==void 0&&(n=n.min(e.minLength,t.minLength(e,e.minLength))),e.maxLength!==void 0&&(n=n.max(e.maxLength,t.maxLength(e,e.maxLength)));let r=resolveTextPattern(e);return r&&(n=n.regex(getCachedRegex(ee,r),t.invalidPattern(e))),n}function createNumberValidator(e,t=m){let n=s.number();return e.min!==void 0&&(n=n.min(e.min,t.minValue(e,e.min))),e.max!==void 0&&(n=n.max(e.max,t.maxValue(e,e.max))),e.renderAs===`rating`&&(n=n.min(e.min??0),n=n.max(e.max??5)),e.unit===`percentage`&&(n=n.min(e.min??0).max(e.max??100)),e.unit===`integer`&&(n=n.int(t.mustBeInteger(e))),n}function createCheckboxValidator(e,t=m){return s.boolean()}function resolveBound(e){if(!e)return null;let t=e===`today`?(/* @__PURE__ */ new Date()).toISOString().slice(0,10):e,n=new Date(t);return Number.isNaN(n.getTime())?null:n}function floorToPrecision(e,t){return e?t===`month`?new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)):t===`year`?new Date(Date.UTC(e.getUTCFullYear(),0,1)):e:null}function createDateValidator(e,t=m){let n=t.invalidDate(e),r=floorToPrecision(resolveBound(e.minDate),e.precision),i=resolveBound(e.maxDate),a=s.any().superRefine((e,t)=>{let a=new Date(e);Number.isNaN(a.getTime())?t.addIssue({code:`custom`,message:n}):(r&&a<r&&t.addIssue({code:`custom`,message:n}),i&&a>i&&t.addIssue({code:`custom`,message:n}))});if(!e.endDate)return a;let o=s.object({start:a,end:a.nullable()}).superRefine((e,t)=>{if(e.end===null)return;let r=new Date(e.start),i=new Date(e.end);!(Number.isNaN(r.getTime())||Number.isNaN(i.getTime()))&&i<r&&t.addIssue({code:`custom`,message:n,path:[`end`]})});return s.preprocess(e=>typeof e==`string`?{start:e,end:null}:e,o)}function isNullishOrEmptyString(e){return e==null||e===``}function isValuePresent(e){return e==null?!1:typeof e==`string`?e.trim()!==``:!Array.isArray(e)||e.length>0}const h={phone:[`countryCode`]};function isEmptyValue(e,t=[]){return e==null||typeof e==`string`&&e.trim()===``?!0:e instanceof Date?!1:typeof e==`object`&&!Array.isArray(e)&&Object.entries(e).filter(([e])=>!t.includes(e)).every(([,e])=>e==null||typeof e==`string`&&e.trim()===``)}function withEmptyToNull(e,t){return s.preprocess(e=>isEmptyValue(e,t)?null:e,e.nullish())}const g=s.object({placeholder:s.string().optional(),description:s.string().optional(),defaultValue:s.unknown().optional(),icon:s.string().optional(),order:s.number().int().optional(),hidden:s.boolean().optional(),archived:s.boolean().optional(),deprecated:s.boolean().optional(),metadata:s.record(s.string(),s.unknown()).optional()}),_=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`],v={icon:r.optional().describe(`Field icon from search_icons`)},y={date:[`precision`],user:[`notifiesOnAssign`,`actors`]};function wireOmittedConfigKeysFor(e){return[..._,...y[e]??[]]}function wireHiddenTypeConfigMask(e){return Object.fromEntries((y[e]??[]).map(e=>[e,!0]))}function refuseForeignKeys(e,t,n=[]){let r=new Set(n);return function refuse(n,i,a,o=[]){let s=e[n];if(s!==void 0&&i!==void 0)for(let e of Object.keys(i))s.has(e)||r.has(e)||a.addIssue({code:`custom`,path:[...o,e],message:`"${e}" is not a ${n} ${t}; keys of ${n}: ${[...s].join(`, `)}`})}}const b=s.object({value:s.string().min(1).describe(`Stored value`),label:s.string().min(1).describe(`Label people see`),description:s.string().describe(`Extra context`).optional(),inverse:s.string().describe(`Paired option's value (symmetric)`).optional(),archived:s.boolean().describe(`Hides without deleting`).optional()}),x=s.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),S=b.extend({color:n}).strict(),C=b.extend({color:n,group:x}).strict(),w=b.extend({color:s.string().optional().describe(`A color id`),group:x.optional()}).strict(),T=new Set(w.keyof().options),te=[`options`,`targetAttributeOptions`];function withoutUnknownOptionKeys(e){let t=e;for(let n of te){let r=e[n];if(!Array.isArray(r))continue;let a=!1,o=r.map(e=>!i(e)||Object.keys(e).every(e=>T.has(e))?e:(a=!0,Object.fromEntries(Object.entries(e).filter(([e])=>T.has(e)))));a&&(t={...t,[n]:o})}let n=e.properties;if(i(n)&&Array.isArray(n.definitions)){let e=n.definitions,r=e.map(e=>i(e)?withoutUnknownOptionKeys(e):e);r.some((t,n)=>t!==e[n])&&(t={...t,properties:{...n,definitions:r}})}return t}const E=s.array(w).min(1).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`});function writeOptionsArraySchema(e){return s.array(e).min(1).max(t.optionsPerAttribute).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`})}const D=writeOptionsArraySchema(S),O=writeOptionsArraySchema(S),k=writeOptionsArraySchema(C),ne=s.object({object:s.string().min(1).describe(`Target object`),displayTemplate:s.string().optional().describe(`Linked record label template`),filter:s.record(s.string(),s.unknown()).optional().describe(`Restricts linkable records`)}),A=s.object({object:s.string().min(1).describe(`Other side's object`),attribute:s.string().min(1).describe(`Other side's attribute`),cardinality:s.enum([`one`,`many`]).optional().describe(`Other side's cardinality`),label:s.string().min(1).optional().describe(`Other side's label`),storageOwner:s.boolean().optional().describe(`Owns the join storage`)}),j=s.object({objectName:s.string().min(1).describe(`API name of the object whose options are mirrored`),attributeName:s.string().min(1).describe(`API name of the select/status attribute to mirror options from`),attributeId:s.string().optional().describe(`Id of the source attribute, resolved by the server`)}),M=g.extend({multiline:s.boolean().describe(`Renders as a multi-line textarea`).optional(),minLength:s.number().int().min(0).describe(`Minimum character count`).optional(),maxLength:s.number().int().min(1).describe(`Maximum character count`).optional(),pattern:s.string().describe(`Regular expression the value must match`).optional(),format:s.enum([`email`,`url`,`slug`]).describe(`Validates and renders as this format`).optional()}),re=g,N=g.extend({renderAs:s.enum([`number`,`rating`]).describe(`Plain number or a star rating`).optional(),min:s.number().describe(`Minimum allowed value`).optional(),max:s.number().describe(`Maximum allowed value`).optional(),unit:s.enum([`integer`,`decimal`,`percentage`]).describe(`How the value is stored and rendered`).optional(),decimals:s.number().int().min(0).max(10).describe(`Decimal places shown`).optional()}),P=g,F=g.extend({dateFormat:s.enum([`short`,`long`,`full`,`relative`]).describe(`How the date is rendered`).optional(),precision:s.enum([`day`,`month`,`year`]).describe(`Whether the value records a day, a month or a year`).optional(),minDate:s.string().describe(`Earliest allowed date (ISO)`).optional(),maxDate:s.string().describe(`Latest allowed date (ISO)`).optional(),includeTime:s.boolean().describe(`Also captures a time of day`).optional(),endDate:s.boolean().describe(`Paired with another date attribute as a range's end`).optional(),timeFormat:s.enum([`12h`,`24h`]).describe(`Clock format when a time is included`).optional()}),I=g.extend({defaultCountryCode:s.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),L=g.extend({defaultCurrency:s.string().length(3).describe(`ISO currency code preselected for new values`).optional(),allowedCurrencies:s.array(s.string().length(3)).describe(`ISO currency codes a value may use; any currency when omitted`).optional(),allowNegative:s.boolean().describe(`Whether a negative amount is accepted`).optional()}),R=g.extend({options:E.describe(`The workflow statuses, in order`)}),z=g.extend({granularity:s.enum([`full`,`address`,`city`,`state`,`country`,`coordinates`]).describe(`How precise a location must be captured`).optional(),defaultCountry:s.string().length(3).describe(`ISO country code preselected for new values`).optional(),allowedCountries:s.array(s.string().length(3)).describe(`ISO country codes a value may use; any country when omitted`).optional()}),B=g.extend({options:E.describe(`Options`),renderAs:s.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),V=g.extend({options:E.describe(`Options`),renderAs:s.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),ie=g.extend({types:s.array(s.enum([`user`,`agent`])).min(1).optional().describe(`Which kinds of actor can be picked; both when omitted`),multiple:s.boolean().optional().describe(`Whether more than one actor can be picked`),notifiesOnAssign:s.boolean().optional().describe(`Whether each person added to the value is notified`),actors:s.boolean().optional().describe(`Whether the value holds actor ids, named by each actor's current name`)}),H={name:e.describe(`Property API name`),label:s.string().min(1).describe(`Label people see`),required:s.boolean().describe(`Required on every edge`).optional()},ae={id:s.string().optional(),objectId:s.string().optional(),system:s.boolean().optional(),unique:s.boolean().optional()},oe=Object.fromEntries(_.map(e=>[e,!0])),U=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],W=[...U,`select`,`multiselect`,`status`],G={text:M,number:N,checkbox:P,date:F,phone:I,currency:L,location:z,select:B,multiselect:V,status:R},K={...G,select:B.extend({options:D.describe(`Options`)}),multiselect:V.extend({options:O.describe(`Options`)}),status:R.extend({options:k.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>K[e].omit(oe).omit(wireHiddenTypeConfigMask(e)).shape,storedPropertyMember=e=>s.object({...H,...ae,type:s.literal(e).describe(`Property type`),...G[e].shape}).strip(),q=s.discriminatedUnion(`type`,W.map(storedPropertyMember)),J=s.object({definitions:s.array(q).min(1).max(t.optionsPerAttribute).describe(`Edge properties`)}).strip().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),se=refuseForeignKeys(Object.fromEntries(W.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(H),`type`]);function refuseForeignPropertyKeys(e,t){se(e.type,e,t)}const ce=U.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>s.object({...H,type:e.length===1?s.literal(e[0]).describe(`Property type`):s.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),Y=s.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),s.object({...H,type:s.enum(U).describe(`Property type`),...ce}).strict().superRefine(refuseForeignPropertyKeys)]),le=s.object({definitions:s.array(Y).min(1).max(t.optionsPerAttribute).describe(`Edge properties`)}).strict().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),X=g.extend({targets:s.array(ne).min(1).describe(`Target object(s)`),cardinality:s.enum([`one`,`many`]).describe(`one or many`),maxItems:s.number().int().min(1).optional().describe(`Max linked records`),bilateral:A.optional().describe(`Syncs the other side's attribute`),properties:J.optional()}),ue=g.extend({expression:s.string().min(1).describe(`The formula expression, compiled against this object's attributes`),returnType:s.enum(f).describe(`The formula's result type`),decimals:s.number().int().min(0).max(10).optional().describe(`Decimal places shown for a number result`),currencyCode:s.string().length(3).optional().describe(`ISO 4217 code a number result renders with; presentation only`),allowRelations:s.boolean().optional().describe(`Whether the expression may read across a relation`),optionsSource:j.optional().describe(`Mirrors an option set`)}),de=g.extend({relationAttribute:s.string().min(1).optional().describe(`API name of the relation this rollup aggregates through`),relationPath:s.string().optional().describe(`Not supported yet — single-hop only`),targetAttribute:s.string().min(1).optional().describe(`API name of the attribute aggregated on the relation's target object; not read by count`),function:s.enum([`sum`,`avg`,`earliest`,`latest`,`count`,`countValues`,`countUniqueValues`,`countEmpty`,`percentEmpty`,`percentNotEmpty`,`original`]).describe(`The aggregation applied across the linked records`),decimals:s.number().int().min(0).max(10).optional().describe(`Decimal places shown for a numeric result`),targetAttributeType:s.string().optional().describe(`Server-set`),targetAttributeOptions:s.array(w).optional().describe(`Server-set`),targetCurrencyCode:s.string().length(3).optional().describe(`Server-set`),optionsSource:j.optional().describe(`Mirrors an option set`)});function rollupTargetIssue(e,t){if(e===`rollup`&&t.function!==`count`&&t.targetAttribute===void 0)return{path:[`targetAttribute`],message:`targetAttribute is required for a "${String(t.function)}" rollup`}}function datePrecisionIssues(e,t,n=[]){let r=[],a=t.precision;if(e===`date`&&a!==void 0&&a!==`day`)for(let e of[`includeTime`,`endDate`])t[e]===!0&&r.push({path:[...n,`precision`],message:`A "${String(a)}" precision cannot be combined with ${e}`});let o=t.properties;return i(o)&&Array.isArray(o.definitions)&&o.definitions.forEach((e,t)=>{i(e)&&r.push(...datePrecisionIssues(String(e.type),e,[...n,`properties`,`definitions`,t]))}),r}const Z={text:M,richtext:re,number:N,checkbox:P,date:F,phone:I,currency:L,status:R,location:z,select:B,multiselect:V,user:ie,relation:X,formula:ue,rollup:de,document:g.extend({properties:J.optional(),accepts:s.array(s.string().min(1)).optional().describe("MIME prefixes or globs a file must match (e.g. `image/*`, `*.pdf`)"),maxFileSize:s.number().int().min(1).optional().describe(`Maximum file size in bytes`)})};function getAttributeConfigSchema(e){let t=Z[e];if(!t)throw new o(`Unsupported attribute type: ${e}`,[]);return t}function parseAttributeConfig(e,t){let n=getAttributeConfigSchema(e).strip().parse(t),r=rollupTargetIssue(e,n);if(r)throw validationErrorFromIssues([r]);return n}function getAttributeConfigWriteSchema(e){let t=getAttributeConfigSchema(e).extend({icon:r.optional()});switch(e){case`select`:return t.extend({options:D.describe(`Options`)});case`multiselect`:return t.extend({options:O.describe(`Options`)});case`status`:return t.extend({options:k.describe(`Statuses`)});default:return t}}function validationErrorFromIssues(e){return o.fromZodErrors(e.map(e=>({path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message})))}function parseWriteSchema(e,t){let n=getAttributeConfigWriteSchema(e).strip().safeParse(t);if(!n.success)throw validationErrorFromIssues(n.error.issues);let r=rollupTargetIssue(e,n.data);if(r)throw validationErrorFromIssues([r]);let i=datePrecisionIssues(e,n.data);if(i.length>0)throw validationErrorFromIssues(i);return n.data}function parseAttributeConfigForCreate(e,t){return parseWriteSchema(e,t)}function validatePatchedIcon(e){if(!Object.prototype.hasOwnProperty.call(e,`icon`))return;let t=r.optional().safeParse(e.icon);if(!t.success)throw o.fromZodErrors(t.error.issues.map(e=>({path:[`icon`,...e.path.map(e=>typeof e==`symbol`?String(e):e)],message:e.message})))}function parseAttributeConfigForUpdate(e,t){let n=Object.prototype.hasOwnProperty.call(t,`options`),r=Object.prototype.hasOwnProperty.call(t,`icon`),i={...e,...t};if(validatePatchedIcon(t),n){let{icon:t,...n}=i,a=parseWriteSchema(e.type,r?i:n);return!r&&t!==void 0&&(a.icon=t),a}let o=e.options;a(e.type,`options`)&&(i.options=[{value:`__legacy__`,label:`__legacy__`}]);let s=getAttributeConfigSchema(e.type).strip().safeParse(i);if(!s.success)throw validationErrorFromIssues(s.error.issues);let c=s.data,l=datePrecisionIssues(e.type,c);if(l.length>0)throw validationErrorFromIssues(l);return a(e.type,`options`)&&(c.options=o),c}function createCurrencyValidator(e,t=m){let n=e.allowNegative?s.number():s.number().min(0);return s.object({code:s.string().length(3),value:n},{message:t.invalidCurrency(e)})}function createLocationValidator(e,t=m){return s.object({address:s.string().optional(),address2:s.string().optional(),city:s.string().optional(),state:s.string().optional(),postalCode:s.string().optional(),country:s.string().length(3).optional(),latitude:s.number().min(-90).max(90).optional(),longitude:s.number().min(-180).max(180).optional()},{message:t.invalidLocation(e)})}function digitsOnly(e){return e.replace(/\D/g,``)}function normalizeCountrylessPhoneNumber(e){return digitsOnly(e)}function getIso2(e){return c(e)?.iso2}function normalizePhoneNumber(e,t){if(!e)return``;let n=getIso2(t);if(!n)return digitsOnly(e);let r=d(e,n);if(r)return absorbDoubledCallingCode(r.nationalNumber,r.isValid(),t,n);let i=c(t),a=digitsOnly(e);if(i){let e=i.phoneCode.replace(`+`,``),t=a.startsWith(e)?a.slice(e.length):a;return u(t,i.phoneTrunkPrefix??``)}return a}function absorbDoubledCallingCode(e,t,n,r){if(t)return e;let i=c(n)?.phoneCode.replace(`+`,``);if(i===void 0||!e.startsWith(i))return e;let a=e.slice(i.length),o=d(`+${i}${a}`,r);return o?.isValid()?o.nationalNumber:e}function formatPhoneForDisplay(e){if(!e.phoneNumber)return``;let t=getIso2(e.countryCode),n=c(e.countryCode)?.phoneCode??``;if(!t)return`${n} ${e.phoneNumber}`.trim();let r=`${n}${digitsOnly(e.phoneNumber)}`,i=d(r);return i?i.formatInternational():`${n} ${e.phoneNumber}`.trim()}function createPhoneValidator(e,t=m){return s.object({countryCode:s.string().length(3),phoneNumber:s.string().min(1,{message:t.required(e)})},{message:t.invalidPhone(e)}).refine(e=>l(e.countryCode),{message:`Invalid country code`}).transform(e=>({countryCode:e.countryCode,phoneNumber:normalizePhoneNumber(e.phoneNumber,e.countryCode)}))}function extractRelationId(e){return typeof e==`object`&&e&&`id`in e?e.id:e}function createSingleRelationValidator(e,t=m){let n=s.guid({message:t.invalidId(e)}),r=s.union([n,s.null()]);return s.union([r,s.object({id:n,props:s.record(s.string(),s.unknown()).optional()}).passthrough()])}function createMultiRelationValidator(e,t=m){let n=s.guid({message:t.invalidId(e)}),r=s.union([n,s.object({id:n,props:s.record(s.string(),s.unknown()).optional()}).passthrough()]),i=s.array(r);return e.maxItems!==void 0&&(i=i.max(e.maxItems,t.maxItems(e,e.maxItems))),i.refine(e=>e.every(e=>{let t=extractRelationId(e);return typeof t==`string`&&n.safeParse(t).success}),{message:t.invalidId(e)})}function createRelationValidator(e,t=m){return e.cardinality===`many`?createMultiRelationValidator(e,t):createSingleRelationValidator(e,t)}function createRichtextValidator(e,t=m){return s.string({message:t.invalidRichtext(e)})}function describeOptions(e){return e.map(e=>e.label===e.value?e.value:`${e.value} (${e.label})`)}function createSelectValidator(e,t=m){let n=e.options.map(e=>e.value);return n.length===0?s.never():s.enum(n,{message:t.invalidOption(e,describeOptions(e.options))})}function createMultiselectValidator(e,t=m){let n=e.options.map(e=>e.value);return n.length===0?s.never():s.array(s.enum(n,{message:t.invalidOption(e,describeOptions(e.options))}))}function createStatusValidator(e,t=m){let n=e.options.map(e=>e.value);return n.length===0?s.never():s.enum(n,{message:t.invalidOption(e,describeOptions(e.options))})}function createUserValidator(e,t=m){let n=s.guid({message:t.invalidId(e)});return e.multiple?s.array(n):n}function createFormulaValidator(e,t=m){return s.unknown()}function createRollupValidator(e,t=m){return s.unknown()}function createAttributeValidator(e,t=m){switch(e.type){case`text`:return createTextValidator(e,t);case`richtext`:return createRichtextValidator(e,t);case`number`:return createNumberValidator(e,t);case`checkbox`:return createCheckboxValidator(e,t);case`date`:return createDateValidator(e,t);case`phone`:return createPhoneValidator(e,t);case`currency`:return createCurrencyValidator(e,t);case`status`:return createStatusValidator(e,t);case`location`:return createLocationValidator(e,t);case`select`:return createSelectValidator(e,t);case`multiselect`:return createMultiselectValidator(e,t);case`user`:return createUserValidator(e,t);case`relation`:return createRelationValidator(e,t);case`formula`:return createFormulaValidator(e,t);case`rollup`:return createRollupValidator(e,t);default:return s.unknown()}}function createFormAttributeValidator(e,t=m){let n=createAttributeValidator(e,t);return e.required?n:withEmptyToNull(n,h[e.type])}const Q=/* @__PURE__ */ new WeakMap,$=/* @__PURE__ */ new WeakMap;function createObjectValidator(e){let t=Q.get(e);if(t)return t;let n={};for(let t of e.attributes){let e=createAttributeValidator(t);t.required?n[t.name]=e.refine(isValuePresent,{message:m.required(t)}):n[t.name]=withEmptyToNull(e,h[t.type])}let r=s.object(n).passthrough();return Q.set(e,r),r}function createDraftValidator(e){let t=$.get(e);if(t)return t;let n={};for(let t of e.attributes){let e=createAttributeValidator(t);n[t.name]=withEmptyToNull(e,h[t.type])}let r=s.object(n).passthrough();return $.set(e,r),r}function validateAttribute(e,t){let n=createAttributeValidator(e);if(!e.required&&t==null)return{success:!0,data:{[e.name]:t}};let r=n.safeParse(t);return r.success?{success:!0,data:{[e.name]:r.data}}:{success:!1,errors:formatZodErrors(r.error).map(t=>({path:[e.name,...t.path],message:t.message}))}}function validateObject(e,t){let n=createObjectValidator(e).safeParse(t);return n.success?{success:!0,data:n.data}:{success:!1,errors:formatZodErrors(n.error)}}function validateObjectOrThrow(e,t){let n=validateObject(e,t);if(!n.success){let t=n.errors??[],r=t.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
3
- `)||`Unknown validation error`;throw new o(`Validation failed for ${e.label}:\n${r}`,t.map(e=>({path:e.path,message:e.message})))}return n.data}function validateDraft(e,t){let n=createDraftValidator(e).safeParse(t);return n.success?{success:!0,data:n.data}:{success:!1,errors:formatZodErrors(n.error)}}function validateDraftOrThrow(e,t){let n=validateDraft(e,t);if(!n.success){let t=n.errors??[],r=t.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
4
- `)||`Unknown validation error`;throw new o(`Draft validation failed for ${e.label}:\n${r}`,t.map(e=>({path:e.path,message:e.message})))}return n.data}function rejectUnknownAttributesOrThrow(e,t){let n=new Set(e.attributes.map(e=>e.name)),r=Object.keys(t).filter(e=>!n.has(e));if(r.length>0)throw new o(`Unknown attribute${r.length>1?`s`:``} for ${e.label}: ${r.join(`, `)}`,r.map(e=>({path:[e],message:`Unknown attribute`})))}export{f as COMPUTED_RETURN_TYPES,m as DEFAULT_VALIDATION_MESSAGES,U as SIMPLE_PROPERTY_TYPES,p as TEXT_FORMAT_PATTERNS,v as WIRE_OFFERED_BASE_CONFIG,_ as WIRE_OMITTED_CONFIG_KEYS,Z as attributeConfigSchemas,createAttributeValidator,createFormAttributeValidator,createObjectValidator,datePrecisionIssues,formatPhoneForDisplay,formatZodErrors,getAttributeConfigSchema,getAttributeConfigWriteSchema,getIso2,isEmptyValue,isNullishOrEmptyString,isValuePresent,normalizeCountrylessPhoneNumber,normalizePhoneNumber,parseAttributeConfig,parseAttributeConfigForCreate,parseAttributeConfigForUpdate,q as propertyAttributeSchema,Y as propertyAttributeWireSchema,J as propertySchemaSchema,le as propertySchemaWireSchema,refuseForeignKeys,rejectUnknownAttributesOrThrow,resolveTextPattern,S as selectOptionWriteSchema,x as statusGroupSchema,C as statusOptionWriteSchema,validateAttribute,validateDraft,validateDraftOrThrow,validateObject,validateObjectOrThrow,wireHiddenTypeConfigMask,wireOmittedConfigKeysFor,withoutUnknownOptionKeys};
@@ -1,11 +0,0 @@
1
- /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- import"./zod-locale.mjs";import{DuplicateError as e,SchemaError as t,SchemaErrorCode as n,ValidationError as r}from"./exceptions.mjs";import*as i from"zod";import{COLORS as a,ICONS as o}from"@standards/constants";const s=i.codec(i.iso.datetime({offset:!0}),i.date(),{decode:e=>new Date(e),encode:e=>e.toISOString()});function brandedString(){return i.string()}function outputSchemaOf(e){return`_zod`in e.output?e.output:void 0}function decodeOperationOutput(e,t){let n=outputSchemaOf(e);if(n===void 0)return t;let r=i.safeDecode(n,t);return r.success?r.data:t}function unchecked(){return i.custom()}const c=[`question`,`approval`,`review`,`handoff`,`report`,`fyi`],l=[`unread`,`read`,`archived`],u=[`none`,`pending`,`completed`,`dismissed`,`expired`],d=[`open`,`snoozed`,`closed`,`answered`,`withdrawn`,`expired`,`unread`,`read`,`archived`],f=[`record`,`session`,`document`,`agent`,`routine`,`page`,`email_thread`,`url`],p=i.object({targetType:i.enum(f),targetId:i.string(),objectName:i.string().optional(),label:i.string().optional()});function formatDecisionLink(e){return e.targetType===`record`?`record:${e.objectName??``}:${e.targetId}`:`${e.targetType}:${e.targetId}`}function parseDecisionLink(e){let[t,...n]=e.split(`:`);if(!f.includes(t??``))return null;let r=t;if(r===`record`){let[e,t]=n;return n.length===2&&e&&t?{targetType:r,targetId:t,objectName:e}:null}let i=n.join(`:`);return i?{targetType:r,targetId:i}:null}function decisionThreadKey(e){return`decision:${e}`}const ee=120,m=200,h=`agent.question`,g=`agent.approval`,_=`agent.review`,v=`agent.setup`,y=`agent.routine_run.failed`,b=`agent.message`,x=`connector.connection.reauth_required`,S=`connector.connection.error`,C=`connector.connection.send_not_granted`,w=`record.assigned`,te=`record.mentioned`,ne=`access.granted`,re=`environment.build.failed`,ie=`person.decision`,ae=`bundle.setup`,oe=[h,g,_,v,y,b,x,S,C,w,te,ne,re,ie,ae],se=[`question`,`approval`,`review`,`handoff`];function isActionableDecisionKind(e){return se.includes(e)}const ce=[`agents`,`connectors`,`assignment`,`mentions`,`sharing`],le={[h]:{kind:`question`,area:null},[g]:{kind:`approval`,area:null},[_]:{kind:`review`,area:null},[v]:{kind:`handoff`,area:null},[y]:{kind:`question`,area:`agents`},[b]:{kind:`report`,area:`agents`},[x]:{kind:`handoff`,area:`connectors`},[S]:{kind:`handoff`,area:`connectors`},[C]:{kind:`handoff`,area:`connectors`},[w]:{kind:`fyi`,area:`assignment`},[te]:{kind:`fyi`,area:`mentions`},[ne]:{kind:`fyi`,area:`sharing`},[re]:{kind:`fyi`,area:`agents`},[ie]:{kind:`question`,area:null},[ae]:{kind:`handoff`,area:null}},ue=[`person`,`agent`,`system`],de=i.object({actorId:i.string(),kind:i.enum(ue),label:i.string()}),fe=i.object({id:i.string(),tenantId:i.string(),senderActorId:i.string().optional(),rootActorId:i.string().optional(),triggeredByActorId:i.string().optional(),kind:i.enum(c),type:i.string(),title:i.string(),summary:i.string().optional(),questions:unchecked().optional(),answer:unchecked().optional(),answeredBy:i.string().optional(),effect:i.string().optional(),links:i.array(p),sender:de.optional(),recipientActorIds:i.array(i.string()).optional(),payload:i.record(i.string(),i.unknown()),threadKey:i.string(),idempotencyKey:i.string().optional(),createdAt:s,updatedAt:s}),pe=i.object({documentId:i.string(),fileId:i.string(),name:i.string(),mimeType:i.string(),size:i.number(),url:i.string()}),me=i.object({id:i.string(),tenantId:i.string(),decisionId:i.string(),recipientActorId:i.string(),inboxState:i.enum(l),workState:i.enum(u),readAt:s.optional(),archivedAt:s.optional(),snoozedUntil:s.optional(),completedAt:s.optional(),dismissedAt:s.optional(),createdAt:s,updatedAt:s}),he=`transfers`;function isDecisionTransfer(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.fromActorId==`string`&&typeof t.toActorId==`string`&&typeof t.toLabel==`string`&&typeof t.at==`string`}function decisionTransfersOf(e){let t=e.payload[he];return Array.isArray(t)?t.filter(isDecisionTransfer):[]}function decisionTransferBy(e,t){return decisionTransfersOf(e).filter(e=>e.fromActorId===t).at(-1)}function decisionTransferTo(e,t){return decisionTransfersOf(e).filter(e=>e.toActorId===t).at(-1)}function decisionHandedBy(e,t){return decisionTransferTo(e,t)?.fromActorId}const ge=i.object({decision:fe,recipient:me,testLink:i.object({link:unchecked(),canOpen:i.boolean()}).optional()}),_e=i.object({items:i.array(ge),nextCursor:i.string().optional()}),ve=[`open`,`answered`,`withdrawn`,`expired`,`info`],ye=i.object({open:i.number(),unread:i.number()}),be=i.object({archivedCount:i.number()}),xe=i.object({to:i.array(i.string()).nullable()}),Se={createdAt:`createdAt`,updatedAt:`updatedAt`,createdBy:`createdBy`,lastUpdatedBy:`lastUpdatedBy`,attachments:`attachments`,parentId:`parentId`,childIds:`childIds`};function getSystemAttributeI18nKey(e){return Se[e]}const Ce={createdAt:{id:`system:createdAt`,name:`createdAt`,label:`Created time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was created`},updatedAt:{id:`system:updatedAt`,name:`updatedAt`,label:`Last edited time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was last modified`},createdBy:{id:`system:createdBy`,name:`createdBy`,label:`Created by`,type:`user`,required:!1,system:!0,multiple:!1,actors:!0,icon:`user`,description:`Actor who created this record`},lastUpdatedBy:{id:`system:lastUpdatedBy`,name:`lastUpdatedBy`,label:`Last edited by`,type:`user`,required:!1,system:!0,multiple:!1,actors:!0,icon:`user`,description:`Actor who last modified this record`},attachments:{id:`system:attachments`,name:`attachments`,label:`Attachments`,type:`document`,required:!1,system:!0,hidden:!0,icon:`paperclip`,description:`Free-form document attachments`}};function getSystemAttributeList(){return Object.values(Ce)}function isManagedSystemAttribute(e){return e.id?.startsWith(`system:`)??!1}const T=[`hierarchy:parentId`,`hierarchy:childIds`],we=/* @__PURE__ */ new Set([`parentId`,`childIds`]),Te=6;function getHierarchyAttributes(e){if(!e.hierarchical)return[];let t=[{object:e.name}];return[{id:T[0],name:`parentId`,label:`Parent`,type:`relation`,cardinality:`one`,targets:t,required:!1,system:!0,icon:`corner-left-up`,description:`The record this one sits under`},{id:T[1],name:`childIds`,label:`Sub-items`,type:`relation`,cardinality:`many`,targets:t,required:!1,system:!0,icon:`corner-down-right`,description:`The records that sit under this one`}]}function isHierarchyAttribute(e){return e.id?.startsWith(`hierarchy:`)??!1}function getObjectSystemAttributes(e){return[...getSystemAttributeList(),...getHierarchyAttributes(e)]}const Ee=[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`],De=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_empty`,`is_not_empty`],Oe=[`is`],ke=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`is_empty`,`is_not_empty`],Ae=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],je=[`any_of`,`none_of`,`is_empty`,`is_not_empty`],Me=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],Ne=[`is_empty`,`is_not_empty`],Pe=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`contains`,`not_contains`,`is_empty`,`is_not_empty`],E=[`city`,`postalCode`,`country`];function isLocationFilterProperty(e){return E.includes(e)}const D={text:Ee,richtext:[],number:De,checkbox:Oe,date:ke,phone:[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`is_empty`,`is_not_empty`],currency:De,status:Ae,select:Ae,multiselect:je,location:[],user:Me,relation:Me,formula:Pe,document:Ne},O={text:{value:`plain`,traits:[`placeholder`,`searchable`,`sortable`]},richtext:{value:`plain`,traits:[`searchable`,`content`]},number:{value:`plain`,traits:[`placeholder`,`sortable`]},checkbox:{value:`boolean`,traits:[`sortable`]},date:{value:`plain`,traits:[`placeholder`,`sortable`]},phone:{value:`plain`,traits:[`placeholder`,`searchable`,`sortable`]},currency:{value:`plain`,traits:[`placeholder`,`sortable`,`groupable`]},status:{value:`options`,traits:[`searchable`,`sortable`,`groupable`]},location:{value:`plain`,traits:[]},select:{value:`options`,traits:[`placeholder`,`searchable`,`sortable`]},multiselect:{value:`options`,traits:[`placeholder`,`searchable`]},user:{value:`reference`,traits:[]},relation:{value:`reference`,traits:[`qualified`]},formula:{value:`computed`,traits:[]},rollup:{value:`computed`,traits:[]},document:{value:`reference`,traits:[`content`,`qualified`]}};function descriptorOf(e){return Object.prototype.hasOwnProperty.call(O,e)?O[e]:void 0}function isValueKindType(e,t){return descriptorOf(e)?.value===t}function hasValueKind(e,t){return isValueKindType(e.type,t)}function hasTypeTrait(e,t){return descriptorOf(e)?.traits.includes(t)??!1}const Fe={plain:`static`,boolean:`automatic`,options:`static`,reference:`static`,computed:`forbidden`};function getAttributeCapabilities(e){let t=!!(e.hidden||e.archived),n=!e.archived,r=descriptorOf(e.type)?.value,i=r===`computed`,a=e.type===`document`,o=r===`reference`&&!isHierarchyAttribute(e),s=getAttributeCardinality(e),c=t?[]:getRawFilterOperators(e),l=c.length>0&&!t,u=!t&&hasTypeTrait(e.type,`searchable`),d=!t&&hasTypeTrait(e.type,`sortable`),f=!t&&hasTypeTrait(e.type,`groupable`),p=!t&&(e.type===`status`||e.type===`select`),ee=isManagedSystemAttribute(e),m=i||a||ee,h=!(t||m),g=r===void 0?`forbidden`:Fe[r],_=r===`boolean`||i?`forbidden`:`allowed`,v=supportsMaxItems(e),y=hasTypeTrait(e.type,`placeholder`),b=hasTypeTrait(e.type,`content`),x=!(!e.deprecated||t),S=resolveEditMode(e);return{lifecycle:{active:n,deprecated:!!e.deprecated,visibleInArchitect:!0,visibleInRuntime:!t,warningWhenDeprecated:x},storage:{mode:i?`computed`:o?`edge`:`value`,cardinality:s,edgeBacked:o,preservesExistingValues:!!e.archived,qualifiedProperties:hasTypeTrait(e.type,`qualified`),polymorphic:getPolymorphicCapability(e),maxItems:v},authoring:{editable:h,readOnly:m,directEdit:h&&S===`inline`,required:_,defaultValue:g,placeholder:y,maxItems:v},presentation:{formField:!t&&e.type!==`richtext`,tableCell:!(t||b),defaultColumn:!(t||b),compactDisplay:!t,popoverEditor:!t&&S===`popover`,placeholder:y,warningWhenDeprecated:x},query:{filterable:l,searchable:u,sortable:d,groupable:f,kanbanGroupable:p,operators:c},agent:{readable:!t,writable:h&&!a,compactReadable:!t,contentReadable:!t&&b,requiresDedicatedTool:a},exchange:{importable:!t,exportable:!t,schemaExportable:!0,metadataExportable:!1}}}function getAttributeFilterOperators(e){return getAttributeCapabilities(e).query.operators}function isAttributeFilterable(e){return getAttributeCapabilities(e).query.filterable}function isAttributeSearchable(e){return getAttributeCapabilities(e).query.searchable}function isAttributeSortable$1(e){return getAttributeCapabilities(e).query.sortable}function isAttributeGroupable(e){return getAttributeCapabilities(e).query.groupable}function isAttributeKanbanGroupable(e){return getAttributeCapabilities(e).query.kanbanGroupable}function resolveEffectiveFilterType(e){if(e.type!==`rollup`)return e.type;let t=e;if(t.function===`earliest`||t.function===`latest`)return`date`;if(t.function===`original`){let e=t.targetAttributeType;if(e&&hasFilterOperatorEntry(e))return e}return`number`}function getRollupFilterOperators$1(e){let t=resolveEffectiveFilterType(e);return hasFilterOperatorEntry(t)?D[t]:D.number}function getRawFilterOperators(e){return e.type===`rollup`?getRollupFilterOperators$1(e):D[e.type]??[]}function getAttributeCardinality(e){return e.type===`multiselect`||e.type===`document`||e.type===`user`&&e.multiple===!0||e.type===`relation`&&e.cardinality===`many`?`many`:`one`}function getPolymorphicCapability(e){if(e.type!==`relation`)return`none`;let t=e.targets??[];return t.length===1&&t[0]?.object===`*`?`internal`:t.length>1?`code-only`:`none`}function supportsMaxItems(e){return e.type===`multiselect`||e.type===`relation`&&e.cardinality===`many`}function resolveEditMode(e){switch(e.type){case`checkbox`:return`inline`;case`number`:return e.renderAs===`rating`?`inline`:`default`;case`select`:case`multiselect`:return e.renderAs===`badges`?`inline`:`popover`;case`status`:case`relation`:case`user`:case`date`:return`popover`;default:return`default`}}function hasFilterOperatorEntry(e){return Object.prototype.hasOwnProperty.call(D,e)}const Ie=[`text`,`richtext`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`location`,`select`,`multiselect`,`user`,`relation`,`formula`,`rollup`,`document`],Le=`*`;function relationTargetsOf(e){return e.type!==`relation`||!Array.isArray(e.targets)?[]:e.targets.map(e=>e.object).filter(e=>e!==`*`)}function isUniversalRelation(e){return e.targets.length===1&&e.targets[0].object===`*`}function isBilateralRelation(e){return e.bilateral!==void 0}function inferInverseCardinality(e){return`many`}function isAttributeSortable(e){return isAttributeSortable$1(e)}const Re=D,ze=[`is_empty`,`is_not_empty`];function isNoValueOperator(e){return ze.includes(e)}function getRollupFilterOperators(e){return getRollupFilterOperators$1(e)}const k=[`skill`,`memory`,`drives`,`artifact`,`meeting`];function isNativeObjectName(e){return k.includes(e)}const A=[`workspace`,`private`],Be=[`all`,...A,`shared`],j=[...A,`shared`];function parseRecordListScope(e){if(typeof e==`string`&&j.includes(e))return e;throw new r(`visibility must be one of: ${j.join(`, `)} (received: ${String(e)})`,[])}function parseResourceVisibility(e){if(typeof e==`string`&&A.includes(e))return e;throw new r(`visibility must be one of: ${A.join(`, `)} (received: ${String(e)})`,[])}const Ve=[`id`,`createdAt`,`updatedAt`,`createdBy`,`lastUpdatedBy`,`visibility`,`ownedBy`],M=[...Ve,`objectId`,`label`,`embeddingText`,`values`,`metadata`,`deletedAt`,`deletedBy`,`schemaVersion`,`appearance`,`owned_by`,`parentId`,`childIds`],He=k,N={attributesPerObject:300,tabsPerView:24,membersPerGroup:4,pageRows:1e3,groupsPerFormTab:12,fieldsPerGroup:60,fieldsPerFormTab:150,columnsPerTab:50,displayAttributesPerCard:8,optionsPerAttribute:200,sidePanelAttributes:100,sidePanelPanes:20,filterRulesPerTab:50,sortsPerTab:20,emailAttributesPerTab:30,objectsPerPlan:20,mutationsPerPlan:500,planBytes:524288,historyDefault:20,historyMax:50,iconQueries:5,iconResults:20,labelLength:128},Ue=100,We=[`count`,`sum`,`cumulative`,`avg`,`min`,`max`],Ge=[`day`,`week`,`month`,`quarter`,`year`],Ke=Object.keys(a),qe=new Set(o),Je=i.enum(Ke).describe(`A color id from the palette`),P=i.string().superRefine((e,t)=>{qe.has(e)||t.addIssue({code:`custom`,message:`Invalid icon name`})}).transform(e=>e),F=[`page`,`record`,`display`];function defineBlock(e){let t=Object.fromEntries(Object.entries(e.inputs).map(([e,t])=>[e,t.isOptional?t.schema.optional():t.schema]));return Object.freeze({name:e.name,label:e.label,icon:e.icon,family:e.family,contexts:Object.freeze([...e.contexts]),inputs:Object.freeze({...e.inputs}),...e.layout===void 0?{}:{layout:Object.freeze({...e.layout})},parameters:i.object(t).strict().superRefine((t,n)=>{let r=e.refine?.(t);r&&n.addIssue({code:`custom`,path:[r.input],message:r.message})}),...e.refine===void 0?{}:{refine:(t,n)=>e.refine?.(t,n)}})}function parseBlockParameters(e,t,n){let i=e.parameters.safeParse(structuredClone(t??{}));if(!i.success)throw r.fromZodErrors(i.error.issues.map(e=>({path:[...n,...e.path.map(String)],message:e.message})));return i.data}function blockObjectInputs(e,t,n){return Object.entries(e.inputs).flatMap(([e,r])=>{let i=t[e];if(r.kind===`object`&&typeof i==`string`)return[i];if(r.kind===`query`&&typeof i==`object`&&i){let e=i.source;if(!e)return[];if(`object`in e&&typeof e.object==`string`)return[e.object];let t=n?.attributes.find(t=>t.name===e.relation);return t?relationTargetsOf(t):[]}return[]})}const Ye=/^\d{4}-\d{2}-\d{2}$/u;function isCalendarDay(e){if(!Ye.test(e))return!1;let t=/* @__PURE__ */ new Date(`${e}T00:00:00Z`);return!Number.isNaN(t.getTime())&&t.toISOString().slice(0,10)===e}function isDynamicValue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`dynamic`in e}function currentActor(){return{dynamic:`actor`,ref:`current`}}function today(){return{dynamic:`date`,anchor:`today`}}function now(){return{dynamic:`date`,anchor:`now`}}function toAmount(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function extractCurrencyFilterValue(e){return typeof e==`object`&&e?`value`in e?toAmount(e.value):null:toAmount(e)}function extractFilterValue(e){return e==null?null:typeof e==`object`&&`value`in e?e.value??null:e}const Xe=/* @__PURE__ */ new Set([`is_not`,`not_contains`,`none_of`,`is_empty`]),Ze={is_not:`is`,not_contains:`contains`,none_of:`any_of`,is_empty:`is_not_empty`};function getOperatorPolarity(e){return Xe.has(e)?`none`:`any`}function normalizeForEdgeRpc(e){return Ze[e]??e}const Qe={is:`any_of`,is_not:`none_of`};function toMultiValueOperator(e){return Qe[e]??e}const $e=new Set(Object.values(Qe).filter(e=>e!==void 0));function isSetMembershipOperator(e){return $e.has(e)}function canonicalizeFilterValue(e,t){let n=e.value;if(isNoValueOperator(e.operator)||n==null||isDynamicValue(n))return;if(isSetMembershipOperator(e.operator)){Array.isArray(n)||(e.value=[n]);return}if(t!==`currency`)return;let i=extractCurrencyFilterValue(n);if(i!==null){e.value=i;return}if(!hasCurrencyAmount(n))return;let a=`Filter on a currency attribute expected a numeric amount, received ${JSON.stringify(n)}`;throw new r(a,[{path:[`value`],message:a}])}function hasCurrencyAmount(e){return typeof e!=`object`||`value`in e&&e.value!=null}const et=`__`;function parseQualifiedAttribute(e){let t=e.indexOf(`__`);return t<=0||t+2>=e.length?{kind:`scalar`,attribute:e}:{kind:`qualified`,root:e.slice(0,t),property:e.slice(t+2)}}function buildQualifiedAttribute(e,t){return`${e}__${t}`}const I=D.text,tt=[`is`,`is_not`,`is_empty`,`is_not_empty`],L=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],R={id:L,objectId:L,tenantId:L,label:D.text,createdAt:D.date,updatedAt:D.date,deletedAt:D.date,createdBy:D.user,lastUpdatedBy:D.user,parentId:L,childIds:[`is_empty`,`is_not_empty`]},nt=/* @__PURE__ */ new Set([`createdAt`,`updatedAt`,`deletedAt`]);function offeredOn(e,t){return nt.has(e)?t.filter(e=>e!==`on_day_month`):t}function fullyOffered(e,t,n,r){return{target:e,attribute:t,...r?{property:r}:{},operators:n,offered:n}}function attributeFilterTarget(e){let t=isHierarchyAttribute(e)?systemColumnFilterTarget(e.name):void 0;if(t)return t;let n=getAttributeFilterOperators(e);return{target:e.name,attribute:e.name,operators:n,offered:offeredOn(e.name,n)}}function locationPartFilterTarget(e,t){return{target:buildQualifiedAttribute(e,t),attribute:e,property:t,operators:I,offered:t===`country`?tt:I}}function edgePropertyFilterTarget(e,t){let n=hasOperatorEntry(t.type)?D[t.type]:[];return fullyOffered(buildQualifiedAttribute(e,t.name),e,n,t.name)}function hasOperatorEntry(e){return Object.prototype.hasOwnProperty.call(D,e)}const rt=[`is`,`is_not`,`is_empty`,`is_not_empty`];function isMetadataKeyPath(e){return e.startsWith(`metadata.`)?e.slice(9).split(`.`).every(e=>e.length>0):!1}function systemColumnFilterTarget(e){if(isMetadataKeyPath(e))return{target:e,attribute:e,operators:rt,offered:[]};let t=Object.prototype.hasOwnProperty.call(R,e)?R[e]:void 0;return t?{target:e,attribute:e,operators:t,offered:offeredOn(e,t)}:void 0}function filterOperatorsOfType(e){return isAttributeType(e)?getAttributeFilterOperators({type:e}):[]}function isAttributeType(e){return Ie.includes(e)}function isLocationPartOperator(e){return I.includes(e)}function carriesEdgeProperties(e){return hasTypeTrait(e.type,`qualified`)}function filterTargetsOf(e){let t=[];for(let n of e){if(n.type===`location`){for(let e of E)t.push(locationPartFilterTarget(n.name,e));continue}if(t.push(attributeFilterTarget(n)),!carriesEdgeProperties(n))continue;let e=n.properties?.definitions;for(let r of e??[])t.push(edgePropertyFilterTarget(n.name,r))}let n=new Set(e.map(e=>e.name));for(let e of Object.keys(R)){if(n.has(e))continue;let r=systemColumnFilterTarget(e);r&&t.push(r)}return t.filter(e=>e.operators.length>0)}const it={eq:`is`,equals:`is`,equal:`is`,"==":`is`,"=":`is`,neq:`is_not`,notEqual:`is_not`,isNot:`is_not`,"!=":`is_not`,"<>":`is_not`,lt:`less_than`,"<":`less_than`,gt:`greater_than`,">":`greater_than`,lte:`less_or_equal`,"<=":`less_or_equal`,gte:`greater_or_equal`,">=":`greater_or_equal`,in:`any_of`,isAnyOf:`any_of`,anyOf:`any_of`,oneOf:`any_of`,notIn:`none_of`,not_in:`none_of`,isNoneOf:`none_of`,noneOf:`none_of`,notOneOf:`none_of`,startsWith:`starts_with`,beginsWith:`starts_with`,endsWith:`ends_with`,doesNotContain:`not_contains`,notContain:`not_contains`,isEmpty:`is_empty`,isNotEmpty:`is_not_empty`};function normalizeOperator(e){return it[e]??e}function normalizeFilterRule(e){let t=normalizeOperator(e.operator);return t===e.operator?e:{...e,operator:t}}const z=864e5,at=/* @__PURE__ */ new Set([`days`,`weeks`,`months`,`years`]),ot=/* @__PURE__ */ new Set([`past`,`future`]);function isRelativeDateValue(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.amount==`number`&&Number.isFinite(t.amount)&&t.amount>0&&typeof t.unit==`string`&&at.has(t.unit)&&typeof t.direction==`string`&&ot.has(t.direction)}function utcDayStart(e){return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function shiftUtcDay(e,t,n){if(n===`days`)return e+t*z;if(n===`weeks`)return e+t*7*z;let r=new Date(e),i=r.getUTCFullYear()+(n===`years`?t:0),a=r.getUTCMonth()+(n===`months`?t:0),o=new Date(Date.UTC(i,a+1,0)).getUTCDate();return Date.UTC(i,a,Math.min(r.getUTCDate(),o))}function resolveIsWithinBounds(e,t=/* @__PURE__ */ new Date){if(!isRelativeDateValue(e))return null;let n=utcDayStart(t),r=Math.trunc(e.amount),i=e.direction===`past`?{startMs:shiftUtcDay(n,-r,e.unit),endMs:n+z}:{startMs:n,endMs:shiftUtcDay(n,r,e.unit)+z};return Number.isFinite(i.startMs)&&Number.isFinite(i.endMs)?i:null}function resolveUtcDayBounds(e){if(!Number.isFinite(e))return null;let t=utcDayStart(new Date(e));return Number.isFinite(t)?{startMs:t,endMs:t+z}:null}function toUtcDayString(e){return new Date(e).toISOString().slice(0,10)}const st=/* @__PURE__ */ new Set([`relation`,`document`,`user`]),ct={id:`text`,objectId:`text`,objectName:`text`,tenantId:`text`,label:`text`,createdAt:`date`,updatedAt:`date`,deletedAt:`date`,deletedBy:`user`,createdBy:`user`,lastUpdatedBy:`user`,visibility:`select`,ownedBy:`user`,parentId:`text`,childIds:`relation`},B={before:`"less_than"`,after:`"greater_than"`,on_or_before:`"less_or_equal"`,on_or_after:`"greater_or_equal"`,is_checked:`"is" with value true`,is_not_checked:`"is" with value false`,day_month_eq:`"on_day_month"`},lt=new Set(Object.entries(D).filter(([,e])=>e.includes(`any_of`)&&!e.includes(`contains`)).map(([e])=>e)),ut={contains:`any_of`,not_contains:`none_of`};function resolveCanonicalOperator(e,t){let n=B[e];if(n){let t=`Unknown filter operator "${e}" — use ${n}`;throw new r(t,[{path:[`operator`],message:t}])}let i=normalizeOperator(e),a=ut[i];if(a&&lt.has(t)){let e=`Operator "${i}" is not valid for type "${t}" — use "${a}"`;throw new r(e,[{path:[`operator`],message:e}])}return i}function assertPropertyOperator(e,t,n){let i=resolveCanonicalOperator(e,t);if(!n.includes(i)){let i=`Operator "${e}" is not valid for property type "${t}". Valid operators: ${n.length?n.join(`, `):`(no operators registered for this type)`}.`;throw new r(i,[{path:[`operator`],message:i}])}return i}function assertRelativeDateValue(e){if(e.operator===`is_within`&&!isRelativeDateValue(e.value)){let e=`Operator "is_within" requires a relative-date value { amount: positive number, unit: days|weeks|months|years, direction: past|future }`;throw new r(e,[{path:[`value`],message:e}])}}const dt=/^(\d{4}-\d{2}-\d{2})(?:[T ](?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-](?:(?:0\d|1[0-3])(?::[0-5]\d)?|14(?::00)?))?)?$/,ft=/* @__PURE__ */ new Set([`is`,`is_not`,`less_than`,`less_or_equal`,`greater_than`,`greater_or_equal`]);function assertAbsoluteDateValue(e,t){if(t!==`date`||!ft.has(e.operator))return;let n=e.value;if(n==null||isDynamicValue(n)||typeof n==`string`&&isCastableDay(n))return;let i=`Filter on a date attribute expected a YYYY-MM-DD day, optionally followed by a time, received ${JSON.stringify(n)}`;throw new r(i,[{path:[`value`],message:i}])}function isCastableDay(e){let t=dt.exec(e)?.[1];return!t||t.startsWith(`0000-`)?!1:isCalendarDay(t)}function resolveComparandType(e){return e.type===`formula`&&e.returnType===`date`?`date`:resolveEffectiveFilterType(e)}function applyCanonicalForm(e,t,n){e.operator=t,canonicalizeFilterValue(e,n),assertRelativeDateValue(e),assertAbsoluteDateValue(e,n)}function assertDynamicValueForAttribute(e,t){if(!isDynamicValue(e.value))return;let n=e.value;if(n.dynamic===`actor`&&t!==`user`){let e=`actor token (@me) is only valid on user attributes, not "${t}"`;throw new r(e,[{path:[`value`],message:e}])}if(n.dynamic===`date`&&t!==`date`){let e=`date token (@today/@now) is only valid on date attributes, not "${t}"`;throw new r(e,[{path:[`value`],message:e}])}}const V=E.map(e=>`"${e}"`).join(`, `);function operatorList(e){return e.length?e.join(`, `):`(not filterable)`}function qualifyWithSchema(e){if(st.has(e.type))return e.properties}function locationPartsHint(e){return e===`location`?` A location is filtered on one of its parts: set "property" to one of ${V} and use a text operator (e.g. contains).`:``}function dottedPathHint(e,t,n){let r=` Dotted paths are not supported — `;if(n.type===`location`)return`${r}set "attribute" to "${e}" and "property" to ${isLocationFilterProperty(t)?`"${t}"`:`one of ${V}`}.`;let i=qualifyWithSchema(n);if(i){let n=i.definitions.map(e=>`"${e.name}"`).join(`, `);return`${r}set "attribute" to "${e}" and "property" to ${i.definitions.some(e=>e.name===t)?`"${t}"`:`one of ${n}`} to filter on the edge property.`}let a=attributeFilterTarget(n).operators;return`${r}${a.length?`set "attribute" to "${e}" and use one of ${a.join(`, `)}`:`"${e}" is not filterable`}; the full-text "query" parameter matches tokens by relevance, not values.`}function collectQualifiedRuleIssues(e,t){try{return validateQualifiedRule({...e},t),[]}catch(e){if(!(e instanceof r))throw e;return e.errors.map(e=>({...e,path:[...e.path]}))}}function validateQualifiedRule(e,t){if(typeof e.attribute!=`string`){let e=`A filter rule needs an attribute: filters are one combinator and a flat list of rules`;throw new r(e,[{path:[`attribute`],message:e}])}let n=t.attributes.find(t=>t.name===e.attribute),i=n?[]:systemColumnFilterTarget(e.attribute)?.operators??[];if(!n&&i.length===0){let[n,...i]=e.attribute.split(`.`),a=i.length>0?t.attributes.find(e=>e.name===n):void 0,o=a?dottedPathHint(n??``,i[0]??``,a):e.attribute.includes(`.`)?` Dotted paths are not supported — filter on the attribute name alone with a structured operator (contains, any_of, …); the full-text "query" parameter matches tokens by relevance, not values.`:``,s=`Unknown attribute: ${e.attribute}${o}`;throw new r(s,[{path:[`attribute`],message:s}])}if(e.quantifier!==void 0&&!e.property){let e=`quantifier is only valid on qualified edge rules (set "property")`;throw new r(e,[{path:[`quantifier`],message:e}])}if(!n){if(e.property)throw new r(`Cannot qualify system attribute "${e.attribute}"`,[{path:[`property`],message:`"${e.attribute}" is a system column, not a reference`}]);let t=ct[e.attribute]??`text`,n=resolveCanonicalOperator(e.operator,t);if(!i.includes(n)){let t=`Operator "${e.operator}" is not valid for system attribute "${e.attribute}". Valid operators: ${i.join(`, `)}.`;throw new r(t,[{path:[`operator`],message:t}])}applyCanonicalForm(e,n,t);return}if(!e.property){assertDynamicValueForAttribute(e,n.type);let t=attributeFilterTarget(n).operators,i=resolveCanonicalOperator(e.operator,n.type);if(!t.includes(i)){let i=`Operator "${e.operator}" is not valid for attribute "${n.name}". Valid operators: ${operatorList(t)}.${locationPartsHint(n.type)}`;throw new r(i,[{path:[`operator`],message:i}])}applyCanonicalForm(e,i,resolveComparandType(n));return}if(n.type===`location`){if(e.quantifier!==void 0){let e=`quantifier is not valid on a location part — a location is one value, not a set of edges`;throw new r(e,[{path:[`quantifier`],message:e}])}if(!isLocationFilterProperty(e.property)){let t=`Property "${e.property}" is not a part of location "${e.attribute}". Valid parts: ${V}.`;throw new r(t,[{path:[`property`],message:t}])}assertDynamicValueForAttribute(e,`text`);let{operators:t}=locationPartFilterTarget(n.name,e.property);applyCanonicalForm(e,assertPropertyOperator(e.operator,`text`,t),`text`);return}if(!st.has(n.type))throw new r(`Cannot qualify ${n.type} attribute "${e.attribute}"`,[{path:[`property`],message:`Attribute "${e.attribute}" is not a reference type`}]);let a=n.properties;if(!a)throw new r(`Attribute "${e.attribute}" has no qualifyWith schema`,[{path:[`property`],message:`"${e.attribute}" has no qualifyWith`}]);let o=a.definitions.find(t=>t.name===e.property);if(!o)throw new r(`Property "${e.property}" not defined on "${e.attribute}".qualifyWith()`,[{path:[`property`],message:`Unknown property: ${e.property}`}]);let{operators:s}=edgePropertyFilterTarget(n.name,o);applyCanonicalForm(e,assertPropertyOperator(e.operator,o.type,s),o.type)}const pt=i.array(i.string()).max(N.columnsPerTab),mt=i.array(i.string().min(1)).max(N.columnsPerTab).refine(e=>new Set(e).size===e.length,{message:`Displayed attribute names must be unique`}),ht=i.object({attribute:i.string().describe(`Attribute to sort by`),direction:i.enum([`asc`,`desc`]).describe(`asc or desc`)}).strict(),H=i.array(ht).max(N.sortsPerTab),gt=i.object({amount:i.number().describe(`Count`),unit:i.enum([`days`,`weeks`,`months`,`years`]).describe(`Unit`),direction:i.enum([`past`,`future`]).describe(`Past or future`)}).strict(),_t=i.object({value:i.number().nullable().describe(`Amount`),code:i.array(i.string()).optional().describe(`Currency codes`)}).strict(),vt=i.object({phoneNumber:i.string().nullable().describe(`Number`),countryCode:i.string().optional().describe(`ISO country code`)}).strict(),yt=i.discriminatedUnion(`dynamic`,[i.object({dynamic:i.literal(`actor`).describe(`Resolved at filter time`),ref:i.literal(`current`).describe(`The current actor`)}).strict(),i.object({dynamic:i.literal(`date`).describe(`Resolved at filter time`),anchor:i.enum([`today`,`now`]).describe(`Anchor`)}).strict()]),bt=i.object({month:i.number().describe(`1-12`),day:i.number().describe(`Day`)}).strict(),xt=i.union([i.string(),i.number(),i.boolean(),i.array(i.string()),gt,_t,vt,bt,yt,i.null()]),St=i.enum([`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`any_of`,`none_of`],{error:e=>{let t=e.input,n=typeof t==`string`?B[t]:void 0;return n?`Unknown filter operator "${t}" — use ${n}`:void 0}}),Ct=i.object({attribute:i.string().describe(`Attribute to filter on`),property:i.string().optional().describe(`Qualified edge property`),quantifier:i.enum([`any`,`none`]).optional().describe(`For a multi-value attribute`),operator:St.describe(`Comparison`),value:xt.describe(`Comparison value, by attribute type`)}).strict(),wt=i.array(Ct).max(N.filterRulesPerTab),U=i.object({combinator:i.enum([`and`,`or`]).describe(`Match every rule or any rule`),rules:wt.describe(`The rules`)}).strict(),W=i.object({object:i.string().optional().describe(`Every record of this object`),relation:i.string().optional().describe(`Records linked through this relation`)}).strict().superRefine((e,t)=>{e.object===void 0&&e.relation===void 0&&t.addIssue({code:`custom`,message:`Collection source must define an object, a relation, or both`})}).transform(e=>e.relation===void 0?{object:e.object}:e.object===void 0?{relation:e.relation}:{object:e.object,relation:e.relation}),Tt=i.object({source:W,filters:U.optional(),sorts:H.optional(),limit:i.number().int().nonnegative().optional()}).strict();var RecordQuery=class{constructor(e){this.state=e}with(e){return new this.constructor({...this.state,...e})}rule(e,t,n){return this.with({rules:[...this.state.rules,{attribute:e,operator:t,value:n}]})}eq(e,t){return this.rule(e,`is`,t)}neq(e,t){return this.rule(e,`is_not`,t)}gt(e,t){return this.rule(e,`greater_than`,t)}gte(e,t){return this.rule(e,`greater_or_equal`,t)}lt(e,t){return this.rule(e,`less_than`,t)}lte(e,t){return this.rule(e,`less_or_equal`,t)}contains(e,t){return this.rule(e,`contains`,t)}notContains(e,t){return this.rule(e,`not_contains`,t)}startsWith(e,t){return this.rule(e,`starts_with`,t)}endsWith(e,t){return this.rule(e,`ends_with`,t)}in(e,t){return this.rule(e,`any_of`,t)}notIn(e,t){return this.rule(e,`none_of`,t)}isEmpty(e){return this.rule(e,`is_empty`,null)}isNotEmpty(e){return this.rule(e,`is_not_empty`,null)}where(...e){return this.with({rules:[...this.state.rules,...e.map(e=>({...e}))]})}or(){return this.with({combinator:`or`})}orderBy(e,t=`asc`){return this.with({sorts:[...this.state.sorts,{attribute:e,direction:t}]})}limit(e){return this.with({limit:e})}offset(e){return this.with({offset:e})}search(e){return this.with({search:e})}related(e){return this.with({scope:{kind:`related`,relation:e}})}relatedFrom(e){return this.with({scope:{kind:`relatedFrom`,relation:e}})}toDefinition(){let{object:e,scope:t,rules:n,combinator:r,sorts:i,limit:a}=this.state;return{source:t?.kind===`related`?{relation:t.relation}:t?.kind===`relatedFrom`?{object:e,relation:t.relation}:{object:e},...n.length>0?{filters:{combinator:r,rules:n.map(e=>({...e}))}}:{},...i.length>0?{sorts:i.map(e=>({...e}))}:{},...a===void 0?{}:{limit:a}}}};function query(e){return new RecordQuery({object:typeof e==`string`?e:e.build().name,combinator:`and`,rules:[],sorts:[]})}const G=[`day`,`week`,`month`,`quarter`,`year`],K=`$query`,Et=`$record`;function createInput(e){return Object.freeze({...e,optional:()=>createInput({...e,isOptional:!0}),inSection:t=>createInput({...e,section:t}),showWhen:(t,n)=>createInput({...e,when:{key:t,...n}}),many:()=>createInput({...e,isMany:!0,schema:i.array(e.schema).min(1)})})}function objectNameOf(e){return e===void 0||typeof e==`string`?e:e.build().name}function scalar(e,t,n){return createInput({kind:e,of:objectNameOf(n),isOptional:!1,isMany:!1,schema:t})}function name(){return i.string().min(1)}const q={object:e=>scalar(`object`,name(),e),attribute:(e,t)=>createInput({kind:`attribute`,of:objectNameOf(e),options:t,isOptional:!1,isMany:!1,schema:name()}),query:e=>scalar(`query`,Tt,e),record:e=>scalar(`record`,name(),e),agent:()=>scalar(`agent`,name()),routine:()=>scalar(`routine`,name()),view:()=>scalar(`view`,name()),url:()=>scalar(`url`,i.url().refine(e=>/^https?:\/\//.test(e),`Only http(s) links`)),emailCategory:()=>scalar(`emailCategory`,name()),enum:e=>createInput({kind:`enum`,isOptional:!1,isMany:!1,schema:i.enum(e)}),text:()=>scalar(`text`,name()),number:()=>scalar(`number`,i.number()),boolean:()=>scalar(`boolean`,i.boolean()),period:()=>scalar(`period`,i.enum(G))},J={size:{w:4,h:4},minWidth:3,height:`flexible`,minHeight:3,maxHeight:10},Dt=defineBlock({name:`artifact_preview`,label:`Preview`,icon:`eye`,family:`context`,contexts:[`record`],layout:{size:{w:6,h:8},minWidth:4,height:`flexible`,minHeight:4,maxHeight:20},inputs:{}}),Ot=[`number`,`currency`],kt=[`status`,`select`,`user`,`relation`,`date`],At=[`bar`,`horizontal_bar`,`line`,`area`,`donut`,`funnel`,`treemap`,`calendar`],jt=[`value_desc`,`value_asc`,`label`],Mt=[`line`,`area`,`funnel`,`calendar`];function measureIssue({measure:e,attribute:t}){return e===`count`?t===void 0?void 0:{input:`attribute`,message:`count measures records; it takes no attribute`}:t===void 0?{input:`attribute`,message:`${String(e)} needs a number or currency attribute`}:void 0}function requires(e,t,n){return e[t]!==void 0&&e[n]===void 0?{input:t,message:`${t} needs ${n}`}:void 0}function together(e,t,n){return requires(e,t,n)??requires(e,n,t)}function kindIssue(e){let{kind:t,by:n,byBucket:r,by2:i,measure:a}=e;if(i!==void 0&&i===n)return{input:`by2`,message:`by2 must differ from by`};if((t===`donut`||t===`funnel`)&&i!==void 0)return{input:`kind`,message:`a ${String(t)} splits one grouping (by), and no second`};if(t===`funnel`&&a!==`count`&&a!==`sum`)return{input:`kind`,message:`a funnel adds stages up: its measure is count or sum`};if(t===`area`&&i===void 0)return{input:`kind`,message:`an area stacks a second grouping (by2); one series is a line`};if(t===`treemap`&&(n===void 0||i!==void 0))return{input:`kind`,message:`a treemap needs one grouping (by), and no second`};if(t===`calendar`&&(r!==`day`||i!==void 0))return{input:`kind`,message:`a calendar needs a date grouping by day, and no second`};let o=Mt;if(e.order!==void 0&&o.includes(t))return{input:`order`,message:`order applies to bar, horizontal_bar, donut or treemap`}}function measuredInputs(){return{query:q.query(),measure:q.enum(We).inSection(`data`),attribute:q.attribute(K,{types:Ot}).optional().showWhen(`measure`,{not:[`count`]}),label:q.text().optional()}}function metricComparePeriod(e){if(e.period)return e.period;if(!e.trendBucket)return`month`;let t=G.indexOf(e.trendBucket);return G[Math.min(t+1,G.length-1)]??`month`}function comparedSpanIssue(e){let{trendBucket:t,compare:n}=e;if(n===void 0||typeof t!=`string`)return;let r=t;if(r===G.at(-1))return{input:`compare`,message:`compare needs a trendBucket finer than year`};let i=metricComparePeriod({trendBucket:r,period:e.period});return G.indexOf(i)>G.indexOf(r)?void 0:{input:`period`,message:`period must be wider than trendBucket (unset, it is one step above)`}}const Nt=defineBlock({name:`metric`,label:`Indicateur`,icon:`trending-up`,family:`data`,contexts:[`page`,`record`,`display`],layout:{size:{w:3,h:2},minWidth:3,height:`fit`,maxHeight:4,figure:!0},inputs:{...measuredInputs(),trend:q.attribute(K,{types:[`date`]}).optional().inSection(`display`),trendBucket:q.period().optional().showWhen(`trend`),compare:q.enum([`previous_period`]).optional(),period:q.period().optional().showWhen(`compare`),target:q.number().optional()},refine:e=>measureIssue(e)??together(e,`trend`,`trendBucket`)??requires(e,`period`,`compare`)??comparedSpanIssue(e)??(e.target!==void 0&&e.target<=0?{input:`target`,message:`target must be above zero`}:void 0)}),Pt=defineBlock({name:`chart`,label:`Graphique`,icon:`chart-bar`,family:`data`,contexts:[`page`,`record`,`display`],layout:{size:{w:4,h:6},minWidth:4,height:`flexible`,minHeight:4,maxHeight:12},inputs:{...measuredInputs(),kind:q.enum(At),by:q.attribute(K,{types:kt}).optional(),byBucket:q.period().optional().inSection(`data`).showWhen(`by`),by2:q.attribute(K,{types:kt}).optional().showWhen(`by`),by2Bucket:q.period().optional().inSection(`data`).showWhen(`by2`),order:q.enum(jt).optional().inSection(`display`).showWhen(`kind`,{not:Mt})},refine:e=>measureIssue(e)??requires(e,`byBucket`,`by`)??requires(e,`by2`,`by`)??requires(e,`by2Bucket`,`by2`)??kindIssue(e)}),Ft=defineBlock({name:`agenda`,label:`Agenda`,icon:`calendar`,family:`data`,contexts:[`page`,`record`,`display`],layout:J,inputs:{query:q.query(),attribute:q.attribute(K,{types:[`date`]}),next:q.number().optional(),yearly:q.boolean().optional(),label:q.text().optional()}}),It=defineBlock({name:`card`,label:`Fiche`,icon:`user-square`,family:`data`,contexts:[`page`,`record`,`display`],layout:{size:{w:4,h:4},minWidth:3,height:`fit`,maxHeight:10},inputs:{object:q.object().optional(),record:q.record().optional(),fields:q.attribute(Et).many().optional()},refine:(e,t)=>requires(e,`record`,`object`)??(t===`page`&&e.record===void 0?{input:`record`,message:`A card outside a record shows a chosen record: content.card(object).record(id)`}:void 0)}),Lt=defineBlock({name:`text_block`,label:`Texte`,icon:`type-text`,family:`layout`,contexts:[`page`,`record`,`display`],layout:{size:{w:12,h:2},minWidth:3,height:`fit`,maxHeight:16},inputs:{markdown:q.text()}}),Rt=defineBlock({name:`heading`,label:`Titre`,icon:`type-text`,family:`layout`,contexts:[`page`,`record`],layout:{size:{w:12,h:1},minWidth:6,height:`fit`,maxHeight:3},inputs:{title:q.text(),description:q.text().optional(),icon:q.text().optional()}}),zt=defineBlock({name:`decisions`,label:`Décisions`,icon:`inbox`,family:`people`,contexts:[`page`],layout:J,inputs:{kinds:q.enum(c).inSection(`data`).many().optional(),limit:q.number().optional()}}),Bt=defineBlock({name:`meetings_upcoming`,label:`Réunions à venir`,icon:`video`,family:`people`,contexts:[`page`],layout:J,inputs:{limit:q.number().optional()},refine:({limit:e})=>e===void 0||Number.isInteger(e)&&e>=1&&e<=50?void 0:{input:`limit`,message:`limit is a whole number from 1 to 50`}}),Vt=defineBlock({name:`mailbox`,label:`E-mails`,icon:`envelope`,family:`people`,contexts:[`page`],layout:J,inputs:{category:q.emailCategory().optional(),important:q.boolean().optional().inSection(`data`),unread:q.boolean().optional().inSection(`data`),limit:q.number().optional(),label:q.text().optional()},refine:({limit:e})=>e===void 0||Number.isInteger(e)&&e>=1&&e<=50?void 0:{input:`limit`,message:`limit is a whole number from 1 to 50`}}),Y=defineBlock({name:`record_links`,label:`Bubble`,icon:`share`,family:`context`,contexts:[`record`,`page`],layout:{size:{w:6,h:8},minWidth:6,height:`flexible`,minHeight:6,maxHeight:16},inputs:{center:q.enum([`record`,`me`]).optional().inSection(`data`),object:q.object().optional(),record:q.record().optional(),depth:q.enum([`1`,`2`,`3`,`4`,`5`]).optional()},refine:(e,t)=>requires(e,`record`,`object`)??(t===`page`&&e.center!==`me`&&e.record===void 0?{input:`record`,message:`Links outside a record centre on a chosen record or on the viewer: { object, record } or { center: "me" }`}:void 0)}),Ht={name:`bubble`,type:`custom`,extension:Y.name,placement:`main`,label:Y.label,icon:Y.icon,parameters:{}},Ut=[Dt,Nt,Pt,Ft,It,Lt,Rt,zt,Bt,Vt,Y],Wt=/* @__PURE__ */ new Set([`name`,`label`,`icon`,`family`,`contexts`,`inputs`,`parameters`,`layout`,`refine`]),Gt=Ut;var ContentExtensionRegistry=class{constructor(){this.extensions=/* @__PURE__ */ new Map,this.seed()}register(t){let n=Array.isArray(t)?t:[t],r=/* @__PURE__ */ new Set;n.forEach((t,n)=>{if(this.prepare(t,n),r.has(t.name))throw new e(`content extension`,t.name);r.add(t.name)});for(let e of n)this.extensions.set(e.name,e);return this}prepare(t,n){let i=[`extensions`,String(n)],reject=e=>{throw new r(e,[{path:i,message:e}])};if((typeof t!=`object`||!t||Array.isArray(t))&&reject(`Expected a content extension declaration`),Object.keys(t).some(e=>!Wt.has(e))&&reject(`Expected only ${[...Wt].join(`, `)}`),(typeof t.name!=`string`||t.name.trim().length===0)&&reject(`API name must not be empty`),(!Array.isArray(t.contexts)||t.contexts.length===0||t.contexts.some(e=>!F.includes(e)))&&reject(`contexts must be a non-empty list of ${F.join(`, `)}`),typeof t.parameters?.safeParse!=`function`&&reject(`parameters must be a Zod schema`),this.extensions.has(t.name))throw new e(`content extension`,t.name)}get(e){return this.extensions.get(e)}has(e){return this.extensions.has(e)}getAll(){return[...this.extensions.values()]}get size(){return this.extensions.size}clear(){this.extensions.clear(),this.seed()}seed(){for(let e of Gt)this.extensions.set(e.name,e)}};const Kt=new ContentExtensionRegistry,qt=12,X=[3,4,6,8,9,12];function overlaps(e,t){return e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h}function findGridViolation(e,t={}){let n=Object.entries(e);for(let[e,{x:t,y:r,w:i,h:a}]of n){if(![t,r,i,a].every(Number.isInteger))return{path:[e],message:`Block "${e}" needs integer grid coordinates`};if(t<0||r<0||i<1||a<1)return{path:[e],message:`Block "${e}" needs x >= 0, y >= 0, w >= 1 and h >= 1`};if(t+i>12)return{path:[e],message:`Block "${e}" overflows the 12-column grid (x + w = ${t+i})`}}let r=n.filter(([e])=>t.exempt?.has(e)!==!0);for(let[e,[t,n]]of r.entries())for(let[i,a]of r.slice(e+1))if(overlaps(n,a))return{path:[i],message:`Blocks "${t}" and "${i}" overlap`}}function groupedMembers(e){let t=new Set(e.filter(e=>e.type!==`group`).map(e=>e.name)),n=/* @__PURE__ */ new Set;for(let r of e)if(r.type===`group`)for(let e of r.members)t.has(e)&&n.add(e);return n}function memberlessGroups(e){let t=new Set(e.filter(e=>e.type!==`group`).map(e=>e.name));return new Set(e.flatMap(e=>e.type===`group`&&!e.members.some(e=>t.has(e))?[e.name]:[]))}function groupSizeMessage(e){return e>=2&&e<=N.membersPerGroup?void 0:`A group holds 2 to ${N.membersPerGroup} blocks, not ${e}`}function findGroupViolation(e){let t=new Map(e.map(e=>[e.name,e])),n=/* @__PURE__ */ new Map;for(let r of e)if(r.type===`group`)for(let e of r.members){let i=t.get(e);if(i===void 0)return{path:[r.name],message:`Group "${r.name}" names "${e}", which is not a content of this page`};if(i.type===`group`)return{path:[r.name],message:`Group "${r.name}" cannot hold the group "${e}"`};let a=n.get(e);if(a!==void 0)return{path:[r.name],message:a===r.name?`Group "${r.name}" names "${e}" twice`:`"${e}" already belongs to the group "${a}"`};n.set(e,r.name)}}function boundsOf(e){let{minHeight:t,maxHeight:n}=e;return t!==void 0&&n!==void 0?`${t} to ${n} rows`:t===void 0?`at most ${String(n)} rows`:`at least ${t} rows`}function findRowLimitViolation(e){let t=Object.entries(e).find(([,e])=>e.y+e.h>N.pageRows);if(t===void 0)return;let[n,r]=t;return{path:[n],message:`Block "${n}" ends at row ${r.y+r.h}, past the page's ${N.pageRows} rows`}}function cellViolation(e,t,n){if(!X.includes(t.w))return{path:[e],message:`Block "${e}" width ${t.w} is not one of ${X.join(`, `)}`};if(t.w<n.minWidth)return{path:[e],message:`Block "${e}" width ${t.w} is below its minimum width ${n.minWidth}`};if(n.height===`flexible`&&(n.minHeight!==void 0&&t.h<n.minHeight||n.maxHeight!==void 0&&t.h>n.maxHeight))return{path:[e],message:`Block "${e}" height ${t.h} is outside its bounds (${boundsOf(n)})`}}function sharesRows(e,t){return e.y<t.y+t.h&&t.y<e.y+e.h}function findLayoutRuleViolation(e,t,n,r=/* @__PURE__ */ new Set){let i=findRowLimitViolation(e);if(i!==void 0)return i;let a=groupedMembers(t),o=Object.entries(e).filter(([e])=>!a.has(e));for(let[e,t]of o){if(r.has(e))continue;let i=cellViolation(e,t,n(e));if(i!==void 0)return i}let[s,c]=o.filter(([e])=>!r.has(e)&&n(e).height===`fill`);if(s!==void 0&&c!==void 0)return{path:[c[0]],message:`Only one block may fill the page: "${s[0]}" and "${c[0]}" both do`};if(s===void 0)return;let[l,u]=s,d=o.find(([e,t])=>e!==l&&sharesRows(t,u));if(d!==void 0)return{path:[l],message:`Block "${l}" fills the page and must be alone in its rows; "${d[0]}" shares them`}}function findRelationAttribute(e,t){return e.attributes.find(e=>e.name===t&&e.type===`relation`)}function relationAcceptsObject(e,t){return e.targets.some(e=>e.object===t||e.object===`*`)}function singleRelationTarget(e){let[t,...n]=e.targets;return t&&n.length===0&&t.object!==`*`?t.object:void 0}function requireSingleRelationTarget(e,t=[e.name,`targets`]){let n=singleRelationTarget(e);if(n===void 0){let n=`Relation "${e.name}" requires one concrete collection target`;throw new r(n,[{path:t,message:n}])}return n}function isCollectionContent(e){return e.type===`collection`}function collectionSourceAddress(e){return e.relation===void 0?{kind:`object`,object:e.object}:e.object===void 0?{kind:`related`,relation:e.relation}:{kind:`relatedFrom`,object:e.object,relation:e.relation}}function collectionSourceAddressOf(e){if(!e||typeof e!=`object`)return;let t=`object`in e?e.object:void 0,n=`relation`in e?e.relation:void 0;if(typeof t==`string`&&typeof n==`string`)return{kind:`relatedFrom`,object:t,relation:n};if(typeof t==`string`&&n===void 0)return{kind:`object`,object:t};if(typeof n==`string`&&t===void 0)return{kind:`related`,relation:n}}function sourcedAttributeOf(e,t){if(t.type===`richtext`)return typeof t.attribute==`string`&&e!==void 0?{object:e,attribute:t.attribute}:void 0;if(t.type!==`collection`)return;let n=collectionSourceAddressOf(t.source);if(n?.kind===`related`)return e===void 0?void 0:{object:e,attribute:n.relation};if(n?.kind===`relatedFrom`)return{object:n.object,attribute:n.relation}}function requireRecordContentContext(e,t,n){if(t!==`record`){let i=`Content "${e}" requires record context. In ${t===`page`?`a standalone page`:`a collection view`} only a collection that lists a whole object, or a custom content that does not require a record, is allowed.`;throw new r(i,[{path:n,message:i}])}}function resolveContentNavigation(e){let t=e.openMode??`page`;return{openMode:t,createMode:e.createMode??t}}function resolveCollectionActions(e,t){return[...new Set(t)].filter(t=>e.actions===void 0||e.actions.includes(t))}const Jt={collection:[`page`,`record`,`display`],group:[`page`,`record`],form:[`record`],activity:[`record`],richtext:[`record`],documents:[`record`],forms:[`record`],emails:[`record`],meetings:[`record`]},Yt={collection:{size:{w:12,h:8},minWidth:6,height:`flexible`,minHeight:4,maxHeight:20},activity:{size:{w:12,h:8},minWidth:6,height:`flexible`},page:{size:{w:12,h:8},minWidth:6,height:`flexible`},group:{size:{w:6,h:4},minWidth:6,height:`flexible`}};function contentReadObjects(e,t,n){if(e.type!==`group`)return[...n(e)];let r=/* @__PURE__ */ new Set;for(let i of e.members){let e=t.get(i);if(e!==void 0&&e.type!==`group`)for(let t of n(e))r.add(t)}return[...r]}function contentPlacementContexts(e,t){return e.type===`custom`?t?.contexts:e.type===`page`||e.type===`collection`&&collectionSourceAddress(e.source).kind!==`object`?[`record`]:Jt[e.type]}function requireContentPlacement(e,t,n,r,i){let a=contentPlacementContexts(e,t);a&&!a.includes(hostPlacementContext(r))&&(requireRecordContentContext(n,r,i),reject(i,`Content "${n}" cannot be placed in a record view or a record page`))}function hostPlacementContext(e){return e===`record`?`record`:`page`}function contentContextOf(e){return e.context===`page`&&e.object!==void 0?`record`:e.context}const Xt=/* @__PURE__ */ new WeakSet;function violationOf(e,n,i,a){if(!(e instanceof t))throw e;let o=e instanceof r?e.errors[0]:void 0;return{key:JSON.stringify([n,i,e.code,Xt.has(e)?`Invalid content view`:e.message]),contentName:i,path:o?.path??a,message:e.message,code:e.code,error:e}}const Zt=systemAttributeMap({name:``});function systemAttributeMap(e){return new Map(getObjectSystemAttributes(e).map(e=>[e.name,e]))}function reject(e,t){throw new r(t,[{path:e,message:t}])}function requireName(e,t){e.trim().length===0&&reject(t,`API name must not be empty`)}function indexUnique(t,n,r){let i=/* @__PURE__ */ new Map;return t.forEach((t,a)=>{if(requireName(t.name,[...r,String(a),`name`]),i.has(t.name))throw new e(n,t.name);i.set(t.name,t)}),i}const Qt=30;function capped(e,t){let n=e.slice(0,t).join(`, `);return e.length>t?`${n} … and ${e.length-t} more`:n}function attributeInventory(e,t){return t.length===0?`Object "${e}" has no attributes yet.`:`Attributes of "${e}": ${capped(t,30)}`}function requireAttribute(e,t,n,r,i){if(requireName(t,n),!e)return;let a=e.attributes?.get(t)??(e.system??Zt).get(t);if(!a){if(!e.attributes||we.has(t))return;let r=attributeInventory(e.name,[...e.attributes.keys()]);reject(n,`Unknown attribute "${e.name}.${t}". ${r}${i?.()??``}`)}let o=r===void 0?[]:[r].flat();return o.length>0&&!o.includes(a.type)&&reject(n,`Attribute "${e.name}.${t}" must have type ${o.join(` or `)}`),a}function collectContentViewCatalogue(t,n=`authoring`){let i=t.mode??`published`,a=/* @__PURE__ */ new Map;t.objects.forEach((t,n)=>{if(requireName(t.name,[`objects`,String(n),`name`]),a.has(t.name))throw new e(`object`,t.name);a.set(t.name,{name:t.name,system:systemAttributeMap(t),attributes:indexUnique(t.attributes,`attribute`,[`objects`,String(n),`attributes`])})});let o=/* @__PURE__ */ new Set;(t.reservedObjects??[]).forEach((e,t)=>{let n=[`reservedObjects`,String(t)];requireName(e,n),a.has(e)||(i!==`draft`&&reject(n,`Unresolved reserved object "${e}"`),o.add(e),a.set(e,{name:e}))});let s=indexUnique(t.extensions??[],`extension`,[`extensions`]);function resolveObject(e,t){requireName(e,t);let n=a.get(e);return n||reject(t,`Unknown object "${e}"`),n}function inverseAddresses(e){let t=[];for(let[n,r]of a)if(n!==e)for(let i of r.attributes?.values()??[])i.type===`relation`&&relationAcceptsObject(i,e)&&t.push(`relatedFrom("${n}", "${i.name}")`);return t.sort().slice(0,3)}let authoringSchemaWith=e=>i===`draft`?draftContentViewDefinitionSchemaFor():contentViewDefinitionSchemaFor({traits:n===`structural`?null:(e,t)=>layoutTraitsOf(e,s,t),viewerFiltered:t.viewerFiltered,...e===void 0?{}:{statics:e}}),c=authoringSchemaWith(),l=i===`draft`||n===`structural`?c:contentViewDefinitionSchemaFor({traits:null,viewerFiltered:t.viewerFiltered}),schemaFor=e=>{if(t.authoringViews!==void 0&&!t.authoringViews.has(e))return l;let n=t.staticsOf?.(e);return n===void 0||n.size===0?c:authoringSchemaWith(n)},u=/* @__PURE__ */ new Map,d=/* @__PURE__ */ new Map,f=[],p=[];function parseView(t,n,i){let a=schemaFor(i).safeParse(t);if(!a.success){let e=new r(invalidViewMessage(t,a.error.issues[0]),a.error.issues.map(e=>({path:[...n,...e.path.map(String)],message:e.message,code:e.code})));throw Xt.add(e),e}let o=a.data;requireName(o.name,[...n,`name`]);let s=o.object??``,c=u.get(s)??/* @__PURE__ */ new Set;if(c.has(o.name))throw new e(`view`,`${s}.${o.name}`);if(c.add(o.name),u.set(s,c),o.context!==`page`&&o.default){let t=d.get(o.object)??/* @__PURE__ */ new Set;if(t.has(o.context))throw new e(`default view`,`${o.object}.${o.context}`);t.add(o.context),d.set(o.object,t)}return o}return t.views.forEach((e,n)=>{let r=[`views`,String(n)],i=e,a=`${String(i?.object??`?`)}.${String(i?.name??n)}`,o,c;try{o=parseView(e,r,n),c=o.object===void 0?void 0:resolveObject(o.object,[...r,`object`])}catch(e){f.push(violationOf(e,a,null,r));return}o.contents.forEach((e,i)=>{let l=[...r,`contents`,String(i)];try{requireName(e.name,[...l,`name`]),validateContent(e,l,c,contentContextOf(o),s,resolveObject,inverseAddresses,t.authoringViews?.has(n)===!0)}catch(t){f.push(violationOf(t,a,e.name,l))}}),p.push(o)}),p.forEach((e,n)=>{e.contents.forEach((i,a)=>{if(i.type!==`page`)return;let o=[`views`,String(n),`contents`,String(a),`page`],s=p.find(e=>e.context===`page`&&e.object===i.page.object&&e.name===i.page.name),c=e.context===`page`?`Content "${i.name}" cannot reference a page from a page`:e.object===i.page.object?s||t.complete!==!0?void 0:`Unknown page "${i.page.object}.${i.page.name}"`:`Content "${i.name}" must reference a page of "${String(e.object)}", not of "${i.page.object}"`;c!==void 0&&f.push(violationOf(new r(c,[{path:o,message:c}]),`${String(e.object)}.${e.name}`,i.name,o))})}),{views:p,unresolvedObjects:[...o].sort(),violations:f}}function validateStoredViews(e){let t=collectContentViewCatalogue(e,`structural`).violations[0];if(t)throw t.error}function describeViewIssue(e){let t=e.path.length>0?` (${e.path.map(String).join(`.`)})`:``;return`${e.message}${t}`}function invalidViewMessage(e,t){let n=typeof e==`object`&&e?e:{},r=typeof n.name==`string`?` "${n.name}"`:``,i=typeof n.object==`string`?` of "${n.object}"`:``;return t?`Invalid content view${r}${i}: ${describeViewIssue(t)}`:`Invalid content view${r}${i}`}function validateContentViewCatalogue(e){let{views:t,unresolvedObjects:n,violations:r}=collectContentViewCatalogue(e),i=r[0];if(i)throw i.error;return{views:t,unresolvedObjects:n}}function resolveStoredQuery(e,t,n,{owner:r,requireRecord:i,resolveObject:a,inverseAddresses:o}){let s=collectionSourceAddress(e.source),c,l;if(s.kind===`object`)c=a(s.object,[...t,`source`,`object`]);else if(s.kind===`related`){i();let e=[...t,`source`,`relation`],hint=()=>{if(!r)return``;let e=o(r.name);return e.length===0?``:`. Records pointing at "${r.name}" are addressed from the other side: ${e.join(`, `)}`},n=requireAttribute(r,s.relation,e,`relation`,hint);n?.type===`relation`&&(l=n,c=a(requireSingleRelationTarget(n,e),e))}else{i(),c=a(s.object,[...t,`source`,`object`]);let o=[...t,`source`,`relation`],l=requireAttribute(c,s.relation,o,`relation`);if(l?.type===`relation`&&r&&!relationAcceptsObject(l,r.name)){let e=l.targets.map(e=>`"${e.object}"`).join(`, `);reject(o,`Relation "${s.object}.${s.relation}" targets ${e}, not "${r.name}"`)}e.filters?.combinator===`or`&&reject([...t,`filters`,`combinator`],`${n} addresses "${s.object}" from the far side, so its filters must use the "and" combinator`)}return e.sorts?.forEach((e,n)=>requireAttribute(c,e.attribute,[...t,`sorts`,String(n),`attribute`])),e.filters?.rules.forEach((e,n)=>requireAttribute(c,e.attribute,[...t,`filters`,`rules`,String(n),`attribute`])),{target:c,relationAttribute:l}}function validateBlockReferences(e,t,n,r){let i=Object.entries(e.inputs),a;for(let[o,s]of i){let i=t[o];s.kind===`query`&&i!==void 0&&(a=resolveStoredQuery(i,[...n,o],`Block "${e.name}"`,r).target)}function attributeScope(o){if(o===void 0)return;if(o===`$query`)return a;if(o!==`$record`)return r.resolveObject(o,n);let s=i.find(([,e])=>e.kind===`object`)?.[0],c=s===void 0?void 0:t[s];return typeof c==`string`?r.resolveObject(c,[...n,s??`object`]):(r.owner||reject(n,`Block "${e.name}" names attributes, so it needs an object or a record host`),r.owner)}for(let[e,r]of i){let i=t[e];if(r.kind!==`attribute`||i===void 0)continue;let a=attributeScope(r.of);(Array.isArray(i)?i:[i]).forEach((t,o)=>{if(typeof t!=`string`)return;let s=Array.isArray(i)?[...n,e,String(o)]:[...n,e];requireAttribute(a,t,s,r.options?.types)})}for(let[r,a]of i){let i=a.when?.key,o=i===void 0?void 0:e.inputs[i],s=i===void 0?void 0:t[i];a.kind===`period`&&t[r]!==void 0&&o?.kind===`attribute`&&typeof s==`string`&&requireAttribute(attributeScope(o.of),s,[...n,i??r],[`date`])}}function isBoardGrouping(e){return(e?.type===`status`||e?.type===`select`)&&!e.hidden}function requireBoardGrouping(e,t,n){let r=t.type===`status`||t.type===`select`?`is hidden`:`is a ${t.type}`;isBoardGrouping(t)||reject(n,`A board groups by a visible status or select attribute: "${e}.${t.name}" ${r}`)}function validateContent(e,t,n,i,a,o,s,c){function requireRecord(){requireRecordContentContext(e.name,i,t)}let l={owner:n,requireRecord,resolveObject:o,inverseAddresses:s},u=hostPlacementContext(i);if(e.type===`custom`){let n=a.get(e.extension);n||reject([...t,`extension`],`Unknown extension "${e.extension}"`),contentPlacementContexts(e,n)?.includes(u)||reject([...t,`extension`],`${e.extension} cannot be placed here`);let i=n.parameters.safeParse(structuredClone(e.parameters??{}));if(!i.success)throw new r(`Invalid extension parameters`,i.error.issues.map(e=>({path:[...t,`parameters`,...e.path.map(String)],message:e.message,code:e.code})));let o=i.data,s=n.refine?.(o,u);s&&reject([...t,`parameters`,s.input],s.message),validateBlockReferences(n,o,[...t,`parameters`],l)}else if(requireContentPlacement(e,void 0,e.name,i,t),e.type!==`page`&&e.type!==`group`){if(e.type===`collection`){let{target:n,relationAttribute:r}=resolveStoredQuery(e,t,`Collection "${e.name}"`,l);if(e.columns?.forEach((e,i)=>{let a=[...t,`columns`,String(i)];if(typeof e==`string`){requireAttribute(n,e,a);return}let o=[...a,`relationProperty`];r||reject(o,`Relation property columns require a relation source`),r.properties?.definitions.some(t=>t.name===e.relationProperty)||reject(o,`Unknown relation property "${e.relationProperty}"`)}),e.displayAttributes?.forEach((e,r)=>requireAttribute(n,e,[...t,`displayAttributes`,String(r)])),c&&e.layout!==`table`&&(e.displayAttributes?.length??0)>N.displayAttributesPerCard&&reject([...t,`displayAttributes`],`A ${e.layout} shows at most ${N.displayAttributesPerCard} displayed attributes`),e.descriptionAttribute!==void 0&&requireAttribute(n,e.descriptionAttribute,[...t,`descriptionAttribute`]),e.layout===`kanban`&&e.groupByAttribute!==void 0){let r=[...t,`groupByAttribute`],i=requireAttribute(n,e.groupByAttribute,r);c&&i&&n&&requireBoardGrouping(n.name,i,r)}}else switch(e.type){case`form`:e.groups.forEach((e,r)=>{let i=[...t,`groups`,String(r)];requireName(e.name,[...i,`name`]),e.fields.forEach((e,t)=>requireAttribute(n,e.attribute,[...i,`fields`,String(t),`attribute`]))});break;case`richtext`:requireAttribute(n,e.attribute,[...t,`attribute`],`richtext`),e.titleAttribute!==void 0&&requireAttribute(n,e.titleAttribute,[...t,`titleAttribute`],`text`);break;case`emails`:case`meetings`:e.emailAttributes.forEach((e,r)=>requireAttribute(n,e,[...t,`emailAttributes`,String(r)],`text`));break;case`documents`:e.relations?.forEach((e,r)=>requireAttribute(n,e,[...t,`relations`,String(r)],`relation`));break;case`forms`:e.objectName!==void 0&&o(e.objectName,[...t,`objectName`]);break;case`activity`:break;default:reject(t,`Unknown content type: ${String(e)}`)}}}const Z=Object.freeze({size:Object.freeze({w:4,h:4}),minWidth:3,height:`flexible`,minHeight:2,figure:!1});function resolveLayout(e){return e===void 0?Z:{size:e.size??Z.size,minWidth:e.minWidth??Z.minWidth,height:e.height??Z.height,...e.minHeight===void 0?{}:{minHeight:e.minHeight},...e.maxHeight===void 0?{}:{maxHeight:e.maxHeight},figure:e.figure??!1}}function baseTraitsOf(e,t){return e.type===`custom`?resolveLayout(t.get(e.extension)?.layout):e.type in Yt?resolveLayout(Yt[e.type]):Z}function widthCovering(e){return X.find(t=>t>=e)??12}function boundOf(e,t){let n=e.filter(e=>e!==void 0);return n.length===0?void 0:t(...n)}function groupTraitsOf(e){if(e.length===0)return resolveLayout(Yt.group);let sum=t=>e.reduce((e,n)=>e+t(n),0),t={w:widthCovering(sum(e=>e.size.w)),h:Math.max(...e.map(e=>e.size.h))},n=widthCovering(sum(e=>e.minWidth)),r=e.every(e=>e.figure);if(e.every(e=>e.height===`fit`)){let i=boundOf(e.map(e=>e.maxHeight),Math.max);return{size:t,minWidth:n,height:`fit`,...i===void 0?{}:{maxHeight:i},figure:r}}let i=e.filter(e=>e.height!==`fit`),a=boundOf(i.map(e=>e.minHeight),Math.max),o=boundOf(i.map(e=>e.maxHeight),Math.min),s=o===void 0?void 0:Math.max(o,a??o);return{size:t,minWidth:n,height:`flexible`,...a===void 0?{}:{minHeight:a},...s===void 0?{}:{maxHeight:s},figure:r}}function layoutTraitsOf(e,t,n){let r=e.type===`group`?groupTraitsOf(e.members.flatMap(e=>{let r=n?.get(e);return r===void 0||r.type===`group`?[]:[layoutTraitsOf(r,t)]})):baseTraitsOf(e,t);return e.height===void 0?r:{...r,height:e.height}}function pageTraitsOf(e,t){return n=>{let r=e.get(n);return r?layoutTraitsOf(r,t,e):Z}}const $t=1e4;function isPlainJsonObject(e){let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null&&t.constructor?.name===`Object`}function addJsonIssue(e,t,n=[]){e.addIssue({code:`custom`,message:t,path:n})}function pushJsonArrayChildren(e,t,n,r){for(let n of Reflect.ownKeys(e))n!==`length`&&(n===`__proto__`?addJsonIssue(r,`The __proto__ key is not allowed in custom props`,[...t.path,n]):typeof n!=`symbol`&&/^(0|[1-9]\d*)$/.test(n)||addJsonIssue(r,`Arrays cannot contain non-index JSON properties`,[...t.path,n]));for(let i=e.length-1;i>=0;i--){let a=Object.getOwnPropertyDescriptor(e,String(i)),o=[...t.path,i];a&&`value`in a?n.push({kind:`enter`,value:a.value,path:o,depth:t.depth+1}):addJsonIssue(r,`Sparse arrays are not valid JSON values`,o)}}function pushJsonObjectChildren(e,t,n,r){let i=Reflect.ownKeys(e);for(let a=i.length-1;a>=0;a--){let o=i[a],s=[...t.path,o];if(o===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,s);continue}if(typeof o==`symbol`){addJsonIssue(r,`Symbol keys are not valid JSON keys`,s);continue}let c=Object.getOwnPropertyDescriptor(e,o);c?.enumerable&&`value`in c?n.push({kind:`enter`,value:c.value,path:s,depth:t.depth+1}):addJsonIssue(r,`Custom props must contain enumerable data properties only`,s)}}function validateJsonProps(e,t){if(typeof e!=`object`||!e){addJsonIssue(t,`Expected a plain JSON object`);return}try{if(Array.isArray(e)||!isPlainJsonObject(e)){addJsonIssue(t,`Expected a plain JSON object`);return}}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`);return}let n=/* @__PURE__ */ new WeakSet,r=[{kind:`enter`,value:e,path:[],depth:0}],i=0;for(;r.length>0;){let e=r.pop();if(!e)break;if(e.kind===`exit`){n.delete(e.value);continue}if(i++,i>$t){addJsonIssue(t,`Custom props cannot exceed ${$t.toLocaleString(`en-US`)} total JSON nodes`,e.path);return}if(e.depth>64){addJsonIssue(t,`Custom props cannot exceed depth 64`,e.path);continue}let a=e.value;if(!(a===null||typeof a==`string`||typeof a==`boolean`||typeof a==`number`&&Number.isFinite(a))){if(typeof a!=`object`)addJsonIssue(t,`Expected a JSON value`,e.path);else if(n.has(a))addJsonIssue(t,`Custom props cannot contain circular references`,e.path);else try{if(Array.isArray(a)){n.add(a),r.push({kind:`exit`,value:a}),pushJsonArrayChildren(a,e,r,t);continue}if(!isPlainJsonObject(a)){addJsonIssue(t,`Expected an array or plain JSON object`,e.path);continue}n.add(a),r.push({kind:`exit`,value:a}),pushJsonObjectChildren(a,e,r,t)}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`,e.path)}}}}const en=i.unknown().superRefine(validateJsonProps).transform(e=>e),tn={span:i.union([i.literal(1),i.literal(2),i.literal(3),i.literal(4),i.literal(5),i.literal(6),i.literal(7),i.literal(8),i.literal(9),i.literal(10),i.literal(11),i.literal(12)]).optional().describe(`Columns of 12 this field occupies`),label:i.string().optional().describe(`Overrides the attribute's label`),readOnly:i.boolean().optional().describe(`Shows the value, not editable`)},nn=i.object({attribute:i.string().describe(`Attribute API name shown by this field`),...tn}).strict(),rn=i.object({name:i.string().describe(`Group API name, unique in the form`),label:i.string().describe(`Label people see`),description:i.string().optional().describe(`Extra context under the label`),collapsible:i.boolean().optional().describe(`Whether the group can be collapsed`),collapsed:i.boolean().optional().describe(`Whether the group starts collapsed`),fields:i.array(nn).max(N.fieldsPerGroup).describe(`Fields in this group, in order`)}).strict();function refineFormContent(e,t){e.groups.reduce((e,t)=>e+t.fields.length,0)>N.fieldsPerFormTab&&t.addIssue({code:`too_big`,origin:`array`,maximum:N.fieldsPerFormTab,inclusive:!0,message:`A form content can contain at most ${N.fieldsPerFormTab} fields`,path:[`groups`]});let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;e.groups.forEach((e,i)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate group name "${e.name}"`,path:[`groups`,i,`name`]}),n.add(e.name),e.fields.forEach((e,n)=>{r.has(e.attribute)&&t.addIssue({code:`custom`,message:`Duplicate field attribute "${e.attribute}"`,path:[`groups`,i,`fields`,n,`attribute`]}),r.add(e.attribute)})})}const Q={name:i.string().describe(`Content API name, unique in the view`),label:i.string().optional().describe(`Label people see`),icon:P.optional().describe(`Icon name`),placement:i.enum([`main`,`aside`,`grid`]).describe(`main: the tab strip. aside: the side panel. grid: a page block`),height:i.enum([`fit`,`flexible`,`fill`]).optional().describe(`Page block height: fit (content), flexible (between bounds) or fill (whole page, one per page)`)},an={...Q,type:i.literal(`collection`),source:W.describe(`object: every record; relation: records linked to this record; both: records of object whose relation points at this record`),visibility:i.enum(Be).optional().describe(`all: no scope; workspace: every member; private: viewer's own; shared: private records other members shared with the viewer`),columns:i.array(i.union([i.string(),i.object({relationProperty:i.string().refine(e=>e.trim().length>0).describe(`Qualified edge property shown as a column`)}).strict()])).max(N.columnsPerTab).optional().describe(`Table columns, in order`),descriptionAttribute:i.string().optional().describe(`Secondary line under each row's title (list layout)`),displayAttributes:mt.optional().describe(`Attributes shown on each card`),filters:U.optional().describe(`Restricts which records show`),sorts:H.optional().describe(`Sort order`),actions:i.enum([`create`,`update`,`delete`,`attach`,`detach`]).array().optional().describe(`Offered actions; absent = every action, [] = none`),openMode:i.enum([`page`,`peek`]).optional().describe(`page or peek (the record panel)`),createMode:i.enum([`page`,`peek`,`inline`]).optional().describe(`page, peek, or inline (creates without opening)`)},on=i.object({...an,layout:i.enum([`table`,`list`,`kanban`]).describe(`table columns, list cards, kanban board grouped by a select/status attribute`),columnSizing:i.record(i.string(),i.number()).optional().describe(`Column widths in pixels, by attribute name`),groupByAttribute:i.string().optional().describe(`Kanban only: the select or status attribute that names the columns`),kanbanColumnOrder:i.array(i.string()).optional().describe(`Kanban: column order by option value`),kanbanColumnVisibility:i.record(i.string(),i.boolean()).optional().describe(`Kanban: which columns are shown`),kanbanPinnedColumns:i.array(i.string()).optional().describe(`Kanban: columns pinned first`)}).strict().superRefine((e,t)=>{let n=[`groupByAttribute`,`kanbanColumnOrder`,`kanbanColumnVisibility`,`kanbanPinnedColumns`];if(e.layout===`kanban`)e.groupByAttribute===void 0&&t.addIssue({code:`custom`,path:[`groupByAttribute`],message:`A kanban layout requires groupByAttribute`});else for(let r of n)e[r]!==void 0&&t.addIssue({code:`custom`,path:[r],message:`Only a kanban layout groups by an attribute`})}),$={...Q,type:i.literal(`form`),groups:i.array(rn).max(N.groupsPerFormTab).describe(`Field groups, in order`),formColumns:i.union([i.literal(1),i.literal(2),i.literal(3)]).optional().describe(`Grid columns, 1-3`),density:i.enum([`compact`,`comfortable`,`spacious`]).optional().describe(`Vertical spacing between fields`)},sn=i.object($).strict().superRefine(refineFormContent),cn=i.object({...$,groups:$.groups.min(1,`A published form content requires at least one group`)}).strict().superRefine(refineFormContent),ln=[on,i.object({...Q,type:i.literal(`group`),placement:i.literal(`grid`).describe(`Always grid`),members:i.array(i.string()).min(1).max(N.membersPerGroup).describe(`Contents side by side`)}).strict(),i.object({...Q,type:i.literal(`custom`),extension:i.string().describe(`Name of a registered extension`),parameters:i.lazy(()=>en).optional().describe(`Extension parameters`)}).strict(),i.object({...Q,type:i.literal(`activity`)}).strict(),i.object({...Q,type:i.literal(`richtext`),attribute:i.string().describe(`Richtext attribute edited in place`),titleAttribute:i.string().optional().describe(`Text attribute shown as the title`)}).strict(),i.object({...Q,type:i.literal(`documents`),allowUpload:i.boolean().optional().describe(`Lets people add files here`),allowRemove:i.boolean().optional().describe(`Lets people remove files here`),hideAttachments:i.boolean().optional().describe(`Hides files attached elsewhere (e.g. emails)`),relations:i.array(i.string()).optional().describe(`Document relations shown; the record's own files if absent`)}).strict(),i.object({...Q,type:i.literal(`forms`),objectName:i.string().optional().describe(`Limits to this object's published forms`)}).strict(),i.object({...Q,type:i.literal(`emails`),emailAttributes:i.array(i.string()).max(N.emailAttributesPerTab).describe(`Addresses`)}).strict(),i.object({...Q,type:i.literal(`meetings`),emailAttributes:i.array(i.string()).max(N.emailAttributesPerTab).describe(`Addresses`)}).strict(),i.object({...Q,type:i.literal(`page`),page:i.object({object:i.string().describe(`Its object`),name:i.string().describe(`Its name`)}).strict().describe(`The record page this tab renders`)}).strict()],un=i.discriminatedUnion(`type`,[sn,...ln]),dn=i.discriminatedUnion(`type`,[cn,...ln]),fn={name:i.string(),label:i.string(),description:i.string().optional(),icon:P.optional()},pn=i.object({x:i.number().describe(`Column`),y:i.number().describe(`Row`),w:i.number().describe(`Width: 3, 4, 6, 8, 9 or 12; x + w ≤ 12`),h:i.number().describe(`Height`)}),mn=pn.strict();function contentViewBaseSchemaFor(e){let t=i.array(e).max(N.tabsPerView);return i.discriminatedUnion(`context`,[i.object({...fn,object:i.string(),context:i.enum([`collection`,`record`]),default:i.boolean().optional(),anchors:i.record(i.string(),i.object({after:i.string()}).strict()).optional(),contents:t}).strict(),i.object({...fn,object:i.string().optional(),context:i.literal(`page`),home:i.boolean().optional(),grid:i.record(i.string(),mn).refine(e=>Object.keys(e).length<=N.tabsPerView,{message:`A page holds at most ${N.tabsPerView} blocks`}),contents:t}).strict()])}const hn=contentViewBaseSchemaFor(un),gn=contentViewBaseSchemaFor(dn);function registryTraits(e,t){return layoutTraitsOf(e,Kt,t)}function addGroupSizeIssues(e,t){for(let n of e.contents){let e=n.type===`group`?groupSizeMessage(n.members.length):void 0;e&&t.addIssue({code:`custom`,message:e,path:[`contents`]})}}function addDuplicateContentNameIssues(e,t){let n=/* @__PURE__ */ new Set;e.contents.forEach((e,r)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate content name "${e.name}"`,path:[`contents`,r,`name`]}),n.add(e.name)})}function addPlacementIssues(e,t){e.contents.forEach((n,r)=>{let i=n.placement===`grid`;e.context===`page`&&!i&&t.addIssue({code:`custom`,message:`Content "${n.name}" of a page must be placed on the grid`,path:[`contents`,r,`placement`]}),e.context!==`page`&&i&&t.addIssue({code:`custom`,message:`Content "${n.name}" cannot be placed on a grid outside a page`,path:[`contents`,r,`placement`]})})}function addIssue(e,t){e.addIssue({code:`custom`,message:t.message,path:[`grid`,...t.path]})}function addGridIssues(e,t,n,r){if(e.context!==`page`||!e.grid)return;let i=new Set(e.contents.map(e=>e.name)),a=groupedMembers(e.contents);for(let n of i)a.has(n)||Object.hasOwn(e.grid,n)||t.addIssue({code:`custom`,message:`Content "${n}" has no grid position`,path:[`grid`]});let o=Object.keys(e.grid).filter(e=>!i.has(e));for(let e of o)t.addIssue({code:`custom`,message:`Grid position "${e}" matches no content`,path:[`grid`,e]});if(e.home&&e.object!==void 0&&t.addIssue({code:`custom`,message:`Only a standalone page can be the home`,path:[`home`]}),o.length>0)return;let s=findGridViolation(e.grid,{exempt:a});if(s){addIssue(t,s);return}if(n===null)return;let c=findGroupViolation(e.contents);if(c){t.addIssue({code:`custom`,message:c.message,path:[`contents`]});return}let l=new Map(e.contents.map(e=>[e.name,e])),u=findLayoutRuleViolation(e.grid,e.contents,e=>n(l.get(e),l),r);u&&addIssue(t,u)}function draftContentViewDefinitionSchemaFor(){return hn.superRefine((e,t)=>{let n=e;addDuplicateContentNameIssues(n,t),addPlacementIssues(n,t),addGridIssues(n,t,null)})}function contentViewDefinitionSchemaFor(e={}){let t=e.traits===void 0?registryTraits:e.traits;return gn.superRefine((n,r)=>{let i=n;addDuplicateContentNameIssues(i,r),addPlacementIssues(i,r),addGridIssues(i,r,t,e.statics),e.viewerFiltered||addGroupSizeIssues(i,r),n.context!==`page`&&!n.contents.some(e=>e.placement===`main`)&&r.addIssue({code:`custom`,message:`A published view requires at least one main content`,path:[`contents`]})})}const _n=draftContentViewDefinitionSchemaFor(),vn=contentViewDefinitionSchemaFor();function isPlainRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const yn=new Set(o),bn=/^[a-zA-Z_][a-zA-Z0-9_]*$/,xn=/^[a-z][a-z0-9-]*$/,Sn=N.labelLength,Cn=i.string().min(1,`Object name cannot be empty`).max(63,`Object name is too long (max 63 characters)`).regex(/^[a-z][a-z0-9-]*$/,{message:`Invalid object name format.
3
- Name must be in kebab-case (slug format):
4
- ✅ Valid: 'products', 'user-profiles', 'order-items'
5
- ❌ Invalid: 'Products', 'userProfiles', 'user_profiles'`});function validateObjectName(e){try{Cn.parse(e)}catch(e){throw e instanceof i.ZodError?new t(e.issues[0].message,n.INVALID_OBJECT_NAME):e}}function validateViewName(e){if(!e||e.length===0)throw new r(`View name cannot be empty`,[{path:[`name`],message:`View name cannot be empty`}]);if(e.length>63)throw new r(`View name is too long`,[{path:[`name`],message:`View name is too long (max 63 characters)`}]);if(!xn.test(e))throw new r(`Invalid view name format`,[{path:[`name`],message:`View name must be in kebab-case (e.g., 'detail', 'list-view')`}])}function assertUniqueBy(e,t,n){let r=/* @__PURE__ */ new Set;for(let i of e){let e=t(i);if(r.has(e))throw n(e);r.add(e)}}const wn=i.string().min(1,`Attribute name cannot be empty`).max(63,`Attribute name is too long (max 63 characters)`).regex(bn,{message:`Invalid attribute name format.
6
- Name must be a valid variable identifier:
7
- ✅ Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'
8
- ❌ Invalid: 'first-name', 'first name', '123name', 'first.name'`}).refine(e=>!M.includes(e),{message:`This is a reserved attribute name. Reserved names: ${M.join(`, `)}`});function validateAttributeName(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute name cannot be empty`);if(e.length>63)throw Error(`[AttributeBuilder] Attribute name is too long (max 63 characters)`);if(!bn.test(e))throw Error(`[AttributeBuilder] Invalid attribute name format.
9
- Name must be a valid variable identifier:
10
- ✅ Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'
11
- ❌ Invalid: 'first-name', 'first name', '123name', 'first.name'`);if(M.includes(e))throw Error(`[AttributeBuilder] "${e}" is a reserved name and cannot be used as an attribute name.\nReserved names: ${M.join(`, `)}`)}function validateLabel(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute label cannot be empty`);if(e.length>Sn)throw Error(`[AttributeBuilder] Attribute label is too long (max ${Sn} characters)`)}function validateIconName(e,t){if(!yn.has(e))throw Error(`[AttributeBuilder] Invalid icon "${e}" in ${t}.\nIcon must be one of the predefined icons from @standards/constants.`)}function validateOptions(e,t){let n=/* @__PURE__ */ new Set;for(let r of t){if(!r.value?.trim())throw Error(`[AttributeBuilder] Option in "${e}" has an empty or missing value.`);if(!r.label?.trim())throw Error(`[AttributeBuilder] Option "${r.value}" in "${e}" has an empty or missing label.`);if(n.has(r.value))throw Error(`[AttributeBuilder] Duplicate option value "${r.value}" in "${e}".`);n.add(r.value)}for(let n of t){if(n.inverse===void 0)continue;let r=t.find(e=>e.value===n.inverse);if(!r)throw Error(`[AttributeBuilder] Option "${n.value}" in "${e}" has inverse "${n.inverse}" which does not match any option value.`);if(r.inverse!==n.value)throw Error(`[AttributeBuilder] Inverse mismatch in "${e}": "${n.value}" points to "${n.inverse}", but "${n.inverse}" points to "${r.inverse??`(none)`}". Inverse pairs must be symmetric.`)}}export{se as ACTIONABLE_DECISION_KINDS,Ft as AGENDA_BLOCK,Ge as AGGREGATE_BUCKETS,We as AGGREGATE_MEASURES,Dt as ARTIFACT_PREVIEW_EXTENSION,D as ATTRIBUTE_FILTER_OPERATORS,wn as ATTRIBUTE_NAME_SCHEMA,Ie as ATTRIBUTE_TYPES,O as ATTRIBUTE_TYPE_DESCRIPTORS,F as BLOCK_CONTEXTS,G as BLOCK_PERIODS,X as BLOCK_WIDTHS,It as CARD_BLOCK,Pt as CHART_BLOCK,At as CHART_KINDS,jt as CHART_ORDERS,Jt as CONTENT_PLACEMENT_CONTEXTS,zt as DECISIONS_BLOCK,l as DECISION_INBOX_STATES,c as DECISION_KINDS,m as DECISION_LINE_MAX_LENGTH,f as DECISION_LINK_TARGET_TYPES,d as DECISION_LIST_STATES,ve as DECISION_READ_STATES,ue as DECISION_SENDER_KINDS,ce as DECISION_SETTINGS_AREAS,ee as DECISION_TITLE_MAX_LENGTH,he as DECISION_TRANSFERS_KEY,oe as DECISION_TYPES_V1,ne as DECISION_TYPE_ACCESS_GRANTED,g as DECISION_TYPE_AGENT_APPROVAL,b as DECISION_TYPE_AGENT_MESSAGE,h as DECISION_TYPE_AGENT_QUESTION,_ as DECISION_TYPE_AGENT_REVIEW,y as DECISION_TYPE_AGENT_ROUTINE_RUN_FAILED,v as DECISION_TYPE_AGENT_SETUP,ae as DECISION_TYPE_BUNDLE_SETUP,S as DECISION_TYPE_CONNECTOR_CONNECTION_ERROR,x as DECISION_TYPE_CONNECTOR_CONNECTION_REAUTH_REQUIRED,C as DECISION_TYPE_CONNECTOR_CONNECTION_SEND_NOT_GRANTED,re as DECISION_TYPE_ENVIRONMENT_BUILD_FAILED,le as DECISION_TYPE_KINDS,ie as DECISION_TYPE_PERSON,w as DECISION_TYPE_RECORD_ASSIGNED,te as DECISION_TYPE_RECORD_MENTIONED,u as DECISION_WORK_STATES,Z as DEFAULT_LAYOUT_TRAITS,kt as GROUPABLE_ATTRIBUTE_TYPES,Rt as HEADING_BLOCK,T as HIERARCHY_ATTRIBUTE_IDS,we as HIERARCHY_ATTRIBUTE_NAMES,Te as HIERARCHY_CHILD_IDS_LIMIT,Qt as INVENTORY_LIMIT,Be as LIST_VIEW_TAB_VISIBILITIES,E as LOCATION_FILTER_PROPERTIES,Vt as MAILBOX_BLOCK,Ue as MAX_AGGREGATE_GROUPS,Ot as MEASURABLE_ATTRIBUTE_TYPES,Bt as MEETINGS_UPCOMING_BLOCK,Nt as METRIC_BLOCK,Ut as NATIVE_BLOCKS,k as NATIVE_OBJECT_NAMES,ze as NO_VALUE_OPERATORS,Cn as OBJECT_NAME_SCHEMA,Re as OPERATORS_BY_TYPE,qt as PAGE_GRID_COLUMNS,et as QUALIFIED_SEPARATOR,K as QUERY_OBJECT,Y as RECORD_LINKS_BLOCK,Ht as RECORD_LINKS_CONTENT,j as RECORD_LIST_SCOPES,Et as RECORD_OBJECT,Le as RELATION_TARGET_ANY,B as REMOVED_OPERATOR_REPLACEMENTS,M as RESERVED_ATTRIBUTE_NAMES,He as RESERVED_OBJECT_NAMES,A as RESOURCE_VISIBILITIES,RecordQuery,N as SCHEMA_LIMITS,it as SYNONYM_ALIASES,Ce as SYSTEM_ATTRIBUTES,Se as SYSTEM_ATTRIBUTE_I18N_KEYS,Ve as SYSTEM_FIELD_NAMES,ct as SYSTEM_FILTER_ATTRIBUTE_TYPES,Lt as TEXT_BLOCK,Mt as UNORDERED_CHART_KINDS,assertUniqueBy,attributeFilterTarget,attributeInventory,blockObjectInputs,brandedString,buildQualifiedAttribute,canonicalizeFilterValue,capped,collectContentViewCatalogue,collectQualifiedRuleIssues,W as collectionContentSourceSchema,collectionSourceAddress,collectionSourceAddressOf,Je as colorIdSchema,pt as columnsSchema,Kt as contentExtensionRegistry,contentReadObjects,vn as contentViewDefinitionSchema,contentViewDefinitionSchemaFor,currentActor,be as decisionArchiveAllResultSchema,pe as decisionAttachmentSchema,ye as decisionCountsSchema,decisionHandedBy,p as decisionLinkSchema,_e as decisionListResultSchema,me as decisionRecipientSchema,fe as decisionSchema,de as decisionSenderSchema,decisionThreadKey,decisionTransferBy,xe as decisionTransferTargetsSchema,decisionTransferTo,decisionTransfersOf,ge as decisionWithRecipientSchema,decodeOperationOutput,defineBlock,describeViewIssue,mt as displayAttributesSchema,_n as draftContentViewDefinitionSchema,draftContentViewDefinitionSchemaFor,edgePropertyFilterTarget,extractCurrencyFilterValue,extractFilterValue,filterOperatorsOfType,U as filterStateSchema,filterTargetsOf,findGridViolation,findGroupViolation,findLayoutRuleViolation,findRelationAttribute,findRowLimitViolation,formatDecisionLink,getAttributeCapabilities,getAttributeFilterOperators,getHierarchyAttributes,getObjectSystemAttributes,getOperatorPolarity,getRollupFilterOperators,getSystemAttributeI18nKey,getSystemAttributeList,pn as gridPositionReadSchema,mn as gridPositionSchema,groupSizeMessage,groupedMembers,hasTypeTrait,hasValueKind,P as iconNameSchema,inferInverseCardinality,q as input,invalidViewMessage,isActionableDecisionKind,isAttributeFilterable,isAttributeGroupable,isAttributeKanbanGroupable,isAttributeSearchable,isAttributeSortable,isBilateralRelation,isBoardGrouping,isCalendarDay,isCollectionContent,isDynamicValue,isHierarchyAttribute,isLocationFilterProperty,isLocationPartOperator,isManagedSystemAttribute,isNativeObjectName,isNoValueOperator,isPlainRecord,isRelativeDateValue,isSetMembershipOperator,isUniversalRelation,isValueKindType,s as isoDateTime,layoutTraitsOf,locationPartFilterTarget,memberlessGroups,metricComparePeriod,normalizeFilterRule,normalizeForEdgeRpc,normalizeOperator,now,outputSchemaOf,overlaps,pageTraitsOf,parseBlockParameters,parseDecisionLink,parseQualifiedAttribute,parseRecordListScope,parseResourceVisibility,dn as publishedViewContentDefinitionSchema,query,Tt as recordQueryDefinitionSchema,relationAcceptsObject,relationTargetsOf,requireContentPlacement,requireRecordContentContext,requireSingleRelationTarget,resolveCollectionActions,resolveContentNavigation,resolveEffectiveFilterType,resolveIsWithinBounds,resolveUtcDayBounds,singleRelationTarget,H as sortsSchema,sourcedAttributeOf,systemColumnFilterTarget,toMultiValueOperator,toUtcDayString,today,unchecked,validateAttributeName,validateContentViewCatalogue,validateIconName,validateLabel,validateObjectName,validateOptions,validateQualifiedRule,validateStoredViews,validateViewName};