@standards/schema 1.0.0-alpha.416 → 1.0.0-alpha.419

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 (51) hide show
  1. package/dist/all-BFZvSwku.mjs +4 -0
  2. package/dist/all-CcI67hiC.d.mts +4305 -0
  3. package/dist/all-cpt9cxka.d.ts +4306 -0
  4. package/dist/all-kYfkyIit.js +4 -0
  5. package/dist/api/index.d.mts +2779 -2131
  6. package/dist/api/index.d.ts +2780 -2132
  7. package/dist/api/index.js +1 -1
  8. package/dist/api/index.mjs +1 -1
  9. package/dist/{exceptions-BIqEbF4H.d.mts → exceptions-C3d0YoMy.d.mts} +11 -6
  10. package/dist/{exceptions-BIqEbF4H.d.ts → exceptions-DzEpWPJ7.d.ts} +12 -6
  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-DXlk2RRR.d.ts → index-D59FeAd4.d.mts} +1979 -1946
  16. package/dist/{index-55_ovYJ8.d.mts → index-DhzoMOYA.d.ts} +5253 -5220
  17. package/dist/index.d.mts +5 -5
  18. package/dist/index.d.ts +5 -5
  19. package/dist/index.js +2 -2
  20. package/dist/index.mjs +2 -2
  21. package/dist/{primitives-DpBFjzxV.mjs → primitives-B-h9MEQ4.mjs} +3 -3
  22. package/dist/primitives-CvuPz5hX.js +11 -0
  23. package/dist/record-operation-BYjGrZ1R.js +2 -0
  24. package/dist/record-operation-q6w-3EDJ.mjs +2 -0
  25. package/dist/rolldown-runtime-CirMkZhQ.mjs +2 -0
  26. package/dist/{utils-iNW5feob.d.ts → utils-Bl7NhRVP.d.mts} +2 -7
  27. package/dist/utils-CZwl7iUo.js +2 -0
  28. package/dist/utils-DKrBP9EH.mjs +2 -0
  29. package/dist/{utils-CIVBFpC3.d.mts → utils-YUFgn36U.d.ts} +2 -7
  30. package/dist/utils.d.mts +1 -1
  31. package/dist/utils.d.ts +1 -1
  32. package/dist/utils.js +1 -1
  33. package/dist/utils.mjs +1 -1
  34. package/dist/validation/all.d.mts +9 -1
  35. package/dist/validation/all.d.ts +9 -1
  36. package/dist/validation/all.js +1 -1
  37. package/dist/validation/all.mjs +1 -1
  38. package/dist/zod-locale.d.ts +1 -1
  39. package/openapi.json +24996 -0
  40. package/package.json +10 -8
  41. package/dist/all-Bldqj4jl.d.ts +0 -4360
  42. package/dist/all-C27HT84u.mjs +0 -4
  43. package/dist/all-CmG4j3B_.d.mts +0 -4360
  44. package/dist/all-CwXmuXAG.js +0 -4
  45. package/dist/primitives-DQwhUe8S.js +0 -11
  46. package/dist/record-operation-DM8ZJvmH.mjs +0 -2
  47. package/dist/record-operation-uV-n22Y9.js +0 -2
  48. package/dist/rolldown-runtime-l_U0UDb-.mjs +0 -2
  49. package/dist/utils-B-gGq3FS.js +0 -2
  50. package/dist/utils-DaejNWxh.mjs +0 -2
  51. package/dist/zod-locale-D_QkXhnp.d.ts +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
- const e=require("./primitives-DQwhUe8S.js"),t=require("./exceptions.js");require("./zod-locale.js");let n=require("zod");n=e.__toESM(n);let r=require("@standards/constants"),i=require("libphonenumber-js");const a=[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`],o=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_empty`,`is_not_empty`],s=[`is`],c=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`is_empty`,`is_not_empty`],l=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],u=[`any_of`,`none_of`,`is_empty`,`is_not_empty`],d=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],f=[`is_empty`,`is_not_empty`],ee=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`contains`,`not_contains`,`is_empty`,`is_not_empty`],p=[`city`,`postalCode`,`country`];function isLocationFilterProperty(e){return p.includes(e)}const m={text:a,richtext:[],number:o,checkbox:s,date:c,phone:[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`is_empty`,`is_not_empty`],currency:o,status:l,select:l,multiselect:u,location:[],user:d,relation:d,formula:ee,document:f},h={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(h,e)?h[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 te={plain:`static`,boolean:`automatic`,options:`static`,reference:`static`,computed:`forbidden`};function getAttributeCapabilities(t){let n=!!(t.hidden||t.archived),r=!t.archived,i=descriptorOf(t.type)?.value,a=i===`computed`,o=t.type===`document`,s=i===`reference`&&!e.isHierarchyAttribute(t),c=getAttributeCardinality(t),l=n?[]:getRawFilterOperators(t),u=l.length>0&&!n,d=!n&&hasTypeTrait(t.type,`searchable`),f=!n&&hasTypeTrait(t.type,`sortable`),ee=!n&&hasTypeTrait(t.type,`groupable`),p=!n&&t.type===`status`,m=e.isManagedSystemAttribute(t),h=a||o||m,g=!(n||h),ne=i===void 0?`forbidden`:te[i],_=i===`boolean`||a?`forbidden`:`allowed`,v=supportsMaxItems(t),y=hasTypeTrait(t.type,`placeholder`),b=hasTypeTrait(t.type,`content`),x=!(!t.deprecated||n),re=resolveEditMode(t);return{lifecycle:{active:r,deprecated:!!t.deprecated,visibleInArchitect:!0,visibleInRuntime:!n,warningWhenDeprecated:x},storage:{mode:a?`computed`:s?`edge`:`value`,cardinality:c,edgeBacked:s,preservesExistingValues:!!t.archived,qualifiedProperties:hasTypeTrait(t.type,`qualified`),polymorphic:getPolymorphicCapability(t),maxItems:v},authoring:{editable:g,readOnly:h,directEdit:g&&re===`inline`,required:_,defaultValue:ne,placeholder:y,maxItems:v},presentation:{formField:!n&&t.type!==`richtext`,tableCell:!(n||b),defaultColumn:!(n||b),compactDisplay:!n,popoverEditor:!n&&re===`popover`,placeholder:y,warningWhenDeprecated:x},query:{filterable:u,searchable:d,sortable:f,groupable:ee,kanbanGroupable:p,operators:l},agent:{readable:!n,writable:g&&!o,compactReadable:!n,contentReadable:!n&&b,requiresDedicatedTool:o},exchange:{importable:!n,exportable:!n,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)?m[t]:m.number}function getRawFilterOperators(e){return e.type===`rollup`?getRollupFilterOperators$1(e):m[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(m,e)}const g=[`text`,`richtext`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`location`,`select`,`multiselect`,`user`,`relation`,`formula`,`rollup`,`document`];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 ne=m,_=[`is_empty`,`is_not_empty`];function isNoValueOperator(e){return _.includes(e)}function getRollupFilterOperators(e){return getRollupFilterOperators$1(e)}const v=[`text`,`number`,`boolean`,`date`,`select`,`multiselect`];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 y={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 b={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?b[e.format]:void 0}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 x={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=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 re=createRegexCache();function createTextValidator(e,t=x){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(re,i),t.invalidPattern(e))),r}function createNumberValidator(e,t=x){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=x){return n.boolean()}function resolveBound(e){if(!e)return null;let t=e===`today`?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=x){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);if(Number.isNaN(n.getTime())){t.addIssue({code:`custom`,message:r});return}i&&n<i&&t.addIssue({code:`custom`,message:r}),a&&n>a&&t.addIssue({code:`custom`,message:r})});if(!e.endDate)return o;let s=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,s)}const S=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()}),C=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`],ie={icon:e.iconNameSchema.optional().describe(`Field icon from search_icons`)},ae={date:[`precision`],user:[`notifiesOnAssign`,`actors`]};function wireOmittedConfigKeysFor(e){return[...C,...ae[e]??[]]}function wireHiddenTypeConfigMask(e){return Object.fromEntries((ae[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 w=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()}),T=n.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),E=w.extend({color:e.colorIdSchema}).strict(),oe=w.extend({color:e.colorIdSchema,group:T}).strict(),D=w.extend({color:n.string().optional().describe(`A color id`),group:T.optional()}).strict(),se=new Set(D.keyof().options),ce=[`options`,`targetAttributeOptions`];function withoutUnknownOptionKeys(t){let n=t;for(let r of ce){let i=t[r];if(!Array.isArray(i))continue;let a=!1,o=i.map(t=>!e.isPlainRecord(t)||Object.keys(t).every(e=>se.has(e))?t:(a=!0,Object.fromEntries(Object.entries(t).filter(([e])=>se.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 O=n.array(D).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 le=writeOptionsArraySchema(E),ue=writeOptionsArraySchema(E),de=writeOptionsArraySchema(oe),fe=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`)}),pe=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`)}),me=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`)}),he=S.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()}),ge=S,_e=S.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()}),ve=S,ye=S.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()}),be=S.extend({defaultCountryCode:n.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),xe=S.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()}),Se=S.extend({options:O.describe(`The workflow statuses, in order`)}),Ce=S.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()}),k=S.extend({options:O.describe(`Options`),renderAs:n.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),A=S.extend({options:O.describe(`Options`),renderAs:n.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),we=S.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`)}),j={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()},Te={id:n.string().optional(),objectId:n.string().optional(),system:n.boolean().optional(),unique:n.boolean().optional()},Ee=Object.fromEntries(C.map(e=>[e,!0])),M=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],De=[...M,`select`,`multiselect`,`status`],Oe={text:he,number:_e,checkbox:ve,date:ye,phone:be,currency:xe,location:Ce,select:k,multiselect:A,status:Se},ke={...Oe,select:k.extend({options:le.describe(`Options`)}),multiselect:A.extend({options:ue.describe(`Options`)}),status:Se.extend({options:de.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>ke[e].omit(Ee).omit(wireHiddenTypeConfigMask(e)).shape,storedPropertyMember=e=>n.object({...j,...Te,type:n.literal(e).describe(`Property type`),...Oe[e].shape}).strip(),Ae=n.discriminatedUnion(`type`,De.map(storedPropertyMember)),N=n.object({definitions:n.array(Ae).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`),je=refuseForeignKeys(Object.fromEntries(De.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(j),`type`]);function refuseForeignPropertyKeys(e,t){je(e.type,e,t)}const Me=M.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>n.object({...j,type:e.length===1?n.literal(e[0]).describe(`Property type`):n.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),Ne=n.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),n.object({...j,type:n.enum(M).describe(`Property type`),...Me}).strict().superRefine(refuseForeignPropertyKeys)]),Pe=n.object({definitions:n.array(Ne).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`),Fe=S.extend({targets:n.array(fe).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:pe.optional().describe(`Syncs the other side's attribute`),properties:N.optional()}),Ie=S.extend({expression:n.string().min(1).describe(`The formula expression, compiled against this object's attributes`),returnType:n.enum(v).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:me.optional().describe(`Mirrors an option set`)}),Le=S.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(D).optional().describe(`Server-set`),targetCurrencyCode:n.string().length(3).optional().describe(`Server-set`),optionsSource:me.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 Re={text:he,richtext:ge,number:_e,checkbox:ve,date:ye,phone:be,currency:xe,status:Se,location:Ce,select:k,multiselect:A,user:we,relation:Fe,formula:Ie,rollup:Le,document:S.extend({properties:N.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=Re[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:le.describe(`Options`)});case`multiselect`:return n.extend({options:ue.describe(`Options`)});case`status`:return n.extend({options:de.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(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 a=e.options;isValueKindType(e.type,`options`)&&(i.options=[{value:`__legacy__`,label:`__legacy__`}]);let o=getAttributeConfigSchema(e.type).strip().safeParse(i);if(!o.success)throw validationErrorFromIssues(o.error.issues);let s=o.data,c=datePrecisionIssues(e.type,s);if(c.length>0)throw validationErrorFromIssues(c);return isValueKindType(e.type,`options`)&&(s.options=a),s}function createCurrencyValidator(e,t=x){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=x){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=x){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=x){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=x){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=x){return e.cardinality===`many`?createMultiRelationValidator(e,t):createSingleRelationValidator(e,t)}function createRichtextValidator(e,t=x){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=x){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=x){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=x){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=x){let r=n.guid({message:t.invalidId(e)});return e.multiple?n.array(r):r}function createFormulaValidator(e,t=x){return n.unknown()}function createRollupValidator(e,t=x){return n.unknown()}function createAttributeValidator(e,t=x){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=x){let n=createAttributeValidator(e,t);return e.required?n:withEmptyToNull(n,y[e.type])}const ze=new WeakMap,Be=new WeakMap;function createObjectValidator(e){let t=ze.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:x.required(t)}):r[t.name]=withEmptyToNull(e,y[t.type])}let i=n.object(r).passthrough();return ze.set(e,i),i}function createDraftValidator(e){let t=Be.get(e);if(t)return t;let r={};for(let t of e.attributes){let e=createAttributeValidator(t);r[t.name]=withEmptyToNull(e,y[t.type])}let i=n.object(r).passthrough();return Be.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`})))}const P=[`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:n.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,n,r){let i=e.parameters.safeParse(structuredClone(n??{}));if(!i.success)throw t.ValidationError.fromZodErrors(i.error.issues.map(e=>({path:[...r,...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 Ve=/^\d{4}-\d{2}-\d{2}$/u;function isCalendarDay(e){if(!Ve.test(e))return!1;let t=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 He=new Set([`is_not`,`not_contains`,`none_of`,`is_empty`]),Ue={is_not:`is`,not_contains:`contains`,none_of:`any_of`,is_empty:`is_not_empty`};function getOperatorPolarity(e){return He.has(e)?`none`:`any`}function normalizeForEdgeRpc(e){return Ue[e]??e}const We={is:`any_of`,is_not:`none_of`};function toMultiValueOperator(e){return We[e]??e}const Ge=new Set(Object.values(We).filter(e=>e!==void 0));function isSetMembershipOperator(e){return Ge.has(e)}function canonicalizeFilterValue(e,n){let r=e.value;if(isNoValueOperator(e.operator)||r==null||isDynamicValue(r))return;if(isSetMembershipOperator(e.operator)){Array.isArray(r)||(e.value=[r]);return}if(n!==`currency`)return;let i=extractCurrencyFilterValue(r);if(i!==null){e.value=i;return}if(!hasCurrencyAmount(r))return;let a=`Filter on a currency attribute expected a numeric amount, received ${JSON.stringify(r)}`;throw new t.ValidationError(a,[{path:[`value`],message:a}])}function hasCurrencyAmount(e){return typeof e!=`object`||`value`in e&&e.value!=null}const F=m.text,Ke=[`is`,`is_not`,`is_empty`,`is_not_empty`],I=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],L={id:I,objectId:I,tenantId:I,label:m.text,createdAt:m.date,updatedAt:m.date,deletedAt:m.date,createdBy:m.user,lastUpdatedBy:m.user,parentId:I,childIds:[`is_empty`,`is_not_empty`]},qe=new Set([`createdAt`,`updatedAt`,`deletedAt`]);function offeredOn(e,t){return qe.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(t){let n=e.isHierarchyAttribute(t)?systemColumnFilterTarget(t.name):void 0;if(n)return n;let r=getAttributeFilterOperators(t);return{target:t.name,attribute:t.name,operators:r,offered:offeredOn(t.name,r)}}function locationPartFilterTarget(e,t){return{target:buildQualifiedAttribute(e,t),attribute:e,property:t,operators:F,offered:t===`country`?Ke:F}}function edgePropertyFilterTarget(e,t){let n=hasOperatorEntry(t.type)?m[t.type]:[];return fullyOffered(buildQualifiedAttribute(e,t.name),e,n,t.name)}function hasOperatorEntry(e){return Object.prototype.hasOwnProperty.call(m,e)}function systemColumnFilterTarget(e){let t=Object.prototype.hasOwnProperty.call(L,e)?L[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 g.includes(e)}function isLocationPartOperator(e){return F.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 p)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(L)){if(n.has(e))continue;let r=systemColumnFilterTarget(e);r&&t.push(r)}return t.filter(e=>e.operators.length>0)}const Je={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 Je[e]??e}function normalizeFilterRule(e){let t=normalizeOperator(e.operator);return t===e.operator?e:{...e,operator:t}}const R=864e5,Ye=new Set([`days`,`weeks`,`months`,`years`]),Xe=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`&&Ye.has(t.unit)&&typeof t.direction==`string`&&Xe.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*R;if(n===`weeks`)return e+t*7*R;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=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+R}:{startMs:n,endMs:shiftUtcDay(n,r,e.unit)+R};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+R}:null}function toUtcDayString(e){return new Date(e).toISOString().slice(0,10)}const Ze=new Set([`relation`,`document`,`user`]),Qe={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`},z={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"`},$e=new Set(Object.entries(m).filter(([,e])=>e.includes(`any_of`)&&!e.includes(`contains`)).map(([e])=>e)),et={contains:`any_of`,not_contains:`none_of`};function resolveCanonicalOperator(e,n){let r=z[e];if(r){let n=`Unknown filter operator "${e}" — use ${r}`;throw new t.ValidationError(n,[{path:[`operator`],message:n}])}let i=normalizeOperator(e),a=et[i];if(a&&$e.has(n)){let e=`Operator "${i}" is not valid for type "${n}" — use "${a}"`;throw new t.ValidationError(e,[{path:[`operator`],message:e}])}return i}function assertPropertyOperator(e,n,r){let i=resolveCanonicalOperator(e,n);if(!r.includes(i)){let i=`Operator "${e}" is not valid for property type "${n}". Valid operators: ${r.length?r.join(`, `):`(no operators registered for this type)`}.`;throw new t.ValidationError(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 t.ValidationError(e,[{path:[`value`],message:e}])}}const tt=/^(\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)?))?)?$/,nt=new Set([`is`,`is_not`,`less_than`,`less_or_equal`,`greater_than`,`greater_or_equal`]);function assertAbsoluteDateValue(e,n){if(n!==`date`||!nt.has(e.operator))return;let r=e.value;if(r==null||isDynamicValue(r)||typeof r==`string`&&isCastableDay(r))return;let i=`Filter on a date attribute expected a YYYY-MM-DD day, optionally followed by a time, received ${JSON.stringify(r)}`;throw new t.ValidationError(i,[{path:[`value`],message:i}])}function isCastableDay(e){let t=tt.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,n){if(!isDynamicValue(e.value))return;let r=e.value;if(r.dynamic===`actor`&&n!==`user`){let e=`actor token (@me) is only valid on user attributes, not "${n}"`;throw new t.ValidationError(e,[{path:[`value`],message:e}])}if(r.dynamic===`date`&&n!==`date`){let e=`date token (@today/@now) is only valid on date attributes, not "${n}"`;throw new t.ValidationError(e,[{path:[`value`],message:e}])}}const B=p.map(e=>`"${e}"`).join(`, `);function operatorList(e){return e.length?e.join(`, `):`(not filterable)`}function qualifyWithSchema(e){if(Ze.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 ${B} 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 ${B}`}.`;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,n){try{return validateQualifiedRule({...e},n),[]}catch(e){if(!(e instanceof t.ValidationError))throw e;return e.errors.map(e=>({...e,path:[...e.path]}))}}function validateQualifiedRule(e,n){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 t.ValidationError(e,[{path:[`attribute`],message:e}])}let r=n.attributes.find(t=>t.name===e.attribute),i=r?[]:systemColumnFilterTarget(e.attribute)?.operators??[];if(!r&&i.length===0){let[r,...i]=e.attribute.split(`.`),a=i.length>0?n.attributes.find(e=>e.name===r):void 0,o=a?dottedPathHint(r??``,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 t.ValidationError(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 t.ValidationError(e,[{path:[`quantifier`],message:e}])}if(!r){if(e.property)throw new t.ValidationError(`Cannot qualify system attribute "${e.attribute}"`,[{path:[`property`],message:`"${e.attribute}" is a system column, not a reference`}]);let n=Qe[e.attribute]??`text`,r=resolveCanonicalOperator(e.operator,n);if(!i.includes(r)){let n=`Operator "${e.operator}" is not valid for system attribute "${e.attribute}". Valid operators: ${i.join(`, `)}.`;throw new t.ValidationError(n,[{path:[`operator`],message:n}])}applyCanonicalForm(e,r,n);return}if(!e.property){assertDynamicValueForAttribute(e,r.type);let n=attributeFilterTarget(r).operators,i=resolveCanonicalOperator(e.operator,r.type);if(!n.includes(i)){let i=`Operator "${e.operator}" is not valid for attribute "${r.name}". Valid operators: ${operatorList(n)}.${locationPartsHint(r.type)}`;throw new t.ValidationError(i,[{path:[`operator`],message:i}])}applyCanonicalForm(e,i,resolveComparandType(r));return}if(r.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 t.ValidationError(e,[{path:[`quantifier`],message:e}])}if(!isLocationFilterProperty(e.property)){let n=`Property "${e.property}" is not a part of location "${e.attribute}". Valid parts: ${B}.`;throw new t.ValidationError(n,[{path:[`property`],message:n}])}assertDynamicValueForAttribute(e,`text`);let{operators:n}=locationPartFilterTarget(r.name,e.property);applyCanonicalForm(e,assertPropertyOperator(e.operator,`text`,n),`text`);return}if(!Ze.has(r.type))throw new t.ValidationError(`Cannot qualify ${r.type} attribute "${e.attribute}"`,[{path:[`property`],message:`Attribute "${e.attribute}" is not a reference type`}]);let a=r.properties;if(!a)throw new t.ValidationError(`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 t.ValidationError(`Property "${e.property}" not defined on "${e.attribute}".qualifyWith()`,[{path:[`property`],message:`Unknown property: ${e.property}`}]);let{operators:s}=edgePropertyFilterTarget(r.name,o);applyCanonicalForm(e,assertPropertyOperator(e.operator,o.type,s),o.type)}const rt=n.array(n.string()).max(e.SCHEMA_LIMITS.columnsPerTab),it=n.array(n.string().min(1)).max(e.SCHEMA_LIMITS.columnsPerTab).refine(e=>new Set(e).size===e.length,{message:`Displayed attribute names must be unique`}),at=n.object({attribute:n.string().describe(`Attribute to sort by`),direction:n.enum([`asc`,`desc`]).describe(`asc or desc`)}).strict(),V=n.array(at).max(e.SCHEMA_LIMITS.sortsPerTab),ot=n.object({amount:n.number().describe(`Count`),unit:n.enum([`days`,`weeks`,`months`,`years`]).describe(`Unit`),direction:n.enum([`past`,`future`]).describe(`Past or future`)}).strict(),st=n.object({value:n.number().nullable().describe(`Amount`),code:n.array(n.string()).optional().describe(`Currency codes`)}).strict(),ct=n.object({phoneNumber:n.string().nullable().describe(`Number`),countryCode:n.string().optional().describe(`ISO country code`)}).strict(),lt=n.discriminatedUnion(`dynamic`,[n.object({dynamic:n.literal(`actor`).describe(`Resolved at filter time`),ref:n.literal(`current`).describe(`The current actor`)}).strict(),n.object({dynamic:n.literal(`date`).describe(`Resolved at filter time`),anchor:n.enum([`today`,`now`]).describe(`Anchor`)}).strict()]),ut=n.object({month:n.number().describe(`1-12`),day:n.number().describe(`Day`)}).strict(),dt=n.union([n.string(),n.number(),n.boolean(),n.array(n.string()),ot,st,ct,ut,lt,n.null()]),ft=n.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`?z[t]:void 0;return n?`Unknown filter operator "${t}" — use ${n}`:void 0}}),pt=n.object({attribute:n.string().describe(`Attribute to filter on`),property:n.string().optional().describe(`Qualified edge property`),quantifier:n.enum([`any`,`none`]).optional().describe(`For a multi-value attribute`),operator:ft.describe(`Comparison`),value:dt.describe(`Comparison value, by attribute type`)}).strict(),mt=n.array(pt).max(e.SCHEMA_LIMITS.filterRulesPerTab),H=n.object({combinator:n.enum([`and`,`or`]).describe(`Match every rule or any rule`),rules:mt.describe(`The rules`)}).strict(),U=n.object({object:n.string().optional().describe(`Every record of this object`),relation:n.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}),ht=n.object({source:U,filters:H.optional(),sorts:V.optional(),limit:n.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 W=[`day`,`week`,`month`,`quarter`,`year`],G=`$query`,gt=`$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:n.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 n.string().min(1)}const K={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`,ht,e),record:e=>scalar(`record`,name(),e),agent:()=>scalar(`agent`,name()),routine:()=>scalar(`routine`,name()),view:()=>scalar(`view`,name()),url:()=>scalar(`url`,n.url().refine(e=>/^https?:\/\//.test(e),`Only http(s) links`)),emailCategory:()=>scalar(`emailCategory`,name()),enum:e=>createInput({kind:`enum`,isOptional:!1,isMany:!1,schema:n.enum(e)}),text:()=>scalar(`text`,name()),number:()=>scalar(`number`,n.number()),boolean:()=>scalar(`boolean`,n.boolean()),period:()=>scalar(`period`,n.enum(W))},q={size:{w:4,h:4},minWidth:3,height:`flexible`,minHeight:3,maxHeight:10},_t=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:{}}),vt=[`number`,`currency`],J=[`status`,`select`,`user`,`relation`,`date`],yt=[`bar`,`horizontal_bar`,`line`,`area`,`donut`,`funnel`,`treemap`,`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`}}function measuredInputs(){return{query:K.query(),measure:K.enum(e.AGGREGATE_MEASURES).inSection(`data`),attribute:K.attribute(G,{types:vt}).optional().showWhen(`measure`,{not:[`count`]}),label:K.text().optional()}}function metricComparePeriod(e){if(e.period)return e.period;if(!e.trendBucket)return`month`;let t=W.indexOf(e.trendBucket);return W[Math.min(t+1,W.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===W.at(-1))return{input:`compare`,message:`compare needs a trendBucket finer than year`};let i=metricComparePeriod({trendBucket:r,period:e.period});return W.indexOf(i)>W.indexOf(r)?void 0:{input:`period`,message:`period must be wider than trendBucket (unset, it is one step above)`}}const bt=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:K.attribute(G,{types:[`date`]}).optional().inSection(`display`),trendBucket:K.period().optional().showWhen(`trend`),compare:K.enum([`previous_period`]).optional(),period:K.period().optional().showWhen(`compare`),target:K.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)}),xt=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:K.enum(yt),by:K.attribute(G,{types:J}).optional(),byBucket:K.period().optional().inSection(`data`).showWhen(`by`),by2:K.attribute(G,{types:J}).optional().showWhen(`by`),by2Bucket:K.period().optional().inSection(`data`).showWhen(`by2`)},refine:e=>measureIssue(e)??requires(e,`byBucket`,`by`)??requires(e,`by2`,`by`)??requires(e,`by2Bucket`,`by2`)??kindIssue(e)}),St=defineBlock({name:`agenda`,label:`Agenda`,icon:`calendar`,family:`data`,contexts:[`page`,`record`,`display`],layout:q,inputs:{query:K.query(),attribute:K.attribute(G,{types:[`date`]}),next:K.number().optional(),yearly:K.boolean().optional(),label:K.text().optional()}}),Ct=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:K.object().optional(),record:K.record().optional(),fields:K.attribute(gt).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)}),wt=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:K.text()}}),Tt=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:K.text(),description:K.text().optional(),icon:K.text().optional()}}),Et=defineBlock({name:`decisions`,label:`Décisions`,icon:`inbox`,family:`people`,contexts:[`page`],layout:q,inputs:{kinds:K.enum(e.DECISION_KINDS).inSection(`data`).many().optional(),limit:K.number().optional()}}),Dt=defineBlock({name:`meetings_upcoming`,label:`Réunions à venir`,icon:`video`,family:`people`,contexts:[`page`],layout:q,inputs:{limit:K.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`}}),Ot=defineBlock({name:`mailbox`,label:`E-mails`,icon:`envelope`,family:`people`,contexts:[`page`],layout:q,inputs:{category:K.emailCategory().optional(),important:K.boolean().optional().inSection(`data`),unread:K.boolean().optional().inSection(`data`),limit:K.number().optional(),label:K.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:K.enum([`record`,`me`]).optional().inSection(`data`),object:K.object().optional(),record:K.record().optional(),depth:K.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)}),kt={name:`bubble`,type:`custom`,extension:Y.name,placement:`main`,label:Y.label,icon:Y.icon,parameters:{}},At=[_t,bt,xt,St,Ct,wt,Tt,Et,Dt,Ot,Y],jt=new Set([`name`,`label`,`icon`,`family`,`contexts`,`inputs`,`parameters`,`layout`,`refine`]),Mt=At;var ContentExtensionRegistry=class{constructor(){this.extensions=new Map,this.seed()}register(e){let n=Array.isArray(e)?e:[e],r=new Set;n.forEach((e,n)=>{if(this.prepare(e,n),r.has(e.name))throw new t.DuplicateError(`content extension`,e.name);r.add(e.name)});for(let e of n)this.extensions.set(e.name,e);return this}prepare(e,n){let r=[`extensions`,String(n)],reject=e=>{throw new t.ValidationError(e,[{path:r,message:e}])};if((typeof e!=`object`||!e||Array.isArray(e))&&reject(`Expected a content extension declaration`),Object.keys(e).some(e=>!jt.has(e))&&reject(`Expected only ${[...jt].join(`, `)}`),(typeof e.name!=`string`||e.name.trim().length===0)&&reject(`API name must not be empty`),(!Array.isArray(e.contexts)||e.contexts.length===0||e.contexts.some(e=>!P.includes(e)))&&reject(`contexts must be a non-empty list of ${P.join(`, `)}`),typeof e.parameters?.safeParse!=`function`&&reject(`parameters must be a Zod schema`),this.extensions.has(e.name))throw new t.DuplicateError(`content extension`,e.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 Mt)this.extensions.set(e.name,e)}};const Nt=new ContentExtensionRegistry,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=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(t){return t>=2&&t<=e.SCHEMA_LIMITS.membersPerGroup?void 0:`A group holds 2 to ${e.SCHEMA_LIMITS.membersPerGroup} blocks, not ${t}`}function findGroupViolation(e){let t=new Map(e.map(e=>[e.name,e])),n=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(t){let n=Object.entries(t).find(([,t])=>t.y+t.h>e.SCHEMA_LIMITS.pageRows);if(n===void 0)return;let[r,i]=n;return{path:[r],message:`Block "${r}" ends at row ${i.y+i.h}, past the page's ${e.SCHEMA_LIMITS.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=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,n=[e.name,`targets`]){let r=singleRelationTarget(e);if(r===void 0){let r=`Relation "${e.name}" requires one concrete collection target`;throw new t.ValidationError(r,[{path:n,message:r}])}return r}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,n,r){if(n!==`record`){let i=`Content "${e}" requires record context. In ${n===`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 t.ValidationError(i,[{path:r,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 Pt={collection:[`page`,`record`,`display`],group:[`page`,`record`],form:[`record`],activity:[`record`],richtext:[`record`],documents:[`record`],forms:[`record`],emails:[`record`],meetings:[`record`]},Z={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=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`]:Pt[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 Ft=new WeakSet;function violationOf(e,n,r,i){if(!(e instanceof t.SchemaError))throw e;let a=e instanceof t.ValidationError?e.errors[0]:void 0;return{key:JSON.stringify([n,r,e.code,Ft.has(e)?`Invalid content view`:e.message]),contentName:r,path:a?.path??i,message:e.message,code:e.code,error:e}}const It=systemAttributeMap({name:``});function systemAttributeMap(t){return new Map(e.getObjectSystemAttributes(t).map(e=>[e.name,e]))}function reject(e,n){throw new t.ValidationError(n,[{path:e,message:n}])}function requireName(e,t){e.trim().length===0&&reject(t,`API name must not be empty`)}function indexUnique(e,n,r){let i=new Map;return e.forEach((e,a)=>{if(requireName(e.name,[...r,String(a),`name`]),i.has(e.name))throw new t.DuplicateError(n,e.name);i.set(e.name,e)}),i}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(t,n,r,i,a){if(requireName(n,r),!t)return;let o=t.attributes?.get(n)??(t.system??It).get(n);if(!o){if(!t.attributes||e.HIERARCHY_ATTRIBUTE_NAMES.has(n))return;let i=attributeInventory(t.name,[...t.attributes.keys()]);reject(r,`Unknown attribute "${t.name}.${n}". ${i}${a?.()??``}`)}let s=i===void 0?[]:[i].flat();return s.length>0&&!s.includes(o.type)&&reject(r,`Attribute "${t.name}.${n}" must have type ${s.join(` or `)}`),o}function collectContentViewCatalogue(e,n=`authoring`){let r=e.mode??`published`,i=new Map;e.objects.forEach((e,n)=>{if(requireName(e.name,[`objects`,String(n),`name`]),i.has(e.name))throw new t.DuplicateError(`object`,e.name);i.set(e.name,{name:e.name,system:systemAttributeMap(e),attributes:indexUnique(e.attributes,`attribute`,[`objects`,String(n),`attributes`])})});let a=new Set;(e.reservedObjects??[]).forEach((e,t)=>{let n=[`reservedObjects`,String(t)];requireName(e,n),!i.has(e)&&(r!==`draft`&&reject(n,`Unresolved reserved object "${e}"`),a.add(e),i.set(e,{name:e}))});let o=indexUnique(e.extensions??[],`extension`,[`extensions`]);function resolveObject(e,t){requireName(e,t);let n=i.get(e);return n||reject(t,`Unknown object "${e}"`),n}function inverseAddresses(e){let t=[];for(let[n,r]of i)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=t=>r===`draft`?draftContentViewDefinitionSchemaFor():contentViewDefinitionSchemaFor({traits:n===`structural`?null:(e,t)=>layoutTraitsOf(e,o,t),viewerFiltered:e.viewerFiltered,...t===void 0?{}:{statics:t}}),s=authoringSchemaWith(),c=r===`draft`||n===`structural`?s:contentViewDefinitionSchemaFor({traits:null,viewerFiltered:e.viewerFiltered}),schemaFor=t=>{if(e.authoringViews!==void 0&&!e.authoringViews.has(t))return c;let n=e.staticsOf?.(t);return n===void 0||n.size===0?s:authoringSchemaWith(n)},l=new Map,u=new Map,d=[],f=[];function parseView(e,n,r){let i=schemaFor(r).safeParse(e);if(!i.success){let r=new t.ValidationError(invalidViewMessage(e,i.error.issues[0]),i.error.issues.map(e=>({path:[...n,...e.path.map(String)],message:e.message,code:e.code})));throw Ft.add(r),r}let a=i.data;requireName(a.name,[...n,`name`]);let o=a.object??``,s=l.get(o)??new Set;if(s.has(a.name))throw new t.DuplicateError(`view`,`${o}.${a.name}`);if(s.add(a.name),l.set(o,s),a.context!==`page`&&a.default){let e=u.get(a.object)??new Set;if(e.has(a.context))throw new t.DuplicateError(`default view`,`${a.object}.${a.context}`);e.add(a.context),u.set(a.object,e)}return a}return e.views.forEach((t,n)=>{let r=[`views`,String(n)],i=t,a=`${String(i?.object??`?`)}.${String(i?.name??n)}`,s,c;try{s=parseView(t,r,n),c=s.object===void 0?void 0:resolveObject(s.object,[...r,`object`])}catch(e){d.push(violationOf(e,a,null,r));return}s.contents.forEach((t,i)=>{let l=[...r,`contents`,String(i)];try{requireName(t.name,[...l,`name`]),validateContent(t,l,c,contentContextOf(s),o,resolveObject,inverseAddresses,e.authoringViews?.has(n)===!0)}catch(e){d.push(violationOf(e,a,t.name,l))}}),f.push(s)}),f.forEach((n,r)=>{n.contents.forEach((i,a)=>{if(i.type!==`page`)return;let o=[`views`,String(r),`contents`,String(a),`page`],s=f.find(e=>e.context===`page`&&e.object===i.page.object&&e.name===i.page.name),c=n.context===`page`?`Content "${i.name}" cannot reference a page from a page`:n.object===i.page.object?s||e.complete!==!0?void 0:`Unknown page "${i.page.object}.${i.page.name}"`:`Content "${i.name}" must reference a page of "${String(n.object)}", not of "${i.page.object}"`;c!==void 0&&d.push(violationOf(new t.ValidationError(c,[{path:o,message:c}]),`${String(n.object)}.${n.name}`,i.name,o))})}),{views:f,unresolvedObjects:[...a].sort(),violations:d}}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.hidden}function requireBoardGrouping(e,t,n){let r=t.type===`status`?`is hidden`:`is a ${t.type}`;isBoardGrouping(t)||reject(n,`A board groups by a visible status attribute: "${e}.${t.name}" ${r}`)}function validateContent(e,n,r,i,a,o,s,c){function requireRecord(){requireRecordContentContext(e.name,i,n)}let l={owner:r,requireRecord,resolveObject:o,inverseAddresses:s},u=hostPlacementContext(i);if(e.type===`custom`){let r=a.get(e.extension);r||reject([...n,`extension`],`Unknown extension "${e.extension}"`),contentPlacementContexts(e,r)?.includes(u)||reject([...n,`extension`],`${e.extension} cannot be placed here`);let i=r.parameters.safeParse(structuredClone(e.parameters??{}));if(!i.success)throw new t.ValidationError(`Invalid extension parameters`,i.error.issues.map(e=>({path:[...n,`parameters`,...e.path.map(String)],message:e.message,code:e.code})));let o=i.data,s=r.refine?.(o,u);s&&reject([...n,`parameters`,s.input],s.message),validateBlockReferences(r,o,[...n,`parameters`],l);return}if(requireContentPlacement(e,void 0,e.name,i,n),e.type!==`page`&&e.type!==`group`){if(e.type===`collection`){let{target:t,relationAttribute:r}=resolveStoredQuery(e,n,`Collection "${e.name}"`,l);if(e.columns?.forEach((e,i)=>{let a=[...n,`columns`,String(i)];if(typeof e==`string`){requireAttribute(t,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(t,e,[...n,`displayAttributes`,String(r)])),e.descriptionAttribute!==void 0&&requireAttribute(t,e.descriptionAttribute,[...n,`descriptionAttribute`]),e.layout===`kanban`&&e.groupByAttribute!==void 0){let r=[...n,`groupByAttribute`],i=requireAttribute(t,e.groupByAttribute,r);c&&i&&t&&requireBoardGrouping(t.name,i,r)}return}switch(e.type){case`form`:e.groups.forEach((e,t)=>{let i=[...n,`groups`,String(t)];requireName(e.name,[...i,`name`]),e.fields.forEach((e,t)=>requireAttribute(r,e.attribute,[...i,`fields`,String(t),`attribute`]))});break;case`richtext`:requireAttribute(r,e.attribute,[...n,`attribute`],`richtext`),e.titleAttribute!==void 0&&requireAttribute(r,e.titleAttribute,[...n,`titleAttribute`],`text`);break;case`emails`:case`meetings`:e.emailAttributes.forEach((e,t)=>requireAttribute(r,e,[...n,`emailAttributes`,String(t)],`text`));break;case`documents`:e.relations?.forEach((e,t)=>requireAttribute(r,e,[...n,`relations`,String(t)],`relation`));break;case`forms`:e.objectName!==void 0&&o(e.objectName,[...n,`objectName`]);break;case`activity`:break;default:reject(n,`Unknown content type: ${String(e)}`)}}}const Q=Object.freeze({size:Object.freeze({w:4,h:4}),minWidth:3,height:`flexible`,minHeight:2,figure:!1});function resolveLayout(e){return e===void 0?Q:{size:e.size??Q.size,minWidth:e.minWidth??Q.minWidth,height:e.height??Q.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 Z?resolveLayout(Z[e.type]):Q}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(Z.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):Q}}const Lt=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))if(n!==`length`){if(n===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,[...t.path,n]);continue}(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];if(!(a&&`value`in a)){addJsonIssue(r,`Sparse arrays are not valid JSON values`,o);continue}n.push({kind:`enter`,value:a.value,path:o,depth:t.depth+1})}}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);if(!(c?.enumerable&&`value`in c)){addJsonIssue(r,`Custom props must contain enumerable data properties only`,s);continue}n.push({kind:`enter`,value:c.value,path:s,depth:t.depth+1})}}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=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>Lt){addJsonIssue(t,`Custom props cannot exceed ${Lt.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);continue}if(n.has(a)){addJsonIssue(t,`Custom props cannot contain circular references`,e.path);continue}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 Rt=n.unknown().superRefine(validateJsonProps).transform(e=>e),zt={span:n.union([n.literal(1),n.literal(2),n.literal(3),n.literal(4),n.literal(5),n.literal(6),n.literal(7),n.literal(8),n.literal(9),n.literal(10),n.literal(11),n.literal(12)]).optional().describe(`Columns of 12 this field occupies`),label:n.string().optional().describe(`Overrides the attribute's label`),readOnly:n.boolean().optional().describe(`Shows the value, not editable`)},Bt=n.object({attribute:n.string().describe(`Attribute API name shown by this field`),...zt}).strict(),Vt=n.object({name:n.string().describe(`Group API name, unique in the form`),label:n.string().describe(`Label people see`),description:n.string().optional().describe(`Extra context under the label`),collapsible:n.boolean().optional().describe(`Whether the group can be collapsed`),collapsed:n.boolean().optional().describe(`Whether the group starts collapsed`),fields:n.array(Bt).max(e.SCHEMA_LIMITS.fieldsPerGroup).describe(`Fields in this group, in order`)}).strict();function refineFormContent(t,n){t.groups.reduce((e,t)=>e+t.fields.length,0)>e.SCHEMA_LIMITS.fieldsPerFormTab&&n.addIssue({code:`too_big`,origin:`array`,maximum:e.SCHEMA_LIMITS.fieldsPerFormTab,inclusive:!0,message:`A form content can contain at most ${e.SCHEMA_LIMITS.fieldsPerFormTab} fields`,path:[`groups`]});let r=new Set,i=new Set;t.groups.forEach((e,t)=>{r.has(e.name)&&n.addIssue({code:`custom`,message:`Duplicate group name "${e.name}"`,path:[`groups`,t,`name`]}),r.add(e.name),e.fields.forEach((e,r)=>{i.has(e.attribute)&&n.addIssue({code:`custom`,message:`Duplicate field attribute "${e.attribute}"`,path:[`groups`,t,`fields`,r,`attribute`]}),i.add(e.attribute)})})}const $={name:n.string().describe(`Content API name, unique in the view`),label:n.string().optional().describe(`Label people see`),icon:e.iconNameSchema.optional().describe(`Icon name`),placement:n.enum([`main`,`aside`,`grid`]).describe(`main: the tab strip. aside: the side panel. grid: a page block`),height:n.enum([`fit`,`flexible`,`fill`]).optional().describe(`Page block height: fit (content), flexible (between bounds) or fill (whole page, one per page)`)},Ht={...$,type:n.literal(`collection`),source:U.describe(`object: every record; relation: records linked to this record; both: records of object whose relation points at this record`),visibility:n.enum(e.LIST_VIEW_TAB_VISIBILITIES).optional().describe(`all: no scope; workspace: every member; private: viewer's own; shared: private records other members shared with the viewer`),columns:n.array(n.union([n.string(),n.object({relationProperty:n.string().refine(e=>e.trim().length>0).describe(`Qualified edge property shown as a column`)}).strict()])).max(e.SCHEMA_LIMITS.columnsPerTab).optional().describe(`Table columns, in order`),descriptionAttribute:n.string().optional().describe(`Secondary line under each row's title (list layout)`),displayAttributes:it.optional().describe(`Attributes shown on each card`),filters:H.optional().describe(`Restricts which records show`),sorts:V.optional().describe(`Sort order`),actions:n.enum([`create`,`update`,`delete`,`attach`,`detach`]).array().optional().describe(`Offered actions; absent = every action, [] = none`),openMode:n.enum([`page`,`peek`]).optional().describe(`page or peek (the record panel)`),createMode:n.enum([`page`,`peek`,`inline`]).optional().describe(`page, peek, or inline (creates without opening)`)},Ut=n.object({...Ht,layout:n.enum([`table`,`list`,`kanban`]).describe(`table columns, list cards, kanban board grouped by a select/status attribute`),columnSizing:n.record(n.string(),n.number()).optional().describe(`Column widths in pixels, by attribute name`),groupByAttribute:n.string().optional().describe(`Kanban only: the select or status attribute that names the columns`),kanbanColumnOrder:n.array(n.string()).optional().describe(`Kanban: column order by option value`),kanbanColumnVisibility:n.record(n.string(),n.boolean()).optional().describe(`Kanban: which columns are shown`),kanbanPinnedColumns:n.array(n.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`});return}for(let r of n)e[r]!==void 0&&t.addIssue({code:`custom`,path:[r],message:`Only a kanban layout groups by an attribute`})}),Wt={...$,type:n.literal(`form`),groups:n.array(Vt).max(e.SCHEMA_LIMITS.groupsPerFormTab).describe(`Field groups, in order`),formColumns:n.union([n.literal(1),n.literal(2),n.literal(3)]).optional().describe(`Grid columns, 1-3`),density:n.enum([`compact`,`comfortable`,`spacious`]).optional().describe(`Vertical spacing between fields`)},Gt=n.object(Wt).strict().superRefine(refineFormContent),Kt=n.object({...Wt,groups:Wt.groups.min(1,`A published form content requires at least one group`)}).strict().superRefine(refineFormContent),qt=[Ut,n.object({...$,type:n.literal(`group`),placement:n.literal(`grid`).describe(`Always grid`),members:n.array(n.string()).min(1).max(e.SCHEMA_LIMITS.membersPerGroup).describe(`Contents side by side`)}).strict(),n.object({...$,type:n.literal(`custom`),extension:n.string().describe(`Name of a registered extension`),parameters:n.lazy(()=>Rt).optional().describe(`Extension parameters`)}).strict(),n.object({...$,type:n.literal(`activity`)}).strict(),n.object({...$,type:n.literal(`richtext`),attribute:n.string().describe(`Richtext attribute edited in place`),titleAttribute:n.string().optional().describe(`Text attribute shown as the title`)}).strict(),n.object({...$,type:n.literal(`documents`),allowUpload:n.boolean().optional().describe(`Lets people add files here`),allowRemove:n.boolean().optional().describe(`Lets people remove files here`),hideAttachments:n.boolean().optional().describe(`Hides files attached elsewhere (e.g. emails)`),relations:n.array(n.string()).optional().describe(`Document relations shown; the record's own files if absent`)}).strict(),n.object({...$,type:n.literal(`forms`),objectName:n.string().optional().describe(`Limits to this object's published forms`)}).strict(),n.object({...$,type:n.literal(`emails`),emailAttributes:n.array(n.string()).max(e.SCHEMA_LIMITS.emailAttributesPerTab).describe(`Addresses`)}).strict(),n.object({...$,type:n.literal(`meetings`),emailAttributes:n.array(n.string()).max(e.SCHEMA_LIMITS.emailAttributesPerTab).describe(`Addresses`)}).strict(),n.object({...$,type:n.literal(`page`),page:n.object({object:n.string().describe(`Its object`),name:n.string().describe(`Its name`)}).strict().describe(`The record page this tab renders`)}).strict()],Jt=n.discriminatedUnion(`type`,[Gt,...qt]),Yt=n.discriminatedUnion(`type`,[Kt,...qt]),Xt={name:n.string(),label:n.string(),description:n.string().optional(),icon:e.iconNameSchema.optional()},Zt=n.object({x:n.number().describe(`Column`),y:n.number().describe(`Row`),w:n.number().describe(`Width: 3, 4, 6, 8, 9 or 12; x + w ≤ 12`),h:n.number().describe(`Height`)}).strict();function contentViewBaseSchemaFor(t){let r=n.array(t).max(e.SCHEMA_LIMITS.tabsPerView);return n.discriminatedUnion(`context`,[n.object({...Xt,object:n.string(),context:n.enum([`collection`,`record`]),default:n.boolean().optional(),anchors:n.record(n.string(),n.object({after:n.string()}).strict()).optional(),contents:r}).strict(),n.object({...Xt,object:n.string().optional(),context:n.literal(`page`),home:n.boolean().optional(),grid:n.record(n.string(),Zt).refine(t=>Object.keys(t).length<=e.SCHEMA_LIMITS.tabsPerView,{message:`A page holds at most ${e.SCHEMA_LIMITS.tabsPerView} blocks`}),contents:r}).strict()])}const Qt=contentViewBaseSchemaFor(Jt),$t=contentViewBaseSchemaFor(Yt);function registryTraits(e,t){return layoutTraitsOf(e,Nt,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=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 Qt.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 $t.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 en=draftContentViewDefinitionSchemaFor(),tn=contentViewDefinitionSchemaFor();Object.defineProperty(exports,"AGENDA_BLOCK",{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,"ARTIFACT_PREVIEW_EXTENSION",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,"ATTRIBUTE_FILTER_OPERATORS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"ATTRIBUTE_TYPES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"ATTRIBUTE_TYPE_DESCRIPTORS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"BLOCK_CONTEXTS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"BLOCK_PERIODS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"BLOCK_WIDTHS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"CARD_BLOCK",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(exports,"CHART_BLOCK",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(exports,"CHART_KINDS",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,"COMPUTED_RETURN_TYPES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"CONTENT_PLACEMENT_CONTEXTS",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(exports,"DECISIONS_BLOCK",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(exports,"DEFAULT_LAYOUT_TRAITS",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"DEFAULT_VALIDATION_MESSAGES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"GROUPABLE_ATTRIBUTE_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"HEADING_BLOCK",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(exports,"INVENTORY_LIMIT",{enumerable:!0,get:function(){return 30}}),Object.defineProperty(exports,"LOCATION_FILTER_PROPERTIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"MAILBOX_BLOCK",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(exports,"MEASURABLE_ATTRIBUTE_TYPES",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,"MEETINGS_UPCOMING_BLOCK",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(exports,"METRIC_BLOCK",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,"NATIVE_BLOCKS",{enumerable:!0,get:function(){return At}}),Object.defineProperty(exports,"NO_VALUE_OPERATORS",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"OPERATORS_BY_TYPE",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"PAGE_GRID_COLUMNS",{enumerable:!0,get:function(){return 12}}),Object.defineProperty(exports,"QUALIFIED_SEPARATOR",{enumerable:!0,get:function(){return`__`}}),Object.defineProperty(exports,"QUERY_OBJECT",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"RECORD_LINKS_BLOCK",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"RECORD_LINKS_CONTENT",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(exports,"RECORD_OBJECT",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(exports,"RELATION_TARGET_ANY",{enumerable:!0,get:function(){return`*`}}),Object.defineProperty(exports,"REMOVED_OPERATOR_REPLACEMENTS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"RecordQuery",{enumerable:!0,get:function(){return RecordQuery}}),Object.defineProperty(exports,"SIMPLE_PROPERTY_TYPES",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"SYNONYM_ALIASES",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(exports,"SYSTEM_FILTER_ATTRIBUTE_TYPES",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"TEXT_BLOCK",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(exports,"TEXT_FORMAT_PATTERNS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"WIRE_OFFERED_BASE_CONFIG",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"WIRE_OMITTED_CONFIG_KEYS",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"attributeConfigSchemas",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"attributeFilterTarget",{enumerable:!0,get:function(){return attributeFilterTarget}}),Object.defineProperty(exports,"attributeInventory",{enumerable:!0,get:function(){return attributeInventory}}),Object.defineProperty(exports,"blockObjectInputs",{enumerable:!0,get:function(){return blockObjectInputs}}),Object.defineProperty(exports,"buildQualifiedAttribute",{enumerable:!0,get:function(){return buildQualifiedAttribute}}),Object.defineProperty(exports,"canonicalizeFilterValue",{enumerable:!0,get:function(){return canonicalizeFilterValue}}),Object.defineProperty(exports,"capped",{enumerable:!0,get:function(){return capped}}),Object.defineProperty(exports,"collectContentViewCatalogue",{enumerable:!0,get:function(){return collectContentViewCatalogue}}),Object.defineProperty(exports,"collectQualifiedRuleIssues",{enumerable:!0,get:function(){return collectQualifiedRuleIssues}}),Object.defineProperty(exports,"collectionContentSourceSchema",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"collectionSourceAddress",{enumerable:!0,get:function(){return collectionSourceAddress}}),Object.defineProperty(exports,"collectionSourceAddressOf",{enumerable:!0,get:function(){return collectionSourceAddressOf}}),Object.defineProperty(exports,"columnsSchema",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(exports,"contentExtensionRegistry",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(exports,"contentReadObjects",{enumerable:!0,get:function(){return contentReadObjects}}),Object.defineProperty(exports,"contentViewDefinitionSchema",{enumerable:!0,get:function(){return tn}}),Object.defineProperty(exports,"contentViewDefinitionSchemaFor",{enumerable:!0,get:function(){return contentViewDefinitionSchemaFor}}),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,"currentActor",{enumerable:!0,get:function(){return currentActor}}),Object.defineProperty(exports,"datePrecisionIssues",{enumerable:!0,get:function(){return datePrecisionIssues}}),Object.defineProperty(exports,"defineBlock",{enumerable:!0,get:function(){return defineBlock}}),Object.defineProperty(exports,"describeViewIssue",{enumerable:!0,get:function(){return describeViewIssue}}),Object.defineProperty(exports,"displayAttributesSchema",{enumerable:!0,get:function(){return it}}),Object.defineProperty(exports,"draftContentViewDefinitionSchema",{enumerable:!0,get:function(){return en}}),Object.defineProperty(exports,"draftContentViewDefinitionSchemaFor",{enumerable:!0,get:function(){return draftContentViewDefinitionSchemaFor}}),Object.defineProperty(exports,"edgePropertyFilterTarget",{enumerable:!0,get:function(){return edgePropertyFilterTarget}}),Object.defineProperty(exports,"extractCurrencyFilterValue",{enumerable:!0,get:function(){return extractCurrencyFilterValue}}),Object.defineProperty(exports,"extractFilterValue",{enumerable:!0,get:function(){return extractFilterValue}}),Object.defineProperty(exports,"filterOperatorsOfType",{enumerable:!0,get:function(){return filterOperatorsOfType}}),Object.defineProperty(exports,"filterStateSchema",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"filterTargetsOf",{enumerable:!0,get:function(){return filterTargetsOf}}),Object.defineProperty(exports,"findGridViolation",{enumerable:!0,get:function(){return findGridViolation}}),Object.defineProperty(exports,"findGroupViolation",{enumerable:!0,get:function(){return findGroupViolation}}),Object.defineProperty(exports,"findLayoutRuleViolation",{enumerable:!0,get:function(){return findLayoutRuleViolation}}),Object.defineProperty(exports,"findRelationAttribute",{enumerable:!0,get:function(){return findRelationAttribute}}),Object.defineProperty(exports,"findRowLimitViolation",{enumerable:!0,get:function(){return findRowLimitViolation}}),Object.defineProperty(exports,"formatPhoneForDisplay",{enumerable:!0,get:function(){return formatPhoneForDisplay}}),Object.defineProperty(exports,"formatZodErrors",{enumerable:!0,get:function(){return formatZodErrors}}),Object.defineProperty(exports,"getAttributeCapabilities",{enumerable:!0,get:function(){return getAttributeCapabilities}}),Object.defineProperty(exports,"getAttributeConfigSchema",{enumerable:!0,get:function(){return getAttributeConfigSchema}}),Object.defineProperty(exports,"getAttributeConfigWriteSchema",{enumerable:!0,get:function(){return getAttributeConfigWriteSchema}}),Object.defineProperty(exports,"getAttributeFilterOperators",{enumerable:!0,get:function(){return getAttributeFilterOperators}}),Object.defineProperty(exports,"getIso2",{enumerable:!0,get:function(){return getIso2}}),Object.defineProperty(exports,"getOperatorPolarity",{enumerable:!0,get:function(){return getOperatorPolarity}}),Object.defineProperty(exports,"getRollupFilterOperators",{enumerable:!0,get:function(){return getRollupFilterOperators}}),Object.defineProperty(exports,"gridPositionSchema",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(exports,"groupSizeMessage",{enumerable:!0,get:function(){return groupSizeMessage}}),Object.defineProperty(exports,"groupedMembers",{enumerable:!0,get:function(){return groupedMembers}}),Object.defineProperty(exports,"hasTypeTrait",{enumerable:!0,get:function(){return hasTypeTrait}}),Object.defineProperty(exports,"hasValueKind",{enumerable:!0,get:function(){return hasValueKind}}),Object.defineProperty(exports,"inferInverseCardinality",{enumerable:!0,get:function(){return inferInverseCardinality}}),Object.defineProperty(exports,"input",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"invalidViewMessage",{enumerable:!0,get:function(){return invalidViewMessage}}),Object.defineProperty(exports,"isAttributeFilterable",{enumerable:!0,get:function(){return isAttributeFilterable}}),Object.defineProperty(exports,"isAttributeGroupable",{enumerable:!0,get:function(){return isAttributeGroupable}}),Object.defineProperty(exports,"isAttributeKanbanGroupable",{enumerable:!0,get:function(){return isAttributeKanbanGroupable}}),Object.defineProperty(exports,"isAttributeSearchable",{enumerable:!0,get:function(){return isAttributeSearchable}}),Object.defineProperty(exports,"isAttributeSortable",{enumerable:!0,get:function(){return isAttributeSortable}}),Object.defineProperty(exports,"isBilateralRelation",{enumerable:!0,get:function(){return isBilateralRelation}}),Object.defineProperty(exports,"isBoardGrouping",{enumerable:!0,get:function(){return isBoardGrouping}}),Object.defineProperty(exports,"isCalendarDay",{enumerable:!0,get:function(){return isCalendarDay}}),Object.defineProperty(exports,"isCollectionContent",{enumerable:!0,get:function(){return isCollectionContent}}),Object.defineProperty(exports,"isDynamicValue",{enumerable:!0,get:function(){return isDynamicValue}}),Object.defineProperty(exports,"isEmptyValue",{enumerable:!0,get:function(){return isEmptyValue}}),Object.defineProperty(exports,"isLocationFilterProperty",{enumerable:!0,get:function(){return isLocationFilterProperty}}),Object.defineProperty(exports,"isLocationPartOperator",{enumerable:!0,get:function(){return isLocationPartOperator}}),Object.defineProperty(exports,"isNoValueOperator",{enumerable:!0,get:function(){return isNoValueOperator}}),Object.defineProperty(exports,"isNullishOrEmptyString",{enumerable:!0,get:function(){return isNullishOrEmptyString}}),Object.defineProperty(exports,"isRelativeDateValue",{enumerable:!0,get:function(){return isRelativeDateValue}}),Object.defineProperty(exports,"isSetMembershipOperator",{enumerable:!0,get:function(){return isSetMembershipOperator}}),Object.defineProperty(exports,"isUniversalRelation",{enumerable:!0,get:function(){return isUniversalRelation}}),Object.defineProperty(exports,"isValueKindType",{enumerable:!0,get:function(){return isValueKindType}}),Object.defineProperty(exports,"isValuePresent",{enumerable:!0,get:function(){return isValuePresent}}),Object.defineProperty(exports,"layoutTraitsOf",{enumerable:!0,get:function(){return layoutTraitsOf}}),Object.defineProperty(exports,"locationPartFilterTarget",{enumerable:!0,get:function(){return locationPartFilterTarget}}),Object.defineProperty(exports,"memberlessGroups",{enumerable:!0,get:function(){return memberlessGroups}}),Object.defineProperty(exports,"metricComparePeriod",{enumerable:!0,get:function(){return metricComparePeriod}}),Object.defineProperty(exports,"normalizeCountrylessPhoneNumber",{enumerable:!0,get:function(){return normalizeCountrylessPhoneNumber}}),Object.defineProperty(exports,"normalizeFilterRule",{enumerable:!0,get:function(){return normalizeFilterRule}}),Object.defineProperty(exports,"normalizeForEdgeRpc",{enumerable:!0,get:function(){return normalizeForEdgeRpc}}),Object.defineProperty(exports,"normalizeOperator",{enumerable:!0,get:function(){return normalizeOperator}}),Object.defineProperty(exports,"normalizePhoneNumber",{enumerable:!0,get:function(){return normalizePhoneNumber}}),Object.defineProperty(exports,"now",{enumerable:!0,get:function(){return now}}),Object.defineProperty(exports,"overlaps",{enumerable:!0,get:function(){return overlaps}}),Object.defineProperty(exports,"pageTraitsOf",{enumerable:!0,get:function(){return pageTraitsOf}}),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,"parseBlockParameters",{enumerable:!0,get:function(){return parseBlockParameters}}),Object.defineProperty(exports,"parseQualifiedAttribute",{enumerable:!0,get:function(){return parseQualifiedAttribute}}),Object.defineProperty(exports,"propertyAttributeSchema",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"propertyAttributeWireSchema",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"propertySchemaSchema",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"propertySchemaWireSchema",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,"publishedViewContentDefinitionSchema",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(exports,"query",{enumerable:!0,get:function(){return query}}),Object.defineProperty(exports,"recordQueryDefinitionSchema",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(exports,"refuseForeignKeys",{enumerable:!0,get:function(){return refuseForeignKeys}}),Object.defineProperty(exports,"rejectUnknownAttributesOrThrow",{enumerable:!0,get:function(){return rejectUnknownAttributesOrThrow}}),Object.defineProperty(exports,"relationAcceptsObject",{enumerable:!0,get:function(){return relationAcceptsObject}}),Object.defineProperty(exports,"relationTargetsOf",{enumerable:!0,get:function(){return relationTargetsOf}}),Object.defineProperty(exports,"requireContentPlacement",{enumerable:!0,get:function(){return requireContentPlacement}}),Object.defineProperty(exports,"requireRecordContentContext",{enumerable:!0,get:function(){return requireRecordContentContext}}),Object.defineProperty(exports,"requireSingleRelationTarget",{enumerable:!0,get:function(){return requireSingleRelationTarget}}),Object.defineProperty(exports,"resolveCollectionActions",{enumerable:!0,get:function(){return resolveCollectionActions}}),Object.defineProperty(exports,"resolveContentNavigation",{enumerable:!0,get:function(){return resolveContentNavigation}}),Object.defineProperty(exports,"resolveEffectiveFilterType",{enumerable:!0,get:function(){return resolveEffectiveFilterType}}),Object.defineProperty(exports,"resolveIsWithinBounds",{enumerable:!0,get:function(){return resolveIsWithinBounds}}),Object.defineProperty(exports,"resolveTextPattern",{enumerable:!0,get:function(){return resolveTextPattern}}),Object.defineProperty(exports,"resolveUtcDayBounds",{enumerable:!0,get:function(){return resolveUtcDayBounds}}),Object.defineProperty(exports,"selectOptionWriteSchema",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"singleRelationTarget",{enumerable:!0,get:function(){return singleRelationTarget}}),Object.defineProperty(exports,"sortsSchema",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"sourcedAttributeOf",{enumerable:!0,get:function(){return sourcedAttributeOf}}),Object.defineProperty(exports,"statusGroupSchema",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"statusOptionWriteSchema",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"systemColumnFilterTarget",{enumerable:!0,get:function(){return systemColumnFilterTarget}}),Object.defineProperty(exports,"toMultiValueOperator",{enumerable:!0,get:function(){return toMultiValueOperator}}),Object.defineProperty(exports,"toUtcDayString",{enumerable:!0,get:function(){return toUtcDayString}}),Object.defineProperty(exports,"today",{enumerable:!0,get:function(){return today}}),Object.defineProperty(exports,"validateAttribute",{enumerable:!0,get:function(){return validateAttribute}}),Object.defineProperty(exports,"validateContentViewCatalogue",{enumerable:!0,get:function(){return validateContentViewCatalogue}}),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,"validateQualifiedRule",{enumerable:!0,get:function(){return validateQualifiedRule}}),Object.defineProperty(exports,"validateStoredViews",{enumerable:!0,get:function(){return validateStoredViews}}),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,11 +0,0 @@
1
- /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,__exportAll=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},__copyProps=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},__toESM=(n,r,o)=>(o=n==null?{}:e(i(n)),__copyProps(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));const o=require("./exceptions.js");require("./zod-locale.js");let s=require("zod");s=__toESM(s);let c=require("@standards/constants");const l=[`question`,`approval`,`review`,`handoff`,`report`,`fyi`],u=[`unread`,`read`,`archived`],d=[`none`,`pending`,`completed`,`dismissed`,`expired`],f=[`open`,`snoozed`,`closed`,`answered`,`withdrawn`,`expired`,`unread`,`read`,`archived`],p=[`record`,`session`,`document`,`agent`,`routine`,`page`,`email_thread`];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(!p.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 m=`agent.question`,h=`agent.approval`,g=`agent.review`,_=`agent.setup`,v=`agent.routine_run.failed`,y=`agent.message`,b=`connector.connection.reauth_required`,x=`connector.connection.error`,S=`record.assigned`,C=`record.mentioned`,w=`access.granted`,T=`environment.build.failed`,E=`person.decision`,D=`bundle.setup`,O=[m,h,g,_,v,y,b,x,S,C,w,T,E,D],k=[`question`,`approval`,`review`,`handoff`];function isActionableDecisionKind(e){return k.includes(e)}const A=[`agents`,`connectors`,`assignment`,`mentions`,`sharing`],j={[m]:{kind:`question`,area:null},[h]:{kind:`approval`,area:null},[g]:{kind:`review`,area:null},[_]:{kind:`handoff`,area:null},[v]:{kind:`question`,area:`agents`},[y]:{kind:`report`,area:`agents`},[b]:{kind:`handoff`,area:`connectors`},[x]:{kind:`handoff`,area:`connectors`},[S]:{kind:`fyi`,area:`assignment`},[C]:{kind:`fyi`,area:`mentions`},[w]:{kind:`fyi`,area:`sharing`},[T]:{kind:`fyi`,area:`agents`},[E]:{kind:`question`,area:null},[D]:{kind:`handoff`,area:null}},M=`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[M];return Array.isArray(t)?t.filter(isDecisionTransfer):[]}function decisionTransferBy(e,t){return decisionTransfersOf(e).filter(e=>e.fromActorId===t).at(-1)}const N=[`open`,`answered`,`withdrawn`,`expired`,`info`],P={createdAt:`createdAt`,updatedAt:`updatedAt`,createdBy:`createdBy`,lastUpdatedBy:`lastUpdatedBy`,attachments:`attachments`,parentId:`parentId`,childIds:`childIds`};function getSystemAttributeI18nKey(e){return P[e]}const F={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(F)}function isManagedSystemAttribute(e){return e.id?.startsWith(`system:`)??!1}const I=[`hierarchy:parentId`,`hierarchy:childIds`],L=new Set([`parentId`,`childIds`]);function getHierarchyAttributes(e){if(!e.hierarchical)return[];let t=[{object:e.name}];return[{id:I[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:I[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 R=[`skill`,`memory`,`drives`,`artifact`,`meeting`];function isNativeObjectName(e){return R.includes(e)}const z=[`workspace`,`private`],B=[`all`,...z,`shared`],V=[...z,`shared`];function parseRecordListScope(e){if(typeof e==`string`&&V.includes(e))return e;throw new o.ValidationError(`visibility must be one of: ${V.join(`, `)} (received: ${String(e)})`,[])}function parseResourceVisibility(e){if(typeof e==`string`&&z.includes(e))return e;throw new o.ValidationError(`visibility must be one of: ${z.join(`, `)} (received: ${String(e)})`,[])}const H=[`id`,`createdAt`,`updatedAt`,`createdBy`,`lastUpdatedBy`,`visibility`,`ownedBy`],U=[...H,`objectId`,`label`,`embeddingText`,`values`,`metadata`,`deletedAt`,`deletedBy`,`schemaVersion`,`appearance`,`owned_by`,`parentId`,`childIds`],W=R,G={attributesPerObject:300,tabsPerView:24,membersPerGroup:4,pageRows:1e3,groupsPerFormTab:12,fieldsPerGroup:60,fieldsPerFormTab:150,columnsPerTab:50,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},K=[`count`,`sum`,`avg`,`min`,`max`],q=[`day`,`week`,`month`,`quarter`,`year`];function isPlainRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const J=new Set(c.ICONS),Y=/^[a-zA-Z_][a-zA-Z0-9_]*$/,X=/^[a-z][a-z0-9-]*$/,Z=G.labelLength,Q=s.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{Q.parse(e)}catch(e){throw e instanceof s.ZodError?new o.SchemaError(e.issues[0].message,o.SchemaErrorCode.INVALID_OBJECT_NAME):e}}function validateViewName(e){if(!e||e.length===0)throw new o.ValidationError(`View name cannot be empty`,[{path:[`name`],message:`View name cannot be empty`}]);if(e.length>63)throw new o.ValidationError(`View name is too long`,[{path:[`name`],message:`View name is too long (max 63 characters)`}]);if(!X.test(e))throw new o.ValidationError(`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=new Set;for(let i of e){let e=t(i);if(r.has(e))throw n(e);r.add(e)}}const $=s.string().min(1,`Attribute name cannot be empty`).max(63,`Attribute name is too long (max 63 characters)`).regex(Y,{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=>!U.includes(e),{message:`This is a reserved attribute name. Reserved names: ${U.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(!Y.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(U.includes(e))throw Error(`[AttributeBuilder] "${e}" is a reserved name and cannot be used as an attribute name.\nReserved names: ${U.join(`, `)}`)}function validateLabel(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute label cannot be empty`);if(e.length>Z)throw Error(`[AttributeBuilder] Attribute label is too long (max ${Z} characters)`)}function validateIconName(e,t){if(!J.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=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.`)}}const ee=Object.keys(c.COLORS),te=new Set(c.ICONS),ne=s.enum(ee).describe(`A color id from the palette`),re=s.string().superRefine((e,t)=>{te.has(e)||t.addIssue({code:`custom`,message:`Invalid icon name`})}).transform(e=>e);Object.defineProperty(exports,"ACTIONABLE_DECISION_KINDS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"AGGREGATE_BUCKETS",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"AGGREGATE_MEASURES",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"ATTRIBUTE_NAME_SCHEMA",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"DECISION_INBOX_STATES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"DECISION_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"DECISION_LINE_MAX_LENGTH",{enumerable:!0,get:function(){return 200}}),Object.defineProperty(exports,"DECISION_LINK_TARGET_TYPES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"DECISION_LIST_STATES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"DECISION_READ_STATES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"DECISION_SETTINGS_AREAS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"DECISION_TITLE_MAX_LENGTH",{enumerable:!0,get:function(){return 120}}),Object.defineProperty(exports,"DECISION_TRANSFERS_KEY",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"DECISION_TYPES_V1",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"DECISION_TYPE_ACCESS_GRANTED",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"DECISION_TYPE_AGENT_APPROVAL",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"DECISION_TYPE_AGENT_MESSAGE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"DECISION_TYPE_AGENT_QUESTION",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"DECISION_TYPE_AGENT_REVIEW",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"DECISION_TYPE_AGENT_ROUTINE_RUN_FAILED",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"DECISION_TYPE_AGENT_SETUP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"DECISION_TYPE_BUNDLE_SETUP",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"DECISION_TYPE_CONNECTOR_CONNECTION_ERROR",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"DECISION_TYPE_CONNECTOR_CONNECTION_REAUTH_REQUIRED",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"DECISION_TYPE_ENVIRONMENT_BUILD_FAILED",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"DECISION_TYPE_KINDS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"DECISION_TYPE_PERSON",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"DECISION_TYPE_RECORD_ASSIGNED",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"DECISION_TYPE_RECORD_MENTIONED",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"DECISION_WORK_STATES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"HIERARCHY_ATTRIBUTE_IDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"HIERARCHY_ATTRIBUTE_NAMES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"HIERARCHY_CHILD_IDS_LIMIT",{enumerable:!0,get:function(){return 6}}),Object.defineProperty(exports,"LIST_VIEW_TAB_VISIBILITIES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"MAX_AGGREGATE_GROUPS",{enumerable:!0,get:function(){return 100}}),Object.defineProperty(exports,"NATIVE_OBJECT_NAMES",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"OBJECT_NAME_SCHEMA",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"RECORD_LIST_SCOPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"RESERVED_ATTRIBUTE_NAMES",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"RESERVED_OBJECT_NAMES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"RESOURCE_VISIBILITIES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"SCHEMA_LIMITS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"SYSTEM_ATTRIBUTES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"SYSTEM_ATTRIBUTE_I18N_KEYS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"SYSTEM_FIELD_NAMES",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"__exportAll",{enumerable:!0,get:function(){return __exportAll}}),Object.defineProperty(exports,"__toESM",{enumerable:!0,get:function(){return __toESM}}),Object.defineProperty(exports,"assertUniqueBy",{enumerable:!0,get:function(){return assertUniqueBy}}),Object.defineProperty(exports,"colorIdSchema",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"decisionThreadKey",{enumerable:!0,get:function(){return decisionThreadKey}}),Object.defineProperty(exports,"decisionTransferBy",{enumerable:!0,get:function(){return decisionTransferBy}}),Object.defineProperty(exports,"decisionTransfersOf",{enumerable:!0,get:function(){return decisionTransfersOf}}),Object.defineProperty(exports,"formatDecisionLink",{enumerable:!0,get:function(){return formatDecisionLink}}),Object.defineProperty(exports,"getHierarchyAttributes",{enumerable:!0,get:function(){return getHierarchyAttributes}}),Object.defineProperty(exports,"getObjectSystemAttributes",{enumerable:!0,get:function(){return getObjectSystemAttributes}}),Object.defineProperty(exports,"getSystemAttributeI18nKey",{enumerable:!0,get:function(){return getSystemAttributeI18nKey}}),Object.defineProperty(exports,"getSystemAttributeList",{enumerable:!0,get:function(){return getSystemAttributeList}}),Object.defineProperty(exports,"iconNameSchema",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"isActionableDecisionKind",{enumerable:!0,get:function(){return isActionableDecisionKind}}),Object.defineProperty(exports,"isHierarchyAttribute",{enumerable:!0,get:function(){return isHierarchyAttribute}}),Object.defineProperty(exports,"isManagedSystemAttribute",{enumerable:!0,get:function(){return isManagedSystemAttribute}}),Object.defineProperty(exports,"isNativeObjectName",{enumerable:!0,get:function(){return isNativeObjectName}}),Object.defineProperty(exports,"isPlainRecord",{enumerable:!0,get:function(){return isPlainRecord}}),Object.defineProperty(exports,"parseDecisionLink",{enumerable:!0,get:function(){return parseDecisionLink}}),Object.defineProperty(exports,"parseRecordListScope",{enumerable:!0,get:function(){return parseRecordListScope}}),Object.defineProperty(exports,"parseResourceVisibility",{enumerable:!0,get:function(){return parseResourceVisibility}}),Object.defineProperty(exports,"validateAttributeName",{enumerable:!0,get:function(){return validateAttributeName}}),Object.defineProperty(exports,"validateIconName",{enumerable:!0,get:function(){return validateIconName}}),Object.defineProperty(exports,"validateLabel",{enumerable:!0,get:function(){return validateLabel}}),Object.defineProperty(exports,"validateObjectName",{enumerable:!0,get:function(){return validateObjectName}}),Object.defineProperty(exports,"validateOptions",{enumerable:!0,get:function(){return validateOptions}}),Object.defineProperty(exports,"validateViewName",{enumerable:!0,get:function(){return validateViewName}});
@@ -1,2 +0,0 @@
1
- /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- import{assertUniqueBy as e,colorIdSchema as t,iconNameSchema as n}from"./primitives-DpBFjzxV.mjs";import{SchemaError as r,SchemaErrorCode as i,ToolGroupGrantError as ee,ValidationError as a}from"./exceptions.mjs";import"./zod-locale.mjs";import*as o from"zod";import{AVATAR_COLOR_IDS as te}from"@standards/constants";const ne=[`completed`,`failed`,`cancelled`];function invalidSessionState(e){throw new r(e,i.INVARIANT_VIOLATION)}function assertSessionState(e){e.phase===`running`?e.runningTurnId===void 0&&invalidSessionState(`running session without runningTurnId`):e.runningTurnId!==void 0&&invalidSessionState(`runningTurnId present on a ${e.phase} session`),e.phase===`parked`?e.parkedOn===void 0&&invalidSessionState(`parked session without parkedOn`):e.parkedOn!==void 0&&invalidSessionState(`parkedOn present on a ${e.phase} session`),e.locked===!0&&e.phase!==`parked`&&invalidSessionState(`locked ${e.phase} session`),e.parkedOn===`human`?e.humanRequestIds===void 0&&invalidSessionState(`human-parked session without humanRequestIds`):e.humanRequestIds!==void 0&&invalidSessionState(`humanRequestIds present on a session not parked on a human`)}const re=[`createdAt`,`lastActivity`],ie=[`mine`,`shared`,`team`],s=Object.freeze({mutation:`ask`,destructive:`ask`,outward:`ask`}),ae=[`active`,`completed`,`abandoned`],c=[`openai`,`anthropic`,`google`,`spacexai`,`deepseek`,`moonshotai`,`alibaba`,`mistral`,`minimax`,`meta`,`zai`,`cursor`],l=[`standard`,`fast`],u=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`],d=[`conversation`,`writing`,`coding`,`analysis`,`extraction`],oe=[`light`,`standard`,`heavy`],se=[`manual`,`auto`],ce={interactive:{inputPerMillionUsd:5,outputPerMillionUsd:25},delegated:{inputPerMillionUsd:2,outputPerMillionUsd:12}},f=[`model`,`speed`,`reasoning`,`imageModel`,`routing`];function mergeSessionInferencePatch(e,t){let n={...e};for(let e of f){let r=t[e];r===null?delete n[e]:r!==void 0&&Object.assign(n,{[e]:r})}return t.model&&t.routing===void 0&&(n.routing=`manual`),n}function isRoutineActorMetadata(e){return e?.kind===`routine`}const le=[`octopus`,`clover`,`flower`,`triangle`,`square`,`blob`,`circle`,`drop`,`hexagon`,`pill`,`pebble`,`puddle`],ue=[`relaxed`,`neutral`],de=4,fe=200;function agentDisplayName(e){return e.label?.trim()||e.name}const pe=5e4,p=[`approval-requested`,`approval-responded`,`approval-dispatched`],me=[`streaming`,`running`,`pending`,...p];function isOpenToolPartState(e){return me.includes(e)}function isToolApprovalState(e){return p.includes(e)}const he=[`records`,`descendants`,`brokenLinks`,`denied`,`files`];function isToolImpactCountKey(e){return he.includes(e)}const m=[`CREDITS_EXHAUSTED`,`MEMBER_CAP_REACHED`,`WAKE_BUDGET_SPENT`];function isSystemPartCode(e){return typeof e==`string`&&m.includes(e)}const ge=20,_e=4e3,ve=32e3;function compareAgentSessionMessages(e,t){let n=e.createdAt.getTime()-t.createdAt.getTime();return n===0?e.id.localeCompare(t.id):n}function orderAgentSessionMessages(e){return[...e].sort(compareAgentSessionMessages)}const ye=200,be=182,xe=366,Se=`agent-notification`;function isAgentNotificationMetadata(e){return e?.kind===Se}const Ce=`agent-message`,we=`senderName`;function isAgentMessageMetadata(e){return e?.kind===Ce}const h=`agent-wake`;function isAgentWakeMetadata(e){return e?.kind===h}const g=`architect-publication`;function isArchitectPublicationMetadata(e){return e?.kind===g}const Te=[`object`,`attribute`,`view`,`page`],Ee=[`objectName`,`attributeName`,`viewName`,`pageId`];function readPublishRefusalTarget(e){if(typeof e!=`object`||!e)return;let t=e,n=Te.find(e=>e===t.kind);if(n===void 0)return;let r={kind:n};for(let e of Ee)typeof t[e]==`string`&&(r[e]=t[e]);return r}function readArchitectPublication(e){if(!isArchitectPublicationMetadata(e))return;let t=e?.publication;if(typeof t!=`object`||!t)return;let n=t;if(n.outcome===`published`){let e=n.operations;return typeof e==`number`&&Number.isInteger(e)&&e>=0?{outcome:`published`,operations:e}:void 0}if(n.outcome!==`refused`)return;let r=readPublishRefusalTarget(n.target);return{outcome:`refused`,...r?{target:r}:{},...typeof n.reason==`string`?{reason:n.reason}:{},...typeof n.code==`string`?{code:n.code}:{}}}const De=`speaksThroughSend`,Oe=`wakeTurn`,ke=`wakeTurnSpoke`,Ae=[`pending`,`in_progress`,`completed`,`blocked`],_=[`objects`,`fields`,`relations`,`views`,`samples`],je=50,Me=80,Ne=500,v=[`sandbox`,`web`,`image`,`memory`,`bulk`,`activity`,`orchestration`,`host`,`cloud-browser`,`agent-config`],y=`browser_launch`,b=[`mcp`,`email.read`,`email.send`,`calendar.read`,`github`,`slack.read`,`slack.write`,`device`,`browser-profile`,`login`],Pe=[`definition`,`default`,`child`,`inline`],Fe=[`manual`,`name-asc`,`name-desc`,`date-desc`,`date-asc`],Ie=100,Le=500,Re=2048,x=[`reader`,`runner`,`editor`],S=[`reader`,`editor`],ze=[`manual`,`meeting_attendee`],Be=new Set([`memory`,`skill`]),C=[`runner`],w=[`reader`];function parseRole(e,t){if(typeof t==`string`&&e.includes(t))return t;let n=`role must be one of: ${e.join(`, `)}`;throw new a(n,[{path:[`role`],message:n}])}function parseRecordAccessRole(e){return parseRole(S,e)}function parseAgentDefinitionAccessRole(e){return parseRole(x,e)}function parsePageAccessRole(e){return parseRole(S,e)}function parseDeviceAccessRole(e){return parseRole(C,e)}function parseAgentSessionAccessRole(e){return parseRole(w,e)}function deriveViewerAccess(e,t){return e.visibility===`workspace`?`workspace`:e.ownedBy!==null&&t.includes(e.ownedBy)?`owner`:e.viewerGrant===`editor`?`editor`:e.viewerGrant===`runner`?`runner`:`reader`}const Ve=[`fr`,`en`],He=2e3,T=[`none`,`estimated`,`exact`];function parseCountMode(e){if(typeof e==`string`&&T.includes(e))return e;throw new a(`countMode must be one of: ${T.join(`, `)} (received: ${String(e)})`,[])}function parseOptionalCountMode(e){return e===void 0?void 0:parseCountMode(e)}const Ue=1e4,We=[`record`,`object`,`attribute`,`view`,`user`,`role`,`settings`,`file`,`agent`,`bundle`,`tenant_invitation`,`api_key`,`agent_session`],Ge=`record.created,record.updated,record.deleted,record.restored,record.purged,record.access_changed,agent.access_changed,agent_session.supervised_read,object.created,object.updated,object.deleted,attribute.created,attribute.updated,attribute.deleted,view.created,view.updated,view.deleted,bundle.synced,bundle.removed,bundle.added,user.created,user.invited,user.updated,user.deleted,user.login,user.logout,tenant_invitation.created,tenant_invitation.delivery_failed,tenant_invitation.resent,tenant_invitation.revoked,tenant_invitation.accepted,role.created,role.updated,role.deleted,role.assigned,role.revoked,api_key.detached,settings.updated,file.uploaded,file.updated,file.deleted`.split(`,`),Ke=`agentSessionId`;function isAgentWrittenAuditEntry(e){return e.actorType===`agent`||typeof e.metadata?.agentSessionId==`string`}const qe=[`draft_schema`],Je=`discard_architect_draft`,E=`request_design_review`,Ye=`get_architect_draft`,D=[`search`,`query`,`read`,`write`,`delete`,`organize`,`copy`,`send`],Xe=`send`,Ze=`copy`,O=[...D,`edit_content`],k=[...O,`compact_context`,`request_work_mode`,`write_todos`],A=[y],j=[`get_agents`,`upsert_agent`],Qe=[`record`,`document`,`file`,`skill`,`schema`,`guide`,`decision`],M={memory:{kinds:[`memory`],capabilities:[],tools:[`propose_memory`]},bulk:{kinds:[],capabilities:[`bulk`],tools:[]},activity:{kinds:[],capabilities:[`activity`],tools:[]},"email.read":{kinds:[`email`,`thread`],capabilities:[`copy_email`],tools:[]},"email.send":{kinds:[`email`,`thread`,`draft`],capabilities:[`copy_email`],tools:[]},"calendar.read":{kinds:[`event`],capabilities:[`transcript`],tools:[]}},N={sandbox:{icon:`terminal`,tools:[`exec_command`,`publish_artifact`,`sandbox_validate_payload`]},web:{icon:`globe`,tools:[`read_webpage`,`web_search`]},image:{icon:`image`,tools:[`generate_image`]},memory:{icon:`book-open`,tools:M.memory.tools},bulk:{icon:`layers-two`,tools:M.bulk.tools},activity:{icon:`activity`,tools:M.activity.tools},orchestration:{icon:`git-branch`,tools:[`spawn_agent`]},host:{icon:`wrench`,tools:[]},"cloud-browser":{icon:`globe`,tools:A},"agent-config":{icon:`sparkles`,tools:j}},P={mcp:{icon:`puzzle`,tools:[]},"email.read":{icon:`envelope`,tools:M[`email.read`].tools},"email.send":{icon:`send`,tools:M[`email.send`].tools},"calendar.read":{icon:`calendar`,tools:M[`calendar.read`].tools},github:{icon:`brand-github`,tools:[]},"slack.read":{icon:`brand-slack`,tools:[`slack_read`,`slack_find`,`slack_download_file`]},"slack.write":{icon:`brand-slack`,tools:[`slack_send`,`slack_react`,`slack_set_status`]},device:{icon:`desktop`,tools:[`exec_command`]},"browser-profile":{icon:`globe`,tools:A},login:{icon:`key`,tools:[]}},$e={sandbox:{kinds:[],capabilities:[],tools:N.sandbox.tools},web:{kinds:[],capabilities:[],tools:N.web.tools},image:{kinds:[],capabilities:[],tools:N.image.tools},memory:M.memory,bulk:M.bulk,activity:M.activity,orchestration:{kinds:[],capabilities:[],tools:N.orchestration.tools},host:{kinds:[],capabilities:[],tools:N.host.tools},"cloud-browser":{kinds:[],capabilities:[],tools:N[`cloud-browser`].tools},"agent-config":{kinds:[],capabilities:[],tools:N[`agent-config`].tools},mcp:{kinds:[],capabilities:[],tools:P.mcp.tools},"email.read":M[`email.read`],"email.send":M[`email.send`],"calendar.read":M[`calendar.read`],github:{kinds:[],capabilities:[],tools:P.github.tools},"slack.read":{kinds:[],capabilities:[],tools:P[`slack.read`].tools},"slack.write":{kinds:[],capabilities:[],tools:P[`slack.write`].tools},device:{kinds:[],capabilities:[],tools:P.device.tools},"browser-profile":{kinds:[],capabilities:[],tools:P[`browser-profile`].tools},login:{kinds:[],capabilities:[],tools:P.login.tools}},et={schema:[`discard_architect_draft`,`draft_schema`,`get_architect_draft`,`get_schema_history`,`request_design_review`,`search_icons`],"agent-config":j,setup:[`request_setup`],internal:[`load_toolset`]},tt=[...new Set([...k,...v.flatMap(e=>N[e].tools),...b.flatMap(e=>P[e].tools)])],nt={"email.read":[`gmail`,`outlook`],"email.send":[`gmail`,`outlook`],"calendar.read":[`google-calendar`,`outlook-calendar`]};function connectionGrantKindsOf(e){switch(e){case`github`:return[`github`];case`slack`:return[`slack.read`,`slack.write`];case`google-calendar`:case`outlook-calendar`:return[`calendar.read`];case`gmail`:case`outlook`:return[`email.read`,`email.send`]}}const rt=[`activity`,`bulk`,`image`,`memory`,`orchestration`,`sandbox`,`web`],it=[`memory`],at=new Set([`sandbox`,`host`,`cloud-browser`]);function needsManageWhenUnattended(e){return at.has(e)||isResourceGrant(e)}function isNativeToolGroup(e){return v.includes(e)}function parseToolGroupGrant(e){if(isNativeToolGroup(e))return{type:`native`,group:e};let t=e.indexOf(`:`);if(t<=0)return null;let n=e.slice(0,t),r=e.slice(t+1);return r.length===0||!b.includes(n)?null:{type:`resource`,kind:n,id:r}}function grantKindOf(e){let t=parseToolGroupGrant(e);return t?.type===`resource`?t.kind:null}function isResourceGrant(e){return parseToolGroupGrant(e)?.type===`resource`}function resourceGrant(e,t){return`${e}:${t}`}function canonicalToolGroups(e){return[...new Set(e)].sort()}const F=`ask_questions`,I=`request_setup`,ot=new Set([F,E,I]),st=new Set([F,I]),ct=new Set([E]),lt=4,ut=2e3,dt=50,ft=o.union([o.object({value:o.string(),label:o.string()}).strict(),o.object({values:o.array(o.string()),labels:o.array(o.string()),text:o.string().optional()}).strict(),o.object({text:o.string()}).strict()]),pt=o.object({skipped:o.boolean().describe(`True if the person skipped all questions`),answers:o.record(o.string(),ft).describe(`Map of question ID to the answer given, with each chosen option's value and label`),unanswered:o.array(o.object({id:o.string(),question:o.string().optional()})).optional().describe(`The questions the person left empty, by ID and text: they did not answer them. Ask again if you still need the answer`),answeredBy:o.object({id:o.string(),name:o.string()}).optional().describe(`Who answered: one of the people the question went to, not always the person you act for`)});function readAskQuestionsResult(e){let t=pt.safeParse(e);return t.success?t.data:null}function hasQuestions(e){return typeof e!=`object`||!e||!(`questions`in e)?!1:Array.isArray(e.questions)&&e.questions.length>0}function isQuestionPart(e){return st.has(e.name)||e.name===`send`&&hasQuestions(e.args)}function argsOf(e){return typeof e.args==`object`&&e.args!==null?e.args:void 0}function awaitedChildOf(e){let t=argsOf(e);if(e.name!==`send`||t?.wait!==!0)return;let n=t.ref;return typeof n==`string`&&n.startsWith(`session:`)?n.slice(8):void 0}function lockingSendCall(e,t){let n=new Map,r=[];for(let i of e){if(i.name!==`send`)continue;if(isQuestionPart(i)){t.requestIds.includes(i.id)&&r.push(i);continue}let e=awaitedChildOf(i);e!==void 0&&n.set(e,i)}for(let[e,i]of n)(t.awaitedChildIds===void 0||t.awaitedChildIds.includes(e))&&r.push(i);let i=new Map(e.map((e,t)=>[e,t]));return r.filter(e=>argsOf(e)?.lock===!0).sort((e,t)=>(i.get(t)??0)-(i.get(e)??0))[0]}function humanRequestKind(e){return isQuestionPart(e)?`question`:e.approvalId==null?ct.has(e.name)?`review`:null:`approval`}function isAwaitingHuman(e){let t=humanRequestKind(e);return t===null||e.state===`streaming`||!isOpenToolPartState(e.state)||e.result!==void 0||e.error!==void 0?!1:t!==`approval`||e.state===`approval-requested`&&e.approved===void 0}function isBlocking(e){let t=humanRequestKind(e);return t===`review`?isOpenToolPartState(e.state):t===`approval`&&e.state===`approval-requested`&&e.approved===void 0}function humanRequestId(e){return isQuestionPart(e)?e.toolCallId:e.approvalId??e.toolCallId}function openRequests(e,t){let n=t.blocking?isBlocking:isAwaitingHuman,r=[];for(let t of e)for(let e of t.parts??[])isToolRequestPart(e)&&n(e)&&r.push({part:e,id:humanRequestId(e),requestedAt:t.createdAt});return r}function isToolRequestPart(e){return e.type===`tool`}function isParkedOnHuman(e){return e?.phase===`parked`&&e.parkedOn===`human`}const mt=50;function recentActivityEntryKey(e){return e.kind===`record`?JSON.stringify([`record`,e.objectName,e.recordId]):JSON.stringify([`conversation`,`sessionId`in e?e.sessionId:e.session.id])}const ht=200,gt=5242880,_t=`Notetaker`,vt=/^\d{1,9}(\.\d{1,6})?$/,yt={meetingRecordingPolicy:`none`,meetingBotDisplayName:_t,memoryPersonMonthlyLimitUsd:null,memoryTenantMonthlyLimitUsd:null,findImages:!0,memberMonthlyCapCredits:null},bt=[`active`,`suspended`],xt=[`architect`,`manual`,`auto`],St=[`panel`,`fullscreen`],Ct=200,wt=50,Tt=200,Et=50,Dt=o.discriminatedUnion(`type`,[o.strictObject({type:o.literal(`record`),object:o.string().min(1),id:o.guid()}),o.strictObject({type:o.literal(`user`),id:o.guid()})]),Ot=o.strictObject({nodes:o.array(Dt).min(1).max(50),limitPerNode:o.number().int().min(1).max(200).default(50)});function recordGraphNodeKey(e){return e.type===`record`?`record:${e.object}:${e.id}`:`user:${e.id}`}const kt=100,At=`work`,jt=`/vercel/sandbox/${At}`,Mt=`/workspace`;function environmentWorkdir(e){return e?jt:Mt}const Nt=[{id:`claude-code`,label:`Claude Code`,provider:`anthropic`,apiKeyEnv:`ANTHROPIC_API_KEY`,models:[{id:`sonnet`,label:`Claude Sonnet`},{id:`opus`,label:`Claude Opus`},{id:`haiku`,label:`Claude Haiku`}],defaultModel:`sonnet`},{id:`codex`,label:`Codex`,provider:`openai`,apiKeyEnv:`OPENAI_API_KEY`,models:[{id:`gpt-6.1-sol`,label:`GPT-6.1 Sol`},{id:`gpt-6-luna`,label:`GPT-6 Luna`},{id:`gpt-6-astra`,label:`GPT-6 Astra`}],defaultModel:`gpt-6.1-sol`},{id:`cursor`,label:`Cursor`,provider:`cursor`,apiKeyEnv:`CURSOR_API_KEY`,models:[{id:`auto`,label:`Auto`,cliDefault:!0},{id:`composer-2.5`,label:`Composer 2.5`}],defaultModel:`auto`}],L=new Map(Nt.map(e=>[e.id,e]));function isEnvironmentHarnessId(e){return L.has(e)}function findEnvironmentHarness(e){return L.get(e)}function environmentHarness(e){let t=L.get(e);if(!t)throw new r(`Unknown harness "${e}"`,i.INVARIANT_VIOLATION);return t}function cliDefaultModelOf(e){return environmentHarness(e).models.find(e=>e.cliDefault)?.id}function compiledHarnessModels(e){let t=environmentHarness(e);return t.models.map(e=>({id:e.id,label:e.label,...e.id===t.defaultModel?{isDefault:!0}:{}}))}function harnessModelChoices(e,t){let{provider:n}=environmentHarness(e);return t.map(e=>({id:e.id,provider:n,label:e.label,...e.isDefault?{isDefault:!0}:{}}))}const Pt=[`code`,`documents`],Ft=[`small`,`default`,`large`],It={small:2,default:4,large:8},Lt=2,Rt=`── `,zt=[`setup`,`bake`,`publish`];function isEnvironmentBuildLogStep(e){return zt.includes(e)}const Bt=65536,Vt=100;function utf8ByteLength(e){return new TextEncoder().encode(e).length}const Ht=[{key:`direct`,icon:`message`,color:`ink`,description:`A message a person wrote to this mailbox: a conversation, a question, a request, a reply.`},{key:`transactional`,icon:`credit-card`,color:`terra`,description:`An automated message about an account or an operation: receipt, invoice, payment, order, shipping, booking, password reset, security alert.`},{key:`notifications`,icon:`bell`,color:`ochre`,description:`An automated alert from a tool or a service: activity on GitHub, Slack, a calendar, a CRM, a monitoring system.`},{key:`newsletters`,icon:`book-open`,color:`stone`,description:`Editorial content the mailbox subscribed to: newsletters, digests, articles, community updates.`},{key:`marketing`,icon:`percentage`,color:`iris`,description:`Promotion or prospecting: offers, discounts, product announcements, cold sales outreach.`}],Ut={direct:{en:`Direct`,fr:`Direct`},transactional:{en:`Transactional`,fr:`Transactionnel`},notifications:{en:`Notifications`,fr:`Notifications`},newsletters:{en:`Newsletters`,fr:`Newsletters`},marketing:{en:`Marketing`,fr:`Marketing`}},Wt=8,Gt=24,Kt=10,qt=500,Jt=`tag`,Yt=`stone`,Xt=new Set(`gmail.com,googlemail.com,outlook.com,hotmail.com,hotmail.fr,outlook.fr,live.com,live.fr,msn.com,yahoo.com,yahoo.fr,icloud.com,me.com,mac.com,proton.me,protonmail.com,gmx.com,gmx.fr,orange.fr,wanadoo.fr,free.fr,laposte.net,sfr.fr,bbox.fr,numericable.fr,aol.com`.split(`,`)),Zt=new Set(Ht.map(e=>e.key)),Qt=new Set(Object.entries(Ut).flatMap(([e,t])=>[e,t.en,t.fr].map(e=>e.toLowerCase())));function isSystemEmailCategory(e){return Zt.has(e)}function isSystemEmailCategoryName(e){return Qt.has(e.trim().toLowerCase())}function isPublicMailDomain(e){return Xt.has(e.toLowerCase())}const R={maxConcurrentRuns:3,retryPolicy:{maxRetries:3,backoffMs:1e3,backoffMultiplier:2}};var AgentBuilder=class{constructor(e){if(!e.name||e.name.trim().length===0)throw new a(`Agent name is required`,[]);this.bp={name:e.name,system:!0,visibility:`workspace`,triggers:[]}}description(e){return this.bp.description=e,this}label(e){return this.bp.label=e,this}avatar(e){return this.bp.avatar={type:e.type,color:e.color,expression:e.expression??`relaxed`},this}starters(e){return e.length===0?delete this.bp.starters:this.bp.starters=[...e],this}systemPrompt(e){return this.bp.systemPrompt=e,this}model(e,t,n){return this.bp.model={provider:e,model:t,...n},this}toolGroups(e){let t=e.find(e=>!isNativeToolGroup(e));if(t!==void 0)throw new ee(i.AGENT_TOOL_GROUP_UNKNOWN,t,`Agent "${this.bp.name}": "${t}" is not a native tool group (blueprints cannot grant tenant resources)`);return this.bp.toolGroups=canonicalToolGroups(e),this}schedule(e){return this.bp.schedule={...e,enabled:e.enabled??!0},this}config(e){let t=this.bp.config??R,n=e.inference===void 0?t.inference:{...t.inference,...e.inference};return this.bp.config={...t,...e,...n===void 0?{}:{inference:n}},this}delegation(e){return Object.assign(this.bp,e),this}approval(e){return this.bp.approval={...s,...this.bp.approval,...e},this}visibility(e){return this.bp.visibility=e,this}trigger(e,t,n){return this.bp.triggers.push({name:e,eventType:t,...n,enabled:n?.enabled??!0}),this}runtime(){return this.bp.system=!1,this}build(){if(!this.bp.systemPrompt)throw new a(`Agent "${this.bp.name}": systemPrompt is required`,[]);if(!this.bp.model)throw new a(`Agent "${this.bp.name}": model is required`,[]);if(this.bp.system&&this.bp.visibility===`private`)throw new a(`Agent "${this.bp.name}": system agents must use workspace visibility`,[]);return e(this.bp.triggers,e=>e.name,e=>new a(`Agent "${this.bp.name}": duplicate trigger name "${e}"`,[])),{...this.bp,visibility:this.bp.visibility??`workspace`,toolGroups:this.bp.toolGroups??[...it],config:this.bp.config??R,systemPrompt:this.bp.systemPrompt,model:this.bp.model}}};function agent(e){return new AgentBuilder(e)}const z={issue:{events:[`issues`],actions:[`opened`,`edited`,`closed`,`reopened`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`milestoned`,`demilestoned`,`transferred`,`pinned`],conditions:[`label`,`issueLabels`,`assignees`,`milestone`,`issueType`,`text`]},pull_request:{events:[`pull_request`],actions:[`opened`,`ready_for_review`,`synchronize`,`review_requested`,`merged`,`closed`,`reopened`,`converted_to_draft`,`labeled`,`assigned`,`edited`],conditions:[`baseBranch`,`headBranch`,`draft`,`issueLabels`,`changedPaths`,`prAuthor`]},review:{events:[`pull_request_review`],actions:[`submitted`,`edited`,`dismissed`],conditions:[`reviewState`,`prAuthor`]},comment:{events:[`issue_comment`,`pull_request_review_comment`,`commit_comment`],actions:[`created`,`edited`,`deleted`],conditions:[`text`,`issueAuthor`,`prAuthor`]},push:{events:[`push`],actions:[`pushed`],conditions:[`branch`,`changedPaths`,`forced`]},ref:{events:[`create`,`delete`],actions:[`created`,`deleted`],conditions:[`refType`,`branch`,`tag`]},workflow:{events:[`workflow_run`],actions:[`requested`,`in_progress`,`completed`],conditions:[`workflowName`,`conclusion`,`branch`,`originEvent`]},check:{events:[`check_suite`,`check_run`],actions:[`completed`,`rerequested`],conditions:[`checkApp`,`checkName`,`conclusion`]},project_item:{events:[`projects_v2_item`],actions:[`created`,`edited`,`archived`,`restored`,`deleted`],conditions:[`project`,`projectField`,`from`,`to`,`itemType`]},release:{events:[`release`],actions:[`published`,`created`,`edited`,`prereleased`,`deleted`],conditions:[`prerelease`,`tag`]},discussion:{events:[`discussion`,`discussion_comment`],actions:[`created`,`commented`,`answered`,`labeled`,`closed`],conditions:[`category`,`issueLabels`,`text`]},repository:{events:[`star`,`fork`,`repository`],actions:[`starred`,`forked`,`created`,`archived`],conditions:[]}},$t={mention:{events:[`app_mention`],conditions:[`text`]},message:{events:[`message`],conditions:[`position`,`text`,`hasFile`]},dm:{events:[`message`],conditions:[`text`,`hasFile`]},reaction:{events:[`reaction_added`],conditions:[`messageAuthor`]},member_joined:{events:[`member_joined_channel`],conditions:[]}},en=o.object({field:o.literal(`text`),operator:o.enum([`contains`,`starts_with`]),value:o.string().min(1)}).strict();function stringCondition(e){return o.object({field:o.literal(e),value:o.string().min(1)}).strict()}function booleanCondition(e){return o.object({field:o.literal(e),value:o.boolean()}).strict()}function listCondition(e){return o.object({field:o.literal(e),operator:o.enum([`any`,`all`]).default(`any`),value:o.array(o.string().min(1)).min(1)}).strict()}const tn=o.discriminatedUnion(`field`,[en,stringCondition(`label`),listCondition(`issueLabels`),listCondition(`assignees`),stringCondition(`milestone`),stringCondition(`issueType`),stringCondition(`baseBranch`),stringCondition(`headBranch`),stringCondition(`branch`),booleanCondition(`draft`),stringCondition(`changedPaths`),booleanCondition(`forced`),stringCondition(`prAuthor`),stringCondition(`issueAuthor`),o.object({field:o.literal(`reviewState`),value:o.enum([`approved`,`changes_requested`,`commented`])}).strict(),stringCondition(`workflowName`),stringCondition(`checkApp`),stringCondition(`checkName`),stringCondition(`conclusion`),stringCondition(`originEvent`),stringCondition(`project`),stringCondition(`projectField`),o.object({field:o.literal(`from`),value:o.string().nullable()}).strict(),o.object({field:o.literal(`to`),value:o.string().nullable()}).strict(),o.object({field:o.literal(`itemType`),value:o.enum([`issue`,`pull_request`,`draft`])}).strict(),booleanCondition(`prerelease`),stringCondition(`tag`),o.object({field:o.literal(`refType`),value:o.enum([`branch`,`tag`])}).strict(),stringCondition(`category`)]),nn=o.discriminatedUnion(`field`,[en,o.object({field:o.literal(`position`),value:o.enum([`top_level`,`reply`])}).strict(),booleanCondition(`hasFile`),stringCondition(`messageAuthor`)]),rn=o.string().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/),an=o.enum([`human`,`me`,`any`]),on=o.object({family:o.enum(Object.keys(z)),actions:o.array(o.string()).default([]),repositories:o.array(rn).default([]),sender:o.union([an,o.object({logins:o.array(o.string().min(1)).min(1)}).strict()]).default(`human`),conditions:o.array(tn).default([])}).strict().superRefine((e,t)=>{let n=z[e.family];e.actions.forEach((r,i)=>{n.actions.includes(r)||t.addIssue({code:`custom`,path:[`actions`,i],message:`Action ${r} is not supported by ${e.family}`})}),e.conditions.forEach((r,i)=>{n.conditions.includes(r.field)||t.addIssue({code:`custom`,path:[`conditions`,i,`field`],message:`Condition ${r.field} is not supported by ${e.family}`})})}).transform(e=>e),sn=o.object({on:o.enum([`mention`,`message`,`dm`,`reaction`,`member_joined`]),channels:o.array(o.string().min(1)).default([]),reactions:o.array(o.string().min(1)).optional(),sender:o.union([an,o.object({users:o.array(o.string().min(1)).min(1)}).strict()]).default(`human`),conditions:o.array(nn).default([])}).strict().superRefine((e,t)=>{e.conditions.forEach((n,r)=>{$t[e.on].conditions.includes(n.field)||t.addIssue({code:`custom`,path:[`conditions`,r,`field`],message:`Condition ${n.field} is not supported by ${e.on}`})}),e.reactions!==void 0&&e.on!==`reaction`&&t.addIssue({code:`custom`,path:[`reactions`],message:`reactions requires on=reaction`})}).transform(e=>e),cn=o.union([on,sn]),ln=[`read`,`write`,`full`],un=[`accepted`,`declined`,`tentative`],dn=`sent nothing back`,fn=`MEETING_BOT_NO_CREDITS`,pn=[`force`,`skip`],mn=[`none`,`all`,`external_only`],hn={override:null,status:`none`,failureReason:null,waitingRoom:!1,botId:null},gn=o.object({speaker:o.string().nullable(),startsAtMs:o.number(),endsAtMs:o.number(),text:o.string()}),_n=o.object({fullText:o.string(),segments:o.array(gn),language:o.string().nullable(),startedAt:o.string().nullable(),endedAt:o.string().nullable()}),vn={width:1280,height:720,maxBytes:13e5,mimeType:`image/jpeg`},yn=Math.ceil(vn.maxBytes/3)*4,bn=o.object({conferenceJoinUrl:o.string().min(1),botDisplayName:o.string().min(1),startsAt:o.string().nullable(),callbackUrl:o.url(),botImageJpeg:o.string().max(yn).optional()}),xn=o.object({botId:o.string().min(1)}),Sn=o.discriminatedUnion(`kind`,[o.object({kind:o.literal(`transcript-ready`),botId:o.string().min(1)}),o.object({kind:o.literal(`failure`),botId:o.string().min(1),reason:o.string()}),o.object({kind:o.literal(`waiting-room`),botId:o.string().min(1),waiting:o.boolean()})]);function recordMeetingsCount(e){return typeof e.total==`number`?{total:e.total,isExact:e.totalIsExact!==!1}:null}const Cn=100;let wn=function(e){return e.Desktop=`desktop`,e}({});function isMailProvider(e){return e===`gmail`||e===`outlook`}const Tn=`DRAFT`;function isProviderDraft(e){return e.includes(Tn)}const En=[`read`,`unread`,`archive`,`trash`,`restore`],Dn=[`threads`,`messages`];function isMailboxListMode(e){return Dn.includes(e)}const On=[`reply`,`reply_all`];function isReplyMode(e){return On.includes(e)}const kn=2e5,An=2e4,jn=998,Mn=100,Nn=/^[A-Za-z0-9_-]+$/,Pn=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,6})?Z$/,Fn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function encodeAgentSessionListCursor(e){return btoa(`${e.at}|${e.id}`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function decodeAgentSessionListCursor(e){if(e.length>256||!Nn.test(e))return null;let t;try{t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`))}catch{return null}let[n,r,...i]=t.split(`|`);return i.length>0||!n||!r||!Pn.test(n)||!Fn.test(r)?null:isRealInstant(n)?{at:n,id:r}:null}function isRealInstant(e){let t=new Date(e);return!Number.isNaN(t.getTime())&&t.toISOString().slice(0,19)===e.slice(0,19)}const In={added:o.array(o.string()).readonly(),removed:o.array(o.string()).readonly(),roleChanged:o.array(o.string()).readonly(),workspaceBefore:o.boolean(),workspaceAfter:o.boolean(),subtreeSize:o.number().int().nonnegative()},Ln=o.object(In).readonly(),Rn=o.object(In).strict().readonly(),B=o.number().finite().nonnegative(),V=o.enum(c),H=o.enum(l),U=o.enum(u),W=o.enum(se),G=o.object({provider:V,model:o.string().min(1)}).strict(),zn=o.object({speed:H.optional(),reasoning:U.optional(),routing:W.optional()}).strict(),K=o.string().regex(/^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9._-]*$/),Bn=o.object({model:G.optional(),speed:H.optional(),reasoning:U.optional(),imageModel:K.optional(),routing:W.optional()}).strict(),Vn=Bn.refine(e=>f.some(t=>e[t]!==void 0),{message:`At least one inference override is required`});function isSessionInferencePatch(e){return Object.keys(e).length>0&&Object.values(e).every(e=>e!==void 0)}const Hn=o.object({model:G.nullable().optional(),speed:H.nullable().optional(),reasoning:U.nullable().optional(),imageModel:K.nullable().optional(),routing:W.nullable().optional()}).strict().refine(isSessionInferencePatch,{message:`At least one inference override is required`}),Un=o.object({model:o.string().min(1),routing:o.object({mode:o.literal(`auto`),tasks:o.array(o.enum(d)).optional(),demand:o.enum(oe).optional(),reason:o.enum([`selected`,`retained`,`fallback`]).optional(),relation:o.enum([`continue`,`modify`,`new`,`aside`,`unknown`]).optional(),anchorMessageId:o.string().min(1).optional()})}),Wn=o.object({objectName:o.string(),id:o.string(),label:o.string(),objectIcon:o.string().optional()}).strict(),q=o.object({label:o.string(),denied:o.boolean().optional(),deletion:o.object({target:o.string().optional(),count:B.optional(),restorableDays:B.optional()}).strict().optional(),record:Wn.optional(),object:o.object({name:o.string(),label:o.string(),draft:o.object({label:o.string(),values:o.array(o.object({attribute:o.string(),value:o.unknown()}).strict())}).strict().optional()}).strict().optional(),email:o.object({from:o.string(),to:o.array(o.string()),cc:o.array(o.string()),bcc:o.array(o.string()),subject:o.string().nullable(),text:o.string(),truncatedChars:B,outsideThread:o.array(o.string()),attachments:o.array(o.object({name:o.string(),size:B}).strict()),updatedAt:o.string(),forwarded:o.object({from:o.string(),subject:o.string().nullable(),quote:o.string(),quoteTruncatedChars:B}).strict().optional()}).strict().optional(),move:Rn.optional(),parent:Wn.nullable().optional(),skill:o.object({source:o.string(),description:o.string(),audience:o.enum([`private`,`workspace`]),files:B,hasScripts:o.boolean()}).strict().optional(),outgoingText:o.string().optional(),counts:o.record(o.string(),B).optional(),warnings:o.array(o.string()).optional()}).strict(),Gn=o.union([o.object({type:o.literal(`text`),text:o.string()}).strict(),o.object({type:o.literal(`reasoning`),text:o.string()}).strict(),o.object({type:o.literal(`system`),code:o.enum(m)}).strict(),o.object({type:o.literal(`sent-message`),text:o.string(),attachments:o.array(o.string()).optional()}).strict(),o.object({type:o.literal(`error`),error:o.string(),errorClass:o.string().optional()}).strict(),o.object({type:o.literal(`tool`),toolCallId:o.string(),name:o.string(),args:o.record(o.string(),o.unknown()),result:o.unknown().optional(),error:o.string().optional(),errorCode:o.enum([`output_limit_reached`,`interrupted`,i.INVALID_TOOL_INPUT,`external_outcome_unknown`,`external_not_dispatched`]).optional(),state:o.enum([`streaming`,`running`,`completed`,`error`,`pending`,`approval-requested`,`approval-responded`,`approval-dispatched`]),durationMs:B.optional(),approvalId:o.string().optional(),approvalImpact:q.optional(),approved:o.boolean().optional(),approvalReason:o.string().optional(),approvalDecidedBy:o.string().optional(),approvalDecidedAt:o.string().optional(),approvalRelaxableByAuto:o.boolean().optional()}).strict(),o.object({type:o.literal(`file`),fileId:o.string(),name:o.string(),mimeType:o.string()}).strict(),o.object({type:o.literal(`compaction`),state:o.literal(`in-progress`),reason:o.enum([`preflight_threshold`,`overflow_recovery`]),estimatedTokens:B.optional(),reportedTokens:B.optional()}).strict(),o.object({type:o.literal(`compaction`),state:o.literal(`completed`),tokensBefore:B,tokensAfter:B,tokensSaved:B,strategy:o.enum([`no-op`,`summary`,`truncation`]),durationMs:B,summary:o.string().optional()}).strict(),o.object({type:o.literal(`compaction`),state:o.literal(`failed`),reason:o.string(),durationMs:B.optional()}).strict()]),Kn=o.object({id:o.string().min(1),name:o.string().min(1),mimeType:o.string().min(1),size:o.number().int().min(0)}).strict(),qn=o.object({id:o.string(),artifactId:o.string(),revision:o.number().int().min(1),selectedText:o.string()}).strict(),Jn=o.object({id:o.string().min(1),type:o.string().min(1).transform(e=>e),entityId:o.string().min(1),label:o.string().min(1),objectName:o.string().min(1).optional(),startIndex:o.number().int().min(0),endIndex:o.number().int().min(0)}).strict(),Yn=o.object({provider:V,model:o.string().min(1),maxTokens:o.number().int().positive().optional(),contextWindow:B.optional()}).strict(),Xn=o.union([o.date(),o.string().datetime({offset:!0}).transform(e=>new Date(e))]),Zn=o.object({id:o.string(),sessionId:o.string(),tenantId:o.string().optional(),runId:o.string().optional(),role:o.enum([`user`,`assistant`,`system`,`tool`]),parts:o.array(Gn),attachments:o.array(Kn).optional(),mentions:o.array(Jn).optional(),quotes:o.array(qn).optional(),model:Yn.optional(),tokenUsage:o.object({input:B,output:B}).strict().optional(),metadata:o.record(o.string(),o.unknown()).optional(),createdAt:Xn}).strict(),Qn=o.object({id:o.string(),description:o.string(),status:o.enum([`pending`,`in_progress`,`completed`,`blocked`]),result:o.string().optional(),updatedAt:B.optional(),target:o.object({phase:o.enum(_)}).strict().optional()}).strict(),$n=o.object({id:o.string(),sessionId:o.string(),status:o.enum([`active`,`completed`,`abandoned`]),todos:o.array(Qn),version:B,createdAt:o.string(),updatedAt:o.string(),completedAt:o.string().optional()}).strict(),J={"compaction-start":o.object({reason:o.enum([`preflight_threshold`,`overflow_recovery`]),estimatedTokens:B.optional(),reportedTokens:B.optional()}).strict(),"compaction-end":o.object({tokensBefore:B,tokensAfter:B,tokensSaved:B,strategy:o.enum([`no-op`,`summary`,`truncation`]),durationMs:B,summary:o.string().optional()}).strict(),"compaction-failed":o.object({reason:o.string()}).strict(),usage:o.object({messageId:o.string().min(1).optional(),inputTokens:B,outputTokens:B,totalTokens:B,cacheReadTokens:B.optional(),cacheCreationTokens:B.optional(),contextWindow:B,residentTokens:B,utilization:o.number().finite().min(0).max(1),costUsd:B.optional()}).strict(),"sent-message":o.object({text:o.string(),attachments:o.array(o.string()).optional()}).strict(),"message-updated":o.object({message:Zn}).strict(),"approval-context":o.object({approvalId:o.string(),toolCallId:o.string(),impact:q.optional(),relaxableByAuto:o.boolean().optional()}).strict()};function isAgentUIDataName(e){return e in J}function agentUIValidationError(e){return new a(`Invalid agent UI message chunk`,e.map(e=>({path:e.path.map(String),message:e.message,code:e.code})))}function assertCustomAgentUIMessageChunk(e){if(typeof e!=`object`||!e||typeof e.type!=`string`)throw new a(`Invalid agent UI message chunk`,[{path:[`type`],message:`Expected UI message chunk type`,code:`invalid_type`}]);let t=e.type;if(!t.startsWith(`data-`))throw new a(`Invalid agent UI message chunk`,[{path:[`type`],message:`Expected agent data chunk type`,code:`invalid_value`}]);let n=t.slice(5);if(!isAgentUIDataName(n))throw new a(`Invalid agent UI message chunk`,[{path:[`type`],message:`Unknown agent UI data type: ${n}`,code:`invalid_value`}]);let r=o.object({type:o.literal(`data-${n}`),id:o.string().optional(),data:J[n],transient:o.boolean().optional()}).strict().safeParse(e);if(!r.success)throw agentUIValidationError(r.error.issues);return r.data}function agentDataChunk(e,t,n){return assertCustomAgentUIMessageChunk({type:`data-${e}`,...n?.id===void 0?{}:{id:n.id},data:t,...n?.transient===void 0?{}:{transient:n.transient}})}const er=o.string().trim().min(1).max(24),tr=o.string().trim().min(10).max(500),nr=o.enum([`address`,`domain`]),rr=o.object({scope:o.enum([`personal`,`workspace`]),name:er,description:tr,icon:n.default(`tag`),color:t.default(Yt)}),ir=o.object({name:er.optional(),description:tr.optional(),icon:n.optional(),color:t.optional()}).refine(e=>Object.values(e).some(e=>e!==void 0),{message:`Nothing to update`}),ar=o.object({moveTo:o.string().min(1).nullable().default(null)}),or=o.object({category:o.string().min(1).optional(),important:o.boolean().optional()}).refine(e=>e.category!==void 0||e.important!==void 0,{message:`Nothing to classify`}),sr=o.object({verdict:o.object({category:o.string().min(1).nullable(),important:o.boolean(),classifiedBy:o.enum([`model`,`rule`,`manual`]).nullable()}),ruleId:o.string().uuid().nullable(),previousRule:o.object({scope:nr,match:o.string().trim().toLowerCase().min(1),category:o.string().min(1)}).nullable()}).refine(e=>e.ruleId!==null||e.previousRule===null,{message:`A previous rule needs the rule it restores`}),cr=o.object({scope:o.literal(`domain`)}),lr=o.object({scope:o.enum([`personal`,`workspace`])}),ur=o.object({type:o.enum(le),color:o.enum(te),expression:o.enum(ue).default(`relaxed`)}).strict(),dr=o.array(o.string().trim().min(1).max(200)).max(4);function agentAvatarFromMetadata(e){let t=ur.safeParse(e);return t.success?t.data:void 0}const Y=[`record.created`,`record.updated`,`record.deleted`,`form.submitted`,`webhook`,`github`,`slack`],fr=new Set([`record.created`,`record.updated`,`record.deleted`]),pr=/^[A-Z_][A-Z0-9_]*$/,mr=o.object({cron:o.string().min(9),timezone:o.string().optional(),enabled:o.boolean(),input:o.record(o.string(),o.unknown()).optional(),runFor:o.enum([`armer`,`audience`]).optional(),audience:o.object({workspace:o.boolean(),roleIds:o.array(o.uuid()),actorIds:o.array(o.uuid())}).optional(),continueConversation:o.boolean().optional()}),hr=/^[A-Za-z0-9_$-]+(\.[A-Za-z0-9_$-]+)*$/,X=o.object({name:o.string().max(120).optional(),eventType:o.enum(Y),objectId:o.guid().optional(),watchedFields:o.array(o.string()).max(50).optional(),debounceMs:o.number().int().min(0).max(3e5).optional(),filter:o.object({combinator:o.enum([`and`,`or`]).default(`and`),rules:o.array(o.object({attribute:o.string(),operator:o.string(),value:o.unknown().optional()}))}).optional(),formDefinitionId:o.string().optional(),continuationKey:o.string().max(200).regex(hr).nullable().optional(),connectionId:o.guid().optional(),match:cn.optional(),continueConversation:o.boolean().optional(),enabled:o.boolean().optional()});function refineTrigger(e){return e.refine(e=>!e.watchedFields?.length||e.eventType===`record.updated`,{message:`watchedFields requires eventType=record.updated`,path:[`watchedFields`]}).refine(e=>!(e.eventType&&fr.has(e.eventType))||!!e.objectId,{message:`objectId is required for record.* triggers`,path:[`objectId`]}).refine(e=>!(e.continuationKey&&e.eventType)||e.eventType===`webhook`,{message:`continuationKey requires eventType=webhook`,path:[`continuationKey`]}).superRefine((e,t)=>{let n=e.eventType===`github`||e.eventType===`slack`;if(n&&!e.connectionId&&t.addIssue({code:`custom`,path:[`connectionId`],message:`connectionId is required for native connector triggers`}),n&&!e.match&&t.addIssue({code:`custom`,path:[`match`],message:`match is required for native connector triggers`}),e.match&&e.eventType&&((e.eventType===`github`?`family`in e.match:e.eventType===`slack`&&`on`in e.match)||t.addIssue({code:`custom`,path:[`match`],message:`match must belong to the trigger provider`})),e.eventType&&!n)for(let n of[`connectionId`,`continueConversation`])e[n]!==void 0&&t.addIssue({code:`custom`,path:[n],message:`${n} requires a native connector trigger`})})}const gr=refineTrigger(X).transform(e=>({...e,...e.eventType===`github`||e.eventType===`slack`?{continueConversation:e.continueConversation??!0}:{}})),_r=X.partial();function parseMergedAgentTrigger(e,t){let n=_r.safeParse(t);if(!n.success)throw triggerValidationError(n.error);let r=Object.fromEntries(Object.entries(n.data).filter(([,e])=>e!==void 0)),i=gr.safeParse({...e,...r});if(!i.success)throw triggerValidationError(i.error);return i.data}function triggerValidationError(e){return new a(`Invalid agent trigger`,e.issues.map(e=>({path:e.path.map(String),message:e.message})))}const vr=100,Z=o.uuid(),Q=o.record(o.string(),o.unknown()),yr=o.strictObject({objectName:o.string(),recordId:Z,attribute:o.string(),base:o.unknown(),props:Q.optional()}),br=o.strictObject({kind:o.literal(`record.set`),objectId:Z,recordId:Z,values:Q,base:Q.optional()}),xr=o.strictObject({kind:o.literal(`record.create`),objectId:Z,recordId:Z,values:Q,options:o.strictObject({visibility:o.enum([`workspace`,`private`]).optional(),allowDraft:o.boolean().optional(),linkTo:yr.optional(),parentId:Z.optional()}).optional()}),Sr=o.strictObject({kind:o.literal(`record.delete`),objectId:Z,recordId:Z}),Cr=o.strictObject({kind:o.literal(`record.restore`),objectId:Z,recordId:Z}),$=o.string().min(1),wr=o.discriminatedUnion(`command`,[o.strictObject({command:o.literal(`replace`),oldText:$,newText:o.string(),replaceAll:o.boolean().optional()}),o.strictObject({command:o.literal(`insert`),text:$,after:$.optional()})]),Tr=o.strictObject({kind:o.literal(`record.patch`),objectId:Z,recordId:Z,attribute:o.string(),edit:wr}),Er=o.discriminatedUnion(`kind`,[br,xr,Sr,Cr,Tr]),Dr=o.strictObject({opId:Z,steps:o.array(Er).min(1).max(100)}).superRefine((e,t)=>{let n=new Set;for(let r of e.steps){if(n.has(r.recordId)){t.addIssue({code:`custom`,message:`one step per record`,path:[`steps`]});return}n.add(r.recordId)}});export{ln as ACCESS_LEVELS,x as ACCESS_ROLES,ve as AGENT_ASIDE_ANSWER_MAX_LENGTH,ge as AGENT_ASIDE_HISTORY_LIMIT,_e as AGENT_ASIDE_QUESTION_MAX_LENGTH,ue as AGENT_AVATAR_EXPRESSIONS,le as AGENT_AVATAR_TYPES,Ce as AGENT_MESSAGE_KIND,we as AGENT_MESSAGE_SENDER_NAME_KEY,Se as AGENT_NOTIFICATION_KIND,w as AGENT_SESSION_ACCESS_ROLES,re as AGENT_SESSION_LIST_ORDERS,Pe as AGENT_SESSION_ORIGINS,ie as AGENT_SESSION_PROVENANCES,de as AGENT_STARTERS_MAX,fe as AGENT_STARTER_MAX_LENGTH,pe as AGENT_SYSTEM_PROMPT_MAX_LENGTH,d as AGENT_TASK_KINDS,h as AGENT_WAKE_KIND,tt as ALL_CATALOG_TOOL_NAMES,Qe as ALWAYS_KINDS,ct as APPROVAL_FAMILY_TOOL_NAMES,g as ARCHITECT_PUBLICATION_KIND,ut as ASK_QUESTIONS_ANSWER_MAX_LENGTH,dt as ASK_QUESTIONS_ANSWER_MAX_VALUES,lt as ASK_QUESTIONS_MAX_BATCH,F as ASK_QUESTIONS_TOOL_NAME,Ge as AUDIT_ACTIONS,Ke as AUDIT_AGENT_SESSION_METADATA_KEY,We as AUDIT_RESOURCE_TYPES,AgentBuilder,y as BROWSER_LAUNCH_TOOL_NAME,A as BROWSER_TOOL_NAMES,Ve as BUNDLE_LOCALES,He as BUNDLE_SETUP_PROMPT_MAX_LENGTH,nt as CONNECTION_GRANT_PROVIDERS,hr as CONTINUATION_KEY_PATTERN,St as CONVERSATION_SURFACES,Ze as COPY_VERB_NAME,O as CORE_RECORD_TOOL_NAMES,k as CORE_TOOL_NAMES,T as COUNT_MODES,R as DEFAULT_AGENT_EXECUTION_CONFIG,rt as DEFAULT_AGENT_TOOL_GROUPS,s as DEFAULT_APPROVAL_POLICY,it as DEFAULT_BLUEPRINT_TOOL_GROUPS,be as DEFAULT_DAILY_ACTIVITY_DAYS,_t as DEFAULT_MEETING_BOT_DISPLAY_NAME,yt as DEFAULT_TENANT_SETTINGS,C as DEVICE_ACCESS_ROLES,Je as DISCARD_ARCHITECT_DRAFT_TOOL_NAME,Fe as DOCUMENT_SORT_MODES,qe as DRAFT_WRITE_TOOL_NAMES,Yt as EMAIL_CATEGORY_DEFAULT_COLOR,Jt as EMAIL_CATEGORY_DEFAULT_ICON,qt as EMAIL_CATEGORY_DESCRIPTION_MAX,Kt as EMAIL_CATEGORY_DESCRIPTION_MIN,Wt as EMAIL_CATEGORY_LIMIT,Gt as EMAIL_CATEGORY_NAME_MAX,zt as ENVIRONMENT_BUILD_LOG_STEPS,Rt as ENVIRONMENT_BUILD_LOG_STEP_PREFIX,Nt as ENVIRONMENT_HARNESSES,At as ENVIRONMENT_HARNESS_SANDBOX_WORKDIR,jt as ENVIRONMENT_HARNESS_WORKDIR,Pt as ENVIRONMENT_IMAGES,Lt as ENVIRONMENT_MEMORY_GB_PER_VCPU,kt as ENVIRONMENT_NAME_MAX_CHARS,Vt as ENVIRONMENT_NETWORK_ALLOW_MAX,Bt as ENVIRONMENT_SCRIPT_MAX_BYTES,Ft as ENVIRONMENT_SIZES,It as ENVIRONMENT_SIZE_VCPUS,Mt as ENVIRONMENT_STANDARDS_WORKDIR,pr as ENV_VAR_KEY_PATTERN,Ue as ESTIMATED_COUNT_CAP,ht as FILE_URLS_MAX_IDS,Ye as GET_ARCHITECT_DRAFT_TOOL_NAME,z as GITHUB_TRIGGER_CATALOG,$e as GRANT_ENABLES,ot as HITL_TOOL_NAMES,u as INFERENCE_REASONING_OPTIONS,se as INFERENCE_ROUTING_MODES,l as INFERENCE_SPEEDS,ye as LAST_RUN_ERROR_MAX_LENGTH,Dn as MAILBOX_LIST_MODES,kn as MAIL_DRAFT_BODY_MAX_CHARS,An as MAIL_SIGNATURE_MAX_CHARS,jn as MAIL_SUBJECT_MAX_CHARS,xe as MAX_DAILY_ACTIVITY_DAYS,je as MAX_TODOS,Ne as MAX_TODO_DESCRIPTION_CHARS,Me as MAX_TODO_ID_CHARS,Cn as MCP_SERVER_NAME_MAX_LENGTH,vn as MEETING_BOT_IMAGE,yn as MEETING_BOT_IMAGE_BASE64_MAX_LENGTH,fn as MEETING_BOT_NO_CREDITS,dn as MEETING_BOT_SILENT_REASON,un as MEETING_RESPONSES,vt as MEMORY_SPEND_LIMIT_PATTERN,wn as McpOAuthCompletionMode,v as NATIVE_TOOL_GROUPS,N as NATIVE_TOOL_GROUP_CATALOG,hn as NO_RECORDING,me as OPEN_TOOL_PART_STATES,vr as OPERATION_MAX_STEPS,Tn as PROVIDER_DRAFT_LABEL,c as PROVIDER_NAMES,Xt as PUBLIC_MAIL_DOMAINS,st as QUESTION_FAMILY_TOOL_NAMES,mt as RECENT_ACTIVITY_LEDGER_LIMIT,Mn as RECIPIENT_IDENTITIES_MAX,pn as RECORDING_OVERRIDES,mn as RECORDING_POLICIES,S as RECORD_ACCESS_ROLES,ze as RECORD_ACCESS_SOURCES,Re as RECORD_DRIVE_CURSOR_MAX_LENGTH,Ie as RECORD_DRIVE_PAGE_DEFAULT_LIMIT,Le as RECORD_DRIVE_PAGE_MAX_LIMIT,Et as RECORD_GRAPH_DEFAULT_LIMIT_PER_NODE,Tt as RECORD_GRAPH_MAX_LIMIT_PER_NODE,wt as RECORD_GRAPH_MAX_NODES,gt as RECORD_IMAGE_MAX_BYTES,On as REPLY_MODES,E as REQUEST_DESIGN_REVIEW_TOOL_NAME,I as REQUEST_SETUP_TOOL_NAME,b as RESOURCE_GRANT_KINDS,P as RESOURCE_KIND_CATALOG,ce as ROUTING_PRICE_CEILINGS,Xe as SEND_VERB_NAME,f as SESSION_INFERENCE_PATCH_KEYS,$t as SLACK_TRIGGER_CATALOG,De as SPEAKS_THROUGH_SEND_METADATA_KEY,et as SURFACE_TOOL_NAMES,Ht as SYSTEM_EMAIL_CATEGORIES,Ut as SYSTEM_EMAIL_CATEGORY_NAMES,m as SYSTEM_PART_CODES,oe as TASK_DEMAND_LEVELS,_ as TODO_PHASES,ae as TODO_PLAN_STATUSES,Ae as TODO_STATUSES,p as TOOL_APPROVAL_STATES,he as TOOL_IMPACT_COUNT_KEYS,En as TRIAGE_ACTIONS,Y as TRIGGER_EVENT_TYPES,ne as TURN_OUTCOMES,Be as UNSHAREABLE_OBJECT_NAMES,Ct as USERS_RESOLVE_MAX_IDS,bt as USER_STATUSES,xt as USER_WORK_POSTURES,D as VERB_NAMES,Oe as WAKE_TURN_METADATA_KEY,ke as WAKE_TURN_SPOKE_METADATA_KEY,agent,agentAvatarFromMetadata,ur as agentAvatarSchema,agentDataChunk,agentDisplayName,zn as agentInferencePreferencesSchema,Kn as agentMessageAttachmentSchema,Gn as agentMessagePartSchema,mr as agentScheduleSchema,Bn as agentSessionInferenceOverridesInputSchema,Vn as agentSessionInferenceOverridesSchema,Zn as agentSessionMessageSchema,dr as agentStartersSchema,X as agentTriggerBaseSchema,_r as agentTriggerPatchSchema,gr as agentTriggerSchema,agentUIValidationError,qn as artifactQuoteSchema,pt as askQuestionsOutputSchema,assertCustomAgentUIMessageChunk,assertSessionState,canonicalToolGroups,sr as classificationRestoreSchema,or as classifyEmailSchema,cliDefaultModelOf,compareAgentSessionMessages,compiledHarnessModels,connectionGrantKindsOf,cn as connectorTriggerMatchSchema,J as customDataChunkSchemas,decodeAgentSessionListCursor,deriveViewerAccess,Xn as durableDateSchema,rr as emailCategoryCreateSchema,ar as emailCategoryDeleteSchema,lr as emailCategoryScopeQuerySchema,ir as emailCategoryUpdateSchema,cr as emailRuleScopeSchema,encodeAgentSessionListCursor,environmentHarness,environmentWorkdir,findEnvironmentHarness,tn as githubConditionSchema,on as githubTriggerMatchSchema,grantKindOf,harnessModelChoices,humanRequestId,humanRequestKind,K as imageModelIdSchema,U as inferenceReasoningSchema,W as inferenceRoutingSchema,H as inferenceSpeedSchema,isAgentMessageMetadata,isAgentNotificationMetadata,isAgentUIDataName,isAgentWakeMetadata,isAgentWrittenAuditEntry,isArchitectPublicationMetadata,isAwaitingHuman,isBlocking,isEnvironmentBuildLogStep,isEnvironmentHarnessId,isMailProvider,isMailboxListMode,isNativeToolGroup,isOpenToolPartState,isParkedOnHuman,isProviderDraft,isPublicMailDomain,isQuestionPart,isReplyMode,isResourceGrant,isRoutineActorMetadata,isSessionInferencePatch,isSystemEmailCategory,isSystemEmailCategoryName,isSystemPartCode,isToolApprovalState,isToolImpactCountKey,lockingSendCall,bn as meetingBotDispatchRequestSchema,xn as meetingBotDispatchResponseSchema,Sn as meetingBotNotificationSchema,gn as meetingTranscriptSegmentSchema,Jn as mentionReferenceSchema,mergeSessionInferencePatch,Yn as modelDefinitionSchema,G as modelReferenceSchema,Ln as moveImpactSchema,needsManageWhenUnattended,_n as normalizedMeetingTranscriptSchema,openRequests,orderAgentSessionMessages,parseAgentDefinitionAccessRole,parseAgentSessionAccessRole,parseCountMode,parseDeviceAccessRole,parseMergedAgentTrigger,parseOptionalCountMode,parsePageAccessRole,parseRecordAccessRole,parseToolGroupGrant,V as providerNameSchema,readArchitectPublication,readAskQuestionsResult,recentActivityEntryKey,recordGraphNodeKey,Ot as recordGraphRequestSchema,recordMeetingsCount,Dr as recordOperationSchema,refineTrigger,resourceGrant,Un as routedMessageInferenceSchema,Hn as sessionInferencePatchSchema,nn as slackConditionSchema,sn as slackTriggerMatchSchema,Qn as todoItemSchema,$n as todoPlanSchema,q as toolImpactSchema,utf8ByteLength};