@angeloashmore/prismic-cli-poc 0.0.0-canary.f8e4066 → 0.0.0-pr.10.032f7ef

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 (58) hide show
  1. package/dist/index.mjs +269 -154
  2. package/package.json +1 -1
  3. package/src/custom-type-add-field-boolean.ts +49 -12
  4. package/src/custom-type-add-field-color.ts +46 -12
  5. package/src/custom-type-add-field-date.ts +46 -12
  6. package/src/custom-type-add-field-embed.ts +46 -12
  7. package/src/custom-type-add-field-geo-point.ts +46 -12
  8. package/src/custom-type-add-field-group.ts +179 -0
  9. package/src/custom-type-add-field-image.ts +46 -12
  10. package/src/custom-type-add-field-key-text.ts +46 -12
  11. package/src/custom-type-add-field-link.ts +46 -12
  12. package/src/custom-type-add-field-number.ts +46 -12
  13. package/src/custom-type-add-field-rich-text.ts +46 -12
  14. package/src/custom-type-add-field-select.ts +47 -21
  15. package/src/custom-type-add-field-timestamp.ts +46 -12
  16. package/src/custom-type-add-field-uid.ts +17 -0
  17. package/src/custom-type-add-field.ts +5 -0
  18. package/src/docs-fetch.ts +146 -0
  19. package/src/docs-list.ts +131 -0
  20. package/src/docs.ts +26 -121
  21. package/src/index.ts +1 -1
  22. package/src/lib/field-path.ts +81 -0
  23. package/src/page-type-add-field-boolean.ts +66 -13
  24. package/src/page-type-add-field-color.ts +66 -13
  25. package/src/page-type-add-field-date.ts +66 -13
  26. package/src/page-type-add-field-embed.ts +66 -13
  27. package/src/page-type-add-field-geo-point.ts +66 -13
  28. package/src/page-type-add-field-group.ts +198 -0
  29. package/src/page-type-add-field-image.ts +66 -13
  30. package/src/page-type-add-field-key-text.ts +66 -13
  31. package/src/page-type-add-field-link.ts +66 -13
  32. package/src/page-type-add-field-number.ts +66 -13
  33. package/src/page-type-add-field-rich-text.ts +66 -13
  34. package/src/page-type-add-field-select.ts +67 -22
  35. package/src/page-type-add-field-timestamp.ts +66 -13
  36. package/src/page-type-add-field-uid.ts +37 -1
  37. package/src/page-type-add-field.ts +5 -0
  38. package/src/page-type-create.ts +25 -0
  39. package/src/repo-create.ts +59 -0
  40. package/src/slice-add-field-boolean.ts +90 -16
  41. package/src/slice-add-field-color.ts +90 -16
  42. package/src/slice-add-field-date.ts +90 -16
  43. package/src/slice-add-field-embed.ts +90 -16
  44. package/src/slice-add-field-geo-point.ts +90 -16
  45. package/src/slice-add-field-group.ts +191 -0
  46. package/src/slice-add-field-image.ts +90 -16
  47. package/src/slice-add-field-key-text.ts +90 -16
  48. package/src/slice-add-field-link.ts +90 -16
  49. package/src/slice-add-field-number.ts +90 -16
  50. package/src/slice-add-field-rich-text.ts +90 -16
  51. package/src/slice-add-field-select.ts +91 -25
  52. package/src/slice-add-field-timestamp.ts +90 -16
  53. package/src/slice-add-field.ts +5 -0
  54. package/src/slice-create.ts +66 -5
  55. package/src/slice-set-screenshot.ts +235 -0
  56. package/src/slice-view.ts +3 -0
  57. package/src/slice.ts +5 -0
  58. package/src/status.ts +164 -124
package/dist/index.mjs CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as r,readdir as i,rename as a,rm as o,writeFile as s}from"node:fs/promises";import*as c from"node:crypto";import{homedir as l}from"node:os";import{pathToFileURL as u}from"node:url";import{exec as d}from"node:child_process";import{createServer as f}from"node:http";var p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,_=(e,t)=>()=>(e&&(t=e(e=0)),t),v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),y=(e,t)=>{let n={};for(var r in e)p(n,r,{get:e[r],enumerable:!0});return t&&p(n,Symbol.toStringTag,{value:`Module`}),n},b=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e},x=e=>g.call(e,`module.exports`)?e[`module.exports`]:b(p({},`__esModule`,{value:!0}),e),ee=`0.0.0-canary.f8e4066`,te=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),r=i([``,``],[``,``]);function i(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function(){function e(){var t=this,n=[...arguments];return a(this,e),this.tag=function(e){var n=[...arguments].slice(1);return typeof e==`function`?t.interimTag.bind(t,e):typeof e==`string`?t.transformEndResult(e):(e=e.map(t.transformString.bind(t)),t.transformEndResult(e.reduce(t.processSubstitutions.bind(t,n))))},n.length>0&&Array.isArray(n[0])&&(n=n[0]),this.transformers=n.map(function(e){return typeof e==`function`?e():e}),this.tag}return n(e,[{key:`interimTag`,value:function(e,t){var n=[...arguments].slice(2);return this.tag(r,e.apply(void 0,[t].concat(n)))}},{key:`processSubstitutions`,value:function(e,t,n){return`${t}${this.transformSubstitution(e.shift(),t)}${n}`}},{key:`transformString`,value:function(e){return this.transformers.reduce(function(e,t){return t.onString?t.onString(e):e},e)}},{key:`transformSubstitution`,value:function(e,t){return this.transformers.reduce(function(e,n){return n.onSubstitution?n.onSubstitution(e,t):e},e)}},{key:`transformEndResult`,value:function(e){return this.transformers.reduce(function(e,t){return t.onEndResult?t.onEndResult(e):e},e)}}]),e}(),t.exports=e.default})),S=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(te());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ne=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``;return{onEndResult:function(t){if(e===``)return t.trim();if(e=e.toLowerCase(),e===`start`||e===`left`)return t.replace(/^\s*/,``);if(e===`end`||e===`right`)return t.replace(/\s*$/,``);throw Error(`Side not supported: `+e)}}},t.exports=e.default})),C=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ne());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),re=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)}e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`initial`;return{onEndResult:function(t){if(e===`initial`){var r=t.match(/^[^\S\n]*(?=\S)/gm),i=r&&Math.min.apply(Math,n(r.map(function(e){return e.length})));if(i){var a=RegExp(`^.{`+i+`}`,`gm`);return t.replace(a,``)}return t}if(e===`all`)return t.replace(/^[^\S\n]+/gm,``);throw Error(`Unknown type: `+e)}}},t.exports=e.default})),ie=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(re());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),w=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onEndResult:function(n){if(e==null||t==null)throw Error(`replaceResultTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),ae=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(w());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),oe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onSubstitution:function(n,r){if(e==null||t==null)throw Error(`replaceSubstitutionTransformer requires at least 2 arguments.`);return n==null?n:n.toString().replace(e,t)}}},t.exports=e.default})),se=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(oe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ce=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onString:function(n){if(e==null||t==null)throw Error(`replaceStringTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),le=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ce());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ue=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n={separator:``,conjunction:``,serial:!1};e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:n;return{onSubstitution:function(t,n){if(Array.isArray(t)){var r=t.length,i=e.separator,a=e.conjunction,o=e.serial,s=n.match(/(\n?[^\S\n]+)$/);if(t=s?t.join(i+s[1]):t.join(i+` `),a&&r>1){var c=t.lastIndexOf(i);t=t.slice(0,c)+(o?i:``)+` `+a+t.slice(c+1)}}return t}}},t.exports=e.default})),T=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ue());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),de=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e){return{onSubstitution:function(t,n){if(e!=null&&typeof e==`string`)typeof t==`string`&&t.includes(e)&&(t=t.split(e));else throw Error(`You need to specify a string character to split by.`);return t}}},t.exports=e.default})),fe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(de());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),pe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(e){return e!=null&&!Number.isNaN(e)&&typeof e!=`boolean`};e.default=function(){return{onSubstitution:function(e){return Array.isArray(e)?e.filter(n):n(e)?e:``}}},t.exports=e.default})),me=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(pe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),he=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(ie()),i=o(T()),a=o(C());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`}),r.default,a.default),t.exports=e.default})),ge=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(he());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),_e=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(ie()),i=o(T()),a=o(C());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`and`}),r.default,a.default),t.exports=e.default})),ve=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(_e());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ye=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(ie()),i=o(T()),a=o(C());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`or`}),r.default,a.default),t.exports=e.default})),be=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ye());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),xe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(S()),r=c(ie()),i=c(T()),a=c(C()),o=c(fe()),s=c(me());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
3
- `),s.default,i.default,r.default,a.default),t.exports=e.default})),Se=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(xe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ce=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Se());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),we=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Se());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Te=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(S()),r=c(ie()),i=c(T()),a=c(C()),o=c(fe()),s=c(se());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
4
- `),i.default,r.default,a.default,(0,s.default)(/&/g,`&amp;`),(0,s.default)(/</g,`&lt;`),(0,s.default)(/>/g,`&gt;`),(0,s.default)(/"/g,`&quot;`),(0,s.default)(/'/g,`&#x27;`),(0,s.default)(/`/g,`&#x60;`)),t.exports=e.default})),Ee=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Te());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),De=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(S()),r=a(C()),i=a(ae());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n(?:\s*))+/g,` `),r.default),t.exports=e.default})),Oe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(De());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ke=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(S()),r=a(C()),i=a(ae());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n\s*)/g,``),r.default),t.exports=e.default})),Ae=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ke());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),je=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(T()),i=o(C()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Me=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(je());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ne=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(T()),i=o(C()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`or`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Pe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ne());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Fe=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(T()),i=o(C()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`and`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Ie=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Fe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Le=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(ie()),i=o(T()),a=o(C());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(i.default,r.default,a.default),t.exports=e.default})),Re=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Le());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ze=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(S()),r=o(T()),i=o(C()),a=o(ae());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Be=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ze());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ve=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(S()),r=a(ie()),i=a(C());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,i.default),t.exports=e.default})),He=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ve());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ue=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(S()),r=a(ie()),i=a(C());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)(`all`),i.default),t.exports=e.default})),We=v(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ue());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),E=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.stripIndents=e.stripIndent=e.oneLineInlineLists=e.inlineLists=e.oneLineCommaListsAnd=e.oneLineCommaListsOr=e.oneLineCommaLists=e.oneLineTrim=e.oneLine=e.safeHtml=e.source=e.codeBlock=e.html=e.commaListsOr=e.commaListsAnd=e.commaLists=e.removeNonPrintingValuesTransformer=e.splitStringTransformer=e.inlineArrayTransformer=e.replaceStringTransformer=e.replaceSubstitutionTransformer=e.replaceResultTransformer=e.stripIndentTransformer=e.trimResultTransformer=e.TemplateTag=void 0;var t=w(S()),n=w(C()),r=w(ie()),i=w(ae()),a=w(se()),o=w(le()),s=w(T()),c=w(fe()),l=w(me()),u=w(ge()),d=w(ve()),f=w(be()),p=w(Se()),m=w(Ce()),h=w(we()),g=w(Ee()),_=w(Oe()),v=w(Ae()),y=w(Me()),b=w(Pe()),x=w(Ie()),ee=w(Re()),te=w(Be()),ne=w(He()),re=w(We());function w(e){return e&&e.__esModule?e:{default:e}}e.TemplateTag=t.default,e.trimResultTransformer=n.default,e.stripIndentTransformer=r.default,e.replaceResultTransformer=i.default,e.replaceSubstitutionTransformer=a.default,e.replaceStringTransformer=o.default,e.inlineArrayTransformer=s.default,e.splitStringTransformer=c.default,e.removeNonPrintingValuesTransformer=l.default,e.commaLists=u.default,e.commaListsAnd=d.default,e.commaListsOr=f.default,e.html=p.default,e.codeBlock=m.default,e.source=h.default,e.safeHtml=g.default,e.oneLine=_.default,e.oneLineTrim=v.default,e.oneLineCommaLists=y.default,e.oneLineCommaListsOr=b.default,e.oneLineCommaListsAnd=x.default,e.inlineLists=ee.default,e.oneLineInlineLists=te.default,e.stripIndent=ne.default,e.stripIndents=re.default}))(),Ge=class extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge==`number`&&e.maxAge===0)throw TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||1/0,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if(typeof this.onEviction==`function`)for(let[t,n]of e)this.onEviction(t,n.value)}_deleteIfExpired(e,t){return typeof t.expiry==`number`&&t.expiry<=Date.now()?(typeof this.onEviction==`function`&&this.onEviction(e,t.value),this.delete(e)):!1}_getOrDeleteIfExpired(e,t){if(this._deleteIfExpired(e,t)===!1)return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){let n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield e)}for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield e)}}get(e){if(this.cache.has(e)){let t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){let t=this.oldCache.get(e);if(this._deleteIfExpired(e,t)===!1)return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){let r=typeof n==`number`&&n!==1/0?Date.now()+n:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:r}):this._set(e,{value:t,expiry:r}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):this.oldCache.has(e)?!this._deleteIfExpired(e,this.oldCache.get(e)):!1}peek(e){if(this.cache.has(e))return this._peek(e,this.cache);if(this.oldCache.has(e))return this._peek(e,this.oldCache)}delete(e){let t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw TypeError("`maxSize` must be a number greater than 0");let t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.cache.has(n)||this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}}*entriesAscending(){for(let[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(let t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}};function Ke(e,t){return(!e||e.endsWith(`
2
+ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as r,readdir as i,rename as a,rm as o,writeFile as s}from"node:fs/promises";import*as c from"node:crypto";import{createHash as l}from"node:crypto";import{homedir as u}from"node:os";import{pathToFileURL as d}from"node:url";import{exec as f}from"node:child_process";import{createServer as p}from"node:http";import{extname as m}from"node:path";var h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,y=(e,t)=>()=>(e&&(t=e(e=0)),t),b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),x=(e,t)=>{let n={};for(var r in e)h(n,r,{get:e[r],enumerable:!0});return t&&h(n,Symbol.toStringTag,{value:`Module`}),n},S=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e},ee=e=>v.call(e,`module.exports`)?e[`module.exports`]:S(h({},`__esModule`,{value:!0}),e),te=`0.0.0-pr.10.032f7ef`,ne=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),r=i([``,``],[``,``]);function i(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}e.default=function(){function e(){var t=this,n=[...arguments];return a(this,e),this.tag=function(e){var n=[...arguments].slice(1);return typeof e==`function`?t.interimTag.bind(t,e):typeof e==`string`?t.transformEndResult(e):(e=e.map(t.transformString.bind(t)),t.transformEndResult(e.reduce(t.processSubstitutions.bind(t,n))))},n.length>0&&Array.isArray(n[0])&&(n=n[0]),this.transformers=n.map(function(e){return typeof e==`function`?e():e}),this.tag}return n(e,[{key:`interimTag`,value:function(e,t){var n=[...arguments].slice(2);return this.tag(r,e.apply(void 0,[t].concat(n)))}},{key:`processSubstitutions`,value:function(e,t,n){return`${t}${this.transformSubstitution(e.shift(),t)}${n}`}},{key:`transformString`,value:function(e){return this.transformers.reduce(function(e,t){return t.onString?t.onString(e):e},e)}},{key:`transformSubstitution`,value:function(e,t){return this.transformers.reduce(function(e,n){return n.onSubstitution?n.onSubstitution(e,t):e},e)}},{key:`transformEndResult`,value:function(e){return this.transformers.reduce(function(e,t){return t.onEndResult?t.onEndResult(e):e},e)}}]),e}(),t.exports=e.default})),C=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ne());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),w=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``;return{onEndResult:function(t){if(e===``)return t.trim();if(e=e.toLowerCase(),e===`start`||e===`left`)return t.replace(/^\s*/,``);if(e===`end`||e===`right`)return t.replace(/\s*$/,``);throw Error(`Side not supported: `+e)}}},t.exports=e.default})),T=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(w());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),re=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)}e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`initial`;return{onEndResult:function(t){if(e===`initial`){var r=t.match(/^[^\S\n]*(?=\S)/gm),i=r&&Math.min.apply(Math,n(r.map(function(e){return e.length})));if(i){var a=RegExp(`^.{`+i+`}`,`gm`);return t.replace(a,``)}return t}if(e===`all`)return t.replace(/^[^\S\n]+/gm,``);throw Error(`Unknown type: `+e)}}},t.exports=e.default})),ie=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(re());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ae=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onEndResult:function(n){if(e==null||t==null)throw Error(`replaceResultTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),oe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ae());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),se=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onSubstitution:function(n,r){if(e==null||t==null)throw Error(`replaceSubstitutionTransformer requires at least 2 arguments.`);return n==null?n:n.toString().replace(e,t)}}},t.exports=e.default})),ce=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(se());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),le=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e,t){return{onString:function(n){if(e==null||t==null)throw Error(`replaceStringTransformer requires at least 2 arguments.`);return n.replace(e,t)}}},t.exports=e.default})),ue=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(le());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),de=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n={separator:``,conjunction:``,serial:!1};e.default=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:n;return{onSubstitution:function(t,n){if(Array.isArray(t)){var r=t.length,i=e.separator,a=e.conjunction,o=e.serial,s=n.match(/(\n?[^\S\n]+)$/);if(t=s?t.join(i+s[1]):t.join(i+` `),a&&r>1){var c=t.lastIndexOf(i);t=t.slice(0,c)+(o?i:``)+` `+a+t.slice(c+1)}}return t}}},t.exports=e.default})),fe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(de());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),pe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(e){return{onSubstitution:function(t,n){if(e!=null&&typeof e==`string`)typeof t==`string`&&t.includes(e)&&(t=t.split(e));else throw Error(`You need to specify a string character to split by.`);return t}}},t.exports=e.default})),me=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(pe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),he=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=function(e){return e!=null&&!Number.isNaN(e)&&typeof e!=`boolean`};e.default=function(){return{onSubstitution:function(e){return Array.isArray(e)?e.filter(n):n(e)?e:``}}},t.exports=e.default})),ge=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(he());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),_e=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(ie()),i=o(fe()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`}),r.default,a.default),t.exports=e.default})),ve=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(_e());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ye=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(ie()),i=o(fe()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`and`}),r.default,a.default),t.exports=e.default})),be=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ye());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),xe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(ie()),i=o(fe()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)({separator:`,`,conjunction:`or`}),r.default,a.default),t.exports=e.default})),Se=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(xe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ce=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(C()),r=c(ie()),i=c(fe()),a=c(T()),o=c(me()),s=c(ge());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
3
+ `),s.default,i.default,r.default,a.default),t.exports=e.default})),we=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ce());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Te=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(we());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ee=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(we());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),De=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=c(C()),r=c(ie()),i=c(fe()),a=c(T()),o=c(me()),s=c(ce());function c(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,o.default)(`
4
+ `),i.default,r.default,a.default,(0,s.default)(/&/g,`&amp;`),(0,s.default)(/</g,`&lt;`),(0,s.default)(/>/g,`&gt;`),(0,s.default)(/"/g,`&quot;`),(0,s.default)(/'/g,`&#x27;`),(0,s.default)(/`/g,`&#x60;`)),t.exports=e.default})),Oe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(De());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ke=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(C()),r=a(T()),i=a(oe());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n(?:\s*))+/g,` `),r.default),t.exports=e.default})),Ae=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ke());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),je=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(C()),r=a(T()),i=a(oe());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,i.default)(/(?:\n\s*)/g,``),r.default),t.exports=e.default})),Me=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(je());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ne=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(fe()),i=o(T()),a=o(oe());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Pe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ne());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Fe=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(fe()),i=o(T()),a=o(oe());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`or`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Ie=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Fe());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Le=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(fe()),i=o(T()),a=o(oe());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)({separator:`,`,conjunction:`and`}),(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),Re=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Le());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),ze=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(ie()),i=o(fe()),a=o(T());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(i.default,r.default,a.default),t.exports=e.default})),Be=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(ze());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ve=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=o(C()),r=o(fe()),i=o(T()),a=o(oe());function o(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,(0,a.default)(/(?:\s+)/g,` `),i.default),t.exports=e.default})),He=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ve());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ue=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(C()),r=a(ie()),i=a(T());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default(r.default,i.default),t.exports=e.default})),We=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ue());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),Ge=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0});var n=a(C()),r=a(ie()),i=a(T());function a(e){return e&&e.__esModule?e:{default:e}}e.default=new n.default((0,r.default)(`all`),i.default),t.exports=e.default})),Ke=b(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var n=r(Ge());function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default,t.exports=e.default})),E=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.stripIndents=e.stripIndent=e.oneLineInlineLists=e.inlineLists=e.oneLineCommaListsAnd=e.oneLineCommaListsOr=e.oneLineCommaLists=e.oneLineTrim=e.oneLine=e.safeHtml=e.source=e.codeBlock=e.html=e.commaListsOr=e.commaListsAnd=e.commaLists=e.removeNonPrintingValuesTransformer=e.splitStringTransformer=e.inlineArrayTransformer=e.replaceStringTransformer=e.replaceSubstitutionTransformer=e.replaceResultTransformer=e.stripIndentTransformer=e.trimResultTransformer=e.TemplateTag=void 0;var t=w(C()),n=w(T()),r=w(ie()),i=w(oe()),a=w(ce()),o=w(ue()),s=w(fe()),c=w(me()),l=w(ge()),u=w(ve()),d=w(be()),f=w(Se()),p=w(we()),m=w(Te()),h=w(Ee()),g=w(Oe()),_=w(Ae()),v=w(Me()),y=w(Pe()),b=w(Ie()),x=w(Re()),S=w(Be()),ee=w(He()),te=w(We()),ne=w(Ke());function w(e){return e&&e.__esModule?e:{default:e}}e.TemplateTag=t.default,e.trimResultTransformer=n.default,e.stripIndentTransformer=r.default,e.replaceResultTransformer=i.default,e.replaceSubstitutionTransformer=a.default,e.replaceStringTransformer=o.default,e.inlineArrayTransformer=s.default,e.splitStringTransformer=c.default,e.removeNonPrintingValuesTransformer=l.default,e.commaLists=u.default,e.commaListsAnd=d.default,e.commaListsOr=f.default,e.html=p.default,e.codeBlock=m.default,e.source=h.default,e.safeHtml=g.default,e.oneLine=_.default,e.oneLineTrim=v.default,e.oneLineCommaLists=y.default,e.oneLineCommaListsOr=b.default,e.oneLineCommaListsAnd=x.default,e.inlineLists=S.default,e.oneLineInlineLists=ee.default,e.stripIndent=te.default,e.stripIndents=ne.default}))(),qe=class extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge==`number`&&e.maxAge===0)throw TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||1/0,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if(typeof this.onEviction==`function`)for(let[t,n]of e)this.onEviction(t,n.value)}_deleteIfExpired(e,t){return typeof t.expiry==`number`&&t.expiry<=Date.now()?(typeof this.onEviction==`function`&&this.onEviction(e,t.value),this.delete(e)):!1}_getOrDeleteIfExpired(e,t){if(this._deleteIfExpired(e,t)===!1)return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){let n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield e)}for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield e)}}get(e){if(this.cache.has(e)){let t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){let t=this.oldCache.get(e);if(this._deleteIfExpired(e,t)===!1)return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){let r=typeof n==`number`&&n!==1/0?Date.now()+n:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:r}):this._set(e,{value:t,expiry:r}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):this.oldCache.has(e)?!this._deleteIfExpired(e,this.oldCache.get(e)):!1}peek(e){if(this.cache.has(e))return this._peek(e,this.cache);if(this.oldCache.has(e))return this._peek(e,this.oldCache)}delete(e){let t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw TypeError("`maxSize` must be a number greater than 0");let t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.cache.has(n)||this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}}*entriesAscending(){for(let[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(let t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}};function Je(e,t){return(!e||e.endsWith(`
5
5
  `))&&!t?.force?e:e+`
6
- `}function D(e,t){return Ke(t)+e}function qe(e,t){return(!e||e.endsWith(`
6
+ `}function D(e,t){return Je(t)+e}function Ye(e,t){return(!e||e.endsWith(`
7
7
 
8
- `))&&!t?.force?e:Ke(e)+`
9
- `}function O(e,t){return qe(t)+e}const Je=`https://prismic.io/docs/slices`,Ye={UID:`https://prismic.io/docs/fields/uid`,Boolean:`https://prismic.io/docs/fields/boolean`,Color:`https://prismic.io/docs/fields/color`,Date:`https://prismic.io/docs/fields/date`,Timestamp:`https://prismic.io/docs/fields/timestamp`,Number:`https://prismic.io/docs/fields/number`,Text:`https://prismic.io/docs/fields/text`,Select:`https://prismic.io/docs/fields/select`,StructuredText:`https://prismic.io/docs/fields/rich-text`,Image:`https://prismic.io/docs/fields/image`,Link:{contentRelationship:`https://prismic.io/docs/fields/content-relationship`,link:`https://prismic.io/docs/fields/link`,linkToMedia:`https://prismic.io/docs/fields/link-to-media`},Embed:`https://prismic.io/docs/fields/embed`,GeoPoint:`https://prismic.io/docs/fields/geopoint`,Table:`https://prismic.io/docs/fields/table`,Group:`https://prismic.io/docs/fields/repeatable-group`,IntegrationFields:`https://prismic.io/docs/fields/integration`,Slices:`https://prismic.io/docs/slices`,Choice:`https://prismic.io/docs/slices`};var Xe=y({__addDisposableResource:()=>wt,__assign:()=>Ot,__asyncDelegator:()=>gt,__asyncGenerator:()=>ht,__asyncValues:()=>_t,__await:()=>mt,__awaiter:()=>ot,__classPrivateFieldGet:()=>xt,__classPrivateFieldIn:()=>Ct,__classPrivateFieldSet:()=>St,__createBinding:()=>kt,__decorate:()=>$e,__disposeResources:()=>Tt,__esDecorate:()=>tt,__exportStar:()=>ct,__extends:()=>Ze,__generator:()=>st,__importDefault:()=>bt,__importStar:()=>yt,__makeTemplateObject:()=>vt,__metadata:()=>at,__param:()=>et,__propKey:()=>rt,__read:()=>ut,__rest:()=>Qe,__rewriteRelativeImportExtension:()=>Et,__runInitializers:()=>nt,__setFunctionName:()=>it,__spread:()=>dt,__spreadArray:()=>pt,__spreadArrays:()=>ft,__values:()=>lt,default:()=>Nt});function Ze(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Dt(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Qe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function $e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function et(e,t){return function(n,r){t(n,r,e)}}function tt(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else (d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function nt(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function rt(e){return typeof e==`symbol`?e:`${e}`}function it(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,`name`,{configurable:!0,value:n?`${n} ${t}`:t})}function at(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function ot(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function st(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function ct(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&kt(t,e,n)}function lt(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function ut(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function dt(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ut(arguments[t]));return e}function ft(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function pt(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function mt(e){return this instanceof mt?(this.v=e,this):new mt(e)}function ht(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof mt?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function gt(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:mt(e[r](t)),done:!1}:i?i(t):t}:i}}function _t(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof lt==`function`?lt(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function vt(e,t){return Object.defineProperty?Object.defineProperty(e,`raw`,{value:t}):e.raw=t,e}function yt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=jt(e),r=0;r<n.length;r++)n[r]!==`default`&&kt(t,e,n[r]);return At(t,e),t}function bt(e){return e&&e.__esModule?e:{default:e}}function xt(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function St(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function Ct(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function wt(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function Tt(e){function t(t){e.error=e.hasError?new Mt(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function Et(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var Dt,Ot,kt,At,jt,Mt,Nt,Pt=_((()=>{Dt=function(e,t){return Dt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Dt(e,t)},Ot=function(){return Ot=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ot.apply(this,arguments)},kt=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),At=Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t},jt=function(e){return jt=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},jt(e)},Mt=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},Nt={__extends:Ze,__assign:Ot,__rest:Qe,__decorate:$e,__param:et,__esDecorate:tt,__runInitializers:nt,__propKey:rt,__setFunctionName:it,__metadata:at,__awaiter:ot,__generator:st,__createBinding:kt,__exportStar:ct,__values:lt,__read:ut,__spread:dt,__spreadArrays:ft,__spreadArray:pt,__await:mt,__asyncGenerator:ht,__asyncDelegator:gt,__asyncValues:_t,__makeTemplateObject:vt,__importStar:yt,__importDefault:bt,__classPrivateFieldGet:xt,__classPrivateFieldSet:St,__classPrivateFieldIn:Ct,__addDisposableResource:wt,__disposeResources:Tt,__rewriteRelativeImportExtension:Et}})),Ft=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.lowerCase=e.localeLowerCase=void 0;var t={tr:{regexp:/\u0130|\u0049|\u0049\u0307/g,map:{İ:`i`,I:`ı`,İ:`i`}},az:{regexp:/\u0130/g,map:{İ:`i`,I:`ı`,İ:`i`}},lt:{regexp:/\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,map:{I:`i̇`,J:`j̇`,Į:`į̇`,Ì:`i̇̀`,Í:`i̇́`,Ĩ:`i̇̃`}}};function n(e,n){var i=t[n.toLowerCase()];return r(i?e.replace(i.regexp,function(e){return i.map[e]}):e)}e.localeLowerCase=n;function r(e){return e.toLowerCase()}e.lowerCase=r})),It=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.noCase=void 0;var t=Ft(),n=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],r=/[^A-Z0-9]+/gi;function i(e,i){i===void 0&&(i={});for(var o=i.splitRegexp,s=o===void 0?n:o,c=i.stripRegexp,l=c===void 0?r:c,u=i.transform,d=u===void 0?t.lowerCase:u,f=i.delimiter,p=f===void 0?` `:f,m=a(a(e,s,`$1\0$2`),l,`\0`),h=0,g=m.length;m.charAt(h)===`\0`;)h++;for(;m.charAt(g-1)===`\0`;)g--;return m.slice(h,g).split(`\0`).map(d).join(p)}e.noCase=i;function a(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce(function(e,t){return e.replace(t,n)},e)}})),Lt=v((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.pascalCase=e.pascalCaseTransformMerge=e.pascalCaseTransform=void 0;var t=(Pt(),x(Xe)),n=It();function r(e,t){var n=e.charAt(0),r=e.substr(1).toLowerCase();return t>0&&n>=`0`&&n<=`9`?`_`+n+r:``+n.toUpperCase()+r}e.pascalCaseTransform=r;function i(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}e.pascalCaseTransformMerge=i;function a(e,i){return i===void 0&&(i={}),n.noCase(e,t.__assign({delimiter:``,transform:r},i))}e.pascalCase=a}))();const k=(...e)=>{let t=(0,Lt.pascalCase)(e.filter(Boolean).join(` `),{transform:Lt.pascalCaseTransformMerge});return/^[0-9]/.test(t)&&(t=`_${t}`),t},Rt={Boolean:`Boolean`,Color:`Color`,Date:`Date`,Embed:`Embed`,GeoPoint:`GeoPoint`,Group:`Group`,Image:`Image`,Integration:`IntegrationFields`,Link:`Link`,Number:`Number`,Select:`Select`,Slices:`Slices`,StructuredText:`StructuredText`,Table:`Table`,Text:`Text`,Timestamp:`Timestamp`,UID:`UID`,IntegrationFields:`IntegrationFields`,Range:`Range`,Separator:`Separator`,LegacySlices:`Choice`};function zt(e){let t=``;for(let n=0;n<e.path.length;n++){n>0&&(t+=`.`);let r=e.path[n];if(r.model&&`type`in r.model&&(r.model.type===`Group`||r.model.type===`Slices`))t+=`${r.name}[]`;else{if(r.name===`items`){let i=e.path[n-1];if(i.model&&`json`in i.model||i.model&&`type`in i.model&&i.model.type===`SharedSlice`){t+=`${r.name}[]`;continue}}t+=r.name}}return t}const Bt=e=>{if(`json`in e.model)return e.model.label||e.model.id;if(`type`in e.model&&e.model.type===`SharedSlice`)return e.model.name;if(`type`in e.model&&e.model.type===`Slice`)return e.model.fieldset||e.name;if(`type`in e.model){if(e.model.config&&`label`in e.model.config)return e.model.config.label||e.name;if(e.model.config&&`fieldset`in e.model)return e.model.fieldset||e.name}return`\`${e.name}\``};function Vt(e){return e.path.map(e=>e.label?e.label:e.model?Bt({model:e.model,name:e.name}):e.name).join(` → `)}function Ht(e){switch(e.field.type){case`StructuredText`:return`Rich Text`;case`IntegrationFields`:{let t=e.field.config?.catalog;return`Integration Fields (Catalog: ${t?`\`${t}\``:`*unknown*`})`}case`Link`:switch(e.field.config?.select){case`document`:return`Content Relationship`;case`media`:return`Link to Media`;default:return`Link`}case`Slices`:return`Slice Zone`;default:return e.field.type}}function Ut(e){switch(e.field.type){case`Link`:{let t=Ye.Link;switch(e.field.config?.select){case`document`:return t.contentRelationship;case`media`:return t.linkToMedia;default:return t.link}}default:{let t=Ye[e.field.type];if(typeof t==`string`)return t}}}function Wt(e){let t=`/**`,n=Bt({model:e.field,name:e.name}),r=Vt({path:e.path}),i=Ht({field:e.field});t=D(` * ${n} field in *${r}*`,t),t=D(` *`,t),t=D(` * - **Field Type**: ${i}`,t),t=D(` * - **Placeholder**: ${e.field.config&&`placeholder`in e.field.config&&e.field.config.placeholder||`*None*`}`,t);let a=e.field.config&&`default_value`in e.field.config?e.field.config.default_value:void 0;a!==void 0&&(t=D(` * - **Default Value**: ${typeof a==`boolean`?`${a}`:a}`,t)),t=D(` * - **API ID Path**: ${zt({path:[...e.path,{name:e.name,model:e.field}]})}`,t),e.tabName&&(t=D(` * - **Tab**: ${e.tabName}`,t));let o=Ut({field:e.field});return o&&(t=D(` * - **Documentation**: ${o}`,t)),t=D(` */`,t),t}function Gt(e){return e.filter(Boolean).join(` | `)||`never`}function Kt(e){let t=Wt({name:e.name,field:e.field,path:e.path,tabName:e.tabName}),n=[],r=[],i=e.name.includes(`-`)||e.name.includes(`:`)||/^[0-9]/.test(e.name)?`"${e.name}"`:e.name;switch(e.field.type){case`UID`:break;case`Boolean`:t=D(`${i}: prismic.BooleanField;`,t);break;case`Color`:t=D(`${i}: prismic.ColorField;`,t);break;case`Date`:t=D(`${i}: prismic.DateField;`,t);break;case`Embed`:{let n=[];if(e.fieldConfigs.embed?.providerTypes)for(let t in e.fieldConfigs.embed?.providerTypes){let r=e.fieldConfigs.embed?.providerTypes[t];n.push(`({ provider_name: "${t}" } & ${r})`)}let r=Gt(n);t=n.length>0?D(`${i}: prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${r})>`,t):D(`${i}: prismic.EmbedField`,t);break}case`GeoPoint`:t=D(`${i}: prismic.GeoPointField;`,t);break;case`Image`:t=e.field.config?.thumbnails&&e.field.config.thumbnails.length>0?D(`${i}: prismic.ImageField<${Gt(e.field.config.thumbnails.map(e=>`"${e.name}"`))}>;`,t):D(`${i}: prismic.ImageField<never>;`,t);break;case`IntegrationFields`:{let n=e.field.config?.catalog?e.fieldConfigs.integrationFields?.catalogTypes?.[e.field.config.catalog]:void 0;t=D(n?`${i}: prismic.IntegrationField<${n}>;`:`${i}: prismic.IntegrationField;`,t);break}case`Link`:{let n=e.field.config&&`variants`in e.field.config&&Array.isArray(e.field.config.variants)&&e.field.config.variants.length>0?e.field.config.variants.map(e=>`"${e.replace(/\"/g,`\\"`)}"`).join(` | `):`never`;switch(e.field.config?.select){case`document`:t=`customtypes`in e.field.config&&e.field.config.customtypes&&e.field.config.customtypes.length>0?D(`${i}: ${Gt(e.field.config.customtypes.map(e=>typeof e==`string`?`prismic.ContentRelationshipField<"${e}">`:`ContentRelationshipFieldWithData<${JSON.stringify([e])}>`))};`,t):D(`${i}: prismic.ContentRelationshipField;`,t);break;case`media`:t=D(`${i}: prismic.LinkToMediaField<prismic.FieldState, ${n}>;`,t);break;default:{let r=`prismic.LinkField<string, string, unknown, prismic.FieldState, ${n}>`;e.field.config?.repeat&&(r=`prismic.Repeatable<${r}>`),t=D(`${i}: ${r};`,t);break}}break}case`Number`:t=D(`${i}: prismic.NumberField;`,t);break;case`StructuredText`:t=D(`${i}: prismic.RichTextField;`,t);break;case`Select`:{let n=(e.field.config?.options)?.map(e=>`"${e}"`)||[],r=n.length?Gt(n):`string`;t=e.field.config?.default_value?D(`${i}: prismic.SelectField<${r}, "filled">;`,t):D(`${i}: prismic.SelectField${n.length>0?`<${r}>`:``};`,t);break}case`Table`:t=D(`${i}: prismic.TableField;`,t);break;case`Text`:t=D(`${i}: prismic.KeyTextField;`,t);break;case`Timestamp`:t=D(`${i}: prismic.TimestampField;`,t);break;case`Group`:{let a=e.path.filter(e=>e.model!==void 0&&`type`in e.model&&e.model.type===Rt.Group),o=a.length>0,s;if(e.path[0].model&&`type`in e.path[0].model&&e.path[0].model.type===`SharedSlice`){let[t,n,r]=e.path;s=k(t.name,`Slice`,n.name,r.name,...a.map(e=>e.name),e.name,`Item`)}else s=k(e.path[0].name,`Document`,`Data`,...a.map(e=>e.name),e.name,`Item`);let c=[...e.path,{name:i,model:e.field}],l=Vt({path:c}),u=qt({fields:e.field.config?.fields||{},fieldConfigs:e.fieldConfigs,path:c});n.push(...u.auxiliaryTypes),r.push(...u.contentTypeNames),n.push({name:s,code:E.source`
8
+ `))&&!t?.force?e:Je(e)+`
9
+ `}function O(e,t){return Ye(t)+e}const Xe=`https://prismic.io/docs/slices`,Ze={UID:`https://prismic.io/docs/fields/uid`,Boolean:`https://prismic.io/docs/fields/boolean`,Color:`https://prismic.io/docs/fields/color`,Date:`https://prismic.io/docs/fields/date`,Timestamp:`https://prismic.io/docs/fields/timestamp`,Number:`https://prismic.io/docs/fields/number`,Text:`https://prismic.io/docs/fields/text`,Select:`https://prismic.io/docs/fields/select`,StructuredText:`https://prismic.io/docs/fields/rich-text`,Image:`https://prismic.io/docs/fields/image`,Link:{contentRelationship:`https://prismic.io/docs/fields/content-relationship`,link:`https://prismic.io/docs/fields/link`,linkToMedia:`https://prismic.io/docs/fields/link-to-media`},Embed:`https://prismic.io/docs/fields/embed`,GeoPoint:`https://prismic.io/docs/fields/geopoint`,Table:`https://prismic.io/docs/fields/table`,Group:`https://prismic.io/docs/fields/repeatable-group`,IntegrationFields:`https://prismic.io/docs/fields/integration`,Slices:`https://prismic.io/docs/slices`,Choice:`https://prismic.io/docs/slices`};var Qe=x({__addDisposableResource:()=>Et,__assign:()=>At,__asyncDelegator:()=>vt,__asyncGenerator:()=>_t,__asyncValues:()=>yt,__await:()=>gt,__awaiter:()=>ct,__classPrivateFieldGet:()=>Ct,__classPrivateFieldIn:()=>Tt,__classPrivateFieldSet:()=>wt,__createBinding:()=>jt,__decorate:()=>tt,__disposeResources:()=>Dt,__esDecorate:()=>rt,__exportStar:()=>ut,__extends:()=>$e,__generator:()=>lt,__importDefault:()=>St,__importStar:()=>xt,__makeTemplateObject:()=>bt,__metadata:()=>st,__param:()=>nt,__propKey:()=>at,__read:()=>ft,__rest:()=>et,__rewriteRelativeImportExtension:()=>Ot,__runInitializers:()=>it,__setFunctionName:()=>ot,__spread:()=>pt,__spreadArray:()=>ht,__spreadArrays:()=>mt,__values:()=>dt,default:()=>Ft});function $e(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);kt(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function et(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function tt(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function nt(e,t){return function(n,r){t(n,r,e)}}function rt(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else (d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function it(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function at(e){return typeof e==`symbol`?e:`${e}`}function ot(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,`name`,{configurable:!0,value:n?`${n} ${t}`:t})}function st(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function ct(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function lt(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function ut(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&jt(t,e,n)}function dt(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function ft(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function pt(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ft(arguments[t]));return e}function mt(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function ht(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function gt(e){return this instanceof gt?(this.v=e,this):new gt(e)}function _t(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof gt?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function vt(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:gt(e[r](t)),done:!1}:i?i(t):t}:i}}function yt(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof dt==`function`?dt(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function bt(e,t){return Object.defineProperty?Object.defineProperty(e,`raw`,{value:t}):e.raw=t,e}function xt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=Nt(e),r=0;r<n.length;r++)n[r]!==`default`&&jt(t,e,n[r]);return Mt(t,e),t}function St(e){return e&&e.__esModule?e:{default:e}}function Ct(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function wt(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function Tt(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function Et(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function Dt(e){function t(t){e.error=e.hasError?new Pt(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function Ot(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var kt,At,jt,Mt,Nt,Pt,Ft,It=y((()=>{kt=function(e,t){return kt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},kt(e,t)},At=function(){return At=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},At.apply(this,arguments)},jt=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),Mt=Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t},Nt=function(e){return Nt=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Nt(e)},Pt=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},Ft={__extends:$e,__assign:At,__rest:et,__decorate:tt,__param:nt,__esDecorate:rt,__runInitializers:it,__propKey:at,__setFunctionName:ot,__metadata:st,__awaiter:ct,__generator:lt,__createBinding:jt,__exportStar:ut,__values:dt,__read:ft,__spread:pt,__spreadArrays:mt,__spreadArray:ht,__await:gt,__asyncGenerator:_t,__asyncDelegator:vt,__asyncValues:yt,__makeTemplateObject:bt,__importStar:xt,__importDefault:St,__classPrivateFieldGet:Ct,__classPrivateFieldSet:wt,__classPrivateFieldIn:Tt,__addDisposableResource:Et,__disposeResources:Dt,__rewriteRelativeImportExtension:Ot}})),Lt=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.lowerCase=e.localeLowerCase=void 0;var t={tr:{regexp:/\u0130|\u0049|\u0049\u0307/g,map:{İ:`i`,I:`ı`,İ:`i`}},az:{regexp:/\u0130/g,map:{İ:`i`,I:`ı`,İ:`i`}},lt:{regexp:/\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,map:{I:`i̇`,J:`j̇`,Į:`į̇`,Ì:`i̇̀`,Í:`i̇́`,Ĩ:`i̇̃`}}};function n(e,n){var i=t[n.toLowerCase()];return r(i?e.replace(i.regexp,function(e){return i.map[e]}):e)}e.localeLowerCase=n;function r(e){return e.toLowerCase()}e.lowerCase=r})),Rt=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.noCase=void 0;var t=Lt(),n=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],r=/[^A-Z0-9]+/gi;function i(e,i){i===void 0&&(i={});for(var o=i.splitRegexp,s=o===void 0?n:o,c=i.stripRegexp,l=c===void 0?r:c,u=i.transform,d=u===void 0?t.lowerCase:u,f=i.delimiter,p=f===void 0?` `:f,m=a(a(e,s,`$1\0$2`),l,`\0`),h=0,g=m.length;m.charAt(h)===`\0`;)h++;for(;m.charAt(g-1)===`\0`;)g--;return m.slice(h,g).split(`\0`).map(d).join(p)}e.noCase=i;function a(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce(function(e,t){return e.replace(t,n)},e)}})),zt=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.pascalCase=e.pascalCaseTransformMerge=e.pascalCaseTransform=void 0;var t=(It(),ee(Qe)),n=Rt();function r(e,t){var n=e.charAt(0),r=e.substr(1).toLowerCase();return t>0&&n>=`0`&&n<=`9`?`_`+n+r:``+n.toUpperCase()+r}e.pascalCaseTransform=r;function i(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}e.pascalCaseTransformMerge=i;function a(e,i){return i===void 0&&(i={}),n.noCase(e,t.__assign({delimiter:``,transform:r},i))}e.pascalCase=a}))();const k=(...e)=>{let t=(0,zt.pascalCase)(e.filter(Boolean).join(` `),{transform:zt.pascalCaseTransformMerge});return/^[0-9]/.test(t)&&(t=`_${t}`),t},Bt={Boolean:`Boolean`,Color:`Color`,Date:`Date`,Embed:`Embed`,GeoPoint:`GeoPoint`,Group:`Group`,Image:`Image`,Integration:`IntegrationFields`,Link:`Link`,Number:`Number`,Select:`Select`,Slices:`Slices`,StructuredText:`StructuredText`,Table:`Table`,Text:`Text`,Timestamp:`Timestamp`,UID:`UID`,IntegrationFields:`IntegrationFields`,Range:`Range`,Separator:`Separator`,LegacySlices:`Choice`};function Vt(e){let t=``;for(let n=0;n<e.path.length;n++){n>0&&(t+=`.`);let r=e.path[n];if(r.model&&`type`in r.model&&(r.model.type===`Group`||r.model.type===`Slices`))t+=`${r.name}[]`;else{if(r.name===`items`){let i=e.path[n-1];if(i.model&&`json`in i.model||i.model&&`type`in i.model&&i.model.type===`SharedSlice`){t+=`${r.name}[]`;continue}}t+=r.name}}return t}const Ht=e=>{if(`json`in e.model)return e.model.label||e.model.id;if(`type`in e.model&&e.model.type===`SharedSlice`)return e.model.name;if(`type`in e.model&&e.model.type===`Slice`)return e.model.fieldset||e.name;if(`type`in e.model){if(e.model.config&&`label`in e.model.config)return e.model.config.label||e.name;if(e.model.config&&`fieldset`in e.model)return e.model.fieldset||e.name}return`\`${e.name}\``};function Ut(e){return e.path.map(e=>e.label?e.label:e.model?Ht({model:e.model,name:e.name}):e.name).join(` → `)}function Wt(e){switch(e.field.type){case`StructuredText`:return`Rich Text`;case`IntegrationFields`:{let t=e.field.config?.catalog;return`Integration Fields (Catalog: ${t?`\`${t}\``:`*unknown*`})`}case`Link`:switch(e.field.config?.select){case`document`:return`Content Relationship`;case`media`:return`Link to Media`;default:return`Link`}case`Slices`:return`Slice Zone`;default:return e.field.type}}function Gt(e){switch(e.field.type){case`Link`:{let t=Ze.Link;switch(e.field.config?.select){case`document`:return t.contentRelationship;case`media`:return t.linkToMedia;default:return t.link}}default:{let t=Ze[e.field.type];if(typeof t==`string`)return t}}}function Kt(e){let t=`/**`,n=Ht({model:e.field,name:e.name}),r=Ut({path:e.path}),i=Wt({field:e.field});t=D(` * ${n} field in *${r}*`,t),t=D(` *`,t),t=D(` * - **Field Type**: ${i}`,t),t=D(` * - **Placeholder**: ${e.field.config&&`placeholder`in e.field.config&&e.field.config.placeholder||`*None*`}`,t);let a=e.field.config&&`default_value`in e.field.config?e.field.config.default_value:void 0;a!==void 0&&(t=D(` * - **Default Value**: ${typeof a==`boolean`?`${a}`:a}`,t)),t=D(` * - **API ID Path**: ${Vt({path:[...e.path,{name:e.name,model:e.field}]})}`,t),e.tabName&&(t=D(` * - **Tab**: ${e.tabName}`,t));let o=Gt({field:e.field});return o&&(t=D(` * - **Documentation**: ${o}`,t)),t=D(` */`,t),t}function qt(e){return e.filter(Boolean).join(` | `)||`never`}function Jt(e){let t=Kt({name:e.name,field:e.field,path:e.path,tabName:e.tabName}),n=[],r=[],i=e.name.includes(`-`)||e.name.includes(`:`)||/^[0-9]/.test(e.name)?`"${e.name}"`:e.name;switch(e.field.type){case`UID`:break;case`Boolean`:t=D(`${i}: prismic.BooleanField;`,t);break;case`Color`:t=D(`${i}: prismic.ColorField;`,t);break;case`Date`:t=D(`${i}: prismic.DateField;`,t);break;case`Embed`:{let n=[];if(e.fieldConfigs.embed?.providerTypes)for(let t in e.fieldConfigs.embed?.providerTypes){let r=e.fieldConfigs.embed?.providerTypes[t];n.push(`({ provider_name: "${t}" } & ${r})`)}let r=qt(n);t=n.length>0?D(`${i}: prismic.EmbedField<prismic.AnyOEmbed & prismic.OEmbedExtra & (${r})>`,t):D(`${i}: prismic.EmbedField`,t);break}case`GeoPoint`:t=D(`${i}: prismic.GeoPointField;`,t);break;case`Image`:t=e.field.config?.thumbnails&&e.field.config.thumbnails.length>0?D(`${i}: prismic.ImageField<${qt(e.field.config.thumbnails.map(e=>`"${e.name}"`))}>;`,t):D(`${i}: prismic.ImageField<never>;`,t);break;case`IntegrationFields`:{let n=e.field.config?.catalog?e.fieldConfigs.integrationFields?.catalogTypes?.[e.field.config.catalog]:void 0;t=D(n?`${i}: prismic.IntegrationField<${n}>;`:`${i}: prismic.IntegrationField;`,t);break}case`Link`:{let n=e.field.config&&`variants`in e.field.config&&Array.isArray(e.field.config.variants)&&e.field.config.variants.length>0?e.field.config.variants.map(e=>`"${e.replace(/\"/g,`\\"`)}"`).join(` | `):`never`;switch(e.field.config?.select){case`document`:t=`customtypes`in e.field.config&&e.field.config.customtypes&&e.field.config.customtypes.length>0?D(`${i}: ${qt(e.field.config.customtypes.map(e=>typeof e==`string`?`prismic.ContentRelationshipField<"${e}">`:`ContentRelationshipFieldWithData<${JSON.stringify([e])}>`))};`,t):D(`${i}: prismic.ContentRelationshipField;`,t);break;case`media`:t=D(`${i}: prismic.LinkToMediaField<prismic.FieldState, ${n}>;`,t);break;default:{let r=`prismic.LinkField<string, string, unknown, prismic.FieldState, ${n}>`;e.field.config?.repeat&&(r=`prismic.Repeatable<${r}>`),t=D(`${i}: ${r};`,t);break}}break}case`Number`:t=D(`${i}: prismic.NumberField;`,t);break;case`StructuredText`:t=D(`${i}: prismic.RichTextField;`,t);break;case`Select`:{let n=(e.field.config?.options)?.map(e=>`"${e}"`)||[],r=n.length?qt(n):`string`;t=e.field.config?.default_value?D(`${i}: prismic.SelectField<${r}, "filled">;`,t):D(`${i}: prismic.SelectField${n.length>0?`<${r}>`:``};`,t);break}case`Table`:t=D(`${i}: prismic.TableField;`,t);break;case`Text`:t=D(`${i}: prismic.KeyTextField;`,t);break;case`Timestamp`:t=D(`${i}: prismic.TimestampField;`,t);break;case`Group`:{let a=e.path.filter(e=>e.model!==void 0&&`type`in e.model&&e.model.type===Bt.Group),o=a.length>0,s;if(e.path[0].model&&`type`in e.path[0].model&&e.path[0].model.type===`SharedSlice`){let[t,n,r]=e.path;s=k(t.name,`Slice`,n.name,r.name,...a.map(e=>e.name),e.name,`Item`)}else s=k(e.path[0].name,`Document`,`Data`,...a.map(e=>e.name),e.name,`Item`);let c=[...e.path,{name:i,model:e.field}],l=Ut({path:c}),u=Yt({fields:e.field.config?.fields||{},fieldConfigs:e.fieldConfigs,path:c});n.push(...u.auxiliaryTypes),r.push(...u.contentTypeNames),n.push({name:s,code:E.source`
10
10
  /**
11
11
  * Item in *${l}*
12
12
  */
13
13
  export interface ${s} {
14
14
  ${u.code}
15
15
  }
16
- `}),r.push(s),t=D(o?`${i}: prismic.NestedGroupField<Simplify<${s}>>;`:`${i}: prismic.GroupField<Simplify<${s}>>;`,t);break}case`Slices`:{let a=[];if(e.field.config?.choices)for(let t in e.field.config.choices){let i=e.field.config.choices[t];if(i.type===`SharedSlice`)a.push(k(t,`Slice`));else if(i.type===`Slice`){let o=k(e.path[0].name,`Document`,`Data`,e.name,t,`Slice`),s;if(i[`non-repeat`]&&Object.keys(i[`non-repeat`]).length>0){s=k(o,`Primary`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`primary`,label:`Primary`}],c=Vt({path:a}),l=qt({fields:i[`non-repeat`],fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
16
+ `}),r.push(s),t=D(o?`${i}: prismic.NestedGroupField<Simplify<${s}>>;`:`${i}: prismic.GroupField<Simplify<${s}>>;`,t);break}case`Slices`:{let a=[];if(e.field.config?.choices)for(let t in e.field.config.choices){let i=e.field.config.choices[t];if(i.type===`SharedSlice`)a.push(k(t,`Slice`));else if(i.type===`Slice`){let o=k(e.path[0].name,`Document`,`Data`,e.name,t,`Slice`),s;if(i[`non-repeat`]&&Object.keys(i[`non-repeat`]).length>0){s=k(o,`Primary`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`primary`,label:`Primary`}],c=Ut({path:a}),l=Yt({fields:i[`non-repeat`],fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
17
17
  /**
18
18
  * Primary content in *${c}*
19
19
  */
@@ -21,7 +21,7 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
21
21
  export interface ${s} {
22
22
  ${l.code}
23
23
  }
24
- `,u):D(`export interface ${s} {}`,u),n.push({name:s,code:u}),r.push(s)}let c;if(i.repeat&&Object.keys(i.repeat).length>0){c=k(o,`Item`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`items`,label:`Items`}],s=Vt({path:a}),l=qt({fields:i.repeat,fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
24
+ `,u):D(`export interface ${s} {}`,u),n.push({name:s,code:u}),r.push(s)}let c;if(i.repeat&&Object.keys(i.repeat).length>0){c=k(o,`Item`);let a=[...e.path,{name:e.name,model:e.field},{name:t,model:i},{name:`items`,label:`Items`}],s=Ut({path:a}),l=Yt({fields:i.repeat,fieldConfigs:e.fieldConfigs,path:a});n.push(...l.auxiliaryTypes),r.push(...l.contentTypeNames);let u=E.stripIndent`
25
25
  /**
26
26
  * Item content in *${s}*
27
27
  */
@@ -31,17 +31,17 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
31
31
  }
32
32
  `,u):D(`export interface ${c} {}`,u),n.push({name:c,code:u}),r.push(c)}n.push({name:o,code:E.stripIndent`
33
33
  /**
34
- * Slice for *${Vt({path:[...e.path,{name:e.name,model:e.field}]})}*
34
+ * Slice for *${Ut({path:[...e.path,{name:e.name,model:e.field}]})}*
35
35
  */
36
36
  export type ${o} = prismic.Slice<"${t}", ${s?`Simplify<${s}>`:`Record<string, never>`}, ${c?`Simplify<${c}>`:`never`}>
37
- `}),a.push(o)}}let o=k(e.path[0].name,`Document`,`Data`,e.name,`Slice`),s=Gt(a);n.push({name:o,code:`type ${o} = ${s}`}),r.push(o),t=D(`${i}: prismic.SliceZone<${o}>;`,t);break}default:t=D(`${i}: unknown;`,t)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function qt(e){let t=``,n=[],r=[];for(let i in e.fields){let a=e.fields[i],o=Kt({name:i,field:a,path:e.path,fieldConfigs:e.fieldConfigs,tabName:e.tabName});t=O(o.code,t),n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function Jt(e){let t=``,n=[],r=[],i=k(e.model.id,`Document`,`Data`),a=Bt({name:e.model.id,model:e.model}),o=``;for(let t in e.model.json){let{uid:i,...a}=e.model.json[t],s=qt({fields:a,fieldConfigs:e.fieldConfigs,path:[{name:e.model.id,model:e.model}],tabName:t});o+=s.code,n.push(...s.auxiliaryTypes),r.push(...s.contentTypeNames)}return t=o?E.source`
37
+ `}),a.push(o)}}let o=k(e.path[0].name,`Document`,`Data`,e.name,`Slice`),s=qt(a);n.push({name:o,code:`type ${o} = ${s}`}),r.push(o),t=D(`${i}: prismic.SliceZone<${o}>;`,t);break}default:t=D(`${i}: unknown;`,t)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function Yt(e){let t=``,n=[],r=[];for(let i in e.fields){let a=e.fields[i],o=Jt({name:i,field:a,path:e.path,fieldConfigs:e.fieldConfigs,tabName:e.tabName});t=O(o.code,t),n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames)}return{code:t,auxiliaryTypes:n,contentTypeNames:r}}function Xt(e){let t=``,n=[],r=[],i=k(e.model.id,`Document`,`Data`),a=Ht({name:e.model.id,model:e.model}),o=``;for(let t in e.model.json){let{uid:i,...a}=e.model.json[t],s=Yt({fields:a,fieldConfigs:e.fieldConfigs,path:[{name:e.model.id,model:e.model}],tabName:t});o+=s.code,n.push(...s.auxiliaryTypes),r.push(...s.contentTypeNames)}return t=o?E.source`
38
38
  /**
39
39
  * Content for ${a} documents
40
40
  */
41
41
  interface ${i} {
42
42
  ${o}
43
43
  }
44
- `:`interface ${i} {}`,{name:i,code:t,auxiliaryTypes:n,contentTypeNames:r}}function Yt(e){return`uid`in Object.assign({},...Object.values(e.json))}const Xt=e=>c.createHash(`sha1`).update(JSON.stringify(e)).digest(`hex`);function Zt(e){if(e.cache){let t=Xt(e.model),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Document`),a=e.localeIDs&&e.localeIDs.length>0?Gt(e.localeIDs.map(e=>`"${e}"`)):`string`,o=Yt(e.model)?`PrismicDocumentWithUID`:`PrismicDocumentWithoutUID`,s=Bt({name:e.model.id,model:e.model}),c=Jt({model:e.model,fieldConfigs:e.fieldConfigs});n.push(...c.auxiliaryTypes),r.push(c.name),r.push(...c.contentTypeNames),t=O(c.code,t),t=O(E.source`
44
+ `:`interface ${i} {}`,{name:i,code:t,auxiliaryTypes:n,contentTypeNames:r}}function Zt(e){return`uid`in Object.assign({},...Object.values(e.json))}const Qt=e=>c.createHash(`sha1`).update(JSON.stringify(e)).digest(`hex`);function $t(e){if(e.cache){let t=Qt(e.model),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Document`),a=e.localeIDs&&e.localeIDs.length>0?qt(e.localeIDs.map(e=>`"${e}"`)):`string`,o=Zt(e.model)?`PrismicDocumentWithUID`:`PrismicDocumentWithoutUID`,s=Ht({name:e.model.id,model:e.model}),c=Xt({model:e.model,fieldConfigs:e.fieldConfigs});n.push(...c.auxiliaryTypes),r.push(c.name),r.push(...c.contentTypeNames),t=O(c.code,t),t=O(E.source`
45
45
  /**
46
46
  * ${s} document from Prismic
47
47
  *
@@ -52,7 +52,7 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
52
52
  * @typeParam Lang - Language API ID of the document.
53
53
  */
54
54
  export type ${i}<Lang extends string = ${a}> = prismic.${o}<Simplify<${c.name}>, "${e.model.id}", Lang>;
55
- `,t);let l={name:i,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Xt(e.model);e.cache.set(t,l)}return l}function Qt(e){if(e.cache){let t=Xt([e.model,e.fieldConfigs]),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Slice`),a=Bt({name:e.model.id,model:e.model}),o=[];for(let s of e.model.variations){let c=k(i,s.id),l;if(s.primary&&Object.keys(s.primary).length>0){l=k(c,`Primary`);let i=[{name:e.model.id,model:e.model},{name:s.id,label:s.name},{name:`primary`,label:`Primary`}],a=Vt({path:i}),o=qt({fields:s.primary,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(l);let u=E.stripIndent`
55
+ `,t);let l={name:i,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Qt(e.model);e.cache.set(t,l)}return l}function en(e){if(e.cache){let t=Qt([e.model,e.fieldConfigs]),n=e.cache.get(t);if(n)return n}let t=``,n=[],r=[],i=k(e.model.id,`Slice`),a=Ht({name:e.model.id,model:e.model}),o=[];for(let s of e.model.variations){let c=k(i,s.id),l;if(s.primary&&Object.keys(s.primary).length>0){l=k(c,`Primary`);let i=[{name:e.model.id,model:e.model},{name:s.id,label:s.name},{name:`primary`,label:`Primary`}],a=Ut({path:i}),o=Yt({fields:s.primary,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(l);let u=E.stripIndent`
56
56
  /**
57
57
  * Primary content in *${a}*
58
58
  */
@@ -64,7 +64,7 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
64
64
  `:E.source`
65
65
  ${u}
66
66
  export interface ${l} {}
67
- `,t)}let u;if(s.items&&Object.keys(s.items).length>0){u=k(c,`Item`);let i=[{name:e.model.id,model:e.model},{name:`items`,label:`Items`}],a=Vt({path:i}),o=qt({fields:s.items,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(u);let l=E.stripIndent`
67
+ `,t)}let u;if(s.items&&Object.keys(s.items).length>0){u=k(c,`Item`);let i=[{name:e.model.id,model:e.model},{name:`items`,label:`Items`}],a=Ut({path:i}),o=Yt({fields:s.items,fieldConfigs:e.fieldConfigs,path:i});n.push(...o.auxiliaryTypes),r.push(...o.contentTypeNames),r.push(u);let l=E.stripIndent`
68
68
  /**
69
69
  * Primary content in *${a}*
70
70
  */
@@ -82,10 +82,10 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
82
82
  *
83
83
  * - **API ID**: \`${s.id}\`
84
84
  * - **Description**: ${s.description||`*None*`}
85
- * - **Documentation**: ${Je}
85
+ * - **Documentation**: ${Xe}
86
86
  */
87
87
  export type ${c} = prismic.SharedSliceVariation<"${s.id}", ${l?`Simplify<${l}>`:`Record<string, never>`}, ${u?`Simplify<${u}>`:`never`}>;
88
- `,t),o.push(c)}let s=k(i,`Variation`),c=Gt(o);r.push(s),r.push(...o),t=O(E.source`
88
+ `,t),o.push(c)}let s=k(i,`Variation`),c=qt(o);r.push(s),r.push(...o),t=O(E.source`
89
89
  /**
90
90
  * Slice variation for *${a}*
91
91
  */
@@ -96,10 +96,10 @@ import{parseArgs as e}from"node:util";import{access as t,mkdir as n,readFile as
96
96
  *
97
97
  * - **API ID**: \`${e.model.id}\`
98
98
  * - **Description**: ${e.model.description||`*None*`}
99
- * - **Documentation**: ${Je}
99
+ * - **Documentation**: ${Xe}
100
100
  */
101
101
  export type ${i} = prismic.SharedSlice<"${e.model.id}", ${s}>;
102
- `,t);let l={name:i,variationNames:o,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Xt([e.model,e.fieldConfigs]);e.cache.set(t,l)}return l}const $t=new Ge({maxSize:1e3});function en(e={}){let t=e.fieldConfigs||{},n=e.cache??!0,r=``,i=e.typesProvider||`@prismicio/types`,a=`prismic`;r=D(`import type * as prismic from "${i}";`,r),(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace)&&i!==`@prismicio/client`&&(a=`prismicClient`,r=D(`import type * as ${a} from "@prismicio/client";`,r)),r=O(`type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };`,r),r=O(`
102
+ `,t);let l={name:i,variationNames:o,code:t,auxiliaryTypes:n,contentTypeNames:r};if(e.cache){let t=Qt([e.model,e.fieldConfigs]);e.cache.set(t,l)}return l}const tn=new qe({maxSize:1e3});function nn(e={}){let t=e.fieldConfigs||{},n=e.cache??!0,r=``,i=e.typesProvider||`@prismicio/types`,a=`prismic`;r=D(`import type * as prismic from "${i}";`,r),(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace)&&i!==`@prismicio/client`&&(a=`prismicClient`,r=D(`import type * as ${a} from "@prismicio/client";`,r)),r=O(`type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };`,r),r=O(`
103
103
  type PickContentRelationshipFieldData<
104
104
  TRelationship extends prismic.CustomTypeModelFetchCustomTypeLevel1 | prismic.CustomTypeModelFetchCustomTypeLevel2 | prismic.CustomTypeModelFetchGroupLevel1 | prismic.CustomTypeModelFetchGroupLevel2,
105
105
  TData extends Record<string, prismic.AnyRegularField | prismic.GroupField | prismic.NestedGroupField | prismic.SliceZone>,
@@ -142,7 +142,7 @@ type ContentRelationshipFieldWithData<
142
142
  >
143
143
  >
144
144
  }[Exclude<TCustomType[number], string>["id"]];
145
- `,r);let o=[];if(e.customTypeModels){let i=[];for(let a of e.customTypeModels){let s=Zt({model:a,localeIDs:e.localeIDs,fieldConfigs:t,cache:n?$t:void 0});for(let e of s.auxiliaryTypes)r=O(e.code,r);r=O(s.code,r),i.push(s.name),o.push(s.name),o.push(...s.contentTypeNames)}if(e.customTypeModels.length>0){let e=`AllDocumentTypes`;r=O(`export type ${e} = ${Gt(i)};`,r),o.push(e)}}if(e.sharedSliceModels)for(let i of e.sharedSliceModels){let e=Qt({model:i,fieldConfigs:t,cache:n?$t:void 0});for(let t of e.auxiliaryTypes)r=O(t.code,r);r=O(e.code,r),o.push(e.name),o.push(...e.contentTypeNames)}if(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace){let t=``;e.clientIntegration.includeCreateClientInterface&&((e.customTypeModels?.length||0)>0?(t=O(`interface CreateClient {
145
+ `,r);let o=[];if(e.customTypeModels){let i=[];for(let a of e.customTypeModels){let s=$t({model:a,localeIDs:e.localeIDs,fieldConfigs:t,cache:n?tn:void 0});for(let e of s.auxiliaryTypes)r=O(e.code,r);r=O(s.code,r),i.push(s.name),o.push(s.name),o.push(...s.contentTypeNames)}if(e.customTypeModels.length>0){let e=`AllDocumentTypes`;r=O(`export type ${e} = ${qt(i)};`,r),o.push(e)}}if(e.sharedSliceModels)for(let i of e.sharedSliceModels){let e=en({model:i,fieldConfigs:t,cache:n?tn:void 0});for(let t of e.auxiliaryTypes)r=O(t.code,r);r=O(e.code,r),o.push(e.name),o.push(...e.contentTypeNames)}if(e.clientIntegration?.includeCreateClientInterface||e.clientIntegration?.includeContentNamespace){let t=``;e.clientIntegration.includeCreateClientInterface&&((e.customTypeModels?.length||0)>0?(t=O(`interface CreateClient {
146
146
  (repositoryNameOrEndpoint: string, options?: ${a}.ClientConfig): ${a}.Client<AllDocumentTypes>;
147
147
  }`,t),t=O(`interface CreateWriteClient {
148
148
  (repositoryNameOrEndpoint: string, options: ${a}.WriteClientConfig): ${a}.WriteClient<AllDocumentTypes>;
@@ -165,7 +165,7 @@ type ContentRelationshipFieldWithData<
165
165
  declare module "@prismicio/client" {
166
166
  ${t}
167
167
  }
168
- `,r)}return r}function tn(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function nn(e){return(void 0)?.get(e)}function rn(e){return(void 0)?.get(e)}function an(e,t){return(void 0)?.get(e)?.get(t)}function on(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function A(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??on(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??an(e.reference,c.lang)??(l?rn(c.lang):null)??r.message??nn(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function j(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},tn())}}}function sn(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function M(e){return e instanceof cn}var cn=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function ln(e){return{kind:`validation`,type:`url`,reference:ln,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&A(this,`URL`,e,t),e}}}function un(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function dn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function N(e,t){return{kind:`schema`,type:`array`,reference:N,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return j(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else A(this,`type`,e,t);return e}}}function P(e){return{kind:`schema`,type:`boolean`,reference:P,expects:`boolean`,async:!1,message:e,get"~standard"(){return j(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:A(this,`type`,e,t),e}}}function fn(e,t){return{kind:`schema`,type:`literal`,reference:fn,expects:on(e),async:!1,literal:e,message:t,get"~standard"(){return j(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:A(this,`type`,e,t),e}}}function pn(e,t){return{kind:`schema`,type:`nullable`,reference:pn,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return j(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=dn(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function mn(e){return{kind:`schema`,type:`number`,reference:mn,expects:`number`,async:!1,message:e,get"~standard"(){return j(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:A(this,`type`,e,t),e}}}function F(e,t){return{kind:`schema`,type:`object`,reference:F,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return j(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`)for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:dn(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=un(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(A(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}else A(this,`type`,e,t);return e}}}function I(e,t){return{kind:`schema`,type:`optional`,reference:I,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return j(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=dn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function L(e,t,n){return{kind:`schema`,type:`record`,reference:L,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return j(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(sn(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else A(this,`type`,e,t);return e}}}function R(e){return{kind:`schema`,type:`string`,reference:R,expects:`string`,async:!1,message:e,get"~standard"(){return j(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:A(this,`type`,e,t),e}}}function z(){return{kind:`schema`,type:`unknown`,reference:z,expects:`unknown`,async:!1,get"~standard"(){return j(this)},"~run"(e){return e.typed=!0,e}}}function hn(e,t,n){let r=e[`~run`]({value:t},tn(n));if(r.issues)throw new cn(r.issues);return r.value}function gn(...e){return{...e[0],pipe:e,get"~standard"(){return j(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function B(e,t,n){let r=e[`~run`]({value:t},tn(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}async function V(e){let t=await Cn();return t.hostname=`${e}.${t.hostname}`,yn(t)}async function _n(){let e=await Cn();return e.hostname=`api.internal.${e.hostname}`,yn(e)}async function vn(){let e=await Cn();return e.hostname=`user-service.${e.hostname}`,yn(e)}function yn(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}const bn=new URL(`.prismic`,yn(u(l()))),xn=`https://prismic.io`;async function Sn(e,t){let n={token:e,host:t?.host};await s(bn,JSON.stringify(n,null,2))}async function H(){let e=await U();if(!e)return!1;try{let t=await Cn();t.hostname=`user-service.${t.hostname}`;let n=new URL(`profile`,t);return(await fetch(n,{headers:{Accept:`application/json`,Cookie:`SESSION=fake_session; prismic-auth=${e}`}})).ok?!0:(await Tn(),!1)}catch{return!1}}async function U(){return(await wn())?.token}async function Cn(){try{let e=await wn();return e?.host?new URL(e.host):new URL(xn)}catch{return new URL(xn)}}async function wn(){try{let e=await r(bn,`utf-8`);return JSON.parse(e)}catch{return}}async function Tn(){try{await t(bn)}catch{return!0}return await wn()?(await o(bn),!0):!1}async function W(e,n={}){let{start:r=u(process.cwd()),stop:i}=n,a=yn(r);for(;;){let n=new URL(e,a);try{return await t(n),n}catch{}if(typeof i==`string`){let e=new URL(i,a);try{await t(e);return}catch{}}else if(i instanceof URL&&i.href===a.href)return;let r=new URL(`..`,a);if(r.href===a.href)return;a=r}}async function En(e){try{return await t(e),!0}catch{return!1}}const Dn=F({id:R(),type:fn(`SharedSlice`),name:R(),description:I(R()),variations:N(F({id:R(),name:R(),description:I(R()),docURL:I(R()),version:I(R()),imageUrl:I(R()),primary:I(L(R(),z())),items:I(L(R(),z()))}))});async function G(e){if(!await W(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await On(),n;try{n=await i(t,{withFileTypes:!1})}catch{return{ok:!1,error:`No slices directory found at ${t.href}`}}for(let i of n){let n=new URL(`${i}/model.json`,t);try{let t=await r(n,`utf8`),i=JSON.parse(t);if(i.id===e){let e=B(Dn,i);return e.success?{ok:!0,model:e.output,modelPath:n}:{ok:!1,error:`Invalid slice model at ${n.href}`}}}catch{}}return{ok:!1,error:`Slice not found: ${e}\n\nCreate it first with: prismic slice create ${e}`}}async function On(){let e=await An(),t=await W(`package.json`);if(!t)throw Error(`Could not find project root (no package.json found)`);let n=new URL(`.`,t);switch(e){case`next`:if(await En(new URL(`src`,n)))return new URL(`src/slices/`,n);case`nuxt`:if(await En(new URL(`app`,n)))return new URL(`app/slices/`,n);case`sveltekit`:return new URL(`src/slices/`,n)}return new URL(`slices/`,n)}const kn=F({dependencies:I(L(R(),R()))});async function An(){let e=await W(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=hn(kn,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function jn(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Mn=F({id:R(),label:I(R()),repeatable:P(),status:P(),format:I(R()),json:L(R(),z())});async function Nn(){let e=await Cn();return e.hostname=`customtypes.${e.hostname}`,e}async function Pn(e){let t=await U();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Nn(),r=new URL(`customtypes`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=B(N(Mn),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Fn(e){let t=await U();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Nn(),r=new URL(`slices`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=B(N(Dn),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function In(){let e=await W(`package.json`);if(!e)return{ok:!1,error:`Could not find project root (no package.json found)`};let t=new URL(`.`,e),n=new URL(`customtypes/`,t),a;try{a=await i(n,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let o=[];for(let e of a){let t=new URL(`${e}/index.json`,n);try{let e=await r(t,`utf8`),n=B(Mn,JSON.parse(e));n.success&&o.push(n.output)}catch{}}return{ok:!0,value:o}}async function Ln(){let e;try{e=await On()}catch{return{ok:!1,error:`Could not find project root (no package.json found)`}}let t;try{t=await i(e,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let n=[];for(let i of t){let t=new URL(`${i}/model.json`,e);try{let e=await r(t,`utf8`),i=B(Dn,JSON.parse(e));i.success&&n.push(i.output)}catch{}}return{ok:!0,value:n}}async function Rn(e,t){let n=await U();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Nn(),i=new URL(`customtypes/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function zn(e,t){let n=await U();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Nn(),i=new URL(`customtypes/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Bn(e,t){let n=await U();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Nn(),i=new URL(`customtypes/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Vn(e,t){let n=await U();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Nn(),i=new URL(`slices/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Hn(e,t){let n=await U();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Nn(),i=new URL(`slices/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Un(e,t){let n=await U();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Nn(),i=new URL(`slices/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Wn(){let{values:{help:t,output:n}}=e({args:process.argv.slice(4),options:{output:{type:`string`,short:`o`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Generate TypeScript types from local custom type and slice models.
168
+ `,r)}return r}function rn(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}function an(e){return(void 0)?.get(e)}function on(e){return(void 0)?.get(e)}function sn(e,t){return(void 0)?.get(e)?.get(t)}function cn(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function ln(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??cn(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??sn(e.reference,c.lang)??(l?on(c.lang):null)??r.message??an(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function un(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},rn())}}}function dn(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function A(e){return e instanceof fn}var fn=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function pn(e){return{kind:`validation`,type:`url`,reference:pn,async:!1,expects:null,requirement(e){try{return new URL(e),!0}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&ln(this,`URL`,e,t),e}}}function mn(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function hn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function j(e,t){return{kind:`schema`,type:`array`,reference:j,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return un(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else ln(this,`type`,e,t);return e}}}function M(e){return{kind:`schema`,type:`boolean`,reference:M,expects:`boolean`,async:!1,message:e,get"~standard"(){return un(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:ln(this,`type`,e,t),e}}}function gn(e,t){return{kind:`schema`,type:`literal`,reference:gn,expects:cn(e),async:!1,literal:e,message:t,get"~standard"(){return un(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:ln(this,`type`,e,t),e}}}function _n(e,t){return{kind:`schema`,type:`nullable`,reference:_n,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return un(this)},"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=hn(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function vn(e){return{kind:`schema`,type:`number`,reference:vn,expects:`number`,async:!1,message:e,get"~standard"(){return un(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:ln(this,`type`,e,t),e}}}function N(e,t){return{kind:`schema`,type:`object`,reference:N,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return un(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`)for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:hn(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=mn(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(ln(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}else ln(this,`type`,e,t);return e}}}function P(e,t){return{kind:`schema`,type:`optional`,reference:P,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return un(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=hn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function F(e,t,n){return{kind:`schema`,type:`record`,reference:F,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return un(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(dn(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else ln(this,`type`,e,t);return e}}}function I(e){return{kind:`schema`,type:`string`,reference:I,expects:`string`,async:!1,message:e,get"~standard"(){return un(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:ln(this,`type`,e,t),e}}}function L(){return{kind:`schema`,type:`unknown`,reference:L,expects:`unknown`,async:!1,get"~standard"(){return un(this)},"~run"(e){return e.typed=!0,e}}}function yn(e,t,n){let r=e[`~run`]({value:t},rn(n));if(r.issues)throw new fn(r.issues);return r.value}function bn(...e){return{...e[0],pipe:e,get"~standard"(){return un(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function R(e,t,n){let r=e[`~run`]({value:t},rn(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}async function z(e){let t=await On();return t.hostname=`${e}.${t.hostname}`,Cn(t)}async function xn(){let e=await On();return e.hostname=`api.internal.${e.hostname}`,Cn(e)}async function Sn(){let e=await On();return e.hostname=`user-service.${e.hostname}`,Cn(e)}function Cn(e){let t=new URL(e);return t.pathname.endsWith(`/`)||(t.pathname+=`/`),t}const wn=new URL(`.prismic`,Cn(d(u()))),Tn=`https://prismic.io`;async function En(e,t){let n={token:e,host:t?.host};await s(wn,JSON.stringify(n,null,2))}async function B(){let e=await Dn();if(!e)return!1;try{let t=await On();t.hostname=`user-service.${t.hostname}`;let n=new URL(`profile`,t);return(await fetch(n,{headers:{Accept:`application/json`,Cookie:`SESSION=fake_session; prismic-auth=${e}`}})).ok?!0:(await An(),!1)}catch{return!1}}async function Dn(){return(await kn())?.token}async function On(){try{let e=await kn();return e?.host?new URL(e.host):new URL(Tn)}catch{return new URL(Tn)}}async function kn(){try{let e=await r(wn,`utf-8`);return JSON.parse(e)}catch{return}}async function An(){try{await t(wn)}catch{return!0}return await kn()?(await o(wn),!0):!1}async function V(e,n={}){let{start:r=d(process.cwd()),stop:i}=n,a=Cn(r);for(;;){let n=new URL(e,a);try{return await t(n),n}catch{}if(typeof i==`string`){let e=new URL(i,a);try{await t(e);return}catch{}}else if(i instanceof URL&&i.href===a.href)return;let r=new URL(`..`,a);if(r.href===a.href)return;a=r}}async function jn(e){try{return await t(e),!0}catch{return!1}}const Mn=N({id:I(),type:gn(`SharedSlice`),name:I(),description:P(I()),variations:j(N({id:I(),name:I(),description:P(I()),docURL:P(I()),version:P(I()),imageUrl:P(I()),primary:P(F(I(),L())),items:P(F(I(),L()))}))});async function H(e){if(!await V(`package.json`))return{ok:!1,error:`Could not find project root (no package.json found)`};let t=await Nn(),n;try{n=await i(t,{withFileTypes:!1})}catch{return{ok:!1,error:`No slices directory found at ${t.href}`}}for(let i of n){let n=new URL(`${i}/model.json`,t);try{let t=await r(n,`utf8`),i=JSON.parse(t);if(i.id===e){let e=R(Mn,i);return e.success?{ok:!0,model:e.output,modelPath:n}:{ok:!1,error:`Invalid slice model at ${n.href}`}}}catch{}}return{ok:!1,error:`Slice not found: ${e}\n\nCreate it first with: prismic slice create ${e}`}}async function Nn(){let e=await Fn(),t=await V(`package.json`);if(!t)throw Error(`Could not find project root (no package.json found)`);let n=new URL(`.`,t);switch(e){case`next`:if(await jn(new URL(`src`,n)))return new URL(`src/slices/`,n);case`nuxt`:if(await jn(new URL(`app`,n)))return new URL(`app/slices/`,n);case`sveltekit`:return new URL(`src/slices/`,n)}return new URL(`slices/`,n)}const Pn=N({dependencies:P(F(I(),I()))});async function Fn(){let e=await V(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=yn(Pn,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function In(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Ln=N({id:I(),label:P(I()),repeatable:M(),status:M(),format:P(I()),json:F(I(),L())});async function Rn(){let e=await On();return e.hostname=`customtypes.${e.hostname}`,e}async function zn(e){let t=await Dn();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Rn(),r=new URL(`customtypes`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=R(j(Ln),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Bn(e){let t=await Dn();if(!t)return{ok:!1,error:`Not authenticated`};let n=await Rn(),r=new URL(`slices`,n);try{let n=await fetch(r,{headers:{Authorization:`Bearer ${t}`,repository:e}});if(!n.ok)return n.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:n.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${n.status} ${n.statusText}`};let i=await n.json(),a=R(j(Mn),i);return a.success?{ok:!0,value:a.output}:{ok:!1,error:`Invalid response from Custom Types API`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Vn(){let e=await V(`package.json`);if(!e)return{ok:!1,error:`Could not find project root (no package.json found)`};let t=new URL(`.`,e),n=new URL(`customtypes/`,t),a;try{a=await i(n,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let o=[];for(let e of a){let t=new URL(`${e}/index.json`,n);try{let e=await r(t,`utf8`),n=R(Ln,JSON.parse(e));n.success&&o.push(n.output)}catch{}}return{ok:!0,value:o}}async function Hn(){let e;try{e=await Nn()}catch{return{ok:!1,error:`Could not find project root (no package.json found)`}}let t;try{t=await i(e,{withFileTypes:!1})}catch{return{ok:!0,value:[]}}let n=[];for(let i of t){let t=new URL(`${i}/model.json`,e);try{let e=await r(t,`utf8`),i=R(Mn,JSON.parse(e));i.success&&n.push(i.output)}catch{}}return{ok:!0,value:n}}async function Un(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),i=new URL(`customtypes/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Wn(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),i=new URL(`customtypes/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Gn(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),i=new URL(`customtypes/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Kn(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),i=new URL(`slices/insert`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function qn(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),i=new URL(`slices/update`,r);try{let r=await fetch(i,{method:`POST`,headers:{Authorization:`Bearer ${n}`,repository:e,"Content-Type":`application/json`},body:JSON.stringify(t)});return r.ok?{ok:!0,value:void 0}:r.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:r.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${r.status} ${r.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Jn(e,t){let n=await Dn();if(!n)return{ok:!1,error:`Not authenticated`};let r=await Rn(),i=new URL(`slices/${encodeURIComponent(t)}`,r);try{let t=await fetch(i,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,repository:e}});return t.ok?{ok:!0,value:void 0}:t.status===401?{ok:!1,error:"Unauthorized. Your session may have expired. Run `prismic login` again."}:t.status===403?{ok:!1,error:`Access denied. You may not have access to repository "${e}".`}:{ok:!1,error:`API error: ${t.status} ${t.statusText}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:e}`}}}async function Yn(){let{values:{help:t,output:n}}=e({args:process.argv.slice(4),options:{output:{type:`string`,short:`o`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Generate TypeScript types from local custom type and slice models.
169
169
 
170
170
  USAGE
171
171
  prismic codegen types [flags]
@@ -176,9 +176,9 @@ FLAGS
176
176
 
177
177
  EXAMPLES
178
178
  prismic codegen types
179
- prismic codegen types --output custom.d.ts`);return}try{await K({output:n}),console.info(`Generated types written to ${n??`prismicio-types.d.ts`}`)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function K(e){let t=e?.output??`prismicio-types.d.ts`,[n,r]=await Promise.all([In(),Ln()]);if(!n.ok)throw Error(`failed to read local custom types: ${n.error}`);if(!r.ok)throw Error(`failed to read local slices: ${r.error}`);let i=n.value,a=r.value;await s(t,`// Code generated by prismic-ts-codegen. DO NOT EDIT.
179
+ prismic codegen types --output custom.d.ts`);return}try{await U({output:n}),console.info(`Generated types written to ${n??`prismicio-types.d.ts`}`)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function U(e){let t=e?.output??`prismicio-types.d.ts`,[n,r]=await Promise.all([Vn(),Hn()]);if(!n.ok)throw Error(`failed to read local custom types: ${n.error}`);if(!r.ok)throw Error(`failed to read local slices: ${r.error}`);let i=n.value,a=r.value;await s(t,`// Code generated by prismic-ts-codegen. DO NOT EDIT.
180
180
 
181
- `+en({customTypeModels:i,sharedSliceModels:a,typesProvider:`@prismicio/client`,clientIntegration:{includeCreateClientInterface:i.length>0||a.length>0,includeContentNamespace:!0}}))}async function Gn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`types`:await Wn();break;default:t&&(console.error(`Unknown codegen subcommand: ${t}\n`),process.exitCode=1),console.info(`Generate code from Prismic models.
181
+ `+nn({customTypeModels:i,sharedSliceModels:a,typesProvider:`@prismicio/client`,clientIntegration:{includeCreateClientInterface:i.length>0||a.length>0,includeContentNamespace:!0}}))}async function Xn(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`types`:await Yn();break;default:t&&(console.error(`Unknown codegen subcommand: ${t}\n`),process.exitCode=1),console.info(`Generate code from Prismic models.
182
182
 
183
183
  USAGE
184
184
  prismic codegen <command> [flags]
@@ -190,7 +190,7 @@ FLAGS
190
190
  -h, --help Show help for command
191
191
 
192
192
  LEARN MORE
193
- Use \`prismic codegen <command> --help\` for more information about a command.`)}}function q(e){return JSON.stringify(e,null,2)}function J(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}const Kn=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function qn(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing custom type.
193
+ Use \`prismic codegen <command> --help\` for more information about a command.`)}}function W(e){let t=e.split(`.`);return t.length===1?{type:`top-level`,fieldId:e}:t.length===2?{type:`nested`,groupId:t[0],nestedFieldId:t[1]}:{type:`nested`,groupId:t[0],nestedFieldId:t.slice(1).join(`.`)}}function G(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Group`&&`config`in e&&typeof e.config==`object`&&e.config!==null&&`fields`in e.config}function K(e,t,n){let r=e[t];return r?G(r)?{ok:!0,group:r}:{ok:!1,error:`Field "${t}" is not a group`}:{ok:!1,error:`Group "${t}" not found in tab "${n}"`}}function Zn(e,t,n){let r=e[t];return r?G(r)?{ok:!0,group:r}:{ok:!1,error:`Field "${t}" is not a group`}:{ok:!1,error:`Group "${t}" not found in variation "${n}"`}}function q(e){return e.type===`nested`&&e.nestedFieldId.includes(`.`)?{ok:!1,error:`Nested groups not supported. Use: group.field`}:{ok:!0}}function J(e){return JSON.stringify(e,null,2)}function Y(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}const Qn=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function $n(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing custom type.
194
194
 
195
195
  USAGE
196
196
  prismic custom-type add-field boolean <type-id> <field-id> [flags]
@@ -213,7 +213,7 @@ EXAMPLES
213
213
  prismic custom-type add-field boolean article published --default
214
214
  prismic custom-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!u){console.error(`Missing required argument: type-id
215
215
  `),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
216
- `),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=await W(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=B(Kn,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`Boolean`,config:{label:i??J(d),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};m.json[g][d]=_;try{await s(p,q(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (Boolean) to "${g}" tab in ${u}`);try{await K({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Jn=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Yn(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing custom type.
216
+ `),console.error(`Usage: prismic custom-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(Qn,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Boolean`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await s(h,J(g))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Boolean) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Boolean) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const er=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function tr(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing custom type.
217
217
 
218
218
  USAGE
219
219
  prismic custom-type add-field color <type-id> <field-id> [flags]
@@ -234,7 +234,7 @@ EXAMPLES
234
234
  prismic custom-type add-field color homepage accent --tab "Design"
235
235
  prismic custom-type add-field color homepage text_color --label "Text Color"`);return}if(!c){console.error(`Missing required argument: type-id
236
236
  `),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
237
- `),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(Jn,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Color`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Color) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Xn=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Zn(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing custom type.
237
+ `),console.error(`Usage: prismic custom-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(er,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Color`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Color) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Color) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const nr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function rr(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing custom type.
238
238
 
239
239
  USAGE
240
240
  prismic custom-type add-field date <type-id> <field-id> [flags]
@@ -256,7 +256,7 @@ EXAMPLES
256
256
  prismic custom-type add-field date event start_date --tab "Schedule"
257
257
  prismic custom-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!l){console.error(`Missing required argument: type-id
258
258
  `),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
259
- `),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=await W(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=B(Xn,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Date`,config:{label:i??J(u),...a&&{placeholder:a},...o&&{default:o}}};p.json[h][u]=g;try{await s(f,q(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Date) to "${h}" tab in ${l}`);try{await K({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Qn=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function $n(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing custom type.
259
+ `),console.error(`Usage: prismic custom-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(nr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Date`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await s(m,J(h))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Date) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Date) to "${_}" tab in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const ir=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function ar(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing custom type.
260
260
 
261
261
  USAGE
262
262
  prismic custom-type add-field embed <type-id> <field-id> [flags]
@@ -277,7 +277,7 @@ EXAMPLES
277
277
  prismic custom-type add-field embed homepage youtube --tab "Media"
278
278
  prismic custom-type add-field embed homepage media --label "Media Embed"`);return}if(!c){console.error(`Missing required argument: type-id
279
279
  `),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
280
- `),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(Qn,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Embed`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Embed) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const er=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function tr(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing custom type.
280
+ `),console.error(`Usage: prismic custom-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(ir,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Embed`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Embed) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Embed) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const or=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function sr(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing custom type.
281
281
 
282
282
  USAGE
283
283
  prismic custom-type add-field geo-point <type-id> <field-id> [flags]
@@ -297,7 +297,28 @@ EXAMPLES
297
297
  prismic custom-type add-field geo-point store address --tab "Details"
298
298
  prismic custom-type add-field geo-point event venue --label "Event Venue"`);return}if(!o){console.error(`Missing required argument: type-id
299
299
  `),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
300
- `),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=await W(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=B(er,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`GeoPoint`,config:{label:i??J(c)}};d.json[p][c]=m;try{await s(u,q(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${c}" (GeoPoint) to "${p}" tab in ${o}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const nr=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function rr(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing custom type.
300
+ `),console.error(`Usage: prismic custom-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await V(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${o}/index.json`,d),p;try{let e=await r(f,`utf8`),t=R(or,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${o}\n`),console.error(`Create it first with: prismic custom-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});let g={type:`GeoPoint`,config:{label:i??Y(l.type===`nested`?l.nestedFieldId:c)}};if(l.type===`nested`){let e=K(p.json[h],l.groupId,h);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=g}else{for(let[e,t]of Object.entries(p.json)){if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[c]){console.error(`Field "${c}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}p.json[h][c]=g}try{await s(f,J(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (GeoPoint) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (GeoPoint) to "${h}" tab in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const cr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function lr(){let{values:{help:t,tab:n,label:i,"non-repeatable":a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing custom type.
301
+
302
+ USAGE
303
+ prismic custom-type add-field group <type-id> <field-id> [flags]
304
+
305
+ ARGUMENTS
306
+ type-id Custom type identifier (required)
307
+ field-id Field identifier (required)
308
+
309
+ FLAGS
310
+ -t, --tab string Target tab (default: first existing tab, or "Main")
311
+ -l, --label string Display label for the field (inferred from field-id if omitted)
312
+ --non-repeatable Make this a non-repeating group (default: repeatable)
313
+ --types string Output file for generated types (default: "prismicio-types.d.ts")
314
+ -h, --help Show help for command
315
+
316
+ EXAMPLES
317
+ prismic custom-type add-field group homepage buttons
318
+ prismic custom-type add-field group article authors --non-repeatable
319
+ prismic custom-type add-field group product variants --tab "Content"`);return}if(!c){console.error(`Missing required argument: type-id
320
+ `),console.error(`Usage: prismic custom-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
321
+ `),console.error(`Usage: prismic custom-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(l.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let u=await V(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=R(cr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Group`,config:{label:i??Y(l),repeat:!a,fields:{}}};f.json[m][l]=h;try{await s(d,J(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Group) to "${m}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic custom-type add-field <type> ${c} ${l}.<field-id>\``),console.info(" Run `prismic status` when done to find next steps")}const ur=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function dr(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing custom type.
301
322
 
302
323
  USAGE
303
324
  prismic custom-type add-field image <type-id> <field-id> [flags]
@@ -318,7 +339,7 @@ EXAMPLES
318
339
  prismic custom-type add-field image article thumbnail --tab "Media"
319
340
  prismic custom-type add-field image product photo --label "Product Photo"`);return}if(!c){console.error(`Missing required argument: type-id
320
341
  `),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
321
- `),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(nr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Image`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Image) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const ir=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function ar(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing custom type.
342
+ `),console.error(`Usage: prismic custom-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(ur,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Image`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Image) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Image) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const fr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function pr(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing custom type.
322
343
 
323
344
  USAGE
324
345
  prismic custom-type add-field key-text <type-id> <field-id> [flags]
@@ -339,7 +360,7 @@ EXAMPLES
339
360
  prismic custom-type add-field key-text homepage meta_title --tab "SEO"
340
361
  prismic custom-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!c){console.error(`Missing required argument: type-id
341
362
  `),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
342
- `),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(ir,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Text`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (Text) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const or=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function sr(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing custom type.
363
+ `),console.error(`Usage: prismic custom-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(fr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Text`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Text) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Text) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const mr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function hr(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing custom type.
343
364
 
344
365
  USAGE
345
366
  prismic custom-type add-field link <type-id> <field-id> [flags]
@@ -365,7 +386,7 @@ EXAMPLES
365
386
  prismic custom-type add-field link homepage cta --variation Primary --variation Secondary
366
387
  prismic custom-type add-field link homepage links --repeatable`);return}if(!f){console.error(`Missing required argument: type-id
367
388
  `),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!p){console.error(`Missing required argument: field-id
368
- `),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=await W(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${f}/index.json`,m),g;try{let e=await r(h,`utf8`),t=B(or,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${f}\n`),console.error(`Create it first with: prismic custom-type create ${f}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});for(let[e,t]of Object.entries(g.json))if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}let y={type:`Link`,config:{label:i??J(p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};g.json[v][p]=y;try{await s(h,q(g))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${p}" (Link) to "${v}" tab in ${f}`);try{await K({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const cr=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function lr(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing custom type.
389
+ `),console.error(`Usage: prismic custom-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=W(p),h=q(m);if(!h.ok){console.error(h.error),process.exitCode=1;return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${f}/index.json`,g),v;try{let e=await r(_,`utf8`),t=R(mr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${_.href}`),process.exitCode=1;return}v=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${f}\n`),console.error(`Create it first with: prismic custom-type create ${f}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});let x={type:`Link`,config:{label:i??Y(m.type===`nested`?m.nestedFieldId:p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};if(m.type===`nested`){let e=K(v.json[b],m.groupId,b);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[m.nestedFieldId]){console.error(`Field "${m.nestedFieldId}" already exists in group "${m.groupId}"`),process.exitCode=1;return}e.group.config.fields[m.nestedFieldId]=x}else{for(let[e,t]of Object.entries(v.json)){if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[p]){console.error(`Field "${p}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}v.json[b][p]=x}try{await s(_,J(v))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}m.type===`nested`?console.info(`Added field "${m.nestedFieldId}" (Link) to group "${m.groupId}" in ${f}`):console.info(`Added field "${p}" (Link) to "${b}" tab in ${f}`);try{await U({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const gr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function _r(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing custom type.
369
390
 
370
391
  USAGE
371
392
  prismic custom-type add-field number <type-id> <field-id> [flags]
@@ -389,7 +410,7 @@ EXAMPLES
389
410
  prismic custom-type add-field number product quantity --min 0 --max 100
390
411
  prismic custom-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!d){console.error(`Missing required argument: type-id
391
412
  `),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
392
- `),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=o===void 0?void 0:Number(o),m=c===void 0?void 0:Number(c),h=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(p)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(m)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(h)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let g=await W(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${d}/index.json`,g),v;try{let e=await r(_,`utf8`),t=B(cr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${_.href}`),process.exitCode=1;return}v=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${d}\n`),console.error(`Create it first with: prismic custom-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});for(let[e,t]of Object.entries(v.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let x={type:`Number`,config:{label:i??J(f),...a&&{placeholder:a},...p!==void 0&&{min:p},...m!==void 0&&{max:m},...h!==void 0&&{step:h}}};v.json[b][f]=x;try{await s(_,q(v))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${f}" (Number) to "${b}" tab in ${d}`);try{await K({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const ur=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function dr(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing custom type.
413
+ `),console.error(`Usage: prismic custom-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=o===void 0?void 0:Number(o),g=c===void 0?void 0:Number(c),_=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(h)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(g)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(_)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let v=await V(`package.json`);if(!v){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let y=new URL(`customtypes/${d}/index.json`,v),b;try{let e=await r(y,`utf8`),t=R(gr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${y.href}`),process.exitCode=1;return}b=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${d}\n`),console.error(`Create it first with: prismic custom-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let x=Object.keys(b.json),S=n??x[0]??`Main`;b.json[S]||(b.json[S]={});let ee={type:`Number`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...h!==void 0&&{min:h},...g!==void 0&&{max:g},..._!==void 0&&{step:_}}};if(p.type===`nested`){let e=K(b.json[S],p.groupId,S);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=ee}else{for(let[e,t]of Object.entries(b.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}b.json[S][f]=ee}try{await s(y,J(b))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (Number) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (Number) to "${S}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const vr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function yr(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing custom type.
393
414
 
394
415
  USAGE
395
416
  prismic custom-type add-field rich-text <type-id> <field-id> [flags]
@@ -419,7 +440,7 @@ EXAMPLES
419
440
  prismic custom-type add-field rich-text page tagline --single "heading1"
420
441
  prismic custom-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!d){console.error(`Missing required argument: type-id
421
442
  `),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
422
- `),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=await W(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${d}/index.json`,p),h;try{let e=await r(m,`utf8`),t=B(ur,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${d}\n`),console.error(`Create it first with: prismic custom-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`StructuredText`,config:{label:i??J(f),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};h.json[_][f]=v;try{await s(m,q(h))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${f}" (StructuredText) to "${_}" tab in ${d}`);try{await K({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const fr=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function pr(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing custom type.
443
+ `),console.error(`Usage: prismic custom-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=await V(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${d}/index.json`,h),_;try{let e=await r(g,`utf8`),t=R(vr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${d}\n`),console.error(`Create it first with: prismic custom-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});let b={type:`StructuredText`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};if(p.type===`nested`){let e=K(_.json[y],p.groupId,y);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=b}else{for(let[e,t]of Object.entries(_.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}_.json[y][f]=b}try{await s(g,J(_))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (StructuredText) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (StructuredText) to "${y}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const br=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function xr(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing custom type.
423
444
 
424
445
  USAGE
425
446
  prismic custom-type add-field select <type-id> <field-id> [flags]
@@ -442,7 +463,7 @@ EXAMPLES
442
463
  prismic custom-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
443
464
  prismic custom-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!u){console.error(`Missing required argument: type-id
444
465
  `),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
445
- `),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=await W(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=B(fr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`Select`,config:{label:i??J(d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};m.json[g][d]=_;try{await s(p,q(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${d}" (Select) to "${g}" tab in ${u}`);try{await K({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const mr=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function hr(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing custom type.
466
+ `),console.error(`Usage: prismic custom-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(br,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${u}\n`),console.error(`Create it first with: prismic custom-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Select`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await s(h,J(g))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Select) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Select) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Sr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Cr(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing custom type.
446
467
 
447
468
  USAGE
448
469
  prismic custom-type add-field timestamp <type-id> <field-id> [flags]
@@ -464,7 +485,7 @@ EXAMPLES
464
485
  prismic custom-type add-field timestamp event start --tab "Schedule"
465
486
  prismic custom-type add-field timestamp article published_at --label "Published At"`);return}if(!l){console.error(`Missing required argument: type-id
466
487
  `),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
467
- `),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=await W(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=B(mr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Timestamp`,config:{label:i??J(u),...a&&{placeholder:a},...o&&{default:o}}};p.json[h][u]=g;try{await s(f,q(p))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${u}" (Timestamp) to "${h}" tab in ${l}`);try{await K({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const gr=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function _r(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing custom type.
488
+ `),console.error(`Usage: prismic custom-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(Sr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${l}\n`),console.error(`Create it first with: prismic custom-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Timestamp`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await s(m,J(h))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Timestamp) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Timestamp) to "${_}" tab in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const wr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Tr(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing custom type.
468
489
 
469
490
  USAGE
470
491
  prismic custom-type add-field uid <type-id> <field-id> [flags]
@@ -485,7 +506,7 @@ EXAMPLES
485
506
  prismic custom-type add-field uid article slug --label "URL Slug"
486
507
  prismic custom-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!c){console.error(`Missing required argument: type-id
487
508
  `),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
488
- `),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(gr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`UID`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (UID) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function vr(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await qn();break;case`color`:await Yn();break;case`date`:await Zn();break;case`embed`:await $n();break;case`geo-point`:await tr();break;case`image`:await rr();break;case`key-text`:await ar();break;case`link`:await sr();break;case`number`:await lr();break;case`rich-text`:await dr();break;case`select`:await pr();break;case`timestamp`:await hr();break;case`uid`:await _r();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing custom type.
509
+ `),console.error(`Usage: prismic custom-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}if(u.type===`nested`){console.error(`UID fields cannot be nested inside groups`),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(wr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${c}\n`),console.error(`Create it first with: prismic custom-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`UID`,config:{label:i??Y(l),...a&&{placeholder:a}}};m.json[g][l]=_;try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Added field "${l}" (UID) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic custom-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function Er(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await $n();break;case`color`:await tr();break;case`date`:await rr();break;case`embed`:await ar();break;case`geo-point`:await sr();break;case`group`:await lr();break;case`image`:await dr();break;case`key-text`:await pr();break;case`link`:await hr();break;case`number`:await _r();break;case`rich-text`:await yr();break;case`select`:await xr();break;case`timestamp`:await Cr();break;case`uid`:await Tr();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing custom type.
489
510
 
490
511
  USAGE
491
512
  prismic custom-type add-field <field-type> <type-id> <field-id> [flags]
@@ -496,6 +517,7 @@ FIELD TYPES
496
517
  date Date picker
497
518
  embed Embed (oEmbed)
498
519
  geo-point Geographic coordinates
520
+ group Repeatable group of fields
499
521
  image Image
500
522
  key-text Single-line text
501
523
  link Any link type
@@ -515,7 +537,7 @@ EXAMPLES
515
537
  prismic custom-type add-field key-text homepage meta_title --tab "SEO"
516
538
  prismic custom-type add-field link homepage button --allow-text
517
539
  prismic custom-type add-field rich-text homepage body --multi "paragraph,heading2,strong,em"
518
- prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const yr=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function br(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a custom type's slice zone.
540
+ prismic custom-type add-field select homepage layout --option "full" --option "sidebar"`)}}const Dr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Or(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a custom type's slice zone.
519
541
 
520
542
  USAGE
521
543
  prismic custom-type connect-slice <type-id> <slice-id> [flags]
@@ -534,7 +556,7 @@ EXAMPLES
534
556
  prismic custom-type connect-slice homepage CallToAction --slice-zone slices
535
557
  prismic custom-type connect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
536
558
  `),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
537
- `),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await G(o);if(!c.ok){console.error(c.error),process.exitCode=1;return}let l=await W(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=B(yr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in custom type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;try{await s(u,q(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function xr(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new custom type in a Prismic repository.
559
+ `),console.error(`Usage: prismic custom-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await H(o);if(!c.ok){console.error(c.error),process.exitCode=1;return}let l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=R(Dr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in custom type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;try{await s(u,J(d))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function kr(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new custom type in a Prismic repository.
538
560
 
539
561
  USAGE
540
562
  prismic custom-type create <id> [flags]
@@ -549,7 +571,7 @@ FLAGS
549
571
  -h, --help Show help for command
550
572
 
551
573
  LEARN MORE
552
- Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let c={id:o,label:r??Sr(o),repeatable:!i,status:!0,format:`custom`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}}}},l=await W(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await s(f,q(c))}catch(e){e instanceof Error?console.error(`Failed to create custom type: ${e.message}`):console.error(`Failed to create custom type`),process.exitCode=1;return}console.info(`Created custom type at ${f.href}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic custom-type add-field`")}function Sr(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Cr=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function wr(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a custom type's slice zone.
574
+ Use \`prismic custom-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let c={id:o,label:r??Ar(o),repeatable:!i,status:!0,format:`custom`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}}}},l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await s(f,J(c))}catch(e){e instanceof Error?console.error(`Failed to create custom type: ${e.message}`):console.error(`Failed to create custom type`),process.exitCode=1;return}console.info(`Created custom type at ${f.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic custom-type add-field`")}function Ar(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const jr=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Mr(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a custom type's slice zone.
553
575
 
554
576
  USAGE
555
577
  prismic custom-type disconnect-slice <type-id> <slice-id> [flags]
@@ -568,7 +590,7 @@ EXAMPLES
568
590
  prismic custom-type disconnect-slice homepage CallToAction --slice-zone slices
569
591
  prismic custom-type disconnect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
570
592
  `),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
571
- `),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await W(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=B(Cr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){console.error(`Slice zone "${d}" not found in custom type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];try{await s(l,q(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Tr=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function Er(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all custom types in a Prismic project.
593
+ `),console.error(`Usage: prismic custom-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await V(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=R(jr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){console.error(`Slice zone "${d}" not found in custom type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];try{await s(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Nr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Pr(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all custom types in a Prismic project.
572
594
 
573
595
  USAGE
574
596
  prismic custom-type list [flags]
@@ -579,7 +601,7 @@ FLAGS
579
601
 
580
602
  EXAMPLES
581
603
  prismic custom-type list
582
- prismic custom-type list --json`);return}let a=await W(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=B(Tr,JSON.parse(e));n.success&&n.output.format!==`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const Dr=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function Or(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom type from the project.
604
+ prismic custom-type list --json`);return}let a=await V(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=R(Nr,JSON.parse(e));n.success&&n.output.format!==`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No custom types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const Fr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ir(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom type from the project.
583
605
 
584
606
  USAGE
585
607
  prismic custom-type remove <type-id> [flags]
@@ -595,7 +617,7 @@ FLAGS
595
617
  EXAMPLES
596
618
  prismic custom-type remove settings
597
619
  prismic custom-type remove settings -y`);return}if(!a){console.error(`Missing required argument: type-id
598
- `),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let s=await W(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=B(Dr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(u.format===`page`){console.error(`"${a}" is not a custom type (format: page)`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove custom type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove custom type: ${e.message}`):console.error(`Failed to remove custom type`),process.exitCode=1;return}console.info(`Removed custom type "${a}"`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const kr=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function Ar(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a custom type.
620
+ `),console.error(`Usage: prismic custom-type remove <type-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=R(Fr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(u.format===`page`){console.error(`"${a}" is not a custom type (format: page)`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove custom type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove custom type: ${e.message}`):console.error(`Failed to remove custom type`),process.exitCode=1;return}console.info(`Removed custom type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Lr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Rr(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a custom type.
599
621
 
600
622
  USAGE
601
623
  prismic custom-type remove-field <type-id> <field-id> [flags]
@@ -613,7 +635,7 @@ EXAMPLES
613
635
  prismic custom-type remove-field settings title
614
636
  prismic custom-type remove-field settings description --tab "Content"`);return}if(!a){console.error(`Missing required argument: type-id
615
637
  `),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
616
- `),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let c=await W(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=B(kr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(u.format===`page`){console.error(`"${a}" is not a custom type (format: page)`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in custom type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of custom type "${a}"`),process.exitCode=1;return}}try{await s(l,q(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Removed field "${o}" from tab "${d}" in custom type "${a}"`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const jr=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function Mr(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a custom type's display name (label).
638
+ `),console.error(`Usage: prismic custom-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let c=await V(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=R(Lr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${a}\n`),console.error(`Create it first with: prismic custom-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(u.format===`page`){console.error(`"${a}" is not a custom type (format: page)`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in custom type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of custom type "${a}"`),process.exitCode=1;return}}try{await s(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Removed field "${o}" from tab "${d}" in custom type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const zr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Br(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a custom type's display name (label).
617
639
 
618
640
  USAGE
619
641
  prismic custom-type set-name <type-id> <new-name> [flags]
@@ -630,7 +652,7 @@ EXAMPLES
630
652
  prismic custom-type set-name settings "Site Settings"
631
653
  prismic custom-type set-name menu "Navigation Menu"`);return}if(!i){console.error(`Missing required argument: type-id
632
654
  `),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: new-name
633
- `),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await W(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=B(jr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}l.label=a;try{await s(c,q(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Renamed custom type "${i}" to "${a}"`);try{await K({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Nr=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function Pr(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific custom type.
655
+ `),console.error(`Usage: prismic custom-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await V(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=R(zr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(l.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}l.label=a;try{await s(c,J(l))}catch(e){e instanceof Error?console.error(`Failed to update custom type: ${e.message}`):console.error(`Failed to update custom type`),process.exitCode=1;return}console.info(`Renamed custom type "${i}" to "${a}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Vr=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Hr(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific custom type.
634
656
 
635
657
  USAGE
636
658
  prismic custom-type view <type-id> [flags]
@@ -645,7 +667,7 @@ FLAGS
645
667
  EXAMPLES
646
668
  prismic custom-type view settings
647
669
  prismic custom-type view settings --json`);return}if(!i){console.error(`Missing required argument: type-id
648
- `),console.error(`Usage: prismic custom-type view <type-id>`),process.exitCode=1;return}let a=await W(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=B(Nr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(s.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function Fr(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await xr();break;case`list`:await Er();break;case`view`:await Pr();break;case`remove`:await Or();break;case`set-name`:await Mr();break;case`add-field`:await vr();break;case`remove-field`:await Ar();break;case`connect-slice`:await br();break;case`disconnect-slice`:await wr();break;default:t&&(console.error(`Unknown custom-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage custom types in a Prismic repository.
670
+ `),console.error(`Usage: prismic custom-type view <type-id>`),process.exitCode=1;return}let a=await V(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=R(Vr,JSON.parse(e));if(!t.success){console.error(`Invalid custom type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Custom type not found: ${i}\n`),console.error(`Create it first with: prismic custom-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read custom type: ${e.message}`):console.error(`Failed to read custom type`),process.exitCode=1;return}if(s.format===`page`){console.error(`"${i}" is not a custom type (format: page)`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function Ur(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await kr();break;case`list`:await Pr();break;case`view`:await Hr();break;case`remove`:await Ir();break;case`set-name`:await Br();break;case`add-field`:await Er();break;case`remove-field`:await Rr();break;case`connect-slice`:await Or();break;case`disconnect-slice`:await Mr();break;default:t&&(console.error(`Unknown custom-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage custom types in a Prismic repository.
649
671
 
650
672
  USAGE
651
673
  prismic custom-type <command> [flags]
@@ -665,10 +687,10 @@ FLAGS
665
687
  -h, --help Show help for command
666
688
 
667
689
  LEARN MORE
668
- Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const Ir=`Fetch and display documentation from Prismic's docs site.
690
+ Use \`prismic custom-type <command> --help\` for more information about a command.`)}}const Wr=`Fetch and display documentation from Prismic's docs site.
669
691
 
670
692
  USAGE
671
- prismic docs <path> [flags]
693
+ prismic docs fetch <path> [flags]
672
694
 
673
695
  ARGUMENTS
674
696
  path Documentation path with optional anchor (e.g., "nextjs" or "nextjs#set-up-a-prismic-client")
@@ -677,13 +699,40 @@ FLAGS
677
699
  -h, --help Show help for command
678
700
 
679
701
  EXAMPLES
680
- prismic docs nextjs
681
- prismic docs nextjs#set-up-a-prismic-client
702
+ prismic docs fetch nextjs
703
+ prismic docs fetch nextjs#set-up-a-prismic-client
682
704
 
683
705
  LEARN MORE
684
- Visit https://prismic.io/docs for the full documentation.`;function Lr(e){let t=e.indexOf(`#`);return t===-1?{path:e}:{path:e.slice(0,t),anchor:e.slice(t+1)}}async function Rr(e){try{let t=await fetch(e);return t.status===404?{ok:!1,error:`Documentation not found: ${e}`}:t.ok?{ok:!0,content:await t.text()}:{ok:!1,error:`Failed to fetch documentation: ${t.status}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:String(e)}`}}}function zr(e){let t=e.split(`-`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`[\\s-]+`);return RegExp(`^(#{1,6})\\s+${t}\\s*$`,`im`)}function Br(e,t){let n=e.split(`
685
- `),r=zr(t),i=-1,a=0;for(let e=0;e<n.length;e++){let t=n[e].match(r);if(t){i=e,a=t[1].length;break}}if(i===-1)return{ok:!1,error:`Anchor not found: #${t}`};let o=n.length;for(let e=i+1;e<n.length;e++){let t=n[e].match(/^(#{1,6})\s/);if(t&&t[1].length<=a){o=e;break}}return{ok:!0,content:n.slice(i,o).join(`
686
- `).trim()}}async function Vr(){let{positionals:[t],values:{help:n}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(Ir);return}if(!t){console.info(Ir);return}let{path:r,anchor:i}=Lr(t),a=await Rr(`https://prismic.io/docs/${r}.md`);if(!a.ok){console.error(a.error),process.exitCode=1;return}let o=a.content;if(i){let e=Br(o,i);if(!e.ok){console.error(e.error),process.exitCode=1;return}o=e.content}console.info(o)}const Hr=`prismic.config.json`,Ur=F({repositoryName:R(),apiEndpoint:I(gn(R(),ln())),localSliceMachineSimulatorURL:I(gn(R(),ln())),libraries:I(N(R())),adapter:I(R()),labs:I(F({legacySliceUpgrader:I(P())}))});async function Wr(e,t=u(process.cwd())){let n=await Yr(t);return n.ok?(await s(n.path,q(e)),{ok:!0,config:e}):n}async function Y(e=u(process.cwd())){let t=await Gr(e);if(t.ok)return t.config.repositoryName}async function Gr(e=u(process.cwd())){let t=await Jr(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=B(Ur,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new Kr(n.issues)}}catch{return{ok:!1,error:new Kr}}}var Kr=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function qr(e,t=u(process.cwd())){let n=await Jr(t);if(!n.ok)return n;let r=await Gr(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,q(i)),{ok:!0,config:i}}async function Jr(e=u(process.cwd())){let t=await W(Hr,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new Xr}}async function Yr(e=u(process.cwd())){let t=await W(`package.json`,{start:e});return t?{ok:!0,path:new URL(Hr,t)}:{ok:!1,error:new Zr}}var Xr=class extends Error{message=`Could not find a prismic.config.json file.`},Zr=class extends Error{message=`Could not find a package.json file.`};async function Qr(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`}}});if(t.help){console.info(`Initialize a Prismic project by creating a prismic.config.json file.
706
+ Visit https://prismic.io/docs for the full documentation.`;function Gr(e){let t=e.indexOf(`#`);return t===-1?{path:e}:{path:e.slice(0,t),anchor:e.slice(t+1)}}async function Kr(e){try{let t=await fetch(e);return t.status===404?{ok:!1,error:`Documentation not found: ${e}`}:t.ok?{ok:!0,content:await t.text()}:{ok:!1,error:`Failed to fetch documentation: ${t.status}`}}catch(e){return{ok:!1,error:`Network error: ${e instanceof Error?e.message:String(e)}`}}}function qr(e){let t=e.split(`-`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`[\\s-]+`);return RegExp(`^(#{1,6})\\s+${t}\\s*$`,`im`)}function Jr(e,t){let n=e.split(`
707
+ `),r=qr(t),i=-1,a=0;for(let e=0;e<n.length;e++){let t=n[e].match(r);if(t){i=e,a=t[1].length;break}}if(i===-1)return{ok:!1,error:`Anchor not found: #${t}`};let o=n.length;for(let e=i+1;e<n.length;e++){let t=n[e].match(/^(#{1,6})\s/);if(t&&t[1].length<=a){o=e;break}}return{ok:!0,content:n.slice(i,o).join(`
708
+ `).trim()}}async function Yr(){let{positionals:[t],values:{help:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(Wr);return}if(!t){console.info(Wr);return}let{path:r,anchor:i}=Gr(t),a=await Kr(`https://prismic.io/docs/${r}.md`);if(!a.ok){console.error(a.error),process.exitCode=1;return}let o=a.content;if(i){let e=Jr(o,i);if(!e.ok){console.error(e.error),process.exitCode=1;return}o=e.content}console.info(o)}const Xr=`https://prismic.io/docs/sitemap.xml`;function Zr(e){return e.replaceAll(`&amp;`,`&`).replaceAll(`&lt;`,`<`).replaceAll(`&gt;`,`>`).replaceAll(`&quot;`,`"`).replaceAll(`&apos;`,`'`)}function Qr(e){let t=/<loc>(.*?)<\/loc>/g,n=[],r=t.exec(e);for(;r;)n.push(Zr(r[1]).trim()),r=t.exec(e);return n.filter(Boolean)}async function $r(e){try{let t=await fetch(e);return t.ok?{ok:!0,xml:await t.text()}:{ok:!1,error:`Failed to fetch sitemap: ${t.status} (${e})`}}catch(t){return{ok:!1,error:`Network error while fetching sitemap ${e}: ${t instanceof Error?t.message:String(t)}`}}}function ei(e){try{let t=new URL(e);return t.hostname!==`prismic.io`||!t.pathname.startsWith(`/docs/`)?null:t.pathname.replace(/^\/docs\//,``).replace(/^\/+|\/+$/g,``)}catch{return null}}async function ti(){let{values:{help:t}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List documentation pages from Prismic's docs site.
709
+
710
+ USAGE
711
+ prismic docs list [flags]
712
+
713
+ FLAGS
714
+ -h, --help Show help for command
715
+
716
+ EXAMPLES
717
+ prismic docs list`);return}let n=await $r(Xr);if(!n.ok){console.error(n.error),process.exitCode=1;return}let r=Qr(n.xml);if(r.length===0){console.error(`No nested sitemaps found in ${Xr}`),process.exitCode=1;return}let i=await Promise.all(r.map(e=>$r(e))),a=i.find(e=>!e.ok);if(a&&!a.ok){console.error(a.error),process.exitCode=1;return}let o=new Set;for(let e of i)if(e.ok)for(let t of Qr(e.xml)){let e=ei(t);e&&o.add(e)}for(let e of[...o].sort((e,t)=>e.localeCompare(t)))console.info(e)}async function ni(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`fetch`:await Yr();break;case`list`:await ti();break;default:t&&(console.error(`Unknown docs subcommand: ${t}\n`),process.exitCode=1),console.info(`Fetch and list documentation from Prismic's docs site.
718
+
719
+ USAGE
720
+ prismic docs <command> [flags]
721
+
722
+ COMMANDS
723
+ fetch Fetch and display a documentation page
724
+ list List documentation pages
725
+
726
+ FLAGS
727
+ -h, --help Show help for command
728
+
729
+ EXAMPLES
730
+ prismic docs fetch nextjs
731
+ prismic docs fetch nextjs#set-up-a-prismic-client
732
+ prismic docs list
733
+
734
+ LEARN MORE
735
+ Use \`prismic docs <command> --help\` for more information about a command.`)}}const ri=`prismic.config.json`,ii=N({repositoryName:I(),apiEndpoint:P(bn(I(),pn())),localSliceMachineSimulatorURL:P(bn(I(),pn())),libraries:P(j(I())),adapter:P(I()),labs:P(N({legacySliceUpgrader:P(M())}))});async function ai(e,t=d(process.cwd())){let n=await ui(t);return n.ok?(await s(n.path,J(e)),{ok:!0,config:e}):n}async function X(e=d(process.cwd())){let t=await oi(e);if(t.ok)return t.config.repositoryName}async function oi(e=d(process.cwd())){let t=await li(e);if(!t.ok)return t;try{let e=await r(t.path,`utf8`),n=R(ii,JSON.parse(e));return n.success?{ok:!0,config:n.output}:{ok:!1,error:new si(n.issues)}}catch{return{ok:!1,error:new si}}}var si=class extends Error{issues;constructor(e=[]){super(`prismic.config.json is invalid.`),this.issues=e}};async function ci(e,t=d(process.cwd())){let n=await li(t);if(!n.ok)return n;let r=await oi(t);if(!r.ok)return r;let i={...r.config,...e};return await s(n.path,J(i)),{ok:!0,config:i}}async function li(e=d(process.cwd())){let t=await V(ri,{start:e,stop:`package.json`});return t?{ok:!0,path:t}:{ok:!1,error:new di}}async function ui(e=d(process.cwd())){let t=await V(`package.json`,{start:e});return t?{ok:!0,path:new URL(ri,t)}:{ok:!1,error:new fi}}var di=class extends Error{message=`Could not find a prismic.config.json file.`},fi=class extends Error{message=`Could not find a package.json file.`};async function pi(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`},repo:{type:`string`,short:`r`}}});if(t.help){console.info(`Initialize a Prismic project by creating a prismic.config.json file.
687
736
 
688
737
  Use this command to connect an existing Prismic repository to your project.
689
738
  To create a new repository, use \`prismic repo create\` instead.
@@ -696,7 +745,7 @@ FLAGS
696
745
  -h, --help Show help for command
697
746
 
698
747
  LEARN MORE
699
- Use \`prismic <command> --help\` for more information about a command.`);return}if(!t.repo){console.error(`Missing required flag: --repo`),process.exitCode=1;return}if((await Gr()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await Wr({repositoryName:t.repo});if(!n.ok){n.error instanceof Zr?console.error(`Could not find a package.json file. Run this command from a project directory.`):console.error(`Failed to create config file.`),process.exitCode=1;return}console.info(`Created prismic.config.json for repository "${t.repo}"`)}async function X(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await U();e&&r.set(`Cookie`,`SESSION=fake_session; prismic-auth=${e}`)}!r.has(`Content-Type`)&&t.body&&r.set(`Content-Type`,`application/json`),t.body instanceof FormData&&r.delete(`Content-Type`);let i=r.get(`Content-Type`)===`application/json`?JSON.stringify(t.body):t.body,a=await fetch(e,{...t,body:i,headers:r}),o=await a.clone().json().catch(()=>a.clone().text());if(a.ok){if(!t?.schema)return{ok:!0,value:o};try{return{ok:!0,value:hn(t.schema,o)}}catch(e){if(M(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new Q(a)};else if(a.status===403)return{ok:!1,value:o,error:new Z(a)};else return{ok:!1,value:o,error:new $r(a)}}var $r=class extends Error{name=`RequestError`;response;constructor(e){super(`fetch failed: ${e.url}`),this.response=e}async text(){return this.response.clone().text()}async json(){return this.response.clone().json()}get status(){return this.response.status}get statusText(){return this.response.statusText}},Z=class extends $r{},Q=class extends $r{};async function ei(){let{values:{help:t,name:n,repo:r=await Y()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new locale to a Prismic repository.
748
+ Use \`prismic <command> --help\` for more information about a command.`);return}if(!t.repo){console.error(`Missing required flag: --repo`),process.exitCode=1;return}if((await oi()).ok){console.error(`A prismic.config.json file already exists.`),process.exitCode=1;return}let n=await ai({repositoryName:t.repo});if(!n.ok){n.error instanceof fi?console.error(`Could not find a package.json file. Run this command from a project directory.`):console.error(`Failed to create config file.`),process.exitCode=1;return}console.info(`Created prismic.config.json for repository "${t.repo}"`)}async function Z(e,t={}){let{credentials:n=`include`}=t,r=new Headers(t.headers);if(r.set(`Accept`,`application/json`),n===`include`){let e=await Dn();e&&r.set(`Cookie`,`SESSION=fake_session; prismic-auth=${e}`)}!r.has(`Content-Type`)&&t.body&&r.set(`Content-Type`,`application/json`),t.body instanceof FormData&&r.delete(`Content-Type`);let i=r.get(`Content-Type`)===`application/json`?JSON.stringify(t.body):t.body,a=await fetch(e,{...t,body:i,headers:r}),o=await a.clone().json().catch(()=>a.clone().text());if(a.ok){if(!t?.schema)return{ok:!0,value:o};try{return{ok:!0,value:yn(t.schema,o)}}catch(e){if(A(e))return{ok:!1,value:o,error:e};throw e}}else if(a.status===401)return{ok:!1,value:o,error:new hi(a)};else if(a.status===403)return{ok:!1,value:o,error:new Q(a)};else return{ok:!1,value:o,error:new mi(a)}}var mi=class extends Error{name=`RequestError`;response;constructor(e){super(`fetch failed: ${e.url}`),this.response=e}async text(){return this.response.clone().text()}async json(){return this.response.clone().json()}get status(){return this.response.status}get statusText(){return this.response.statusText}},Q=class extends mi{},hi=class extends mi{};async function gi(){let{values:{help:t,name:n,repo:r=await X()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new locale to a Prismic repository.
700
749
 
701
750
  By default, this command reads the repository from prismic.config.json at the
702
751
  project root.
@@ -713,7 +762,7 @@ FLAGS
713
762
  -h, --help Show help for command
714
763
 
715
764
  LEARN MORE
716
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){ri();return}let a=n?await ni(r,i,n):await ti(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof Z?ri():(console.error(`Failed to add locale: ${q(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function ti(e,t){return await X(new URL(`/app/settings/multilanguages`,await V(e)),{method:`POST`,body:{languages:[t]}})}async function ni(e,t,n){let[r,i]=t.split(`-`);return await X(new URL(`/app/settings/multilanguages/custom`,await V(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function ri(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ii(){let{values:{help:t,repo:n=await Y(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all locales in a Prismic repository.
765
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){yi();return}let a=n?await vi(r,i,n):await _i(r,i);if(!a.ok){if(typeof a.value==`string`&&a.value.includes(`already existing languages`))return;a.error instanceof Q?yi():(console.error(`Failed to add locale: ${J(a.value)}`),process.exitCode=1);return}console.info(`Locale added: ${i}`)}async function _i(e,t){return await Z(new URL(`/app/settings/multilanguages`,await z(e)),{method:`POST`,body:{languages:[t]}})}async function vi(e,t,n){let[r,i]=t.split(`-`);return await Z(new URL(`/app/settings/multilanguages/custom`,await z(e)),{method:`POST`,body:{lang:{label:n,id:r||t},region:{label:n,id:i||r||t}}})}function yi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function bi(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all locales in a Prismic repository.
717
766
 
718
767
  By default, this command reads the repository from prismic.config.json at the
719
768
  project root.
@@ -727,7 +776,7 @@ FLAGS
727
776
  -h, --help Show help for command
728
777
 
729
778
  LEARN MORE
730
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){si();return}let i=await oi(n);if(!i.ok){i.error instanceof Z?si():M(i.error)?(console.error(`Failed to list locales: Invalid response: ${q(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(q(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const ai=F({results:N(F({id:R(),label:R(),customName:pn(R()),isMaster:P()}))});async function oi(e){let t=new URL(`/locale/repository/locales`,await _n());return t.searchParams.set(`repository`,e),await X(t,{schema:ai})}function si(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ci(){let{values:{repo:t=await Y(),help:n},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(`Remove a locale from a Prismic repository.
779
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Ci();return}let i=await Si(n);if(!i.ok){i.error instanceof Q?Ci():A(i.error)?(console.error(`Failed to list locales: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list locales: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(J(a));else for(let e of a){let t=e.isMaster?` (default)`:``;console.info(`${e.id} ${e.label}${t}`)}}const xi=N({results:j(N({id:I(),label:I(),customName:_n(I()),isMaster:M()}))});async function Si(e){let t=new URL(`/locale/repository/locales`,await xn());return t.searchParams.set(`repository`,e),await Z(t,{schema:xi})}function Ci(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function wi(){let{values:{repo:t=await X(),help:n},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(n){console.info(`Remove a locale from a Prismic repository.
731
780
 
732
781
  By default, this command reads the repository from prismic.config.json at the
733
782
  project root.
@@ -743,7 +792,7 @@ FLAGS
743
792
  -h, --help Show help for command
744
793
 
745
794
  LEARN MORE
746
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!t){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){ui();return}let i=await li(t,r);if(!i.ok){i.error instanceof Z?ui():(console.error(`Failed to remove locale: ${q(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function li(e,t){let n=new URL(`/locale/repository/locales/${t}`,await _n());return n.searchParams.set(`repository`,e),await X(n,{method:`DELETE`})}function ui(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function di(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the default locale for a Prismic repository.
795
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!t){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Ei();return}let i=await Ti(t,r);if(!i.ok){i.error instanceof Q?Ei():(console.error(`Failed to remove locale: ${J(i.value)}`),process.exitCode=1);return}console.info(`Removed locale: ${r}`)}async function Ti(e,t){let n=new URL(`/locale/repository/locales/${t}`,await xn());return n.searchParams.set(`repository`,e),await Z(n,{method:`DELETE`})}function Ei(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Di(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the default locale for a Prismic repository.
747
796
 
748
797
  By default, this command reads the repository from prismic.config.json at the
749
798
  project root.
@@ -759,7 +808,7 @@ FLAGS
759
808
  -h, --help Show help for command
760
809
 
761
810
  LEARN MORE
762
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){pi();return}let i=await oi(n);if(!i.ok){i.error instanceof Z?pi():M(i.error)?(console.error(`Failed to set default locale: Invalid response: ${q(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.results,o=a.find(e=>e.id===r);if(!o){console.error(`Locale "${r}" not found in repository. Available locales: ${a.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.isMaster){console.error(`Locale "${r}" is already the default.`),process.exitCode=1;return}let s=await fi(n,o);if(!s.ok){s.error instanceof Z?pi():(console.error(`Failed to set default locale: ${q(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function fi(e,t){let n=new URL(`/locale/repository/locales`,await _n());return n.searchParams.set(`repository`,e),await X(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function pi(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function mi(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await ei();break;case`list`:await ii();break;case`remove`:await ci();break;case`set-default`:await di();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
811
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <code>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ki();return}let i=await Si(n);if(!i.ok){i.error instanceof Q?ki():A(i.error)?(console.error(`Failed to set default locale: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set default locale: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results,o=a.find(e=>e.id===r);if(!o){console.error(`Locale "${r}" not found in repository. Available locales: ${a.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.isMaster){console.error(`Locale "${r}" is already the default.`),process.exitCode=1;return}let s=await Oi(n,o);if(!s.ok){s.error instanceof Q?ki():(console.error(`Failed to set default locale: ${J(s.value)}`),process.exitCode=1);return}console.info(`Default locale set: ${r}`)}async function Oi(e,t){let n=new URL(`/locale/repository/locales`,await xn());return n.searchParams.set(`repository`,e),await Z(n,{method:`POST`,body:{id:t.id,label:t.label,customName:t.customName,isMaster:!0}})}function ki(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ai(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await gi();break;case`list`:await bi();break;case`remove`:await wi();break;case`set-default`:await Di();break;default:t&&(console.error(`Unknown locale subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage locales in a Prismic repository.
763
812
 
764
813
  USAGE
765
814
  prismic locale <command> [flags]
@@ -774,7 +823,7 @@ FLAGS
774
823
  -h, --help Show help for command
775
824
 
776
825
  LEARN MORE
777
- Use \`prismic locale <command> --help\` for more information about a command.`)}}const hi=`https://prismic.io`;async function gi(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log in to Prismic via browser.
826
+ Use \`prismic locale <command> --help\` for more information about a command.`)}}const ji=`https://prismic.io`;async function Mi(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log in to Prismic via browser.
778
827
 
779
828
  USAGE
780
829
  prismic login [flags]
@@ -783,7 +832,7 @@ FLAGS
783
832
  -h, --help Show help for command
784
833
 
785
834
  LEARN MORE
786
- Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=f((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":hi,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(t.method===`POST`){let a=``;t.on(`data`,e=>{a+=e.toString()}),t.on(`end`,async()=>{try{let{cookies:t,email:o}=JSON.parse(a),s=t.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!s){i.writeHead(400,{"Access-Control-Allow-Origin":hi,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await Sn(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":hi,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":hi,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}))}});return}i.writeHead(404),i.end()}),r=setTimeout(()=>{n.close(),t(Error(`Login timed out. Please try again.`))},18e4),i=()=>{let e=n.address();if(!e||typeof e==`string`){clearTimeout(r),n.close(),t(Error(`Failed to start login server`));return}let i=e.port,a=_i(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),vi(a)};n.on(`error`,e=>{e.code===`EADDRINUSE`&&n.listening===!1?n.listen(0,`0.0.0.0`,i):(clearTimeout(r),t(e))}),n.listen(5555,`0.0.0.0`,i)})}function _i(e){let t=new URL(`https://prismic.io/dashboard/cli/login`);return t.searchParams.set(`source`,`slice-machine`),t.searchParams.set(`port`,e.toString()),t}function vi(e){d(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function yi(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log out of Prismic.
835
+ Use \`prismic <command> --help\` for more information about a command.`);return}return new Promise((e,t)=>{let n=p((t,i)=>{if(t.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":ji,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(t.method===`POST`){let a=``;t.on(`data`,e=>{a+=e.toString()}),t.on(`end`,async()=>{try{let{cookies:t,email:o}=JSON.parse(a),s=t.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!s){i.writeHead(400,{"Access-Control-Allow-Origin":ji,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await En(s),console.info(`Logged in to Prismic as ${o}`),i.writeHead(200,{"Access-Control-Allow-Origin":ji,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(r),n.close(),e()}catch{i.writeHead(400,{"Access-Control-Allow-Origin":ji,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}))}});return}i.writeHead(404),i.end()}),r=setTimeout(()=>{n.close(),t(Error(`Login timed out. Please try again.`))},18e4),i=()=>{let e=n.address();if(!e||typeof e==`string`){clearTimeout(r),n.close(),t(Error(`Failed to start login server`));return}let i=e.port,a=Ni(i);console.info(`Opening browser to complete login...`),console.info(`If the browser doesn't open, visit: ${a}`),Pi(a)};n.on(`error`,e=>{e.code===`EADDRINUSE`&&n.listening===!1?n.listen(0,`0.0.0.0`,i):(clearTimeout(r),t(e))}),n.listen(5555,`0.0.0.0`,i)})}function Ni(e){let t=new URL(`https://prismic.io/dashboard/cli/login`);return t.searchParams.set(`source`,`slice-machine`),t.searchParams.set(`port`,e.toString()),t}function Pi(e){f(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e.toString()}"`)}async function Fi(){let{values:t}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t.help){console.info(`Log out of Prismic.
787
836
 
788
837
  USAGE
789
838
  prismic logout [flags]
@@ -792,7 +841,7 @@ FLAGS
792
841
  -h, --help Show help for command
793
842
 
794
843
  LEARN MORE
795
- Use \`prismic <command> --help\` for more information about a command.`);return}await Tn()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const bi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function xi(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
844
+ Use \`prismic <command> --help\` for more information about a command.`);return}await An()?console.info(`Logged out of Prismic`):(console.error(`Logout failed. You can log out manually by deleting the file.`),process.exitCode=1)}const Ii=N({dependencies:P(F(I(),I())),devDependencies:P(F(I(),I()))});async function $(){let e=await V(`package.json`);if(!e)return;let t=new URL(`.`,e),n;try{let t=await r(e,`utf8`),{dependencies:i={},devDependencies:a={}}=yn(Ii,JSON.parse(t)),o={...i,...a};`next`in o?n=`next`:`nuxt`in o?n=`nuxt`:`@sveltejs/kit`in o&&(n=`sveltekit`)}catch{}let i=!1;return n===`next`||n===`sveltekit`?i=await jn(new URL(`src/`,t)):n===`nuxt`&&(i=await jn(new URL(`app/`,t))),{framework:n,hasSrcDir:i,projectRoot:t}}function Li(e){switch(e){case`next`:return[`@prismicio/client`,`@prismicio/react`,`@prismicio/next`];case`nuxt`:return[`@nuxtjs/prismic`];case`sveltekit`:return[`@prismicio/client`,`@prismicio/svelte`];default:return[`@prismicio/client`]}}function Ri(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/prismicio.ts`:`prismicio.ts`;case`nuxt`:return null;case`sveltekit`:return`src/lib/prismicio.ts`;default:return`prismicio.ts`}}function zi(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/slices/`:`slices/`;case`nuxt`:return e.hasSrcDir?`app/slices/`:`slices/`;case`sveltekit`:return`src/lib/slices/`;default:return`slices/`}}function Bi(e){switch(e){case`next`:return[`.tsx`,`.ts`,`.jsx`,`.js`];case`nuxt`:return[`.vue`];case`sveltekit`:return[`.svelte`];default:return[`.tsx`,`.ts`,`.jsx`,`.js`]}}function Vi(e,t){switch(e.framework){case`next`:{let n=e.hasSrcDir?`src/app`:`app`;return t===`/slice-simulator`?{path:`${n}/slice-simulator/page`,extensions:[`.tsx`,`.ts`,`.jsx`,`.js`]}:t===`/api/preview`?{path:`${n}/api/preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/exit-preview`?{path:`${n}/api/exit-preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/revalidate`?{path:`${n}/api/revalidate/route`,extensions:[`.ts`,`.js`]}:null}case`nuxt`:return t===`/slice-simulator`?{path:`pages/slice-simulator`,extensions:[`.vue`]}:null;case`sveltekit`:return t===`/slice-simulator`?{path:`src/routes/slice-simulator/+page`,extensions:[`.svelte`]}:t===`/api/preview`?{path:`src/routes/api/preview/+server`,extensions:[`.ts`,`.js`]}:null;default:return null}}const Hi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Ui(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Wi(){let{values:{help:t,tab:n,label:i,default:a,"true-label":o,"false-label":c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing page type.
796
845
 
797
846
  USAGE
798
847
  prismic page-type add-field boolean <type-id> <field-id> [flags]
@@ -815,7 +864,7 @@ EXAMPLES
815
864
  prismic page-type add-field boolean article published --default
816
865
  prismic page-type add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!u){console.error(`Missing required argument: type-id
817
866
  `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
818
- `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=await W(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=B(bi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`Boolean`,config:{label:i??J(d),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};m.json[g][d]=_;try{await s(p,q(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (Boolean) to "${g}" tab in ${u}`);try{await K({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Si=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Ci(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
867
+ `),console.error(`Usage: prismic page-type add-field boolean <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(Hi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Boolean`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{default_value:!0},...o&&{placeholder_true:o},...c&&{placeholder_false:c}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await s(h,J(g))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Boolean) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Boolean) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let b=await $();if(b?.framework){let e=Ui(b.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const Gi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Ki(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function qi(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing page type.
819
868
 
820
869
  USAGE
821
870
  prismic page-type add-field color <type-id> <field-id> [flags]
@@ -836,7 +885,7 @@ EXAMPLES
836
885
  prismic page-type add-field color homepage accent --tab "Design"
837
886
  prismic page-type add-field color homepage text_color --label "Text Color"`);return}if(!c){console.error(`Missing required argument: type-id
838
887
  `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
839
- `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(Si,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Color`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Color) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const wi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Ti(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
888
+ `),console.error(`Usage: prismic page-type add-field color <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(Gi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Color`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Color) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Color) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=Ki(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const Ji=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Yi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Xi(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date field to an existing page type.
840
889
 
841
890
  USAGE
842
891
  prismic page-type add-field date <type-id> <field-id> [flags]
@@ -858,7 +907,7 @@ EXAMPLES
858
907
  prismic page-type add-field date event start_date --tab "Schedule"
859
908
  prismic page-type add-field date article date --label "Publication Date" --default "2024-01-01"`);return}if(!l){console.error(`Missing required argument: type-id
860
909
  `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
861
- `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=await W(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=B(wi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Date`,config:{label:i??J(u),...a&&{placeholder:a},...o&&{default:o}}};p.json[h][u]=g;try{await s(f,q(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Date) to "${h}" tab in ${l}`);try{await K({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Ei=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Di(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
910
+ `),console.error(`Usage: prismic page-type add-field date <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(Ji,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Date`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await s(m,J(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Date) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Date) to "${_}" tab in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let y=await $();if(y?.framework){let e=Yi(y.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const Zi=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Qi(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function $i(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed field to an existing page type.
862
911
 
863
912
  USAGE
864
913
  prismic page-type add-field embed <type-id> <field-id> [flags]
@@ -879,7 +928,7 @@ EXAMPLES
879
928
  prismic page-type add-field embed homepage youtube --tab "Media"
880
929
  prismic page-type add-field embed homepage media --label "Media Embed"`);return}if(!c){console.error(`Missing required argument: type-id
881
930
  `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
882
- `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(Ei,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Embed`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Embed) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Oi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function ki(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
931
+ `),console.error(`Usage: prismic page-type add-field embed <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(Zi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Embed`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Embed) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Embed) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=Qi(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const ea=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ta(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function na(){let{values:{help:t,tab:n,label:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geo-point (location) field to an existing page type.
883
932
 
884
933
  USAGE
885
934
  prismic page-type add-field geo-point <type-id> <field-id> [flags]
@@ -899,7 +948,28 @@ EXAMPLES
899
948
  prismic page-type add-field geo-point store address --tab "Details"
900
949
  prismic page-type add-field geo-point event venue --label "Event Venue"`);return}if(!o){console.error(`Missing required argument: type-id
901
950
  `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
902
- `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=await W(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${o}/index.json`,l),d;try{let e=await r(u,`utf8`),t=B(Oi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=Object.keys(d.json),p=n??f[0]??`Main`;d.json[p]||(d.json[p]={});for(let[e,t]of Object.entries(d.json))if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}let m={type:`GeoPoint`,config:{label:i??J(c)}};d.json[p][c]=m;try{await s(u,q(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${c}" (GeoPoint) to "${p}" tab in ${o}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Ai=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function ji(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
951
+ `),console.error(`Usage: prismic page-type add-field geo-point <type-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await V(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${o}/index.json`,d),p;try{let e=await r(f,`utf8`),t=R(ea,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${o}\n`),console.error(`Create it first with: prismic page-type create ${o}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});let g={type:`GeoPoint`,config:{label:i??Y(l.type===`nested`?l.nestedFieldId:c)}};if(l.type===`nested`){let e=K(p.json[h],l.groupId,h);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=g}else{for(let[e,t]of Object.entries(p.json)){if(t[c]){console.error(`Field "${c}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[c]){console.error(`Field "${c}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}p.json[h][c]=g}try{await s(f,J(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (GeoPoint) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (GeoPoint) to "${h}" tab in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let _=await $();if(_?.framework){let e=ta(_.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const ra=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ia(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function aa(){let{values:{help:t,tab:n,label:i,"non-repeatable":a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing page type.
952
+
953
+ USAGE
954
+ prismic page-type add-field group <type-id> <field-id> [flags]
955
+
956
+ ARGUMENTS
957
+ type-id Page type identifier (required)
958
+ field-id Field identifier (required)
959
+
960
+ FLAGS
961
+ -t, --tab string Target tab (default: first existing tab, or "Main")
962
+ -l, --label string Display label for the field (inferred from field-id if omitted)
963
+ --non-repeatable Make this a non-repeating group (default: repeatable)
964
+ --types string Output file for generated types (default: "prismicio-types.d.ts")
965
+ -h, --help Show help for command
966
+
967
+ EXAMPLES
968
+ prismic page-type add-field group homepage buttons
969
+ prismic page-type add-field group article authors --non-repeatable
970
+ prismic page-type add-field group product variants --tab "Content"`);return}if(!c){console.error(`Missing required argument: type-id
971
+ `),console.error(`Usage: prismic page-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
972
+ `),console.error(`Usage: prismic page-type add-field group <type-id> <field-id>`),process.exitCode=1;return}if(l.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let u=await V(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=R(ra,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Group`,config:{label:i??Y(l),repeat:!a,fields:{}}};f.json[m][l]=h;try{await s(d,J(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Group) to "${m}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic page-type add-field <type> ${c} ${l}.<field-id>\``);let g=await $();if(g?.framework){let e=ia(g.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const oa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function sa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ca(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing page type.
903
973
 
904
974
  USAGE
905
975
  prismic page-type add-field image <type-id> <field-id> [flags]
@@ -920,7 +990,7 @@ EXAMPLES
920
990
  prismic page-type add-field image article thumbnail --tab "Media"
921
991
  prismic page-type add-field image product photo --label "Product Photo"`);return}if(!c){console.error(`Missing required argument: type-id
922
992
  `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
923
- `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(Ai,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Image`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Image) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Mi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Ni(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing page type.
993
+ `),console.error(`Usage: prismic page-type add-field image <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(oa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Image`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Image) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Image) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=sa(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const la=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ua(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function da(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing page type.
924
994
 
925
995
  USAGE
926
996
  prismic page-type add-field key-text <type-id> <field-id> [flags]
@@ -941,7 +1011,7 @@ EXAMPLES
941
1011
  prismic page-type add-field key-text homepage meta_title --tab "SEO"
942
1012
  prismic page-type add-field key-text homepage subtitle --label "Subtitle" --placeholder "Enter subtitle"`);return}if(!c){console.error(`Missing required argument: type-id
943
1013
  `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
944
- `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(Mi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`Text`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (Text) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Pi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Fi(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
1014
+ `),console.error(`Usage: prismic page-type add-field key-text <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(la,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});let _={type:`Text`,config:{label:i??Y(u.type===`nested`?u.nestedFieldId:l),...a&&{placeholder:a}}};if(u.type===`nested`){let e=K(m.json[g],u.groupId,g);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[u.nestedFieldId]){console.error(`Field "${u.nestedFieldId}" already exists in group "${u.groupId}"`),process.exitCode=1;return}e.group.config.fields[u.nestedFieldId]=_}else{for(let[e,t]of Object.entries(m.json)){if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[l]){console.error(`Field "${l}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}m.json[g][l]=_}try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}u.type===`nested`?console.info(`Added field "${u.nestedFieldId}" (Text) to group "${u.groupId}" in ${c}`):console.info(`Added field "${l}" (Text) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=ua(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const fa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function pa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ma(){let{values:{help:t,tab:n,label:i,placeholder:a,variation:o,"allow-text":c,"allow-target-blank":l,repeatable:u,types:d},positionals:[f,p]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},variation:{type:`string`,multiple:!0},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing page type.
945
1015
 
946
1016
  USAGE
947
1017
  prismic page-type add-field link <type-id> <field-id> [flags]
@@ -967,7 +1037,7 @@ EXAMPLES
967
1037
  prismic page-type add-field link homepage cta --variation Primary --variation Secondary
968
1038
  prismic page-type add-field link homepage links --repeatable`);return}if(!f){console.error(`Missing required argument: type-id
969
1039
  `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}if(!p){console.error(`Missing required argument: field-id
970
- `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=await W(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${f}/index.json`,m),g;try{let e=await r(h,`utf8`),t=B(Pi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${f}\n`),console.error(`Create it first with: prismic page-type create ${f}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});for(let[e,t]of Object.entries(g.json))if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}let y={type:`Link`,config:{label:i??J(p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};g.json[v][p]=y;try{await s(h,q(g))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${p}" (Link) to "${v}" tab in ${f}`);try{await K({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Ii=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Li(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
1040
+ `),console.error(`Usage: prismic page-type add-field link <type-id> <field-id>`),process.exitCode=1;return}let m=W(p),h=q(m);if(!h.ok){console.error(h.error),process.exitCode=1;return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${f}/index.json`,g),v;try{let e=await r(_,`utf8`),t=R(fa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${_.href}`),process.exitCode=1;return}v=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${f}\n`),console.error(`Create it first with: prismic page-type create ${f}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});let x={type:`Link`,config:{label:i??Y(m.type===`nested`?m.nestedFieldId:p),...a&&{placeholder:a},...o&&o.length>0&&{variants:o},...c&&{allowText:!0},...l&&{allowTargetBlank:!0},...u&&{repeat:!0}}};if(m.type===`nested`){let e=K(v.json[b],m.groupId,b);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[m.nestedFieldId]){console.error(`Field "${m.nestedFieldId}" already exists in group "${m.groupId}"`),process.exitCode=1;return}e.group.config.fields[m.nestedFieldId]=x}else{for(let[e,t]of Object.entries(v.json)){if(t[p]){console.error(`Field "${p}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[p]){console.error(`Field "${p}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}v.json[b][p]=x}try{await s(_,J(v))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}m.type===`nested`?console.info(`Added field "${m.nestedFieldId}" (Link) to group "${m.groupId}" in ${f}`):console.info(`Added field "${p}" (Link) to "${b}" tab in ${f}`);try{await U({output:d}),console.info(`Updated types in ${d??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let S=await $();if(S?.framework){let e=pa(S.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const ha=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ga(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function _a(){let{values:{help:t,tab:n,label:i,placeholder:a,min:o,max:c,step:l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},min:{type:`string`},max:{type:`string`},step:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing page type.
971
1041
 
972
1042
  USAGE
973
1043
  prismic page-type add-field number <type-id> <field-id> [flags]
@@ -991,7 +1061,7 @@ EXAMPLES
991
1061
  prismic page-type add-field number product quantity --min 0 --max 100
992
1062
  prismic page-type add-field number settings rating --min 1 --max 5 --step 1`);return}if(!d){console.error(`Missing required argument: type-id
993
1063
  `),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
994
- `),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=o===void 0?void 0:Number(o),m=c===void 0?void 0:Number(c),h=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(p)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(m)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(h)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let g=await W(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`customtypes/${d}/index.json`,g),v;try{let e=await r(_,`utf8`),t=B(Ii,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${_.href}`),process.exitCode=1;return}v=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let y=Object.keys(v.json),b=n??y[0]??`Main`;v.json[b]||(v.json[b]={});for(let[e,t]of Object.entries(v.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let x={type:`Number`,config:{label:i??J(f),...a&&{placeholder:a},...p!==void 0&&{min:p},...m!==void 0&&{max:m},...h!==void 0&&{step:h}}};v.json[b][f]=x;try{await s(_,q(v))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${f}" (Number) to "${b}" tab in ${d}`);try{await K({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Ri=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function zi(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
1064
+ `),console.error(`Usage: prismic page-type add-field number <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=o===void 0?void 0:Number(o),g=c===void 0?void 0:Number(c),_=l===void 0?void 0:Number(l);if(o!==void 0&&Number.isNaN(h)){console.error(`Invalid --min value: must be a number`),process.exitCode=1;return}if(c!==void 0&&Number.isNaN(g)){console.error(`Invalid --max value: must be a number`),process.exitCode=1;return}if(l!==void 0&&Number.isNaN(_)){console.error(`Invalid --step value: must be a number`),process.exitCode=1;return}let v=await V(`package.json`);if(!v){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let y=new URL(`customtypes/${d}/index.json`,v),b;try{let e=await r(y,`utf8`),t=R(ha,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${y.href}`),process.exitCode=1;return}b=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let x=Object.keys(b.json),S=n??x[0]??`Main`;b.json[S]||(b.json[S]={});let ee={type:`Number`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...h!==void 0&&{min:h},...g!==void 0&&{max:g},..._!==void 0&&{step:_}}};if(p.type===`nested`){let e=K(b.json[S],p.groupId,S);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=ee}else{for(let[e,t]of Object.entries(b.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}b.json[S][f]=ee}try{await s(y,J(b))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (Number) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (Number) to "${S}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let te=await $();if(te?.framework){let e=ga(te.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const va=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function ya(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ba(){let{values:{help:t,tab:n,label:i,placeholder:a,single:o,multi:c,"allow-target-blank":l,types:u},positionals:[d,f]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing page type.
995
1065
 
996
1066
  USAGE
997
1067
  prismic page-type add-field rich-text <type-id> <field-id> [flags]
@@ -1021,7 +1091,7 @@ EXAMPLES
1021
1091
  prismic page-type add-field rich-text page tagline --single "heading1"
1022
1092
  prismic page-type add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!d){console.error(`Missing required argument: type-id
1023
1093
  `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}if(!f){console.error(`Missing required argument: field-id
1024
- `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=await W(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${d}/index.json`,p),h;try{let e=await r(m,`utf8`),t=B(Ri,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});for(let[e,t]of Object.entries(h.json))if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}let v={type:`StructuredText`,config:{label:i??J(f),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};h.json[_][f]=v;try{await s(m,q(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${f}" (StructuredText) to "${_}" tab in ${d}`);try{await K({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Bi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Vi(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
1094
+ `),console.error(`Usage: prismic page-type add-field rich-text <type-id> <field-id>`),process.exitCode=1;return}let p=W(f),m=q(p);if(!m.ok){console.error(m.error),process.exitCode=1;return}let h=await V(`package.json`);if(!h){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let g=new URL(`customtypes/${d}/index.json`,h),_;try{let e=await r(g,`utf8`),t=R(va,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${g.href}`),process.exitCode=1;return}_=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${d}\n`),console.error(`Create it first with: prismic page-type create ${d}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let v=Object.keys(_.json),y=n??v[0]??`Main`;_.json[y]||(_.json[y]={});let b={type:`StructuredText`,config:{label:i??Y(p.type===`nested`?p.nestedFieldId:f),...a&&{placeholder:a},...o&&{single:o},...c&&{multi:c},...l&&{allowTargetBlank:!0}}};if(p.type===`nested`){let e=K(_.json[y],p.groupId,y);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[p.nestedFieldId]){console.error(`Field "${p.nestedFieldId}" already exists in group "${p.groupId}"`),process.exitCode=1;return}e.group.config.fields[p.nestedFieldId]=b}else{for(let[e,t]of Object.entries(_.json)){if(t[f]){console.error(`Field "${f}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[f]){console.error(`Field "${f}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}_.json[y][f]=b}try{await s(g,J(_))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}p.type===`nested`?console.info(`Added field "${p.nestedFieldId}" (StructuredText) to group "${p.groupId}" in ${d}`):console.info(`Added field "${f}" (StructuredText) to "${y}" tab in ${d}`);try{await U({output:u}),console.info(`Updated types in ${u??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let x=await $();if(x?.framework){let e=ya(x.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const xa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Sa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Ca(){let{values:{help:t,tab:n,label:i,placeholder:a,option:o,default:c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing page type.
1025
1095
 
1026
1096
  USAGE
1027
1097
  prismic page-type add-field select <type-id> <field-id> [flags]
@@ -1044,7 +1114,7 @@ EXAMPLES
1044
1114
  prismic page-type add-field select product size --option "small" --option "medium" --option "large" --default "medium"
1045
1115
  prismic page-type add-field select article status --option "draft" --option "published" --label "Status"`);return}if(!u){console.error(`Missing required argument: type-id
1046
1116
  `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
1047
- `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=await W(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${u}/index.json`,f),m;try{let e=await r(p,`utf8`),t=B(Bi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`Select`,config:{label:i??J(d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};m.json[g][d]=_;try{await s(p,q(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${d}" (Select) to "${g}" tab in ${u}`);try{await K({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Hi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Ui(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing page type.
1117
+ `),console.error(`Usage: prismic page-type add-field select <type-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await V(`package.json`);if(!m){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let h=new URL(`customtypes/${u}/index.json`,m),g;try{let e=await r(h,`utf8`),t=R(xa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${h.href}`),process.exitCode=1;return}g=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${u}\n`),console.error(`Create it first with: prismic page-type create ${u}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let _=Object.keys(g.json),v=n??_[0]??`Main`;g.json[v]||(g.json[v]={});let y={type:`Select`,config:{label:i??Y(f.type===`nested`?f.nestedFieldId:d),...a&&{placeholder:a},...o&&o.length>0&&{options:o},...c&&{default_value:c}}};if(f.type===`nested`){let e=K(g.json[v],f.groupId,v);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=y}else{for(let[e,t]of Object.entries(g.json)){if(t[d]){console.error(`Field "${d}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[d]){console.error(`Field "${d}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}g.json[v][d]=y}try{await s(h,J(g))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Select) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Select) to "${v}" tab in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let b=await $();if(b?.framework){let e=Sa(b.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const wa=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Ta(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function Ea(){let{values:{help:t,tab:n,label:i,placeholder:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing page type.
1048
1118
 
1049
1119
  USAGE
1050
1120
  prismic page-type add-field timestamp <type-id> <field-id> [flags]
@@ -1066,7 +1136,7 @@ EXAMPLES
1066
1136
  prismic page-type add-field timestamp event start --tab "Schedule"
1067
1137
  prismic page-type add-field timestamp article published_at --label "Published At"`);return}if(!l){console.error(`Missing required argument: type-id
1068
1138
  `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
1069
- `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=await W(`package.json`);if(!d){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let f=new URL(`customtypes/${l}/index.json`,d),p;try{let e=await r(f,`utf8`),t=B(Hi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${f.href}`),process.exitCode=1;return}p=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let m=Object.keys(p.json),h=n??m[0]??`Main`;p.json[h]||(p.json[h]={});for(let[e,t]of Object.entries(p.json))if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}let g={type:`Timestamp`,config:{label:i??J(u),...a&&{placeholder:a},...o&&{default:o}}};p.json[h][u]=g;try{await s(f,q(p))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${u}" (Timestamp) to "${h}" tab in ${l}`);try{await K({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}const Wi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Gi(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
1139
+ `),console.error(`Usage: prismic page-type add-field timestamp <type-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await V(`package.json`);if(!p){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let m=new URL(`customtypes/${l}/index.json`,p),h;try{let e=await r(m,`utf8`),t=R(wa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${m.href}`),process.exitCode=1;return}h=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${l}\n`),console.error(`Create it first with: prismic page-type create ${l}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let g=Object.keys(h.json),_=n??g[0]??`Main`;h.json[_]||(h.json[_]={});let v={type:`Timestamp`,config:{label:i??Y(d.type===`nested`?d.nestedFieldId:u),...a&&{placeholder:a},...o&&{default:o}}};if(d.type===`nested`){let e=K(h.json[_],d.groupId,_);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=v}else{for(let[e,t]of Object.entries(h.json)){if(t[u]){console.error(`Field "${u}" already exists in tab "${e}"`),process.exitCode=1;return}for(let[n,r]of Object.entries(t))if(G(r)&&r.config.fields[u]){console.error(`Field "${u}" already exists in group "${n}" in tab "${e}"`),process.exitCode=1;return}}h.json[_][u]=v}try{await s(m,J(h))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Timestamp) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Timestamp) to "${_}" tab in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let y=await $();if(y?.framework){let e=Ta(y.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}const Da=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});function Oa(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}async function ka(){let{values:{help:t,tab:n,label:i,placeholder:a,types:o},positionals:[c,l]}=e({args:process.argv.slice(5),options:{tab:{type:`string`,short:`t`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a UID (unique identifier) field to an existing page type.
1070
1140
 
1071
1141
  USAGE
1072
1142
  prismic page-type add-field uid <type-id> <field-id> [flags]
@@ -1087,7 +1157,7 @@ EXAMPLES
1087
1157
  prismic page-type add-field uid article slug --label "URL Slug"
1088
1158
  prismic page-type add-field uid product sku --placeholder "Enter unique SKU"`);return}if(!c){console.error(`Missing required argument: type-id
1089
1159
  `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}if(!l){console.error(`Missing required argument: field-id
1090
- `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=await W(`package.json`);if(!u){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let d=new URL(`customtypes/${c}/index.json`,u),f;try{let e=await r(d,`utf8`),t=B(Wi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${d.href}`),process.exitCode=1;return}f=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let p=Object.keys(f.json),m=n??p[0]??`Main`;f.json[m]||(f.json[m]={});for(let[e,t]of Object.entries(f.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let h={type:`UID`,config:{label:i??J(l),...a&&{placeholder:a}}};f.json[m][l]=h;try{await s(d,q(f))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (UID) to "${m}" tab in ${c}`);try{await K({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function Ki(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await xi();break;case`color`:await Ci();break;case`date`:await Ti();break;case`embed`:await Di();break;case`geo-point`:await ki();break;case`image`:await ji();break;case`key-text`:await Ni();break;case`link`:await Fi();break;case`number`:await Li();break;case`rich-text`:await zi();break;case`select`:await Vi();break;case`timestamp`:await Ui();break;case`uid`:await Gi();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
1160
+ `),console.error(`Usage: prismic page-type add-field uid <type-id> <field-id>`),process.exitCode=1;return}let u=W(l),d=q(u);if(!d.ok){console.error(d.error),process.exitCode=1;return}if(u.type===`nested`){console.error(`UID fields cannot be nested inside groups`),process.exitCode=1;return}let f=await V(`package.json`);if(!f){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let p=new URL(`customtypes/${c}/index.json`,f),m;try{let e=await r(p,`utf8`),t=R(Da,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${p.href}`),process.exitCode=1;return}m=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${c}\n`),console.error(`Create it first with: prismic page-type create ${c}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let h=Object.keys(m.json),g=n??h[0]??`Main`;m.json[g]||(m.json[g]={});for(let[e,t]of Object.entries(m.json))if(t[l]){console.error(`Field "${l}" already exists in tab "${e}"`),process.exitCode=1;return}let _={type:`UID`,config:{label:i??Y(l),...a&&{placeholder:a}}};m.json[g][l]=_;try{await s(p,J(m))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Added field "${l}" (UID) to "${g}" tab in ${c}`);try{await U({output:o}),console.info(`Updated types in ${o??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic page-type add-field`");let v=await $();if(v?.framework){let e=Oa(v.framework);console.info(` Run \`prismic docs fetch ${e}#write-page-components\` to learn how to implement a page file`)}}async function Aa(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await Wi();break;case`color`:await qi();break;case`date`:await Xi();break;case`embed`:await $i();break;case`geo-point`:await na();break;case`group`:await aa();break;case`image`:await ca();break;case`key-text`:await da();break;case`link`:await ma();break;case`number`:await _a();break;case`rich-text`:await ba();break;case`select`:await Ca();break;case`timestamp`:await Ea();break;case`uid`:await ka();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing page type.
1091
1161
 
1092
1162
  USAGE
1093
1163
  prismic page-type add-field <field-type> <type-id> <field-id> [flags]
@@ -1098,6 +1168,7 @@ FIELD TYPES
1098
1168
  date Date picker
1099
1169
  embed Embed (oEmbed)
1100
1170
  geo-point Geographic coordinates
1171
+ group Repeatable group of fields
1101
1172
  image Image
1102
1173
  key-text Single-line text
1103
1174
  link Any link type
@@ -1117,7 +1188,7 @@ EXAMPLES
1117
1188
  prismic page-type add-field key-text homepage meta_title --tab "SEO"
1118
1189
  prismic page-type add-field link homepage button --allow-text
1119
1190
  prismic page-type add-field rich-text homepage body --multi "paragraph,heading2,strong,em"
1120
- prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const qi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Ji(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
1191
+ prismic page-type add-field select homepage layout --option "full" --option "sidebar"`)}}const ja=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Ma(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Connect a shared slice to a page type's slice zone.
1121
1192
 
1122
1193
  USAGE
1123
1194
  prismic page-type connect-slice <type-id> <slice-id> [flags]
@@ -1136,7 +1207,7 @@ EXAMPLES
1136
1207
  prismic page-type connect-slice homepage CallToAction --slice-zone slices
1137
1208
  prismic page-type connect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
1138
1209
  `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
1139
- `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await G(o);if(!c.ok){console.error(c.error),process.exitCode=1;return}let l=await W(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=B(qi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in page type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;try{await s(u,q(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Yi(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
1210
+ `),console.error(`Usage: prismic page-type connect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await H(o);if(!c.ok){console.error(c.error),process.exitCode=1;return}let l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/${a}/index.json`,l),d;try{let e=await r(u,`utf8`),t=R(ja,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${u.href}`),process.exitCode=1;return}d=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let f=n??`slices`,p,m;for(let[,e]of Object.entries(d.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===f){p=n,m=t;break}if(p)break}if(!p){if(n){console.error(`Slice zone "${n}" not found in page type "${a}"`),process.exitCode=1;return}let e=Object.keys(d.json)[0]??`Main`;d.json[e]||(d.json[e]={});let t={type:`Slices`,fieldset:`Slice Zone`,config:{choices:{}}};d.json[e][f]=t,p=t,m=f}if(p.config||={choices:{}},p.config.choices||(p.config.choices={}),o in p.config.choices){console.info(`Slice "${o}" is already connected to slice zone "${m}" in ${a}`);return}let h={type:`SharedSlice`};p.config.choices[o]=h;try{await s(u,J(d))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Connected slice "${o}" to slice zone "${m}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function Na(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Pa(e){return`#write-page-components`}async function Fa(){let{values:{help:t,name:r,single:i,types:a},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},single:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new page type in a Prismic repository.
1140
1211
 
1141
1212
  USAGE
1142
1213
  prismic page-type create <id> [flags]
@@ -1151,7 +1222,7 @@ FLAGS
1151
1222
  -h, --help Show help for command
1152
1223
 
1153
1224
  LEARN MORE
1154
- Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let c={id:o,label:r??Xi(o),repeatable:!i,status:!0,format:`page`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}},"SEO & Metadata":{meta_title:{type:`Text`,config:{label:`Meta Title`,placeholder:`A title of the page used for social media and search engines`}},meta_description:{type:`Text`,config:{label:`Meta Description`,placeholder:`A brief summary of the page`}},meta_image:{type:`Image`,config:{label:`Meta Image`,constraint:{width:2400,height:1260},thumbnails:[]}}}}},l=await W(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await s(f,q(c))}catch(e){e instanceof Error?console.error(`Failed to create page type: ${e.message}`):console.error(`Failed to create page type`),process.exitCode=1;return}console.info(`Created page type at ${f.href}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic page-type add-field`")}function Xi(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const Zi=F({id:R(),label:R(),repeatable:P(),status:P(),format:R(),json:L(R(),L(R(),z()))});async function Qi(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
1225
+ Use \`prismic page-type <command> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: id`),process.exitCode=1;return}let c={id:o,label:r??Ia(o),repeatable:!i,status:!0,format:`page`,json:{Main:i?{}:{uid:{type:`UID`,config:{label:`UID`,placeholder:``}}},"SEO & Metadata":{meta_title:{type:`Text`,config:{label:`Meta Title`,placeholder:`A title of the page used for social media and search engines`}},meta_description:{type:`Text`,config:{label:`Meta Description`,placeholder:`A brief summary of the page`}},meta_image:{type:`Image`,config:{label:`Meta Image`,constraint:{width:2400,height:1260},thumbnails:[]}}}}},l=await V(`package.json`);if(!l){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let u=new URL(`customtypes/`,l),d=new URL(o+`/`,u),f=new URL(`index.json`,d);try{await n(new URL(`.`,f),{recursive:!0}),await s(f,J(c))}catch(e){e instanceof Error?console.error(`Failed to create page type: ${e.message}`):console.error(`Failed to create page type`),process.exitCode=1;return}console.info(`Created page type at ${f.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic page-type add-field`");let p=await $();if(p?.framework){let e=Na(p.framework),t=Pa(p.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement a page file`)}}function Ia(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}const La=N({id:I(),label:I(),repeatable:M(),status:M(),format:I(),json:F(I(),F(I(),L()))});async function Ra(){let{values:{help:t,"slice-zone":n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{"slice-zone":{type:`string`,short:`z`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disconnect a shared slice from a page type's slice zone.
1155
1226
 
1156
1227
  USAGE
1157
1228
  prismic page-type disconnect-slice <type-id> <slice-id> [flags]
@@ -1170,7 +1241,7 @@ EXAMPLES
1170
1241
  prismic page-type disconnect-slice homepage CallToAction --slice-zone slices
1171
1242
  prismic page-type disconnect-slice article HeroSection -z body`);return}if(!a){console.error(`Missing required argument: type-id
1172
1243
  `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: slice-id
1173
- `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await W(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=B(Zi,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){console.error(`Slice zone "${d}" not found in page type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];try{await s(l,q(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const $i=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function ea(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all page types in a Prismic project.
1244
+ `),console.error(`Usage: prismic page-type disconnect-slice <type-id> <slice-id>`),process.exitCode=1;return}let c=await V(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=R(La,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}let d=n??`slices`,f,p;for(let[,e]of Object.entries(u.json)){for(let[t,n]of Object.entries(e))if(n.type===`Slices`&&t===d){f=n,p=t;break}if(f)break}if(!f){console.error(`Slice zone "${d}" not found in page type "${a}"`),process.exitCode=1;return}if(!f.config?.choices||!(o in f.config.choices)){console.error(`Slice "${o}" is not connected to slice zone "${p}" in ${a}`),process.exitCode=1;return}delete f.config.choices[o];try{await s(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Disconnected slice "${o}" from slice zone "${p}" in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const za=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ba(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all page types in a Prismic project.
1174
1245
 
1175
1246
  USAGE
1176
1247
  prismic page-type list [flags]
@@ -1181,7 +1252,7 @@ FLAGS
1181
1252
 
1182
1253
  EXAMPLES
1183
1254
  prismic page-type list
1184
- prismic page-type list --json`);return}let a=await W(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=B($i,JSON.parse(e));n.success&&n.output.format===`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const ta=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function na(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
1255
+ prismic page-type list --json`);return}let a=await V(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/`,a),s;try{s=await i(o,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}let c=[];for(let e of s){let t=new URL(`${e}/index.json`,o);try{let e=await r(t,`utf8`),n=R(za,JSON.parse(e));n.success&&n.output.format===`page`&&c.push({id:n.output.id,label:n.output.label,repeatable:n.output.repeatable})}catch{}}if(c.length===0){n?console.info(JSON.stringify([])):console.info(`No page types found.`);return}if(n)console.info(JSON.stringify(c,null,2));else{console.info(`ID LABEL TYPE`);for(let e of c){let t=e.repeatable?`repeatable`:`singleton`;console.info(`${e.id}\t${e.label}\t${t}`)}}}const Va=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ha(){let{values:{help:t,y:n,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a page type from the project.
1185
1256
 
1186
1257
  USAGE
1187
1258
  prismic page-type remove <type-id> [flags]
@@ -1197,7 +1268,7 @@ FLAGS
1197
1268
  EXAMPLES
1198
1269
  prismic page-type remove homepage
1199
1270
  prismic page-type remove homepage -y`);return}if(!a){console.error(`Missing required argument: type-id
1200
- `),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let s=await W(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=B(ta,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove page type: ${e.message}`):console.error(`Failed to remove page type`),process.exitCode=1;return}console.info(`Removed page type "${a}"`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const ra=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function ia(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
1271
+ `),console.error(`Usage: prismic page-type remove <type-id>`),process.exitCode=1;return}let s=await V(`package.json`);if(!s){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${a}/`,s),l=new URL(`index.json`,c),u;try{let e=await r(l,`utf8`),t=R(Va,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}if(!n){console.error(`Refusing to remove page type "${a}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove page type: ${e.message}`):console.error(`Failed to remove page type`),process.exitCode=1;return}console.info(`Removed page type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ua=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Wa(){let{values:{help:t,tab:n,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{tab:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a page type.
1201
1272
 
1202
1273
  USAGE
1203
1274
  prismic page-type remove-field <type-id> <field-id> [flags]
@@ -1215,7 +1286,7 @@ EXAMPLES
1215
1286
  prismic page-type remove-field homepage title
1216
1287
  prismic page-type remove-field homepage meta_title --tab "SEO & Metadata"`);return}if(!a){console.error(`Missing required argument: type-id
1217
1288
  `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1218
- `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let c=await W(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=B(ra,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in page type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of page type "${a}"`),process.exitCode=1;return}}try{await s(l,q(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Removed field "${o}" from tab "${d}" in page type "${a}"`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const aa=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function oa(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
1289
+ `),console.error(`Usage: prismic page-type remove-field <type-id> <field-id>`),process.exitCode=1;return}let c=await V(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${a}/index.json`,c),u;try{let e=await r(l,`utf8`),t=R(Ua,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${a}\n`),console.error(`Create it first with: prismic page-type create ${a}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${a}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}let d;if(n){if(!u.json[n]){console.error(`Tab "${n}" not found in page type "${a}"`),console.error(`Available tabs: ${Object.keys(u.json).join(`, `)}`),process.exitCode=1;return}if(!(o in u.json[n])){console.error(`Field "${o}" not found in tab "${n}"`),process.exitCode=1;return}delete u.json[n][o],d=n}else{for(let[e,t]of Object.entries(u.json))if(o in t){delete t[o],d=e;break}if(!d){console.error(`Field "${o}" not found in any tab of page type "${a}"`),process.exitCode=1;return}}try{await s(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Removed field "${o}" from tab "${d}" in page type "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ga=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ka(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Change a page type's display name (label).
1219
1290
 
1220
1291
  USAGE
1221
1292
  prismic page-type set-name <type-id> <new-name> [flags]
@@ -1232,7 +1303,7 @@ EXAMPLES
1232
1303
  prismic page-type set-name homepage "Home Page"
1233
1304
  prismic page-type set-name blog_post "Blog Post"`);return}if(!i){console.error(`Missing required argument: type-id
1234
1305
  `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: new-name
1235
- `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await W(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=B(aa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}l.label=a;try{await s(c,q(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Renamed page type "${i}" to "${a}"`);try{await K({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const sa=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function ca(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
1306
+ `),console.error(`Usage: prismic page-type set-name <type-id> <new-name>`),process.exitCode=1;return}let o=await V(`package.json`);if(!o){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let c=new URL(`customtypes/${i}/index.json`,o),l;try{let e=await r(c,`utf8`),t=R(Ga,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${c.href}`),process.exitCode=1;return}l=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(l.format!==`page`){console.error(`"${i}" is not a page type (format: ${l.format??`custom`})`),process.exitCode=1;return}l.label=a;try{await s(c,J(l))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}console.info(`Renamed page type "${i}" to "${a}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const qa=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Ja(){let{values:{help:t,types:n},positionals:[i,a]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set whether a page type is repeatable.
1236
1307
 
1237
1308
  USAGE
1238
1309
  prismic page-type set-repeatable <type-id> <true|false> [flags]
@@ -1249,7 +1320,7 @@ EXAMPLES
1249
1320
  prismic page-type set-repeatable homepage true
1250
1321
  prismic page-type set-repeatable settings false`);return}if(!i){console.error(`Missing required argument: type-id
1251
1322
  `),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: true|false
1252
- `),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(a!==`true`&&a!==`false`){console.error(`Invalid value: "${a}". Must be "true" or "false".`),process.exitCode=1;return}let o=a===`true`,c=await W(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,c),u;try{let e=await r(l,`utf8`),t=B(sa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${i}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}u.repeatable=o;try{await s(l,q(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}let d=o?`repeatable`:`singleton`;console.info(`Set page type "${i}" to ${d}`);try{await K({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const la=F({id:R(),label:R(),repeatable:P(),status:P(),format:I(R()),json:L(R(),L(R(),z()))});async function ua(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific page type.
1323
+ `),console.error(`Usage: prismic page-type set-repeatable <type-id> <true|false>`),process.exitCode=1;return}if(a!==`true`&&a!==`false`){console.error(`Invalid value: "${a}". Must be "true" or "false".`),process.exitCode=1;return}let o=a===`true`,c=await V(`package.json`);if(!c){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let l=new URL(`customtypes/${i}/index.json`,c),u;try{let e=await r(l,`utf8`),t=R(qa,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${l.href}`),process.exitCode=1;return}u=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(u.format!==`page`){console.error(`"${i}" is not a page type (format: ${u.format??`custom`})`),process.exitCode=1;return}u.repeatable=o;try{await s(l,J(u))}catch(e){e instanceof Error?console.error(`Failed to update page type: ${e.message}`):console.error(`Failed to update page type`),process.exitCode=1;return}let d=o?`repeatable`:`singleton`;console.info(`Set page type "${i}" to ${d}`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ya=N({id:I(),label:I(),repeatable:M(),status:M(),format:P(I()),json:F(I(),F(I(),L()))});async function Xa(){let{values:{help:t,json:n},positionals:[i]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific page type.
1253
1324
 
1254
1325
  USAGE
1255
1326
  prismic page-type view <type-id> [flags]
@@ -1264,7 +1335,7 @@ FLAGS
1264
1335
  EXAMPLES
1265
1336
  prismic page-type view homepage
1266
1337
  prismic page-type view homepage --json`);return}if(!i){console.error(`Missing required argument: type-id
1267
- `),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await W(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=B(la,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(s.format!==`page`){console.error(`"${i}" is not a page type (format: ${s.format??`custom`})`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function da(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Yi();break;case`list`:await ea();break;case`view`:await ua();break;case`remove`:await na();break;case`set-name`:await oa();break;case`set-repeatable`:await ca();break;case`add-field`:await Ki();break;case`remove-field`:await ia();break;case`connect-slice`:await Ji();break;case`disconnect-slice`:await Qi();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
1338
+ `),console.error(`Usage: prismic page-type view <type-id>`),process.exitCode=1;return}let a=await V(`package.json`);if(!a){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let o=new URL(`customtypes/${i}/index.json`,a),s;try{let e=await r(o,`utf8`),t=R(Ya,JSON.parse(e));if(!t.success){console.error(`Invalid page type model: ${o.href}`),process.exitCode=1;return}s=t.output}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){console.error(`Page type not found: ${i}\n`),console.error(`Create it first with: prismic page-type create ${i}`),process.exitCode=1;return}e instanceof Error?console.error(`Failed to read page type: ${e.message}`):console.error(`Failed to read page type`),process.exitCode=1;return}if(s.format!==`page`){console.error(`"${i}" is not a page type (format: ${s.format??`custom`})`),process.exitCode=1;return}if(n){console.info(JSON.stringify(s,null,2));return}console.info(`ID: ${s.id}`),console.info(`Label: ${s.label}`),console.info(`Repeatable: ${s.repeatable}`);let c=Object.entries(s.json);console.info(`\nTabs (${c.length}):`);for(let[e,t]of c){let n=Object.keys(t).length;console.info(` - ${e}: ${n} fields`)}}async function Za(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Fa();break;case`list`:await Ba();break;case`view`:await Xa();break;case`remove`:await Ha();break;case`set-name`:await Ka();break;case`set-repeatable`:await Ja();break;case`add-field`:await Aa();break;case`remove-field`:await Wa();break;case`connect-slice`:await Ma();break;case`disconnect-slice`:await Ra();break;default:t&&(console.error(`Unknown page-type subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage page types in a Prismic repository.
1268
1339
 
1269
1340
  USAGE
1270
1341
  prismic page-type <command> [flags]
@@ -1285,7 +1356,7 @@ FLAGS
1285
1356
  -h, --help Show help for command
1286
1357
 
1287
1358
  LEARN MORE
1288
- Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function fa(){let{values:{help:t,name:n,repo:r=await Y()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a preview configuration to a Prismic repository.
1359
+ Use \`prismic page-type <command> --help\` for more information about a command.`)}}async function Qa(){let{values:{help:t,name:n,repo:r=await X()},positionals:[i]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a preview configuration to a Prismic repository.
1289
1360
 
1290
1361
  By default, this command reads the repository from prismic.config.json at the
1291
1362
  project root.
@@ -1302,7 +1373,7 @@ FLAGS
1302
1373
  -h, --help Show help for command
1303
1374
 
1304
1375
  LEARN MORE
1305
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){ha();return}let a=pa(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await ma(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof Z?ha():(console.error(`Failed to add preview: ${q(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function pa(e){try{let t=new URL(e);return{websiteURL:`${t.protocol}//${t.host}`,resolverPath:t.pathname===`/`?void 0:t.pathname,hostname:t.hostname}}catch{return}}async function ma(e,t){return await X(new URL(`/previews/new`,await V(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function ha(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ga(){let{values:{help:t,repo:n=await Y(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the slice simulator URL for a Prismic repository.
1376
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){to();return}let a=$a(i);if(!a){console.error(`Invalid URL: ${i}`),process.exitCode=1;return}let o=await eo(r,{name:n||a.hostname,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!o.ok){o.error instanceof Q?to():(console.error(`Failed to add preview: ${J(o.value)}`),process.exitCode=1);return}console.info(`Preview added: ${i}`)}function $a(e){try{let t=new URL(e);return{websiteURL:`${t.protocol}//${t.host}`,resolverPath:t.pathname===`/`?void 0:t.pathname,hostname:t.hostname}}catch{return}}async function eo(e,t){return await Z(new URL(`/previews/new`,await z(e)),{method:`POST`,body:{name:t.name,websiteURL:t.websiteURL,resolverPath:t.resolverPath}})}function to(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function no(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the slice simulator URL for a Prismic repository.
1306
1377
 
1307
1378
  By default, this command reads the repository from prismic.config.json at the
1308
1379
  project root.
@@ -1316,7 +1387,7 @@ FLAGS
1316
1387
  -h, --help Show help for command
1317
1388
 
1318
1389
  LEARN MORE
1319
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){ya();return}let i=await va(n);if(!i.ok){i.error instanceof Z?ya():M(i.error)?(console.error(`Failed to get simulator URL: Invalid response: ${q(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to get simulator URL: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.simulator_url;if(!a){r?console.info(q({simulator_url:null})):console.info(`No simulator URL configured.`);return}r?console.info(q({simulator_url:a})):console.info(a)}const _a=F({simulator_url:I(R())});async function va(e){return await X(new URL(`/core/repository`,await V(e)),{schema:_a})}function ya(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ba(){let{values:{help:t,repo:n=await Y(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all preview configurations in a Prismic repository.
1390
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ao();return}let i=await io(n);if(!i.ok){i.error instanceof Q?ao():A(i.error)?(console.error(`Failed to get simulator URL: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to get simulator URL: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.simulator_url;if(!a){r?console.info(J({simulator_url:null})):console.info(`No simulator URL configured.`);return}r?console.info(J({simulator_url:a})):console.info(a)}const ro=N({simulator_url:P(I())});async function io(e){return await Z(new URL(`/core/repository`,await z(e)),{schema:ro})}function ao(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function oo(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all preview configurations in a Prismic repository.
1320
1391
 
1321
1392
  By default, this command reads the repository from prismic.config.json at the
1322
1393
  project root.
@@ -1330,7 +1401,7 @@ FLAGS
1330
1401
  -h, --help Show help for command
1331
1402
 
1332
1403
  LEARN MORE
1333
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Ca();return}let i=await Sa(n);if(!i.ok){i.error instanceof Z?Ca():M(i.error)?(console.error(`Failed to list previews: Invalid response: ${q(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(q(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const xa=F({results:N(F({id:R(),label:R(),url:R()}))});async function Sa(e){return await X(new URL(`/core/repository/preview_configs`,await V(e)),{schema:xa})}function Ca(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function wa(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a preview configuration from a Prismic repository.
1404
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){lo();return}let i=await co(n);if(!i.ok){i.error instanceof Q?lo():A(i.error)?(console.error(`Failed to list previews: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list previews: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results;if(r)console.info(J(a));else for(let e of a)console.info(`${e.url} ${e.label}`)}const so=N({results:j(N({id:I(),label:I(),url:I()}))});async function co(e){return await Z(new URL(`/core/repository/preview_configs`,await z(e)),{schema:so})}function lo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function uo(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a preview configuration from a Prismic repository.
1334
1405
 
1335
1406
  By default, this command reads the repository from prismic.config.json at the
1336
1407
  project root.
@@ -1346,7 +1417,7 @@ FLAGS
1346
1417
  -h, --help Show help for command
1347
1418
 
1348
1419
  LEARN MORE
1349
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Ea();return}let i=await Sa(n);if(!i.ok){i.error instanceof Z?Ea():(console.error(`Failed to fetch previews: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.results.find(e=>e.url===r);if(!a){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let o=await Ta(n,a.id);if(!o.ok){o.error instanceof Z?Ea():(console.error(`Failed to remove preview: ${q(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function Ta(e,t){return await X(new URL(`/previews/delete/${t}`,await V(e)),{method:`POST`,body:{}})}function Ea(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Da(){let{values:{help:t,repo:n=await Y()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Remove the slice simulator URL from a Prismic repository.
1420
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){po();return}let i=await co(n);if(!i.ok){i.error instanceof Q?po():(console.error(`Failed to fetch previews: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.results.find(e=>e.url===r);if(!a){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let o=await fo(n,a.id);if(!o.ok){o.error instanceof Q?po():(console.error(`Failed to remove preview: ${J(o.value)}`),process.exitCode=1);return}console.info(`Preview removed: ${r}`)}async function fo(e,t){return await Z(new URL(`/previews/delete/${t}`,await z(e)),{method:`POST`,body:{}})}function po(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function mo(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Remove the slice simulator URL from a Prismic repository.
1350
1421
 
1351
1422
  By default, this command reads the repository from prismic.config.json at the
1352
1423
  project root.
@@ -1359,7 +1430,7 @@ FLAGS
1359
1430
  -h, --help Show help for command
1360
1431
 
1361
1432
  LEARN MORE
1362
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){ka();return}let r=await Oa(n);if(!r.ok){r.error instanceof Z?ka():(console.error(`Failed to remove simulator URL: ${q(r.value)}`),process.exitCode=1);return}console.info(`Simulator URL removed.`)}async function Oa(e){return await X(new URL(`/core/repository`,await V(e)),{method:`PATCH`,body:{simulator_url:``}})}function ka(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Aa(){let{values:{help:t,repo:n=await Y()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update the name of a preview configuration.
1433
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){go();return}let r=await ho(n);if(!r.ok){r.error instanceof Q?go():(console.error(`Failed to remove simulator URL: ${J(r.value)}`),process.exitCode=1);return}console.info(`Simulator URL removed.`)}async function ho(e){return await Z(new URL(`/core/repository`,await z(e)),{method:`PATCH`,body:{simulator_url:``}})}function go(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function _o(){let{values:{help:t,repo:n=await X()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update the name of a preview configuration.
1363
1434
 
1364
1435
  By default, this command reads the repository from prismic.config.json at the
1365
1436
  project root.
@@ -1376,7 +1447,7 @@ FLAGS
1376
1447
  -h, --help Show help for command
1377
1448
 
1378
1449
  LEARN MORE
1379
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Ma();return}let a=pa(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await Sa(n);if(!o.ok){o.error instanceof Z?Ma():(console.error(`Failed to fetch previews: ${q(o.value)}`),process.exitCode=1);return}let s=o.value.results.find(e=>e.url===r);if(!s){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let c=await ja(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof Z?Ma():(console.error(`Failed to update preview: ${q(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function ja(e,t,n){return await X(new URL(`/previews/save/${t}`,await V(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function Ma(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Na(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the slice simulator URL for a Prismic repository.
1450
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){yo();return}let a=$a(r);if(!a){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let o=await co(n);if(!o.ok){o.error instanceof Q?yo():(console.error(`Failed to fetch previews: ${J(o.value)}`),process.exitCode=1);return}let s=o.value.results.find(e=>e.url===r);if(!s){console.error(`Preview not found: ${r}`),process.exitCode=1;return}let c=await vo(n,s.id,{name:i,websiteURL:a.websiteURL,resolverPath:a.resolverPath});if(!c.ok){c.error instanceof Q?yo():(console.error(`Failed to update preview: ${J(c.value)}`),process.exitCode=1);return}console.info(`Preview updated: ${r}`)}async function vo(e,t,n){return await Z(new URL(`/previews/save/${t}`,await z(e)),{method:`POST`,body:{name:n.name,websiteURL:n.websiteURL,resolverPath:n.resolverPath}})}function yo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function bo(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the slice simulator URL for a Prismic repository.
1380
1451
 
1381
1452
  If the URL pathname does not end with /slice-simulator, it is appended
1382
1453
  automatically.
@@ -1399,7 +1470,7 @@ EXAMPLES
1399
1470
  prismic preview set-simulator http://localhost:3000/slice-simulator
1400
1471
 
1401
1472
  LEARN MORE
1402
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Ia();return}let i=Pa(r);if(!i){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let a=await Fa(n,i);if(!a.ok){a.error instanceof Z?Ia():(console.error(`Failed to set simulator URL: ${q(a.value)}`),process.exitCode=1);return}console.info(`Simulator URL set: ${i}`)}function Pa(e){try{let t=new URL(e);return t.pathname.endsWith(`/slice-simulator`)||(t.pathname=t.pathname.replace(/\/+$/,``)+`/slice-simulator`),t.toString()}catch{return}}async function Fa(e,t){return await X(new URL(`/core/repository`,await V(e)),{method:`PATCH`,body:{simulator_url:t}})}function Ia(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function La(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await fa();break;case`list`:await ba();break;case`remove`:await wa();break;case`set-name`:await Aa();break;case`set-simulator`:await Na();break;case`get-simulator`:await ga();break;case`remove-simulator`:await Da();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
1473
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Co();return}let i=xo(r);if(!i){console.error(`Invalid URL: ${r}`),process.exitCode=1;return}let a=await So(n,i);if(!a.ok){a.error instanceof Q?Co():(console.error(`Failed to set simulator URL: ${J(a.value)}`),process.exitCode=1);return}console.info(`Simulator URL set: ${i}`)}function xo(e){try{let t=new URL(e);return t.pathname.endsWith(`/slice-simulator`)||(t.pathname=t.pathname.replace(/\/+$/,``)+`/slice-simulator`),t.toString()}catch{return}}async function So(e,t){return await Z(new URL(`/core/repository`,await z(e)),{method:`PATCH`,body:{simulator_url:t}})}function Co(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function wo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`add`:await Qa();break;case`list`:await oo();break;case`remove`:await uo();break;case`set-name`:await _o();break;case`set-simulator`:await bo();break;case`get-simulator`:await no();break;case`remove-simulator`:await mo();break;default:t&&(console.error(`Unknown preview subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage preview configurations in a Prismic repository.
1403
1474
 
1404
1475
  USAGE
1405
1476
  prismic preview <command> [flags]
@@ -1417,7 +1488,7 @@ FLAGS
1417
1488
  -h, --help Show help for command
1418
1489
 
1419
1490
  LEARN MORE
1420
- Use \`prismic preview <command> --help\` for more information about a command.`)}}async function Ra(){let{values:{help:t,repo:r=await Y(),"dry-run":i,"types-only":a,"slices-only":o,json:c,types:l}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},json:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Pull custom types and slices from Prismic to local files.
1491
+ Use \`prismic preview <command> --help\` for more information about a command.`)}}async function To(){let{values:{help:t,repo:r=await X(),"dry-run":i,"types-only":a,"slices-only":o,json:c,types:l}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},json:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Pull custom types and slices from Prismic to local files.
1421
1492
 
1422
1493
  By default, this command reads the repository from prismic.config.json at the
1423
1494
  project root.
@@ -1438,9 +1509,9 @@ EXAMPLES
1438
1509
  prismic pull
1439
1510
  prismic pull --repo my-repo
1440
1511
  prismic pull --dry-run
1441
- prismic pull --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}c||console.info(`Pulling from repository: ${r}\n`);let u=!o,d=!a,[f,p]=await Promise.all([u?Pn(r):Promise.resolve({ok:!0,value:[]}),d?Fn(r):Promise.resolve({ok:!0,value:[]})]);if(!f.ok){console.error(`Failed to fetch custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch slices: ${p.error}`),process.exitCode=1;return}let m=f.value,h=p.value;if(c||(u&&console.info(`Fetching custom types... ${m.length} types`),d&&console.info(`Fetching slices... ${h.length} slices`)),i){if(c)console.info(q({customTypes:m,slices:h}));else{if(console.info(``),u&&m.length>0){console.info(`Would write custom types:`);for(let e of m)console.info(` customtypes/${e.id}/index.json`)}if(d&&h.length>0){let e=za(await On());console.info(`Would write slices:`);for(let t of h)console.info(` ${e}${jn(t.name)}/model.json`)}console.info(`\nDry run complete: ${m.length} custom types, ${h.length} slices`)}return}let g=await W(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`.`,g),v=[],y=[];if(u&&m.length>0){c||console.info(`
1442
- Writing custom types:`);let e=new URL(`customtypes/`,_);for(let t of m){let r=new URL(`${t.id}/`,e),i=new URL(`index.json`,r);try{await n(r,{recursive:!0}),await s(i,q(t));let e=`customtypes/${t.id}/index.json`;v.push(e),c||console.info(` ${e}`)}catch(e){console.error(`Failed to write custom type ${t.id}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(d&&h.length>0){c||console.info(`
1443
- Writing slices:`);let e=await On();for(let t of h){let r=new URL(`${jn(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,q(t));let a=`${za(e)}${jn(t.name)}/model.json`;y.push(a),c||console.info(` ${a}`)}catch(e){console.error(`Failed to write slice ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(c?console.info(q({writtenTypes:v,writtenSlices:y})):console.info(`\nPull complete: ${v.length} custom types, ${y.length} slices`),!c)try{await K({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function za(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function Ba(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[],a=[],o=[];for(let t of e){let e=r.get(t.id);e?JSON.stringify(t)!==JSON.stringify(e)&&a.push(t):i.push(t)}for(let e of t)n.has(e.id)||o.push(e.id);return{toInsert:i,toUpdate:a,toDelete:o}}async function Va(){let{values:{help:t,repo:n=await Y(),"dry-run":r,"types-only":i,"slices-only":a,delete:o,json:s}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},delete:{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Push custom types and slices to Prismic from local files.
1512
+ prismic pull --types-only`);return}if(!r){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}c||console.info(`Pulling from repository: ${r}\n`);let u=!o,d=!a,[f,p]=await Promise.all([u?zn(r):Promise.resolve({ok:!0,value:[]}),d?Bn(r):Promise.resolve({ok:!0,value:[]})]);if(!f.ok){console.error(`Failed to fetch custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch slices: ${p.error}`),process.exitCode=1;return}let m=f.value,h=p.value;if(c||(u&&console.info(`Fetching custom types... ${m.length} types`),d&&console.info(`Fetching slices... ${h.length} slices`)),i){if(c)console.info(J({customTypes:m,slices:h}));else{if(console.info(``),u&&m.length>0){console.info(`Would write custom types:`);for(let e of m)console.info(` customtypes/${e.id}/index.json`)}if(d&&h.length>0){let e=Eo(await Nn());console.info(`Would write slices:`);for(let t of h)console.info(` ${e}${In(t.name)}/model.json`)}console.info(`\nDry run complete: ${m.length} custom types, ${h.length} slices`)}return}let g=await V(`package.json`);if(!g){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let _=new URL(`.`,g),v=[],y=[];if(u&&m.length>0){c||console.info(`
1513
+ Writing custom types:`);let e=new URL(`customtypes/`,_);for(let t of m){let r=new URL(`${t.id}/`,e),i=new URL(`index.json`,r);try{await n(r,{recursive:!0}),await s(i,J(t));let e=`customtypes/${t.id}/index.json`;v.push(e),c||console.info(` ${e}`)}catch(e){console.error(`Failed to write custom type ${t.id}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(d&&h.length>0){c||console.info(`
1514
+ Writing slices:`);let e=await Nn();for(let t of h){let r=new URL(`${In(t.name)}/`,e),i=new URL(`model.json`,r);try{await n(r,{recursive:!0}),await s(i,J(t));let a=`${Eo(e)}${In(t.name)}/model.json`;y.push(a),c||console.info(` ${a}`)}catch(e){console.error(`Failed to write slice ${t.name}: ${e instanceof Error?e.message:e}`),process.exitCode=1;return}}}if(c?console.info(J({writtenTypes:v,writtenSlices:y})):console.info(`\nPull complete: ${v.length} custom types, ${y.length} slices`),!c)try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}function Eo(e){let t=process.cwd(),n=e.pathname;return n.startsWith(t)?n.slice(t.length+1):n}function Do(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[],a=[],o=[];for(let t of e){let e=r.get(t.id);e?JSON.stringify(t)!==JSON.stringify(e)&&a.push(t):i.push(t)}for(let e of t)n.has(e.id)||o.push(e.id);return{toInsert:i,toUpdate:a,toDelete:o}}async function Oo(){let{values:{help:t,repo:n=await X(),"dry-run":r,"types-only":i,"slices-only":a,delete:o,json:s}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},"dry-run":{type:`boolean`},"types-only":{type:`boolean`},"slices-only":{type:`boolean`},delete:{type:`boolean`},json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Push custom types and slices to Prismic from local files.
1444
1515
 
1445
1516
  By default, this command reads the repository from prismic.config.json at the
1446
1517
  project root.
@@ -1462,10 +1533,10 @@ EXAMPLES
1462
1533
  prismic push --repo my-repo
1463
1534
  prismic push --dry-run
1464
1535
  prismic push --types-only
1465
- prismic push --delete`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}s||console.info(`Pushing to repository: ${n}\n`);let c=!a,l=!i,[u,d,f,p]=await Promise.all([c?In():Promise.resolve({ok:!0,value:[]}),l?Ln():Promise.resolve({ok:!0,value:[]}),c?Pn(n):Promise.resolve({ok:!0,value:[]}),l?Fn(n):Promise.resolve({ok:!0,value:[]})]);if(!u.ok){console.error(`Failed to read local custom types: ${u.error}`),process.exitCode=1;return}if(!d.ok){console.error(`Failed to read local slices: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch remote custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch remote slices: ${p.error}`),process.exitCode=1;return}let m=u.value,h=d.value,g=f.value,_=p.value;s||(c&&(console.info(`Local custom types: ${m.length}`),console.info(`Remote custom types: ${g.length}`)),l&&(console.info(`Local slices: ${h.length}`),console.info(`Remote slices: ${_.length}`)));let v=c?Ba([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?Ba([...h],[..._]):{toInsert:[],toUpdate:[],toDelete:[]};o||(v.toDelete=[],y.toDelete=[]);let b=v.toInsert.length+v.toUpdate.length+v.toDelete.length+y.toInsert.length+y.toUpdate.length+y.toDelete.length;if(b===0){s?console.info(q({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
1466
- No changes to push.`);return}if(r){if(s)console.info(q({customTypes:{toInsert:v.toInsert.map(e=>e.id),toUpdate:v.toUpdate.map(e=>e.id),toDelete:v.toDelete},slices:{toInsert:y.toInsert.map(e=>e.id),toUpdate:y.toUpdate.map(e=>e.id),toDelete:y.toDelete}}));else{if(console.info(``),c){if(v.toInsert.length>0){console.info(`Would insert custom types:`);for(let e of v.toInsert)console.info(` + ${e.id}`)}if(v.toUpdate.length>0){console.info(`Would update custom types:`);for(let e of v.toUpdate)console.info(` ~ ${e.id}`)}if(v.toDelete.length>0){console.info(`Would delete custom types:`);for(let e of v.toDelete)console.info(` - ${e}`)}}if(l){if(y.toInsert.length>0){console.info(`Would insert slices:`);for(let e of y.toInsert)console.info(` + ${e.id}`)}if(y.toUpdate.length>0){console.info(`Would update slices:`);for(let e of y.toUpdate)console.info(` ~ ${e.id}`)}if(y.toDelete.length>0){console.info(`Would delete slices:`);for(let e of y.toDelete)console.info(` - ${e}`)}}console.info(`\nDry run complete: ${b} changes would be made`)}return}let x={customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}};if(c){!s&&(v.toInsert.length>0||v.toUpdate.length>0||v.toDelete.length>0)&&console.info(`
1467
- Pushing custom types:`);for(let e of v.toInsert){let t=await Rn(n,e);if(!t.ok){console.error(`Failed to insert custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of v.toUpdate){let t=await zn(n,e);if(!t.ok){console.error(`Failed to update custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of v.toDelete){let t=await Bn(n,e);if(!t.ok){console.error(`Failed to delete custom type ${e}: ${t.error}`),process.exitCode=1;return}x.customTypes.deleted.push(e),s||console.info(` - ${e}`)}}if(l){!s&&(y.toInsert.length>0||y.toUpdate.length>0||y.toDelete.length>0)&&console.info(`
1468
- Pushing slices:`);for(let e of y.toInsert){let t=await Vn(n,e);if(!t.ok){console.error(`Failed to insert slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of y.toUpdate){let t=await Hn(n,e);if(!t.ok){console.error(`Failed to update slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of y.toDelete){let t=await Un(n,e);if(!t.ok){console.error(`Failed to delete slice ${e}: ${t.error}`),process.exitCode=1;return}x.slices.deleted.push(e),s||console.info(` - ${e}`)}}if(s)console.info(q(x));else{let e=x.customTypes.inserted.length+x.customTypes.updated.length+x.customTypes.deleted.length+x.slices.inserted.length+x.slices.updated.length+x.slices.deleted.length;console.info(`\nPush complete: ${e} changes`)}}const Ha=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;async function Ua(){let{values:{help:t,name:n,"no-config":r,replace:i},positionals:[a]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},name:{type:`string`,short:`n`},"no-config":{type:`boolean`},replace:{type:`boolean`}},allowPositionals:!0});if(t){console.info(`Create a new Prismic repository.
1536
+ prismic push --delete`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}s||console.info(`Pushing to repository: ${n}\n`);let c=!a,l=!i,[u,d,f,p]=await Promise.all([c?Vn():Promise.resolve({ok:!0,value:[]}),l?Hn():Promise.resolve({ok:!0,value:[]}),c?zn(n):Promise.resolve({ok:!0,value:[]}),l?Bn(n):Promise.resolve({ok:!0,value:[]})]);if(!u.ok){console.error(`Failed to read local custom types: ${u.error}`),process.exitCode=1;return}if(!d.ok){console.error(`Failed to read local slices: ${d.error}`),process.exitCode=1;return}if(!f.ok){console.error(`Failed to fetch remote custom types: ${f.error}`),process.exitCode=1;return}if(!p.ok){console.error(`Failed to fetch remote slices: ${p.error}`),process.exitCode=1;return}let m=u.value,h=d.value,g=f.value,_=p.value;s||(c&&(console.info(`Local custom types: ${m.length}`),console.info(`Remote custom types: ${g.length}`)),l&&(console.info(`Local slices: ${h.length}`),console.info(`Remote slices: ${_.length}`)));let v=c?Do([...m],[...g]):{toInsert:[],toUpdate:[],toDelete:[]},y=l?Do([...h],[..._]):{toInsert:[],toUpdate:[],toDelete:[]};o||(v.toDelete=[],y.toDelete=[]);let b=v.toInsert.length+v.toUpdate.length+v.toDelete.length+y.toInsert.length+y.toUpdate.length+y.toDelete.length;if(b===0){s?console.info(J({customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}})):console.info(`
1537
+ No changes to push.`);return}if(r){if(s)console.info(J({customTypes:{toInsert:v.toInsert.map(e=>e.id),toUpdate:v.toUpdate.map(e=>e.id),toDelete:v.toDelete},slices:{toInsert:y.toInsert.map(e=>e.id),toUpdate:y.toUpdate.map(e=>e.id),toDelete:y.toDelete}}));else{if(console.info(``),c){if(v.toInsert.length>0){console.info(`Would insert custom types:`);for(let e of v.toInsert)console.info(` + ${e.id}`)}if(v.toUpdate.length>0){console.info(`Would update custom types:`);for(let e of v.toUpdate)console.info(` ~ ${e.id}`)}if(v.toDelete.length>0){console.info(`Would delete custom types:`);for(let e of v.toDelete)console.info(` - ${e}`)}}if(l){if(y.toInsert.length>0){console.info(`Would insert slices:`);for(let e of y.toInsert)console.info(` + ${e.id}`)}if(y.toUpdate.length>0){console.info(`Would update slices:`);for(let e of y.toUpdate)console.info(` ~ ${e.id}`)}if(y.toDelete.length>0){console.info(`Would delete slices:`);for(let e of y.toDelete)console.info(` - ${e}`)}}console.info(`\nDry run complete: ${b} changes would be made`)}return}let x={customTypes:{inserted:[],updated:[],deleted:[]},slices:{inserted:[],updated:[],deleted:[]}};if(c){!s&&(v.toInsert.length>0||v.toUpdate.length>0||v.toDelete.length>0)&&console.info(`
1538
+ Pushing custom types:`);for(let e of v.toInsert){let t=await Un(n,e);if(!t.ok){console.error(`Failed to insert custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of v.toUpdate){let t=await Wn(n,e);if(!t.ok){console.error(`Failed to update custom type ${e.id}: ${t.error}`),process.exitCode=1;return}x.customTypes.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of v.toDelete){let t=await Gn(n,e);if(!t.ok){console.error(`Failed to delete custom type ${e}: ${t.error}`),process.exitCode=1;return}x.customTypes.deleted.push(e),s||console.info(` - ${e}`)}}if(l){!s&&(y.toInsert.length>0||y.toUpdate.length>0||y.toDelete.length>0)&&console.info(`
1539
+ Pushing slices:`);for(let e of y.toInsert){let t=await Kn(n,e);if(!t.ok){console.error(`Failed to insert slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.inserted.push(e.id),s||console.info(` + ${e.id}`)}for(let e of y.toUpdate){let t=await qn(n,e);if(!t.ok){console.error(`Failed to update slice ${e.id}: ${t.error}`),process.exitCode=1;return}x.slices.updated.push(e.id),s||console.info(` ~ ${e.id}`)}for(let e of y.toDelete){let t=await Jn(n,e);if(!t.ok){console.error(`Failed to delete slice ${e}: ${t.error}`),process.exitCode=1;return}x.slices.deleted.push(e),s||console.info(` - ${e}`)}}if(s)console.info(J(x));else{let e=x.customTypes.inserted.length+x.customTypes.updated.length+x.customTypes.deleted.length+x.slices.inserted.length+x.slices.updated.length+x.slices.deleted.length;console.info(`\nPush complete: ${e} changes`)}}const ko=/^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$/;function Ao(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function jo(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}async function Mo(){let{values:{help:t,name:n,"no-config":r,replace:i},positionals:[a]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},name:{type:`string`,short:`n`},"no-config":{type:`boolean`},replace:{type:`boolean`}},allowPositionals:!0});if(t){console.info(`Create a new Prismic repository.
1469
1540
 
1470
1541
  Creates prismic.config.json in the current directory. If a config file already
1471
1542
  exists, use --replace to update it with the new repository.
@@ -1484,7 +1555,7 @@ FLAGS
1484
1555
  -h, --help Show help for command
1485
1556
 
1486
1557
  LEARN MORE
1487
- Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: domain`),process.exitCode=1;return}if(!Ha.test(a)){console.error(`Invalid domain format.`),console.error(`Must be at least 4 characters, start and end with alphanumeric, and contain only alphanumerics and hyphens.`),process.exitCode=1;return}if(!await H()){Ga();return}let o=await Gr();if(!r&&o.ok&&!i){console.error(`This project already has a repository: ${o.config.repositoryName}`),console.error(`Use --replace to replace it, or --no-config to skip config creation.`),process.exitCode=1;return}let s=await Wa(a,n);if(!s.ok){s.error instanceof Z?Ga():(console.error(`Failed to create repository: ${q(s.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await qr({repositoryName:a});e.ok?console.info(`Updated prismic.config.json`):console.warn(`Could not update prismic.config.json: `+e.error.message)}else{let e=await Wr({repositoryName:a});e.ok?console.info(`Created prismic.config.json`):console.warn(`Could not create prismic.config.json: `+e.error.message)}console.info(`Repository created: ${a}`),console.info(`URL: ${await V(a)}`)}async function Wa(e,t=e){return await X(new URL(`/app/dashboard/repositories`,await Cn()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function Ga(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ka=F({repository:F({api_access:R()})});async function qa(){let{values:{help:t,repo:n=await Y()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Get the Content API access level of a Prismic repository.
1558
+ Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: domain`),process.exitCode=1;return}if(!ko.test(a)){console.error(`Invalid domain format.`),console.error(`Must be at least 4 characters, start and end with alphanumeric, and contain only alphanumerics and hyphens.`),process.exitCode=1;return}if(!await B()){Fo();return}let o=await oi();if(!r&&o.ok&&!i){console.error(`This project already has a repository: ${o.config.repositoryName}`),console.error(`Use --replace to replace it, or --no-config to skip config creation.`),process.exitCode=1;return}let s=await No(a);if(!s.ok){s.error instanceof Q?Fo():(console.error(`Failed to check domain availability: ${J(s.error)}`),process.exitCode=1);return}if(!s.value){console.error(`Repository name "${a}" is already taken.`),process.exitCode=1;return}let c=await Po(a,n);if(!c.ok){c.error instanceof Q?Fo():(console.error(`Failed to create repository: ${J(c.error)}`),process.exitCode=1);return}if(!r)if(o.ok){let e=await ci({repositoryName:a});e.ok?console.info(`Updated prismic.config.json`):console.warn(`Could not update prismic.config.json: `+e.error.message)}else{let e=await ai({repositoryName:a});e.ok?console.info(`Created prismic.config.json`):console.warn(`Could not create prismic.config.json: `+e.error.message)}console.info(`Repository created: ${a}`),console.info(`URL: ${await z(a)}`);let l=await $();if(l?.framework){let e=Ao(l.framework),t=jo(l.framework),n=Ri(l),r=n?`creating ${n}`:`configuring Prismic`;console.info(),console.info(`Next: Run \`prismic docs fetch ${e}${t}\` for instructions on ${r}`)}}async function No(e){let t=await Z(new URL(`/app/dashboard/repositories/${e}/exists`,await On()));return t.ok?{ok:!0,value:t.value===`true`}:t}async function Po(e,t=e){return await Z(new URL(`/app/dashboard/repositories`,await On()),{method:`POST`,body:{domain:e,name:t,framework:`next`,plan:`personal`,usageIntent:`Exploring Prismic's features for future projects.`,usageIntentIndex:0}})}function Fo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Io=N({repository:N({api_access:I()})});async function Lo(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Get the Content API access level of a Prismic repository.
1488
1559
 
1489
1560
  By default, this command reads the repository from prismic.config.json at the
1490
1561
  project root.
@@ -1497,7 +1568,7 @@ FLAGS
1497
1568
  -h, --help Show help for command
1498
1569
 
1499
1570
  LEARN MORE
1500
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Ya();return}let r=await Ja(n);if(!r.ok){r.error instanceof Z?Ya():(console.error(`Failed to get repository access: ${q(r.value)}`),process.exitCode=1);return}console.info(r.value.repository.api_access)}async function Ja(e){let t=await V(e);return await X(new URL(`syncState`,t),{schema:Ka})}function Ya(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Xa=F({repositories:N(F({domain:R(),name:I(R()),role:R()}))});async function Za(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},json:{type:`boolean`}}});if(t){console.info(`List all Prismic repositories.
1571
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){zo();return}let r=await Ro(n);if(!r.ok){r.error instanceof Q?zo():(console.error(`Failed to get repository access: ${J(r.value)}`),process.exitCode=1);return}console.info(r.value.repository.api_access)}async function Ro(e){let t=await z(e);return await Z(new URL(`syncState`,t),{schema:Io})}function zo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Bo=N({repositories:j(N({domain:I(),name:P(I()),role:I()}))});async function Vo(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`},json:{type:`boolean`}}});if(t){console.info(`List all Prismic repositories.
1501
1572
 
1502
1573
  USAGE
1503
1574
  prismic repo list [flags]
@@ -1507,7 +1578,7 @@ FLAGS
1507
1578
  -h, --help Show help for command
1508
1579
 
1509
1580
  LEARN MORE
1510
- Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await H()){$a();return}let r=await Qa();if(!r.ok){r.error instanceof Z?$a():(console.error(`Failed to fetch repositories: ${q(r.value)}`),process.exitCode=1);return}let i=r.value.repositories;if(n){let e=await Promise.all(i.map(async e=>({domain:e.domain,name:e.name||null,role:e.role,url:(await V(e.domain)).toString()})));console.info(q(e));return}if(i.length===0){console.info(`No repositories found.`);return}for(let e of i){let t=e.name||`(no name)`;console.info(`${e.domain} ${t} ${e.role}`)}}async function Qa(){return await X(new URL(`profile`,await vn()),{schema:Xa})}function $a(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const eo=[`private`,`public`,`open`];async function to(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the Content API access level of a Prismic repository.
1581
+ Use \`prismic repo <command> --help\` for more information about a command.`);return}if(!await B()){Uo();return}let r=await Ho();if(!r.ok){r.error instanceof Q?Uo():(console.error(`Failed to fetch repositories: ${J(r.value)}`),process.exitCode=1);return}let i=r.value.repositories;if(n){let e=await Promise.all(i.map(async e=>({domain:e.domain,name:e.name||null,role:e.role,url:(await z(e.domain)).toString()})));console.info(J(e));return}if(i.length===0){console.info(`No repositories found.`);return}for(let e of i){let t=e.name||`(no name)`;console.info(`${e.domain} ${t} ${e.role}`)}}async function Ho(){return await Z(new URL(`profile`,await Sn()),{schema:Bo})}function Uo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Wo=[`private`,`public`,`open`];async function Go(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the Content API access level of a Prismic repository.
1511
1582
 
1512
1583
  By default, this command reads the repository from prismic.config.json at the
1513
1584
  project root.
@@ -1523,7 +1594,7 @@ FLAGS
1523
1594
  -h, --help Show help for command
1524
1595
 
1525
1596
  LEARN MORE
1526
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <level>`),process.exitCode=1;return}if(!eo.includes(r)){console.error(`Invalid access level: ${r}. Must be one of: ${eo.join(`, `)}`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){ro();return}let i=await no(n,r);if(!i.ok){i.error instanceof Z?ro():(console.error(`Failed to set repository access: ${q(i.value)}`),process.exitCode=1);return}console.info(`Repository access set to: ${r}`)}async function no(e,t){let n=await V(e);return await X(new URL(`settings/security/apiaccess`,n),{method:`POST`,body:{api_access:t}})}function ro(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function io(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the display name of a Prismic repository.
1597
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <level>`),process.exitCode=1;return}if(!Wo.includes(r)){console.error(`Invalid access level: ${r}. Must be one of: ${Wo.join(`, `)}`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){qo();return}let i=await Ko(n,r);if(!i.ok){i.error instanceof Q?qo():(console.error(`Failed to set repository access: ${J(i.value)}`),process.exitCode=1);return}console.info(`Repository access set to: ${r}`)}async function Ko(e,t){let n=await z(e);return await Z(new URL(`settings/security/apiaccess`,n),{method:`POST`,body:{api_access:t}})}function qo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Jo(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the display name of a Prismic repository.
1527
1598
 
1528
1599
  By default, this command reads the repository from prismic.config.json at the
1529
1600
  project root.
@@ -1539,7 +1610,7 @@ FLAGS
1539
1610
  -h, --help Show help for command
1540
1611
 
1541
1612
  LEARN MORE
1542
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){oo();return}let i=await ao(n,r);if(!i.ok){i.error instanceof Z?oo():M(i.error)?(console.error(`Failed to set repository name: Invalid response: ${q(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${q(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function ao(e,t){let n=await V(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await X(r,{method:`POST`,body:i,schema:F({repository:F({name:R()})})})}function oo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const so=F({repositories:N(F({domain:R(),name:I(R())}))});async function co(){let{values:{help:t,repo:n=await Y(),web:r}}=e({args:process.argv.slice(4),options:{web:{type:`boolean`,short:`w`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}}});if(t){console.info(`View a Prismic repository.
1613
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <name>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Xo();return}let i=await Yo(n,r);if(!i.ok){i.error instanceof Q?Xo():A(i.error)?(console.error(`Failed to set repository name: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to set repository name: ${J(i.value)}`),process.exitCode=1);return}console.info(`Repository name set to: ${i.value.repository.name}`)}async function Yo(e,t){let n=await z(e),r=new URL(`app/settings/repository`,n),i=new FormData;return i.set(`displayname`,t),await Z(r,{method:`POST`,body:i,schema:N({repository:N({name:I()})})})}function Xo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Zo=N({repositories:j(N({domain:I(),name:P(I())}))});async function Qo(){let{values:{help:t,repo:n=await X(),web:r}}=e({args:process.argv.slice(4),options:{web:{type:`boolean`,short:`w`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}}});if(t){console.info(`View a Prismic repository.
1543
1614
 
1544
1615
  By default, this command reads the repository from prismic.config.json at the
1545
1616
  project root.
@@ -1553,7 +1624,7 @@ FLAGS
1553
1624
  -h, --help Show help for command
1554
1625
 
1555
1626
  LEARN MORE
1556
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}let i=await V(n);if(r){uo(i.toString()),console.info(`Opening ${i}`);return}if(!await H()){fo();return}let a=await lo();if(!a.ok){a.error instanceof Z?fo():(console.error(`Failed to fetch repository info: ${q(a.value)}`),process.exitCode=1);return}let o=a.value.repositories.find(e=>e.domain===n);if(!o){console.error(`Repository not found: ${n}`),process.exitCode=1;return}let s=o.name||`(no name)`;console.info(`Name: ${s}`),console.info(`URL: ${i}`)}async function lo(){return await X(new URL(`profile`,await vn()),{schema:so})}function uo(e){d(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function fo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function po(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Ua();break;case`list`:await Za();break;case`view`:await co();break;case`get-access`:await qa();break;case`set-access`:await to();break;case`set-name`:await io();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
1627
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}let i=await z(n);if(r){es(i.toString()),console.info(`Opening ${i}`);return}if(!await B()){ts();return}let a=await $o();if(!a.ok){a.error instanceof Q?ts():(console.error(`Failed to fetch repository info: ${J(a.value)}`),process.exitCode=1);return}let o=a.value.repositories.find(e=>e.domain===n);if(!o){console.error(`Repository not found: ${n}`),process.exitCode=1;return}let s=o.name||`(no name)`;console.info(`Name: ${s}`),console.info(`URL: ${i}`)}async function $o(){return await Z(new URL(`profile`,await Sn()),{schema:Zo})}function es(e){f(`${process.platform===`darwin`?`open`:process.platform===`win32`?`start`:`xdg-open`} "${e}"`)}function ts(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ns(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Mo();break;case`list`:await Vo();break;case`view`:await Qo();break;case`get-access`:await Lo();break;case`set-access`:await Go();break;case`set-name`:await Jo();break;default:t&&(console.error(`Unknown repo subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage Prismic repositories.
1557
1628
 
1558
1629
  USAGE
1559
1630
  prismic repo <command> [flags]
@@ -1570,7 +1641,7 @@ FLAGS
1570
1641
  -h, --help Show help for command
1571
1642
 
1572
1643
  LEARN MORE
1573
- Use \`prismic repo <command> --help\` for more information about a command.`)}}async function mo(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
1644
+ Use \`prismic repo <command> --help\` for more information about a command.`)}}function rs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function is(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function as(){let{values:{help:t,variation:n,label:r,default:i,"true-label":a,"false-label":o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},default:{type:`boolean`},"true-label":{type:`string`},"false-label":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a boolean (toggle) field to an existing slice.
1574
1645
 
1575
1646
  USAGE
1576
1647
  prismic slice add-field boolean <slice-id> <field-id> [flags]
@@ -1593,7 +1664,7 @@ EXAMPLES
1593
1664
  prismic slice add-field boolean hero show_overlay --default
1594
1665
  prismic slice add-field boolean product available --true-label "In Stock" --false-label "Out of Stock"`);return}if(!l){console.error(`Missing required argument: slice-id
1595
1666
  `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
1596
- `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let d=await G(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`Boolean`,config:{label:r??J(u),...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};m.primary[u]=h;try{await s(p,q(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (Boolean) to "${m.id}" variation in ${l}`);try{await K({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function ho(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
1667
+ `),console.error(`Usage: prismic slice add-field boolean <slice-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await H(l);if(!p.ok){console.error(p.error),process.exitCode=1;return}let{model:m,modelPath:h}=p;if(m.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let g=n?m.variations.find(e=>e.id===n):m.variations[0];if(!g){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${m.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}g.primary||={};let _={type:`Boolean`,config:{label:r??Y(d.type===`nested`?d.nestedFieldId:u),...i&&{default_value:!0},...a&&{placeholder_true:a},...o&&{placeholder_false:o}}};if(d.type===`nested`){let e=Zn(g.primary,d.groupId,g.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=_}else{for(let e of m.variations){if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[u]){console.error(`Field "${u}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}g.primary[u]=_}try{await s(h,J(m))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Boolean) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Boolean) to "${g.id}" variation in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let v=await $();if(v?.framework){let e=rs(v.framework),t=is(v.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function os(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ss(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function cs(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a color picker field to an existing slice.
1597
1668
 
1598
1669
  USAGE
1599
1670
  prismic slice add-field color <slice-id> <field-id> [flags]
@@ -1614,7 +1685,7 @@ EXAMPLES
1614
1685
  prismic slice add-field color hero accent --label "Accent Color"
1615
1686
  prismic slice add-field color banner theme_color --variation "dark"`);return}if(!o){console.error(`Missing required argument: slice-id
1616
1687
  `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
1617
- `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let l=await G(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Color`,config:{label:r??J(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,q(u))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${c}" (Color) to "${f.id}" variation in ${o}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function go(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
1688
+ `),console.error(`Usage: prismic slice add-field color <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Color`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Color) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Color) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=os(g.framework),t=ss(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function ls(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function us(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ds(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a date picker field to an existing slice.
1618
1689
 
1619
1690
  USAGE
1620
1691
  prismic slice add-field date <slice-id> <field-id> [flags]
@@ -1635,7 +1706,7 @@ EXAMPLES
1635
1706
  prismic slice add-field date event start_date --label "Start Date"
1636
1707
  prismic slice add-field date promo end_date --variation "countdown"`);return}if(!o){console.error(`Missing required argument: slice-id
1637
1708
  `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
1638
- `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let l=await G(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Date`,config:{label:r??J(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,q(u))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${c}" (Date) to "${f.id}" variation in ${o}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function _o(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
1709
+ `),console.error(`Usage: prismic slice add-field date <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Date`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Date) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Date) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=ls(g.framework),t=us(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function fs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ps(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ms(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an embed (oEmbed) field to an existing slice.
1639
1710
 
1640
1711
  USAGE
1641
1712
  prismic slice add-field embed <slice-id> <field-id> [flags]
@@ -1656,7 +1727,7 @@ EXAMPLES
1656
1727
  prismic slice add-field embed gallery media --label "Media Embed"
1657
1728
  prismic slice add-field embed social tweet --variation "twitter"`);return}if(!o){console.error(`Missing required argument: slice-id
1658
1729
  `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
1659
- `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let l=await G(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Embed`,config:{label:r??J(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,q(u))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${c}" (Embed) to "${f.id}" variation in ${o}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function vo(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
1730
+ `),console.error(`Usage: prismic slice add-field embed <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Embed`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Embed) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Embed) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=fs(g.framework),t=ps(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function hs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function gs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function _s(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a geographic coordinates field to an existing slice.
1660
1731
 
1661
1732
  USAGE
1662
1733
  prismic slice add-field geo-point <slice-id> <field-id> [flags]
@@ -1676,7 +1747,28 @@ EXAMPLES
1676
1747
  prismic slice add-field geo-point store coordinates --label "Store Location"
1677
1748
  prismic slice add-field geo-point map marker --variation "interactive"`);return}if(!a){console.error(`Missing required argument: slice-id
1678
1749
  `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1679
- `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let c=await G(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`GeoPoint`,config:{label:r??J(o)}};d.primary[o]=f;try{await s(u,q(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (GeoPoint) to "${d.id}" variation in ${a}`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function yo(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
1750
+ `),console.error(`Usage: prismic slice add-field geo-point <slice-id> <field-id>`),process.exitCode=1;return}let c=W(o),l=q(c);if(!l.ok){console.error(l.error),process.exitCode=1;return}let u=await H(a);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};let m={type:`GeoPoint`,config:{label:r??Y(c.type===`nested`?c.nestedFieldId:o)}};if(c.type===`nested`){let e=Zn(p.primary,c.groupId,p.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[c.nestedFieldId]){console.error(`Field "${c.nestedFieldId}" already exists in group "${c.groupId}"`),process.exitCode=1;return}e.group.config.fields[c.nestedFieldId]=m}else{for(let e of d.variations){if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[o]){console.error(`Field "${o}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}p.primary[o]=m}try{await s(f,J(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}c.type===`nested`?console.info(`Added field "${c.nestedFieldId}" (GeoPoint) to group "${c.groupId}" in ${a}`):console.info(`Added field "${o}" (GeoPoint) to "${p.id}" variation in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let h=await $();if(h?.framework){let e=hs(h.framework),t=gs(h.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function vs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function ys(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function bs(){let{values:{help:t,variation:n,label:r,"non-repeatable":i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},"non-repeatable":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a group field to an existing slice.
1751
+
1752
+ USAGE
1753
+ prismic slice add-field group <slice-id> <field-id> [flags]
1754
+
1755
+ ARGUMENTS
1756
+ slice-id Slice identifier (required)
1757
+ field-id Field identifier (required)
1758
+
1759
+ FLAGS
1760
+ -v, --variation string Target variation (default: first variation)
1761
+ -l, --label string Display label for the field (inferred from field-id if omitted)
1762
+ --non-repeatable Make this a non-repeating group (default: repeatable)
1763
+ --types string Output file for generated types (default: "prismicio-types.d.ts")
1764
+ -h, --help Show help for command
1765
+
1766
+ EXAMPLES
1767
+ prismic slice add-field group my_slice buttons
1768
+ prismic slice add-field group hero ctas --non-repeatable
1769
+ prismic slice add-field group product variants --variation "withImage"`);return}if(!o){console.error(`Missing required argument: slice-id
1770
+ `),console.error(`Usage: prismic slice add-field group <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
1771
+ `),console.error(`Usage: prismic slice add-field group <slice-id> <field-id>`),process.exitCode=1;return}if(c.includes(`.`)){console.error(`Groups cannot be nested inside other groups`),process.exitCode=1;return}let l=await H(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Group`,config:{label:r??Y(c),repeat:!i,fields:{}}};f.primary[c]=p;try{await s(d,J(u))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${c}" (Group) to "${f.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info(`Next: Add fields to the group with \`prismic slice add-field <type> ${o} ${c}.<field-id>\``);let m=await $();if(m?.framework){let e=vs(m.framework),t=ys(m.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function xs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ss(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Cs(){let{values:{help:t,variation:n,label:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add an image field to an existing slice.
1680
1772
 
1681
1773
  USAGE
1682
1774
  prismic slice add-field image <slice-id> <field-id> [flags]
@@ -1696,7 +1788,7 @@ EXAMPLES
1696
1788
  prismic slice add-field image hero banner --label "Hero Banner"
1697
1789
  prismic slice add-field image gallery thumbnail --variation "grid"`);return}if(!a){console.error(`Missing required argument: slice-id
1698
1790
  `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1699
- `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let c=await G(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let d=n?l.variations.find(e=>e.id===n):l.variations[0];if(!d){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d.primary||={};for(let e of l.variations)if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}let f={type:`Image`,config:{label:r??J(o)}};d.primary[o]=f;try{await s(u,q(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${o}" (Image) to "${d.id}" variation in ${a}`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function bo(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
1791
+ `),console.error(`Usage: prismic slice add-field image <slice-id> <field-id>`),process.exitCode=1;return}let c=W(o),l=q(c);if(!l.ok){console.error(l.error),process.exitCode=1;return}let u=await H(a);if(!u.ok){console.error(u.error),process.exitCode=1;return}let{model:d,modelPath:f}=u;if(d.variations.length===0){console.error(`Slice "${a}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let p=n?d.variations.find(e=>e.id===n):d.variations[0];if(!p){console.error(`Variation "${n}" not found in slice "${a}"\n`),console.error(`Available variations: ${d.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}p.primary||={};let m={type:`Image`,config:{label:r??Y(c.type===`nested`?c.nestedFieldId:o)}};if(c.type===`nested`){let e=Zn(p.primary,c.groupId,p.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[c.nestedFieldId]){console.error(`Field "${c.nestedFieldId}" already exists in group "${c.groupId}"`),process.exitCode=1;return}e.group.config.fields[c.nestedFieldId]=m}else{for(let e of d.variations){if(e.primary?.[o]){console.error(`Field "${o}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[o]){console.error(`Field "${o}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}p.primary[o]=m}try{await s(f,J(d))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}c.type===`nested`?console.info(`Added field "${c.nestedFieldId}" (Image) to group "${c.groupId}" in ${a}`):console.info(`Added field "${o}" (Image) to "${p.id}" variation in ${a}`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let h=await $();if(h?.framework){let e=xs(h.framework),t=Ss(h.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function ws(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ts(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Es(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a key-text (single-line text) field to an existing slice.
1700
1792
 
1701
1793
  USAGE
1702
1794
  prismic slice add-field key-text <slice-id> <field-id> [flags]
@@ -1717,7 +1809,7 @@ EXAMPLES
1717
1809
  prismic slice add-field key-text hero heading --label "Heading"
1718
1810
  prismic slice add-field key-text cta button_text --placeholder "Enter button text"`);return}if(!o){console.error(`Missing required argument: slice-id
1719
1811
  `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
1720
- `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let l=await G(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Text`,config:{label:r??J(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,q(u))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${c}" (Text) to "${f.id}" variation in ${o}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function xo(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
1812
+ `),console.error(`Usage: prismic slice add-field key-text <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Text`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Text) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Text) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=ws(g.framework),t=Ts(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function Ds(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Os(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function ks(){let{values:{help:t,variation:n,label:r,placeholder:i,"allow-text":a,"allow-target-blank":o,repeatable:c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},"allow-text":{type:`boolean`},"allow-target-blank":{type:`boolean`},repeatable:{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a link field to an existing slice.
1721
1813
 
1722
1814
  USAGE
1723
1815
  prismic slice add-field link <slice-id> <field-id> [flags]
@@ -1742,7 +1834,7 @@ EXAMPLES
1742
1834
  prismic slice add-field link navigation links --repeatable
1743
1835
  prismic slice add-field link hero cta --allow-text --allow-target-blank`);return}if(!u){console.error(`Missing required argument: slice-id
1744
1836
  `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
1745
- `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let f=await G(u);if(!f.ok){console.error(f.error),process.exitCode=1;return}let{model:p,modelPath:m}=f;if(p.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let h=n?p.variations.find(e=>e.id===n):p.variations[0];if(!h){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${p.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}h.primary||={};for(let e of p.variations)if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}let g={type:`Link`,config:{label:r??J(d),...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};h.primary[d]=g;try{await s(m,q(p))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${d}" (Link) to "${h.id}" variation in ${u}`);try{await K({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function So(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
1837
+ `),console.error(`Usage: prismic slice add-field link <slice-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await H(u);if(!m.ok){console.error(m.error),process.exitCode=1;return}let{model:h,modelPath:g}=m;if(h.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let _=n?h.variations.find(e=>e.id===n):h.variations[0];if(!_){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${h.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}_.primary||={};let v={type:`Link`,config:{label:r??Y(f.type===`nested`?f.nestedFieldId:d),...i&&{placeholder:i},...a&&{allowText:!0},...o&&{allowTargetBlank:!0},...c&&{repeat:!0}}};if(f.type===`nested`){let e=Zn(_.primary,f.groupId,_.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=v}else{for(let e of h.variations){if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[d]){console.error(`Field "${d}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}_.primary[d]=v}try{await s(g,J(h))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (Link) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (Link) to "${_.id}" variation in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let y=await $();if(y?.framework){let e=Ds(y.framework),t=Os(y.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function As(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function js(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Ms(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a number field to an existing slice.
1746
1838
 
1747
1839
  USAGE
1748
1840
  prismic slice add-field number <slice-id> <field-id> [flags]
@@ -1763,7 +1855,7 @@ EXAMPLES
1763
1855
  prismic slice add-field number product quantity --label "Quantity"
1764
1856
  prismic slice add-field number stats count --variation "detailed"`);return}if(!o){console.error(`Missing required argument: slice-id
1765
1857
  `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
1766
- `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let l=await G(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Number`,config:{label:r??J(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,q(u))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${c}" (Number) to "${f.id}" variation in ${o}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function Co(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
1858
+ `),console.error(`Usage: prismic slice add-field number <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Number`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Number) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Number) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=As(g.framework),t=js(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function Ns(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ps(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Fs(){let{values:{help:t,variation:n,label:r,placeholder:i,single:a,multi:o,"allow-target-blank":c,types:l},positionals:[u,d]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},single:{type:`string`},multi:{type:`string`},"allow-target-blank":{type:`boolean`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a rich text field to an existing slice.
1767
1859
 
1768
1860
  USAGE
1769
1861
  prismic slice add-field rich-text <slice-id> <field-id> [flags]
@@ -1793,7 +1885,7 @@ EXAMPLES
1793
1885
  prismic slice add-field rich-text hero tagline --single "heading1"
1794
1886
  prismic slice add-field rich-text blog post --multi "paragraph,strong,em,hyperlink" --allow-target-blank`);return}if(!u){console.error(`Missing required argument: slice-id
1795
1887
  `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}if(!d){console.error(`Missing required argument: field-id
1796
- `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let f=await G(u);if(!f.ok){console.error(f.error),process.exitCode=1;return}let{model:p,modelPath:m}=f;if(p.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let h=n?p.variations.find(e=>e.id===n):p.variations[0];if(!h){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${p.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}h.primary||={};for(let e of p.variations)if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}let g={type:`StructuredText`,config:{label:r??J(d),...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};h.primary[d]=g;try{await s(m,q(p))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${d}" (StructuredText) to "${h.id}" variation in ${u}`);try{await K({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function wo(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
1888
+ `),console.error(`Usage: prismic slice add-field rich-text <slice-id> <field-id>`),process.exitCode=1;return}let f=W(d),p=q(f);if(!p.ok){console.error(p.error),process.exitCode=1;return}let m=await H(u);if(!m.ok){console.error(m.error),process.exitCode=1;return}let{model:h,modelPath:g}=m;if(h.variations.length===0){console.error(`Slice "${u}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let _=n?h.variations.find(e=>e.id===n):h.variations[0];if(!_){console.error(`Variation "${n}" not found in slice "${u}"\n`),console.error(`Available variations: ${h.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}_.primary||={};let v={type:`StructuredText`,config:{label:r??Y(f.type===`nested`?f.nestedFieldId:d),...i&&{placeholder:i},...a&&{single:a},...o&&{multi:o},...c&&{allowTargetBlank:!0}}};if(f.type===`nested`){let e=Zn(_.primary,f.groupId,_.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[f.nestedFieldId]){console.error(`Field "${f.nestedFieldId}" already exists in group "${f.groupId}"`),process.exitCode=1;return}e.group.config.fields[f.nestedFieldId]=v}else{for(let e of h.variations){if(e.primary?.[d]){console.error(`Field "${d}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[d]){console.error(`Field "${d}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}_.primary[d]=v}try{await s(g,J(h))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}f.type===`nested`?console.info(`Added field "${f.nestedFieldId}" (StructuredText) to group "${f.groupId}" in ${u}`):console.info(`Added field "${d}" (StructuredText) to "${_.id}" variation in ${u}`);try{await U({output:l}),console.info(`Updated types in ${l??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let y=await $();if(y?.framework){let e=Ns(y.framework),t=Ps(y.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function Is(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Ls(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Rs(){let{values:{help:t,variation:n,label:r,placeholder:i,option:a,default:o,types:c},positionals:[l,u]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},option:{type:`string`,multiple:!0},default:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a select (dropdown) field to an existing slice.
1797
1889
 
1798
1890
  USAGE
1799
1891
  prismic slice add-field select <slice-id> <field-id> [flags]
@@ -1816,7 +1908,7 @@ EXAMPLES
1816
1908
  prismic slice add-field select hero style --option "light" --option "dark" --default "light"
1817
1909
  prismic slice add-field select product size --option "small" --option "medium" --option "large" --label "Size"`);return}if(!l){console.error(`Missing required argument: slice-id
1818
1910
  `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}if(!u){console.error(`Missing required argument: field-id
1819
- `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let d=await G(l);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};for(let e of f.variations)if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}let h={type:`Select`,config:{label:r??J(u),...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};m.primary[u]=h;try{await s(p,q(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${u}" (Select) to "${m.id}" variation in ${l}`);try{await K({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function To(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
1911
+ `),console.error(`Usage: prismic slice add-field select <slice-id> <field-id>`),process.exitCode=1;return}let d=W(u),f=q(d);if(!f.ok){console.error(f.error),process.exitCode=1;return}let p=await H(l);if(!p.ok){console.error(p.error),process.exitCode=1;return}let{model:m,modelPath:h}=p;if(m.variations.length===0){console.error(`Slice "${l}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let g=n?m.variations.find(e=>e.id===n):m.variations[0];if(!g){console.error(`Variation "${n}" not found in slice "${l}"\n`),console.error(`Available variations: ${m.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}g.primary||={};let _={type:`Select`,config:{label:r??Y(d.type===`nested`?d.nestedFieldId:u),...i&&{placeholder:i},...a&&a.length>0&&{options:a},...o&&{default_value:o}}};if(d.type===`nested`){let e=Zn(g.primary,d.groupId,g.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[d.nestedFieldId]){console.error(`Field "${d.nestedFieldId}" already exists in group "${d.groupId}"`),process.exitCode=1;return}e.group.config.fields[d.nestedFieldId]=_}else{for(let e of m.variations){if(e.primary?.[u]){console.error(`Field "${u}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[u]){console.error(`Field "${u}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}g.primary[u]=_}try{await s(h,J(m))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}d.type===`nested`?console.info(`Added field "${d.nestedFieldId}" (Select) to group "${d.groupId}" in ${l}`):console.info(`Added field "${u}" (Select) to "${g.id}" variation in ${l}`);try{await U({output:c}),console.info(`Updated types in ${c??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let v=await $();if(v?.framework){let e=Is(v.framework),t=Ls(v.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}function zs(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`}}function Bs(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}async function Vs(){let{values:{help:t,variation:n,label:r,placeholder:i,types:a},positionals:[o,c]}=e({args:process.argv.slice(5),options:{variation:{type:`string`,short:`v`},label:{type:`string`,short:`l`},placeholder:{type:`string`,short:`p`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a timestamp (date and time) field to an existing slice.
1820
1912
 
1821
1913
  USAGE
1822
1914
  prismic slice add-field timestamp <slice-id> <field-id> [flags]
@@ -1837,7 +1929,7 @@ EXAMPLES
1837
1929
  prismic slice add-field timestamp event start_time --label "Event Start"
1838
1930
  prismic slice add-field timestamp schedule meeting_time --variation "detailed"`);return}if(!o){console.error(`Missing required argument: slice-id
1839
1931
  `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}if(!c){console.error(`Missing required argument: field-id
1840
- `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let l=await G(o);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l;if(u.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let f=n?u.variations.find(e=>e.id===n):u.variations[0];if(!f){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}f.primary||={};for(let e of u.variations)if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}let p={type:`Timestamp`,config:{label:r??J(c),...i&&{placeholder:i}}};f.primary[c]=p;try{await s(d,q(u))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added field "${c}" (Timestamp) to "${f.id}" variation in ${o}`);try{await K({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`"),console.info(" Run `prismic status` when done to find next steps")}async function Eo(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await mo();break;case`color`:await ho();break;case`date`:await go();break;case`embed`:await _o();break;case`geo-point`:await vo();break;case`image`:await yo();break;case`key-text`:await bo();break;case`link`:await xo();break;case`number`:await So();break;case`rich-text`:await Co();break;case`select`:await wo();break;case`timestamp`:await To();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
1932
+ `),console.error(`Usage: prismic slice add-field timestamp <slice-id> <field-id>`),process.exitCode=1;return}let l=W(c),u=q(l);if(!u.ok){console.error(u.error),process.exitCode=1;return}let d=await H(o);if(!d.ok){console.error(d.error),process.exitCode=1;return}let{model:f,modelPath:p}=d;if(f.variations.length===0){console.error(`Slice "${o}" has no variations.\n`),console.error(`Add a variation first before adding fields.`),process.exitCode=1;return}let m=n?f.variations.find(e=>e.id===n):f.variations[0];if(!m){console.error(`Variation "${n}" not found in slice "${o}"\n`),console.error(`Available variations: ${f.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}m.primary||={};let h={type:`Timestamp`,config:{label:r??Y(l.type===`nested`?l.nestedFieldId:c),...i&&{placeholder:i}}};if(l.type===`nested`){let e=Zn(m.primary,l.groupId,m.id);if(!e.ok){console.error(e.error),process.exitCode=1;return}if(e.group.config.fields[l.nestedFieldId]){console.error(`Field "${l.nestedFieldId}" already exists in group "${l.groupId}"`),process.exitCode=1;return}e.group.config.fields[l.nestedFieldId]=h}else{for(let e of f.variations){if(e.primary?.[c]){console.error(`Field "${c}" already exists in variation "${e.id}"`),process.exitCode=1;return}for(let[t,n]of Object.entries(e.primary??{}))if(G(n)&&n.config.fields[c]){console.error(`Field "${c}" already exists in group "${t}" in variation "${e.id}"`),process.exitCode=1;return}}m.primary[c]=h}try{await s(p,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}l.type===`nested`?console.info(`Added field "${l.nestedFieldId}" (Timestamp) to group "${l.groupId}" in ${o}`):console.info(`Added field "${c}" (Timestamp) to "${m.id}" variation in ${o}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add more fields with `prismic slice add-field`");let g=await $();if(g?.framework){let e=zs(g.framework),t=Bs(g.framework);console.info(` Run \`prismic docs fetch ${e}${t}\` to learn how to implement the slice's component`)}}async function Hs(){let{positionals:[t]}=e({args:process.argv.slice(4),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`boolean`:await as();break;case`color`:await cs();break;case`date`:await ds();break;case`embed`:await ms();break;case`geo-point`:await _s();break;case`group`:await bs();break;case`image`:await Cs();break;case`key-text`:await Es();break;case`link`:await ks();break;case`number`:await Ms();break;case`rich-text`:await Fs();break;case`select`:await Rs();break;case`timestamp`:await Vs();break;default:t&&(console.error(`Unknown field type: ${t}\n`),process.exitCode=1),console.info(`Add a field to an existing slice.
1841
1933
 
1842
1934
  USAGE
1843
1935
  prismic slice add-field <field-type> <slice-id> <field-id> [flags]
@@ -1848,6 +1940,7 @@ FIELD TYPES
1848
1940
  date Date picker
1849
1941
  embed Embed (oEmbed)
1850
1942
  geo-point Geographic coordinates
1943
+ group Repeatable group of fields
1851
1944
  image Image
1852
1945
  key-text Single-line text
1853
1946
  link Any link type
@@ -1866,7 +1959,7 @@ EXAMPLES
1866
1959
  prismic slice add-field key-text my_slice title --label "Title"
1867
1960
  prismic slice add-field link my_slice cta --allow-text
1868
1961
  prismic slice add-field rich-text my_slice body --multi "paragraph,heading2,strong,em"
1869
- prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function Do(){let{values:{help:t,name:n,"copy-from":r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
1962
+ prismic slice add-field select my_slice layout --option "full" --option "sidebar"`)}}async function Us(){let{values:{help:t,name:n,"copy-from":r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{name:{type:`string`},"copy-from":{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a new variation to a slice.
1870
1963
 
1871
1964
  USAGE
1872
1965
  prismic slice add-variation <slice-id> <variation-id> [flags]
@@ -1886,7 +1979,26 @@ EXAMPLES
1886
1979
  prismic slice add-variation MySlice withImage --name "With Image"
1887
1980
  prismic slice add-variation MySlice withImage --copy-from default`);return}if(!a){console.error(`Missing required argument: slice-id
1888
1981
  `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: variation-id
1889
- `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let c=await G(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.some(e=>e.id===o)){console.error(`Variation "${o}" already exists in slice "${a}"`),process.exitCode=1;return}let d;if(r){let e=l.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d={...structuredClone(e),id:o,name:n??jn(o)}}else d={id:o,name:n??jn(o),description:o,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let f={...l,variations:[...l.variations,d]};try{await s(u,q(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added variation "${o}" to slice "${a}"`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Oo(){let{values:{help:t,name:r,types:i},positionals:[a]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
1982
+ `),console.error(`Usage: prismic slice add-variation <slice-id> <variation-id>`),process.exitCode=1;return}let c=await H(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;if(l.variations.some(e=>e.id===o)){console.error(`Variation "${o}" already exists in slice "${a}"`),process.exitCode=1;return}let d;if(r){let e=l.variations.find(e=>e.id===r);if(!e){console.error(`Source variation not found: ${r}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}d={...structuredClone(e),id:o,name:n??In(o)}}else d={id:o,name:n??In(o),description:o,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}};let f={...l,variations:[...l.variations,d]};try{await s(u,J(f))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Added variation "${o}" to slice "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}const Ws=N({uploadEndpoint:I(),requiredFormDataFields:F(I(),I()),imgixEndpoint:I()});async function Gs(e){let{data:t,repo:n,sliceId:r,variationId:i,filename:a}=e,o=await Z(`https://acl-provider.prismic.io/create`,{method:`POST`,body:{},schema:Ws});if(!o.ok)throw Error(`Failed to get upload credentials from Prismic`);let{uploadEndpoint:s,requiredFormDataFields:c,imgixEndpoint:u}=o.value,d=l(`md5`).update(t).digest(`hex`),f=m(a).toLowerCase().slice(1)||`png`,p=`${n}/shared-slices/${r}/${i}/${d}.${f}`,h=new FormData;for(let[e,t]of Object.entries(c))h.append(e,t);h.append(`key`,p),h.append(`Content-Type`,Ks(f)),h.append(`file`,new Blob([new Uint8Array(t)],{type:Ks(f)}),a);let g=await fetch(s,{method:`POST`,body:h});if(!g.ok){let e=await g.text();throw Error(`Failed to upload screenshot: ${e}`)}return`${u}/${p}?auto=compress,format`}function Ks(e){switch(e){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;default:return`image/png`}}async function qs(){let{values:{help:t,variation:n,repo:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,short:`v`,default:`default`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set a screenshot for a slice variation.
1983
+
1984
+ USAGE
1985
+ prismic slice set-screenshot <slice-id> <image-path> [flags]
1986
+
1987
+ ARGUMENTS
1988
+ slice-id Slice identifier (required)
1989
+ image-path Path to the image file (required)
1990
+
1991
+ FLAGS
1992
+ -v, --variation string Variation ID (default: "default")
1993
+ -r, --repo string Repository name (uses config if not provided)
1994
+ -h, --help Show help for command
1995
+
1996
+ EXAMPLES
1997
+ prismic slice set-screenshot MySlice ./screenshot.png
1998
+ prismic slice set-screenshot MySlice ./screenshot.png --variation dark
1999
+ prismic slice set-screenshot MySlice ./screenshot.png --repo my-repo`);return}if(!a){console.error(`Missing required argument: slice-id
2000
+ `),console.error(`Usage: prismic slice set-screenshot <slice-id> <image-path>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: image-path
2001
+ `),console.error(`Usage: prismic slice set-screenshot <slice-id> <image-path>`),process.exitCode=1;return}if(!await B()){console.error(`You must be logged in to set a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let c=i??await X();if(!c){console.error(`Could not determine repository.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let l=await H(a);if(!l.ok){console.error(l.error),process.exitCode=1;return}let{model:u,modelPath:d}=l,f=u.variations.findIndex(e=>e.id===n);if(f===-1){console.error(`Variation "${n}" not found in slice "${a}"`),console.error(`Available variations: ${u.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let p;try{p=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read image file: ${e.message}`):console.error(`Failed to read image file`),process.exitCode=1;return}let m;try{m=await Gs({data:p,repo:c,sliceId:a,variationId:n??`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}u.variations[f].imageUrl=m;try{await s(d,J(u))}catch(e){e instanceof Error?console.error(`Failed to update slice model: ${e.message}`):console.error(`Failed to update slice model`),process.exitCode=1;return}console.info(`Screenshot set for slice "${a}" variation "${n}"`),console.info(`URL: ${m}`)}async function Js(){let{values:{help:t,name:i,types:a,screenshot:o,repo:c},positionals:[l]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},screenshot:{type:`string`},repo:{type:`string`,short:`r`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new slice in a Prismic project.
1890
2002
 
1891
2003
  USAGE
1892
2004
  prismic slice create <id> [flags]
@@ -1895,12 +2007,14 @@ ARGUMENTS
1895
2007
  id Slice identifier (required)
1896
2008
 
1897
2009
  FLAGS
1898
- -n, --name string Display name for the slice
1899
- --types string Output file for generated types (default: "prismicio-types.d.ts")
1900
- -h, --help Show help for command
2010
+ -n, --name string Display name for the slice
2011
+ --screenshot string Path to screenshot image for default variation
2012
+ -r, --repo string Repository name (required for screenshot)
2013
+ --types string Output file for generated types (default: "prismicio-types.d.ts")
2014
+ -h, --help Show help for command
1901
2015
 
1902
2016
  LEARN MORE
1903
- Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!a){console.error(`Missing required argument: id`),process.exitCode=1;return}let o={id:a,type:`SharedSlice`,name:r??Mo(a),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:``,docURL:``,version:`initial`,primary:{},items:{}}]},c=await ko(),l=new URL(Mo(o.name)+`/`,c),u=new URL(`model.json`,l);try{await n(new URL(`.`,u),{recursive:!0}),await s(u,q(o))}catch(e){e instanceof Error?console.error(`Failed to create slice: ${e.message}`):console.error(`Failed to create slice`),process.exitCode=1;return}console.info(`Created slice at ${u.href}`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic slice add-field`")}async function ko(){let e=await jo(),t=await W(`package.json`);switch(e){case`next`:if(await En(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await En(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const Ao=F({dependencies:I(L(R(),R()))});async function jo(){let e=await W(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=hn(Ao,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Mo(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function No(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all slices in a Prismic project.
2017
+ Use \`prismic slice <command> --help\` for more information about a command.`);return}if(!l){console.error(`Missing required argument: id`),process.exitCode=1;return}let u;if(o){if(!await B()){console.error(`You must be logged in to upload a screenshot.`),console.error("Run `prismic login` to authenticate."),process.exitCode=1;return}let e=c??await X();if(!e){console.error(`Could not determine repository for screenshot upload.`),console.error(`Use --repo flag or run from a directory with prismic.config.json`),process.exitCode=1;return}let t;try{t=await r(o)}catch(e){e instanceof Error?console.error(`Failed to read screenshot file: ${e.message}`):console.error(`Failed to read screenshot file`),process.exitCode=1;return}try{u=await Gs({data:t,repo:e,sliceId:l,variationId:`default`,filename:o})}catch(e){e instanceof Error?console.error(`Failed to upload screenshot: ${e.message}`):console.error(`Failed to upload screenshot`),process.exitCode=1;return}}let d={id:l,type:`SharedSlice`,name:i??Qs(l),description:``,variations:[{id:`default`,name:`Default`,description:`Default`,imageUrl:u??``,docURL:``,version:`initial`,primary:{},items:{}}]},f=await Ys(),p=new URL(Qs(d.name)+`/`,f),m=new URL(`model.json`,p);try{await n(new URL(`.`,m),{recursive:!0}),await s(m,J(d))}catch(e){e instanceof Error?console.error(`Failed to create slice: ${e.message}`):console.error(`Failed to create slice`),process.exitCode=1;return}console.info(`Created slice at ${m.href}`);try{await U({output:a}),console.info(`Updated types in ${a??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}console.info(),console.info("Next: Add fields with `prismic slice add-field`")}async function Ys(){let e=await Zs(),t=await V(`package.json`);switch(e){case`next`:if(await jn(new URL(`src`,t)))return new URL(`src/slices/`,t);case`nuxt`:if(await jn(new URL(`app`,t)))return new URL(`app/slices/`,t);case`sveltekit`:return new URL(`src/slices/`,t)}return new URL(`slices/`,t)}const Xs=N({dependencies:P(F(I(),I()))});async function Zs(){let e=await V(`package.json`);if(e)try{let t=await r(e,`utf8`),{dependencies:n={}}=yn(Xs,JSON.parse(t));if(`next`in n)return`next`;if(`nuxt`in n)return`nuxt`;if(`@sveltejs/kit`in n)return`sveltekit`}catch{}}function Qs(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function $s(){let{values:{help:t,json:n}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all slices in a Prismic project.
1904
2018
 
1905
2019
  USAGE
1906
2020
  prismic slice list [flags]
@@ -1911,7 +2025,7 @@ FLAGS
1911
2025
 
1912
2026
  EXAMPLES
1913
2027
  prismic slice list
1914
- prismic slice list --json`);return}let a=await On(),o;try{o=await i(a,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}let s=[];for(let e of o){let t=new URL(`${e}/model.json`,a);try{let e=await r(t,`utf8`),n=B(Dn,JSON.parse(e));n.success&&s.push({id:n.output.id,name:n.output.name})}catch{}}if(s.length===0){n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}if(n)console.info(JSON.stringify(s,null,2));else{console.info(`ID NAME`);for(let e of s)console.info(`${e.id}\t${e.name}`)}}async function Po(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all variations for a slice.
2028
+ prismic slice list --json`);return}let a=await Nn(),o;try{o=await i(a,{withFileTypes:!1})}catch{n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}let s=[];for(let e of o){let t=new URL(`${e}/model.json`,a);try{let e=await r(t,`utf8`),n=R(Mn,JSON.parse(e));n.success&&s.push({id:n.output.id,name:n.output.name})}catch{}}if(s.length===0){n?console.info(JSON.stringify([])):console.info(`No slices found.`);return}if(n)console.info(JSON.stringify(s,null,2));else{console.info(`ID NAME`);for(let e of s)console.info(`${e.id}\t${e.name}`)}}async function ec(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`List all variations for a slice.
1915
2029
 
1916
2030
  USAGE
1917
2031
  prismic slice list-variations <slice-id> [flags]
@@ -1926,7 +2040,7 @@ FLAGS
1926
2040
  EXAMPLES
1927
2041
  prismic slice list-variations MySlice
1928
2042
  prismic slice list-variations MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
1929
- `),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await G(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i,o=a.variations.map(e=>({id:e.id,name:e.name}));if(n){console.info(JSON.stringify(o,null,2));return}console.info(`ID NAME`);for(let e of o)console.info(`${e.id}\t${e.name}`)}async function Fo(){let{values:{help:t,y:n,types:r},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
2043
+ `),console.error(`Usage: prismic slice list-variations <slice-id>`),process.exitCode=1;return}let i=await H(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i,o=a.variations.map(e=>({id:e.id,name:e.name}));if(n){console.info(JSON.stringify(o,null,2));return}console.info(`ID NAME`);for(let e of o)console.info(`${e.id}\t${e.name}`)}async function tc(){let{values:{help:t,y:n,types:r},positionals:[i]}=e({args:process.argv.slice(4),options:{y:{type:`boolean`,short:`y`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a slice from the project.
1930
2044
 
1931
2045
  USAGE
1932
2046
  prismic slice remove <slice-id> [flags]
@@ -1942,7 +2056,7 @@ FLAGS
1942
2056
  EXAMPLES
1943
2057
  prismic slice remove MySlice
1944
2058
  prismic slice remove MySlice -y`);return}if(!i){console.error(`Missing required argument: slice-id
1945
- `),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let a=await G(i);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{modelPath:s}=a,c=new URL(`.`,s);if(!n){console.error(`Refusing to remove slice "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove slice: ${e.message}`):console.error(`Failed to remove slice`),process.exitCode=1;return}console.info(`Removed slice "${i}"`);try{await K({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Io(){let{values:{help:t,variation:n,zone:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
2059
+ `),console.error(`Usage: prismic slice remove <slice-id>`),process.exitCode=1;return}let a=await H(i);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{modelPath:s}=a,c=new URL(`.`,s);if(!n){console.error(`Refusing to remove slice "${i}" (this will delete the entire directory).`),console.error(`Re-run with -y to confirm.`),process.exitCode=1;return}try{await o(c,{recursive:!0})}catch(e){e instanceof Error?console.error(`Failed to remove slice: ${e.message}`):console.error(`Failed to remove slice`),process.exitCode=1;return}console.info(`Removed slice "${i}"`);try{await U({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function nc(){let{values:{help:t,variation:n,zone:r,types:i},positionals:[a,o]}=e({args:process.argv.slice(4),options:{variation:{type:`string`,default:`default`},zone:{type:`string`,default:`primary`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a field from a slice variation.
1946
2060
 
1947
2061
  USAGE
1948
2062
  prismic slice remove-field <slice-id> <field-id> [flags]
@@ -1962,7 +2076,7 @@ EXAMPLES
1962
2076
  prismic slice remove-field MySlice title --variation withImage
1963
2077
  prismic slice remove-field MySlice item_title --zone items`);return}if(!a){console.error(`Missing required argument: slice-id
1964
2078
  `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: field-id
1965
- `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(r!==`primary`&&r!==`items`){console.error(`Invalid zone: ${r}. Must be "primary" or "items".`),process.exitCode=1;return}let c=await G(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c,d=l.variations.find(e=>e.id===n);if(!d){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let f=r===`primary`?d.primary:d.items;if(!f||!(o in f)){console.error(`Field "${o}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete f[o];try{await s(u,q(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed field "${o}" from ${r} zone in variation "${n}" of slice "${a}"`);try{await K({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Lo(){let{values:{help:t,types:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
2079
+ `),console.error(`Usage: prismic slice remove-field <slice-id> <field-id>`),process.exitCode=1;return}if(r!==`primary`&&r!==`items`){console.error(`Invalid zone: ${r}. Must be "primary" or "items".`),process.exitCode=1;return}let c=await H(a);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c,d=l.variations.find(e=>e.id===n);if(!d){console.error(`Variation not found: ${n}`),console.error(`Available variations: ${l.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}let f=r===`primary`?d.primary:d.items;if(!f||!(o in f)){console.error(`Field "${o}" not found in ${r} zone of variation "${n}"`),process.exitCode=1;return}delete f[o];try{await s(u,J(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed field "${o}" from ${r} zone in variation "${n}" of slice "${a}"`);try{await U({output:i}),console.info(`Updated types in ${i??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function rc(){let{values:{help:t,types:n},positionals:[r,i]}=e({args:process.argv.slice(4),options:{types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a variation from a slice.
1966
2080
 
1967
2081
  USAGE
1968
2082
  prismic slice remove-variation <slice-id> <variation-id> [flags]
@@ -1978,7 +2092,7 @@ FLAGS
1978
2092
  EXAMPLES
1979
2093
  prismic slice remove-variation MySlice withImage`);return}if(!r){console.error(`Missing required argument: slice-id
1980
2094
  `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: variation-id
1981
- `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let a=await G(r);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{model:o,modelPath:c}=a;if(!o.variations.some(e=>e.id===i)){console.error(`Variation not found: ${i}`),console.error(`Available variations: ${o.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let l={...o,variations:o.variations.filter(e=>e.id!==i)};try{await s(c,q(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed variation "${i}" from slice "${r}"`);try{await K({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function Ro(){let{values:{help:t,id:n,types:r},positionals:[i,o]}=e({args:process.argv.slice(4),options:{id:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
2095
+ `),console.error(`Usage: prismic slice remove-variation <slice-id> <variation-id>`),process.exitCode=1;return}let a=await H(r);if(!a.ok){console.error(a.error),process.exitCode=1;return}let{model:o,modelPath:c}=a;if(!o.variations.some(e=>e.id===i)){console.error(`Variation not found: ${i}`),console.error(`Available variations: ${o.variations.map(e=>e.id).join(`, `)}`),process.exitCode=1;return}if(o.variations.length===1){console.error(`Cannot remove the last variation from a slice.`),process.exitCode=1;return}let l={...o,variations:o.variations.filter(e=>e.id!==i)};try{await s(c,J(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}console.info(`Removed variation "${i}" from slice "${r}"`);try{await U({output:n}),console.info(`Updated types in ${n??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function ic(){let{values:{help:t,id:n,types:r},positionals:[i,o]}=e({args:process.argv.slice(4),options:{id:{type:`string`},types:{type:`string`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Rename a slice (updates name field, optionally id and directory).
1982
2096
 
1983
2097
  USAGE
1984
2098
  prismic slice rename <slice-id> <new-name> [flags]
@@ -1996,7 +2110,7 @@ EXAMPLES
1996
2110
  prismic slice rename MySlice "My New Name"
1997
2111
  prismic slice rename MySlice "My New Name" --id NewSliceId`);return}if(!i){console.error(`Missing required argument: slice-id
1998
2112
  `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}if(!o){console.error(`Missing required argument: new-name
1999
- `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let c=await G(i);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;l.name=o,n&&(l.id=n);try{await s(u,q(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}if(n){let e=await On(),t=new URL(`.`,u),r=new URL(jn(o)+`/`,e);if(t.href!==r.href)try{await a(t,r),console.info(`Renamed slice "${i}" to "${n}" (${o})`),console.info(`Moved directory to ${r.href}`)}catch(e){e instanceof Error?console.error(`Failed to rename directory: ${e.message}`):console.error(`Failed to rename directory`),process.exitCode=1;return}else console.info(`Renamed slice "${i}" to "${n}" (${o})`)}else console.info(`Renamed slice "${i}" to "${o}"`);try{await K({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function zo(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific slice.
2113
+ `),console.error(`Usage: prismic slice rename <slice-id> <new-name>`),process.exitCode=1;return}let c=await H(i);if(!c.ok){console.error(c.error),process.exitCode=1;return}let{model:l,modelPath:u}=c;l.name=o,n&&(l.id=n);try{await s(u,J(l))}catch(e){e instanceof Error?console.error(`Failed to update slice: ${e.message}`):console.error(`Failed to update slice`),process.exitCode=1;return}if(n){let e=await Nn(),t=new URL(`.`,u),r=new URL(In(o)+`/`,e);if(t.href!==r.href)try{await a(t,r),console.info(`Renamed slice "${i}" to "${n}" (${o})`),console.info(`Moved directory to ${r.href}`)}catch(e){e instanceof Error?console.error(`Failed to rename directory: ${e.message}`):console.error(`Failed to rename directory`),process.exitCode=1;return}else console.info(`Renamed slice "${i}" to "${n}" (${o})`)}else console.info(`Renamed slice "${i}" to "${o}"`);try{await U({output:r}),console.info(`Updated types in ${r??`prismicio-types.d.ts`}`)}catch(e){console.warn(`Could not generate types: ${e instanceof Error?e.message:e}`)}}async function ac(){let{values:{help:t,json:n},positionals:[r]}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a specific slice.
2000
2114
 
2001
2115
  USAGE
2002
2116
  prismic slice view <slice-id> [flags]
@@ -2011,8 +2125,8 @@ FLAGS
2011
2125
  EXAMPLES
2012
2126
  prismic slice view MySlice
2013
2127
  prismic slice view MySlice --json`);return}if(!r){console.error(`Missing required argument: slice-id
2014
- `),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await G(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i;if(n){console.info(JSON.stringify(a,null,2));return}console.info(`ID: ${a.id}`),console.info(`Name: ${a.name}`),a.description&&console.info(`Description: ${a.description}`),console.info(`Variations: ${a.variations.length}`),console.info(`
2015
- Variations:`);for(let e of a.variations){let t=Object.keys(e.primary??{}).length,n=Object.keys(e.items??{}).length;console.info(` - ${e.id} (${e.name}): ${t} primary fields, ${n} items fields`)}}async function Bo(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Oo();break;case`list`:await No();break;case`view`:await zo();break;case`rename`:await Ro();break;case`remove`:await Fo();break;case`add-field`:await Eo();break;case`remove-field`:await Io();break;case`add-variation`:await Do();break;case`remove-variation`:await Lo();break;case`list-variations`:await Po();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
2128
+ `),console.error(`Usage: prismic slice view <slice-id>`),process.exitCode=1;return}let i=await H(r);if(!i.ok){console.error(i.error),process.exitCode=1;return}let{model:a}=i;if(n){console.info(JSON.stringify(a,null,2));return}console.info(`ID: ${a.id}`),console.info(`Name: ${a.name}`),a.description&&console.info(`Description: ${a.description}`),console.info(`Variations: ${a.variations.length}`),console.info(`
2129
+ Variations:`);for(let e of a.variations){let t=Object.keys(e.primary??{}).length,n=Object.keys(e.items??{}).length;console.info(` - ${e.id} (${e.name}): ${t} primary fields, ${n} items fields`),e.imageUrl&&console.info(` Screenshot: ${e.imageUrl}`)}}async function oc(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`create`:await Js();break;case`list`:await $s();break;case`view`:await ac();break;case`rename`:await ic();break;case`remove`:await tc();break;case`add-field`:await Hs();break;case`remove-field`:await nc();break;case`add-variation`:await Us();break;case`remove-variation`:await rc();break;case`list-variations`:await ec();break;case`set-screenshot`:await qs();break;default:t&&(console.error(`Unknown slice subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage slices in a Prismic project.
2016
2130
 
2017
2131
  USAGE
2018
2132
  prismic slice <command> [flags]
@@ -2028,12 +2142,13 @@ COMMANDS
2028
2142
  add-variation Add a variation to a slice
2029
2143
  remove-variation Remove a variation from a slice
2030
2144
  list-variations List all variations of a slice
2145
+ set-screenshot Set a screenshot for a slice variation
2031
2146
 
2032
2147
  FLAGS
2033
2148
  -h, --help Show help for command
2034
2149
 
2035
2150
  LEARN MORE
2036
- Use \`prismic slice <command> --help\` for more information about a command.`)}}const Vo=F({dependencies:I(L(R(),R())),devDependencies:I(L(R(),R()))});async function Ho(){let e=await W(`package.json`);if(!e)return;let t=new URL(`.`,e),n;try{let t=await r(e,`utf8`),{dependencies:i={},devDependencies:a={}}=hn(Vo,JSON.parse(t)),o={...i,...a};`next`in o?n=`next`:`nuxt`in o?n=`nuxt`:`@sveltejs/kit`in o&&(n=`sveltekit`)}catch{}let i=!1;return n===`next`||n===`sveltekit`?i=await En(new URL(`src/`,t)):n===`nuxt`&&(i=await En(new URL(`app/`,t))),{framework:n,hasSrcDir:i,projectRoot:t}}function Uo(e){switch(e){case`next`:return[`@prismicio/client`,`@prismicio/react`,`@prismicio/next`];case`nuxt`:return[`@nuxtjs/prismic`];case`sveltekit`:return[`@prismicio/client`,`@prismicio/svelte`];default:return[`@prismicio/client`]}}function Wo(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/prismicio.ts`:`prismicio.ts`;case`nuxt`:return null;case`sveltekit`:return`src/lib/prismicio.ts`;default:return`prismicio.ts`}}function Go(e){switch(e.framework){case`next`:return e.hasSrcDir?`src/slices/`:`slices/`;case`nuxt`:return e.hasSrcDir?`app/slices/`:`slices/`;case`sveltekit`:return`src/lib/slices/`;default:return`slices/`}}function Ko(e){switch(e){case`next`:return[`.tsx`,`.ts`,`.jsx`,`.js`];case`nuxt`:return[`.vue`];case`sveltekit`:return[`.svelte`];default:return[`.tsx`,`.ts`,`.jsx`,`.js`]}}function qo(e,t){switch(e.framework){case`next`:{let n=e.hasSrcDir?`src/app`:`app`;return t===`/slice-simulator`?{path:`${n}/slice-simulator/page`,extensions:[`.tsx`,`.ts`,`.jsx`,`.js`]}:t===`/api/preview`?{path:`${n}/api/preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/exit-preview`?{path:`${n}/api/exit-preview/route`,extensions:[`.ts`,`.js`]}:t===`/api/revalidate`?{path:`${n}/api/revalidate/route`,extensions:[`.ts`,`.js`]}:null}case`nuxt`:return t===`/slice-simulator`?{path:`pages/slice-simulator`,extensions:[`.vue`]}:null;case`sveltekit`:return t===`/slice-simulator`?{path:`src/routes/slice-simulator/+page`,extensions:[`.svelte`]}:t===`/api/preview`?{path:`src/routes/api/preview/+server`,extensions:[`.ts`,`.js`]}:null;default:return null}}const Jo={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function Yo(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a webhook in a Prismic repository.
2151
+ Use \`prismic slice <command> --help\` for more information about a command.`)}}const sc={documentsPublished:`document.published`,documentsUnpublished:`document.unpublished`,releasesCreated:`release.created`,releasesUpdated:`release.updated`,tagsCreated:`tag.created`,tagsDeleted:`tag.deleted`};async function cc(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`View details of a webhook in a Prismic repository.
2037
2152
 
2038
2153
  By default, this command reads the repository from prismic.config.json at the
2039
2154
  project root.
@@ -2049,10 +2164,10 @@ FLAGS
2049
2164
  -h, --help Show help for command
2050
2165
 
2051
2166
  LEARN MORE
2052
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Xo();return}let i=await $(n);if(!i.ok){i.error instanceof Z?Xo():(console.error(`Failed to view webhook: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let{config:o}=a;console.info(`URL: ${o.url}`),console.info(`Name: ${o.name||`(none)`}`),console.info(`Status: ${o.active?`enabled`:`disabled`}`),console.info(`Secret: ${o.secret?`(set)`:`(none)`}`);let s=[];for(let[e,t]of Object.entries(Jo))o[e]&&s.push(t);if(console.info(`Triggers: ${s.length>0?s.join(`, `):`(none)`}`),Object.keys(o.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(o.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}function Xo(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Zo=F({config:F({_id:R(),url:R(),active:P(),name:pn(R()),secret:pn(R()),headers:L(R(),R()),documentsPublished:P(),documentsUnpublished:P(),releasesCreated:P(),releasesUpdated:P(),tagsCreated:P(),tagsDeleted:P()})});async function $(e){return await X(new URL(`/app/settings/webhooks`,await V(e)),{schema:N(Zo)})}function Qo(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`;default:return``}}function $o(e,t){return e?` (run \`prismic docs ${t?`${e}${t}`:e}\`)`:``}function es(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}function ts(e){switch(e){case`next`:return`#set-up-previews-in-next-js`;case`sveltekit`:return`#set-up-previews-in-sveltekit`;default:return``}}function ns(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}function rs(e,t,n,r,i,a){let o=Qo(t.framework),s=e.find(e=>e.title===`Setup`),c=s?.items.filter(e=>!e.done&&e.hint===`not installed`);if(c&&c.length>0)return{message:`Install Prismic packages with 'npm install ${c.map(e=>e.label).join(` `)}'`};let l=s?.items.find(e=>!e.done&&e.hint?.includes(`client`));if(l)return{message:`Create a ${l.label} file${$o(o,es(t.framework))}`};let u=e.find(e=>e.title===`Preview`);if(u){if(u.items.find(e=>e.label===`/slice-simulator route`&&!e.done))return{message:`Create the /slice-simulator route${$o(o,`#set-up-live-previewing`)}`};if(u.items.find(e=>e.label===`/api/preview endpoint`&&!e.done))return{message:`Create the /api/preview route${$o(o,ts(t.framework))}`};if(u.items.find(e=>e.label===`/api/exit-preview endpoint`&&!e.done))return{message:`Create the /api/exit-preview route${$o(o,ts(t.framework))}`};if(u.items.find(e=>e.label===`Slice simulator URL`&&!e.done))return{message:`Configure the slice simulator URL with 'prismic preview set-simulator'`};if(u.items.find(e=>e.label===`Preview environment`&&!e.done))return{message:`Add a preview environment with 'prismic preview add'`}}if(n.some(e=>e.status===`to_pull`)||r.some(e=>e.status===`to_pull`))return{message:`Pull remote models with 'prismic pull'`};if(a.length>0){let e=[...a].sort()[0];return{message:`Connect ${e} to a page type with 'prismic page-type connect-slice <type-id> ${e}'`}}if(n.some(e=>e.status===`to_push`)||r.some(e=>e.status===`to_push`))return{message:`Push local models with 'prismic push'`};if(i.length>0){let e=[...i].sort()[0];return{message:`Implement the ${e} slice component at ${`${Go(t)}${e}/index${Ko(t.framework)[0]}`}${$o(o,ns(t.framework))}`}}let d=e.find(e=>e.title===`Deployment`);if(d){if(d.items.find(e=>e.label===`/api/revalidate endpoint`&&!e.done))return{message:`Create the /api/revalidate route for ISR${$o(o,`#handle-content-changes`)}`};if(d.items.find(e=>e.label===`Revalidation webhook`&&!e.done))return{message:`Create a revalidation webhook with 'prismic webhook create'`}}}async function is(){let{values:{help:t,repo:n=await Y()}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the status of the current Prismic project.
2167
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){lc();return}let i=await dc(n);if(!i.ok){i.error instanceof Q?lc():(console.error(`Failed to view webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let{config:o}=a;console.info(`URL: ${o.url}`),console.info(`Name: ${o.name||`(none)`}`),console.info(`Status: ${o.active?`enabled`:`disabled`}`),console.info(`Secret: ${o.secret?`(set)`:`(none)`}`);let s=[];for(let[e,t]of Object.entries(sc))o[e]&&s.push(t);if(console.info(`Triggers: ${s.length>0?s.join(`, `):`(none)`}`),Object.keys(o.headers).length>0){console.info(`Headers:`);for(let[e,t]of Object.entries(o.headers))console.info(` ${e}: ${t}`)}else console.info(`Headers: (none)`)}function lc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const uc=N({config:N({_id:I(),url:I(),active:M(),name:_n(I()),secret:_n(I()),headers:F(I(),I()),documentsPublished:M(),documentsUnpublished:M(),releasesCreated:M(),releasesUpdated:M(),tagsCreated:M(),tagsDeleted:M()})});async function dc(e){return await Z(new URL(`/app/settings/webhooks`,await z(e)),{schema:j(uc)})}function fc(e){switch(e){case`next`:return`nextjs/with-cli`;case`nuxt`:return`nuxt/with-cli`;case`sveltekit`:return`sveltekit/with-cli`;default:return``}}function pc(e,t){return e?`\`prismic docs fetch ${t?`${e}${t}`:e}\``:``}function mc(e){switch(e){case`nuxt`:return`#configure-the-modules-prismic-client`;default:return`#set-up-a-prismic-client`}}function hc(e){switch(e){case`next`:return`#set-up-previews-in-next-js`;case`sveltekit`:return`#set-up-previews-in-sveltekit`;default:return``}}function gc(e){switch(e){case`nuxt`:return`#write-vue-components`;case`sveltekit`:return`#write-svelte-components`;default:return`#write-react-components`}}function _c(e,t){let n=[],r=fc(t.framework),i=e.filter(e=>!e.done&&e.hint===`not installed`);if(i.length>0){let e=i.map(e=>e.label).join(` `);n.push({action:`Install dependencies: Run \`npm install ${e}\``})}if(e.find(e=>!e.done&&e.hint?.includes(`client`))){let e=pc(r,mc(t.framework));n.push({action:`Create Prismic client file: Run ${e} and create the file as shown`})}return n}function vc(e){let t=[],n=e.some(e=>e.status===`to_push`),r=e.some(e=>e.status===`to_pull`);return n&&t.push({action:"Push local models to Prismic: Run `prismic push`"}),r&&t.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),t}function yc(e,t,n,r){let i=[],a=fc(r.framework);if(t.length>0){let e=pc(a,gc(r.framework));i.push({action:`Implement slice components: Run ${e} and create each component file`})}let o=e.some(e=>e.status===`to_pull`),s=e.some(e=>e.status===`to_push`);if(o&&i.push({action:"Pull remote models from Prismic: Run `prismic pull`"}),n.length>0){let e=[...n].sort()[0];i.push({action:`Connect slice to page type: Run \`prismic page-type connect-slice <type-id> ${e}\``})}return s&&i.push({action:"Push local models to Prismic: Run `prismic push`"}),i}function bc(e,t){let n=[],r=fc(t.framework);if(e.find(e=>e.label===`/slice-simulator route`&&!e.done)){let e=pc(r,`#set-up-live-previewing`);n.push({action:`Create /slice-simulator route: Run ${e} and create the route file as shown`})}e.find(e=>e.label===`Slice simulator URL`&&!e.done)&&n.push({action:"Configure slice simulator URL: Run `prismic preview set-simulator`"});let i=e.find(e=>e.label===`/api/preview endpoint`&&!e.done),a=e.find(e=>e.label===`/api/exit-preview endpoint`&&!e.done);if(i||a){let e=pc(r,hc(t.framework));n.push({action:`Create preview endpoints: Run ${e} and create the endpoint files as shown`})}return e.find(e=>e.label===`Preview environment`&&!e.done)&&n.push({action:"Add preview environment: Run `prismic preview add`"}),n}function xc(e,t){let n=[],r=fc(t.framework);if(e.find(e=>e.label===`/api/revalidate endpoint`&&!e.done)){let e=pc(r,`#handle-content-changes`);n.push({action:`Create /api/revalidate endpoint: Run ${e} and create the endpoint as shown`})}return e.find(e=>e.label===`Revalidation webhook`&&!e.done)&&n.push({action:"Create revalidation webhook: Run `prismic webhook create`"}),n}async function Sc(){let{values:{help:t,repo:n=await X()}}=e({args:process.argv.slice(3),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`Show the status of the current Prismic project.
2053
2168
 
2054
- Includes a "Next:" step showing the most important action to take based on
2055
- project state.
2169
+ Each section with incomplete items includes "Next steps:" with actionable
2170
+ instructions.
2056
2171
 
2057
2172
  By default, this command reads the repository from prismic.config.json at the
2058
2173
  project root.
@@ -2065,7 +2180,7 @@ FLAGS
2065
2180
  -h, --help Show help for command
2066
2181
 
2067
2182
  LEARN MORE
2068
- Use \`prismic <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}let r=await Ho();if(!r){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let[i,a,o,s,c,l,u,d]=await Promise.all([ss(n),ls(n),$(n),In(),Pn(n),Ln(),Fn(n),ds(r)]),f=await V(n);console.info(`Repository: ${n}`),console.info(`URL: ${f.href}`),console.info(``);let p=[],m=[],h=[],g=[],_=[],v=await fs(r,d);if(p.push(v),s.ok&&c.ok){let{pageTypes:e,customTypes:t,allTypeStatuses:n}=hs(s.value,c.value);p.push(e),p.push(t),m=n}if(l.ok&&u.ok){let{section:e,statuses:t,missingComponents:n,slicesReadyToConnect:i}=await ys(l.value,u.value,r,s.ok?s.value:[]);p.push(e),h=t,g=n,_=i}let y=await Ss(r,a.ok?a.value:void 0,i.ok?i.value.simulator_url:void 0);if(p.push(y),r.framework===`next`){let e=await ws(r,o.ok?o.value:[]);p.push(e)}for(let e of p)as(e);let b=rs(p,r,m,h,g,_);b&&console.info(`Next: ${b.message}`)}function as(e){let t=e.items.filter(e=>!e.done).length,n=t>0?`${e.title} (${t} remaining)`:e.title;console.info(n);let r=e.items.filter(e=>e.done),i=e.items.filter(e=>!e.done);if(r.length>0)if(r.length===1){let e=r[0],t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ✓ ${e.label}${t}`)}else{let e=r.map(e=>e.label).join(`, `),t=r.every(e=>e.hint===r[0].hint)&&r[0].hint?` \u2014 ${r[0].hint}`:``;console.info(` ✓ ${e}${t}`)}for(let e of i){let t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ○ ${e.label}${t}`)}console.info(``)}const os=F({simulator_url:I(R())});async function ss(e){let t=await X(new URL(`/core/repository`,await V(e)),{schema:os});return t.ok?{ok:!0,value:t.value}:{ok:!1}}const cs=F({results:N(F({id:R(),label:R(),url:R()}))});async function ls(e){let t=await X(new URL(`/core/repository/preview_configs`,await V(e)),{schema:cs});return t.ok?{ok:!0,value:t.value.results}:{ok:!1}}const us=F({dependencies:I(L(R(),R())),devDependencies:I(L(R(),R()))});async function ds(e){let t=new URL(`package.json`,e.projectRoot);try{let e=await r(t,`utf8`),{dependencies:n={},devDependencies:i={}}=hn(us,JSON.parse(e));return new Set([...Object.keys(n),...Object.keys(i)])}catch{return new Set}}async function fs(e,t){let n=[],r=Uo(e.framework);for(let e of r)n.push({done:t.has(e),label:e,hint:t.has(e)?`installed`:`not installed`});let i=Wo(e);if(i){let t=await En(new URL(i,e.projectRoot));n.push({done:t,label:i,hint:t?void 0:`create Prismic client file`})}else if(e.framework===`nuxt`){let t=await ps(e);n.push({done:t,label:`nuxt.config.ts`,hint:t?`prismic configured`:`add @nuxtjs/prismic to modules`})}return{title:`Setup`,items:n}}async function ps(e){let t=new URL(`nuxt.config.ts`,e.projectRoot);try{let e=await r(t,`utf8`);return e.includes(`@nuxtjs/prismic`)||e.includes(`prismic:`)}catch{return!1}}function ms(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[];for(let t of e){let e=t.label||t.id,n=r.get(t.id);n&&JSON.stringify(t)===JSON.stringify(n)?i.push({id:t.id,label:e,status:`in_sync`}):i.push({id:t.id,label:e,status:`to_push`})}for(let e of t)if(!n.has(e.id)){let t=e.label||e.id;i.push({id:e.id,label:t,status:`to_pull`})}return i}function hs(e,t){let n=ms(e,t),r=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return a&&a.format===`page`}),i=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return!a||a.format!==`page`}),a=r.map(e=>({done:e.status===`in_sync`,label:e.label,hint:gs(e.status)})),o=i.map(e=>({done:e.status===`in_sync`,label:e.label,hint:gs(e.status)}));return{pageTypes:{title:`Page Types`,items:a},customTypes:{title:`Custom Types`,items:o},allTypeStatuses:n}}function gs(e){switch(e){case`in_sync`:return`in sync`;case`to_push`:return`to push`;case`to_pull`:return`to pull`}}function _s(e){for(let t of e.variations){let e=Object.keys(t.primary??{}),n=Object.keys(t.items??{});if(e.length>0||n.length>0)return!0}return!1}function vs(e,t){for(let n of t)for(let t of Object.values(n.json))for(let n of Object.values(t)){let t=n;if(t.type===`Slices`&&t.config?.choices?.[e])return!0}return!1}async function ys(e,t,n,r){let i=ms(e,t),a=[],o=[],s=[],c=Go(n),l=Ko(n.framework);for(let t of i){let i=e.find(e=>e.id===t.id);if(i){let e=_s(i),n=vs(t.id,r);e&&!n&&s.push(t.label)}let u=await bs(n,c,t.id,l);t.status===`in_sync`&&u?a.push({done:!0,label:t.label,hint:`component implemented`}):t.status===`in_sync`&&!u?(a.push({done:!1,label:t.label,hint:`missing component`}),o.push(t.label)):a.push({done:!1,label:t.label,hint:gs(t.status)})}return{section:{title:`Slices`,items:a},statuses:i,missingComponents:o,slicesReadyToConnect:s}}async function bs(e,t,n,r){let i=xs(n);for(let n of r)if(await En(new URL(`${t}${i}/index${n}`,e.projectRoot)))return!0;return!1}function xs(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Ss(e,t,n){let r=[];r.push({done:!!n,label:`Slice simulator URL`,hint:n?`configured`:"run `prismic preview set-simulator`"});let i=qo(e,`/slice-simulator`);if(i){let t=await Cs(e,i);r.push({done:t,label:`/slice-simulator route`,hint:t?void 0:`create route for Page Builder`})}let a=t&&t.length>0;if(r.push({done:!!a,label:`Preview environment`,hint:a?void 0:"run `prismic preview add`"}),e.framework!==`nuxt`){let t=qo(e,`/api/preview`);if(t){let n=await Cs(e,t);r.push({done:n,label:`/api/preview endpoint`,hint:n?void 0:`create preview endpoint`})}}if(e.framework===`next`){let t=qo(e,`/api/exit-preview`);if(t){let n=await Cs(e,t);r.push({done:n,label:`/api/exit-preview endpoint`,hint:n?void 0:`create exit-preview endpoint`})}}return{title:`Preview`,items:r}}async function Cs(e,t){for(let n of t.extensions)if(await En(new URL(`${t.path}${n}`,e.projectRoot)))return!0;return!1}async function ws(e,t){let n=[],r=qo(e,`/api/revalidate`);if(r){let t=await Cs(e,r);n.push({done:t,label:`/api/revalidate endpoint`,hint:t?void 0:`create for ISR`})}let i=t.some(e=>e.config.active&&e.config.url.toLowerCase().includes(`revalidate`));return n.push({done:i,label:`Revalidation webhook`,hint:i?`configured`:"run `prismic webhook create`"}),{title:`Deployment`,items:n}}async function Ts(){let{values:{help:t,repo:n=await Y(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all API tokens for a Prismic repository.
2183
+ Use \`prismic <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1;return}let r=await $();if(!r){console.error(`Could not find project root (no package.json found)`),process.exitCode=1;return}let[i,a,o,s,c,l,u,d]=await Promise.all([Tc(n),Dc(n),dc(n),Vn(),zn(n),Hn(),Bn(n),kc(r)]),f=await z(n);console.info(`Repository: ${n}`),console.info(`URL: ${f.href}`),console.info(``);let p=[],m=await Ac(r,d);if(m.nextSteps=_c(m.items,r),p.push(m),s.ok&&c.ok){let{pageTypes:e,customTypes:t,pageTypeStatuses:n,customTypeStatuses:r}=Nc(s.value,c.value);e.nextSteps=vc(n),t.nextSteps=vc(r),p.push(e),p.push(t)}if(l.ok&&u.ok){let{section:e,statuses:t,missingComponents:n,slicesReadyToConnect:i}=await Lc(l.value,u.value,r,s.ok?s.value:[]);e.nextSteps=yc(t,n,i,r),p.push(e)}let h=await Bc(r,a.ok?a.value:void 0,i.ok?i.value.simulator_url:void 0);if(h.nextSteps=bc(h.items,r),p.push(h),r.framework===`next`){let e=await Hc(r,o.ok?o.value:[]);e.nextSteps=xc(e.items,r),p.push(e)}for(let e of p)Cc(e)}function Cc(e){let t=e.items.filter(e=>!e.done).length,n=t>0?`${e.title} (${t} remaining)`:e.title;console.info(n);let r=e.items.filter(e=>e.done),i=e.items.filter(e=>!e.done);if(r.length>0)if(r.length===1){let e=r[0],t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ✓ ${e.label}${t}`)}else{let e=r.map(e=>e.label).join(`, `),t=r.every(e=>e.hint===r[0].hint)&&r[0].hint?` \u2014 ${r[0].hint}`:``;console.info(` ✓ ${e}${t}`)}for(let e of i){let t=e.hint?` \u2014 ${e.hint}`:``;console.info(` ○ ${e.label}${t}`)}if(e.nextSteps&&e.nextSteps.length>0){console.info(``),console.info(` Next steps:`);for(let t of e.nextSteps)console.info(` - ${t.action}`)}console.info(``)}const wc=N({simulator_url:P(I())});async function Tc(e){let t=await Z(new URL(`/core/repository`,await z(e)),{schema:wc});return t.ok?{ok:!0,value:t.value}:{ok:!1}}const Ec=N({results:j(N({id:I(),label:I(),url:I()}))});async function Dc(e){let t=await Z(new URL(`/core/repository/preview_configs`,await z(e)),{schema:Ec});return t.ok?{ok:!0,value:t.value.results}:{ok:!1}}const Oc=N({dependencies:P(F(I(),I())),devDependencies:P(F(I(),I()))});async function kc(e){let t=new URL(`package.json`,e.projectRoot);try{let e=await r(t,`utf8`),{dependencies:n={},devDependencies:i={}}=yn(Oc,JSON.parse(e));return new Set([...Object.keys(n),...Object.keys(i)])}catch{return new Set}}async function Ac(e,t){let n=[],r=Li(e.framework);for(let e of r)n.push({done:t.has(e),label:e,hint:t.has(e)?`installed`:`not installed`});let i=Ri(e);if(i){let t=await jn(new URL(i,e.projectRoot));n.push({done:t,label:i,hint:t?void 0:`create Prismic client file`})}else if(e.framework===`nuxt`){let t=await jc(e);n.push({done:t,label:`nuxt.config.ts`,hint:t?`prismic configured`:`add @nuxtjs/prismic to modules`})}return{title:`Setup`,items:n}}async function jc(e){let t=new URL(`nuxt.config.ts`,e.projectRoot);try{let e=await r(t,`utf8`);return e.includes(`@nuxtjs/prismic`)||e.includes(`prismic:`)}catch{return!1}}function Mc(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e])),i=[];for(let t of e){let e=t.label||t.id,n=r.get(t.id);n&&JSON.stringify(t)===JSON.stringify(n)?i.push({id:t.id,label:e,status:`in_sync`}):i.push({id:t.id,label:e,status:`to_push`})}for(let e of t)if(!n.has(e.id)){let t=e.label||e.id;i.push({id:e.id,label:t,status:`to_pull`})}return i}function Nc(e,t){let n=Mc(e,t),r=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return a&&a.format===`page`}),i=n.filter(n=>{let r=e.find(e=>e.id===n.id),i=t.find(e=>e.id===n.id),a=r||i;return!a||a.format!==`page`}),a=r.map(e=>({done:e.status===`in_sync`,label:e.label,hint:Pc(e.status)})),o=i.map(e=>({done:e.status===`in_sync`,label:e.label,hint:Pc(e.status)}));return{pageTypes:{title:`Page Types`,items:a},customTypes:{title:`Custom Types`,items:o},pageTypeStatuses:r,customTypeStatuses:i}}function Pc(e){switch(e){case`in_sync`:return`in sync`;case`to_push`:return`to push`;case`to_pull`:return`to pull`}}function Fc(e){for(let t of e.variations){let e=Object.keys(t.primary??{}),n=Object.keys(t.items??{});if(e.length>0||n.length>0)return!0}return!1}function Ic(e,t){for(let n of t)for(let t of Object.values(n.json))for(let n of Object.values(t)){let t=n;if(t.type===`Slices`&&t.config?.choices?.[e])return!0}return!1}async function Lc(e,t,n,r){let i=Mc(e,t),a=[],o=[],s=[],c=zi(n),l=Bi(n.framework);for(let t of i){let i=e.find(e=>e.id===t.id);if(i){let e=Fc(i),n=Ic(t.id,r);e&&!n&&s.push(t.label)}let u=await Rc(n,c,t.id,l);t.status===`in_sync`&&u?a.push({done:!0,label:t.label,hint:`component implemented`}):t.status===`in_sync`&&!u?(a.push({done:!1,label:t.label,hint:`missing component`}),o.push(t.label)):a.push({done:!1,label:t.label,hint:Pc(t.status)})}return{section:{title:`Slices`,items:a},statuses:i,missingComponents:o,slicesReadyToConnect:s}}async function Rc(e,t,n,r){let i=zc(n);for(let n of r)if(await jn(new URL(`${t}${i}/index${n}`,e.projectRoot)))return!0;return!1}function zc(e){return e.toLowerCase().replace(/(^|[-_\s]+)(.)?/g,(e,t,n)=>n?.toUpperCase()??``)}async function Bc(e,t,n){let r=[];r.push({done:!!n,label:`Slice simulator URL`,hint:n?`configured`:"run `prismic preview set-simulator`"});let i=Vi(e,`/slice-simulator`);if(i){let t=await Vc(e,i);r.push({done:t,label:`/slice-simulator route`,hint:t?void 0:`create route for Page Builder`})}let a=t&&t.length>0;if(r.push({done:!!a,label:`Preview environment`,hint:a?void 0:"run `prismic preview add`"}),e.framework!==`nuxt`){let t=Vi(e,`/api/preview`);if(t){let n=await Vc(e,t);r.push({done:n,label:`/api/preview endpoint`,hint:n?void 0:`create preview endpoint`})}}if(e.framework===`next`){let t=Vi(e,`/api/exit-preview`);if(t){let n=await Vc(e,t);r.push({done:n,label:`/api/exit-preview endpoint`,hint:n?void 0:`create exit-preview endpoint`})}}return{title:`Preview`,items:r}}async function Vc(e,t){for(let n of t.extensions)if(await jn(new URL(`${t.path}${n}`,e.projectRoot)))return!0;return!1}async function Hc(e,t){let n=[],r=Vi(e,`/api/revalidate`);if(r){let t=await Vc(e,r);n.push({done:t,label:`/api/revalidate endpoint`,hint:t?void 0:`create for ISR`})}let i=t.some(e=>e.config.active&&e.config.url.toLowerCase().includes(`revalidate`));return n.push({done:i,label:`Revalidation webhook`,hint:i?`configured`:"run `prismic webhook create`"}),{title:`Deployment`,items:n}}async function Uc(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all API tokens for a Prismic repository.
2069
2184
 
2070
2185
  By default, this command reads the repository from prismic.config.json at the
2071
2186
  project root.
@@ -2079,7 +2194,7 @@ FLAGS
2079
2194
  -h, --help Show help for command
2080
2195
 
2081
2196
  LEARN MORE
2082
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Is();return}let[i,a]=await Promise.all([Ms(n),Ns(n)]);if(!i.ok){i.error instanceof Z||i.error instanceof Q?Is():M(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${q(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${q(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Z||a.error instanceof Q?Is():M(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${q(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${q(a.value)}`),process.exitCode=1);return}let o=i.value.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,appId:e.id,authId:t.id,scope:t.scope,token:t.token,createdAt:t.created_at.$date}))),s=a.value.tokens;if(r)console.info(q({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=Ps(e.token),n=Fs(e.createdAt);console.info(` ${e.name} ${e.scope} ${t} ${n}`)}}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),s.length>0){console.info(`WRITE TOKENS`);for(let e of s){let t=Ps(e.token),n=Fs(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Es=F({$date:mn()}),Ds=F({id:R(),origin:R(),domain:R(),app:R(),scope:R(),expired_at:Es,created_at:Es,owner:pn(R()),token:R()}),Os=F({id:R(),secret:R(),name:R(),owner:R(),created_at:Es,authorized_domains:N(R()),wroom_auths:N(Ds)}),ks=F({app_name:R(),token:R(),timestamp:mn()}),As=F({max_tokens:mn(),tokens:N(ks)}),js=N(Os);async function Ms(e){return await X(new URL(`settings/security/contentapi`,await V(e)),{schema:js})}async function Ns(e){return await X(new URL(`settings/security/customtypesapi`,await V(e)),{schema:As})}function Ps(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Fs(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function Is(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ls(){let{values:{help:t,repo:n=await Y(),json:r,write:i,name:a=`Prismic CLI`,"allow-releases":o}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`},write:{type:`boolean`,short:`w`},name:{type:`string`,short:`n`},"allow-releases":{type:`boolean`}},allowPositionals:!1});if(t){console.info(`Create a new API token for a Prismic repository.
2197
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){el();return}let[i,a]=await Promise.all([Xc(n),Zc(n)]);if(!i.ok){i.error instanceof Q||i.error instanceof hi?el():A(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Q||a.error instanceof hi?el():A(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(a.value)}`),process.exitCode=1);return}let o=i.value.flatMap(e=>e.wroom_auths.map(t=>({name:e.name,appId:e.id,authId:t.id,scope:t.scope,token:t.token,createdAt:t.created_at.$date}))),s=a.value.tokens;if(r)console.info(J({accessTokens:o,writeTokens:s}));else{if(o.length>0){console.info(`ACCESS TOKENS`);for(let e of o){let t=Qc(e.token),n=$c(e.createdAt);console.info(` ${e.name} ${e.scope} ${t} ${n}`)}}else console.info(`ACCESS TOKENS (none)`);if(console.info(``),s.length>0){console.info(`WRITE TOKENS`);for(let e of s){let t=Qc(e.token),n=$c(e.timestamp);console.info(` ${e.app_name} ${t} ${n}`)}}else console.info(`WRITE TOKENS (none)`)}}const Wc=N({$date:vn()}),Gc=N({id:I(),origin:I(),domain:I(),app:I(),scope:I(),expired_at:Wc,created_at:Wc,owner:_n(I()),token:I()}),Kc=N({id:I(),secret:I(),name:I(),owner:I(),created_at:Wc,authorized_domains:j(I()),wroom_auths:j(Gc)}),qc=N({app_name:I(),token:I(),timestamp:vn()}),Jc=N({max_tokens:vn(),tokens:j(qc)}),Yc=j(Kc);async function Xc(e){return await Z(new URL(`settings/security/contentapi`,await z(e)),{schema:Yc})}async function Zc(e){return await Z(new URL(`settings/security/customtypesapi`,await z(e)),{schema:Jc})}function Qc(e){return e.length<=12?e:`${e.slice(0,8)}...${e.slice(-4)}`}function $c(e){let t=typeof e==`number`?e*1e3:e.$date;return new Date(t).toISOString().split(`T`)[0]}function el(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function tl(){let{values:{help:t,repo:n=await X(),json:r,write:i,name:a=`Prismic CLI`,"allow-releases":o}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`},write:{type:`boolean`,short:`w`},name:{type:`string`,short:`n`},"allow-releases":{type:`boolean`}},allowPositionals:!1});if(t){console.info(`Create a new API token for a Prismic repository.
2083
2198
 
2084
2199
  By default, this command reads the repository from prismic.config.json at the
2085
2200
  project root.
@@ -2096,7 +2211,7 @@ FLAGS
2096
2211
  -h, --help Show help for command
2097
2212
 
2098
2213
  LEARN MORE
2099
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(i&&o){console.error(`--allow-releases is only valid for access tokens (not with --write)`),process.exitCode=1;return}if(!await H()){Bs();return}if(i){let e=await Rs(n,a);if(!e.ok){e.error instanceof Z||e.error instanceof Q?Bs():M(e.error)?(console.error(`Failed to create write token: Invalid response: ${q(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${q(e.value)}`),process.exitCode=1);return}r?console.info(q(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await zs(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof Z||e.error instanceof Q?Bs():M(e.error)?(console.error(`Failed to create access token: Invalid response: ${q(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${q(e.value)}`),process.exitCode=1);return}r?console.info(q(e.value)):console.info(`Token created: ${e.value.token}`)}}async function Rs(e,t){return await X(new URL(`settings/security/token`,await V(e)),{method:`POST`,body:{app_name:t},schema:ks})}async function zs(e,t,n){let r=await Ms(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await X(new URL(`settings/security/oauthapp`,await V(e)),{method:`POST`,body:{app_name:t},schema:Os});if(!n.ok)return n;i=n.value}return await X(new URL(`settings/security/authorizations`,await V(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Ds})}function Bs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Vs(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a token from a Prismic repository.
2214
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(i&&o){console.error(`--allow-releases is only valid for access tokens (not with --write)`),process.exitCode=1;return}if(!await B()){il();return}if(i){let e=await nl(n,a);if(!e.ok){e.error instanceof Q||e.error instanceof hi?il():A(e.error)?(console.error(`Failed to create write token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create write token: ${J(e.value)}`),process.exitCode=1);return}r?console.info(J(e.value)):console.info(`Token created: ${e.value.token}`)}else{let e=await rl(n,a,o?`master+releases`:`master`);if(!e.ok){e.error instanceof Q||e.error instanceof hi?il():A(e.error)?(console.error(`Failed to create access token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to create access token: ${J(e.value)}`),process.exitCode=1);return}r?console.info(J(e.value)):console.info(`Token created: ${e.value.token}`)}}async function nl(e,t){return await Z(new URL(`settings/security/token`,await z(e)),{method:`POST`,body:{app_name:t},schema:qc})}async function rl(e,t,n){let r=await Xc(e);if(!r.ok)return r;let i=r.value.find(e=>e.name===t);if(!i){let n=await Z(new URL(`settings/security/oauthapp`,await z(e)),{method:`POST`,body:{app_name:t},schema:Kc});if(!n.ok)return n;i=n.value}return await Z(new URL(`settings/security/authorizations`,await z(e)),{method:`POST`,body:{app:i.id,scope:n},schema:Gc})}function il(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function al(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a token from a Prismic repository.
2100
2215
 
2101
2216
  By default, this command reads the repository from prismic.config.json at the
2102
2217
  project root.
@@ -2112,7 +2227,7 @@ FLAGS
2112
2227
  -h, --help Show help for command
2113
2228
 
2114
2229
  LEARN MORE
2115
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Hs();return}let[i,a]=await Promise.all([Ms(n),Ns(n)]);if(!i.ok){i.error instanceof Z||i.error instanceof Q?Hs():M(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${q(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${q(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Z||a.error instanceof Q?Hs():M(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${q(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${q(a.value)}`),process.exitCode=1);return}let o;for(let e of i.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){o=t;break}if(o)break}if(o){let e=await X(new URL(`settings/security/authorizations/${o.id}`,await V(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Z||e.error instanceof Q?Hs():(console.error(`Failed to delete token: ${q(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}let s=a.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r));if(s){let e=await X(new URL(`settings/security/token/${s.token}`,await V(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Z||e.error instanceof Q?Hs():(console.error(`Failed to delete token: ${q(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function Hs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Us(){let{values:{help:t,repo:n=await Y()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the name of a token in a Prismic repository.
2230
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ol();return}let[i,a]=await Promise.all([Xc(n),Zc(n)]);if(!i.ok){i.error instanceof Q||i.error instanceof hi?ol():A(i.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(i.value)}`),process.exitCode=1);return}if(!a.ok){a.error instanceof Q||a.error instanceof hi?ol():A(a.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(a.value)}`),process.exitCode=1);return}let o;for(let e of i.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){o=t;break}if(o)break}if(o){let e=await Z(new URL(`settings/security/authorizations/${o.id}`,await z(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Q||e.error instanceof hi?ol():(console.error(`Failed to delete token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}let s=a.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r));if(s){let e=await Z(new URL(`settings/security/token/${s.token}`,await z(n)),{method:`DELETE`});if(!e.ok){e.error instanceof Q||e.error instanceof hi?ol():(console.error(`Failed to delete token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token deleted`);return}console.error(`Token not found: ${r}`),process.exitCode=1}function ol(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function sl(){let{values:{help:t,repo:n=await X()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Set the name of a token in a Prismic repository.
2116
2231
 
2117
2232
  Note: Only access tokens can be renamed. Write tokens cannot be renamed without
2118
2233
  changing the token value.
@@ -2132,7 +2247,7 @@ FLAGS
2132
2247
  -h, --help Show help for command
2133
2248
 
2134
2249
  LEARN MORE
2135
- Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: name`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Ws();return}let[a,o]=await Promise.all([Ms(n),Ns(n)]);if(!a.ok){a.error instanceof Z||a.error instanceof Q?Ws():M(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${q(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${q(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof Z||o.error instanceof Q?Ws():M(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${q(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${q(o.value)}`),process.exitCode=1);return}let s;for(let e of a.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){s=e;break}if(s)break}if(s){let e=await X(new URL(`settings/security/oauthapp/${s.id}`,await V(n)),{method:`POST`,body:{name:i},schema:Os});if(!e.ok){e.error instanceof Z||e.error instanceof Q?Ws():M(e.error)?(console.error(`Failed to rename token: Invalid response: ${q(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${q(e.value)}`),process.exitCode=1);return}console.info(`Token renamed to: ${i}`);return}if(o.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r))){console.error(`Write tokens cannot be renamed. Delete and create a new token with the desired name.`),process.exitCode=1;return}console.error(`Token not found: ${r}`),process.exitCode=1}function Ws(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Gs(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Ts();break;case`create`:await Ls();break;case`set-name`:await Us();break;case`delete`:await Vs();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
2250
+ Use \`prismic token <command> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: token`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: name`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){cl();return}let[a,o]=await Promise.all([Xc(n),Zc(n)]);if(!a.ok){a.error instanceof Q||a.error instanceof hi?cl():A(a.error)?(console.error(`Failed to list access tokens: Invalid response: ${J(a.error.issues)}`),process.exitCode=1):(console.error(`Failed to list access tokens: ${J(a.value)}`),process.exitCode=1);return}if(!o.ok){o.error instanceof Q||o.error instanceof hi?cl():A(o.error)?(console.error(`Failed to list write tokens: Invalid response: ${J(o.error.issues)}`),process.exitCode=1):(console.error(`Failed to list write tokens: ${J(o.value)}`),process.exitCode=1);return}let s;for(let e of a.value){for(let t of e.wroom_auths)if(t.token===r||t.token.startsWith(r)||t.token.endsWith(r)){s=e;break}if(s)break}if(s){let e=await Z(new URL(`settings/security/oauthapp/${s.id}`,await z(n)),{method:`POST`,body:{name:i},schema:Kc});if(!e.ok){e.error instanceof Q||e.error instanceof hi?cl():A(e.error)?(console.error(`Failed to rename token: Invalid response: ${J(e.error.issues)}`),process.exitCode=1):(console.error(`Failed to rename token: ${J(e.value)}`),process.exitCode=1);return}console.info(`Token renamed to: ${i}`);return}if(o.value.tokens.find(e=>e.token===r||e.token.startsWith(r)||e.token.endsWith(r))){console.error(`Write tokens cannot be renamed. Delete and create a new token with the desired name.`),process.exitCode=1;return}console.error(`Token not found: ${r}`),process.exitCode=1}function cl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ll(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await Uc();break;case`create`:await tl();break;case`set-name`:await sl();break;case`delete`:await al();break;default:t&&(console.error(`Unknown token subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage API tokens for a Prismic repository.
2136
2251
 
2137
2252
  USAGE
2138
2253
  prismic token <command> [flags]
@@ -2147,7 +2262,7 @@ FLAGS
2147
2262
  -h, --help Show help for command
2148
2263
 
2149
2264
  LEARN MORE
2150
- Use \`prismic token <command> --help\` for more information about a command.`)}}async function Ks(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Enable a webhook in a Prismic repository.
2265
+ Use \`prismic token <command> --help\` for more information about a command.`)}}async function ul(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Enable a webhook in a Prismic repository.
2151
2266
 
2152
2267
  By default, this command reads the repository from prismic.config.json at the
2153
2268
  project root.
@@ -2163,7 +2278,7 @@ FLAGS
2163
2278
  -h, --help Show help for command
2164
2279
 
2165
2280
  LEARN MORE
2166
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Js();return}let i=await $(n);if(!i.ok){i.error instanceof Z?Js():(console.error(`Failed to enable webhook: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(a.config.active){console.info(`Webhook already enabled: ${r}`);return}let o=structuredClone(a.config);o.active=!0;let s=await qs(n,a.config._id,o);if(!s.ok){s.error instanceof Z?Js():(console.error(`Failed to enable webhook: ${q(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function qs(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await V(e)),i=new FormData;return i.set(`url`,n.url),i.set(`name`,n.name??``),i.set(`secret`,n.secret??``),i.set(`headers`,JSON.stringify(n.headers??{})),i.set(`active`,n.active?`on`:`off`),i.set(`documentsPublished`,n.documentsUnpublished.toString()),i.set(`documentsUnpublished`,n.documentsUnpublished.toString()),i.set(`releasesCreated`,n.documentsUnpublished.toString()),i.set(`releasesUpdated`,n.documentsUnpublished.toString()),i.set(`tagsCreated`,n.documentsUnpublished.toString()),i.set(`documentsPublished`,n.documentsUnpublished.toString()),await X(r,{method:`POST`,body:i})}function Js(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Ys(){let{values:{help:t,repo:n=await Y()},positionals:[r,i,a]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a custom HTTP header to a webhook.
2281
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){fl();return}let i=await dc(n);if(!i.ok){i.error instanceof Q?fl():(console.error(`Failed to enable webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(a.config.active){console.info(`Webhook already enabled: ${r}`);return}let o=structuredClone(a.config);o.active=!0;let s=await dl(n,a.config._id,o);if(!s.ok){s.error instanceof Q?fl():(console.error(`Failed to enable webhook: ${J(s.value)}`),process.exitCode=1);return}console.info(`Webhook enabled: ${r}`)}async function dl(e,t,n){let r=new URL(`/app/settings/webhooks/${t}`,await z(e)),i=new FormData;return i.set(`url`,n.url),i.set(`name`,n.name??``),i.set(`secret`,n.secret??``),i.set(`headers`,JSON.stringify(n.headers??{})),i.set(`active`,n.active?`on`:`off`),i.set(`documentsPublished`,n.documentsUnpublished.toString()),i.set(`documentsUnpublished`,n.documentsUnpublished.toString()),i.set(`releasesCreated`,n.documentsUnpublished.toString()),i.set(`releasesUpdated`,n.documentsUnpublished.toString()),i.set(`tagsCreated`,n.documentsUnpublished.toString()),i.set(`documentsPublished`,n.documentsUnpublished.toString()),await Z(r,{method:`POST`,body:i})}function fl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function pl(){let{values:{help:t,repo:n=await X()},positionals:[r,i,a]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Add a custom HTTP header to a webhook.
2167
2282
 
2168
2283
  By default, this command reads the repository from prismic.config.json at the
2169
2284
  project root.
@@ -2181,7 +2296,7 @@ FLAGS
2181
2296
  -h, --help Show help for command
2182
2297
 
2183
2298
  LEARN MORE
2184
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: <value>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){Xs();return}let o=await $(n);if(!o.ok){o.error instanceof Z?Xs():(console.error(`Failed to add header: ${q(o.value)}`),process.exitCode=1);return}let s=o.value.find(e=>e.config.url===r);if(!s){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let c=structuredClone(s.config);c.headers[i]=a;let l=await qs(n,s.config._id,c);if(!l.ok){l.error instanceof Z?Xs():(console.error(`Failed to add header: ${q(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function Xs(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Zs=Object.values(Jo);async function Qs(){let{values:{help:t,repo:n=await Y(),name:r,secret:i,trigger:a=[]},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},secret:{type:`string`,short:`s`},trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new webhook in a Prismic repository.
2299
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!a){console.error(`Missing required argument: <value>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){ml();return}let o=await dc(n);if(!o.ok){o.error instanceof Q?ml():(console.error(`Failed to add header: ${J(o.value)}`),process.exitCode=1);return}let s=o.value.find(e=>e.config.url===r);if(!s){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let c=structuredClone(s.config);c.headers[i]=a;let l=await dl(n,s.config._id,c);if(!l.ok){l.error instanceof Q?ml():(console.error(`Failed to add header: ${J(l.value)}`),process.exitCode=1);return}console.info(`Header added: ${i}`)}function ml(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const hl=Object.values(sc);async function gl(){let{values:{help:t,repo:n=await X(),name:r,secret:i,trigger:a=[]},positionals:[o]}=e({args:process.argv.slice(4),options:{name:{type:`string`,short:`n`},secret:{type:`string`,short:`s`},trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Create a new webhook in a Prismic repository.
2185
2300
 
2186
2301
  By default, this command reads the repository from prismic.config.json at the
2187
2302
  project root.
@@ -2210,7 +2325,7 @@ TRIGGERS
2210
2325
  If no triggers specified, all are enabled.
2211
2326
 
2212
2327
  LEARN MORE
2213
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}for(let e of a)if(!Zs.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${Zs.join(`, `)}`),process.exitCode=1;return}if(!await H()){ec();return}let s=!(a.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of a){let[t]=Object.entries(Jo).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await $s(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof Z?ec():(console.error(`Failed to create webhook: ${q(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function $s(e,t){let n=new URL(`/app/settings/webhooks/create`,await V(e)),r=new FormData;return r.set(`url`,t.url),r.set(`name`,t.name??``),r.set(`secret`,t.secret??``),r.set(`headers`,JSON.stringify({})),r.set(`active`,`on`),r.set(`documentsPublished`,t.documentsUnpublished.toString()),r.set(`documentsUnpublished`,t.documentsUnpublished.toString()),r.set(`releasesCreated`,t.documentsUnpublished.toString()),r.set(`releasesUpdated`,t.documentsUnpublished.toString()),r.set(`tagsCreated`,t.documentsUnpublished.toString()),r.set(`documentsPublished`,t.documentsUnpublished.toString()),await X(n,{method:`POST`,body:r})}function ec(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function tc(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disable a webhook in a Prismic repository.
2328
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!o){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}for(let e of a)if(!hl.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${hl.join(`, `)}`),process.exitCode=1;return}if(!await B()){vl();return}let s=!(a.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of a){let[t]=Object.entries(sc).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await _l(n,{url:o,name:r??null,secret:i??null,...c});if(!l.ok){l.error instanceof Q?vl():(console.error(`Failed to create webhook: ${J(l.value)}`),process.exitCode=1);return}console.info(`Webhook created: ${o}`)}async function _l(e,t){let n=new URL(`/app/settings/webhooks/create`,await z(e)),r=new FormData;return r.set(`url`,t.url),r.set(`name`,t.name??``),r.set(`secret`,t.secret??``),r.set(`headers`,JSON.stringify({})),r.set(`active`,`on`),r.set(`documentsPublished`,t.documentsUnpublished.toString()),r.set(`documentsUnpublished`,t.documentsUnpublished.toString()),r.set(`releasesCreated`,t.documentsUnpublished.toString()),r.set(`releasesUpdated`,t.documentsUnpublished.toString()),r.set(`tagsCreated`,t.documentsUnpublished.toString()),r.set(`documentsPublished`,t.documentsUnpublished.toString()),await Z(n,{method:`POST`,body:r})}function vl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function yl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Disable a webhook in a Prismic repository.
2214
2329
 
2215
2330
  By default, this command reads the repository from prismic.config.json at the
2216
2331
  project root.
@@ -2226,7 +2341,7 @@ FLAGS
2226
2341
  -h, --help Show help for command
2227
2342
 
2228
2343
  LEARN MORE
2229
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){nc();return}let i=await $(n);if(!i.ok){i.error instanceof Z?nc():(console.error(`Failed to disable webhook: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!a.config.active){console.info(`Webhook already disabled: ${r}`);return}let o=structuredClone(a.config);o.active=!1;let s=await qs(n,a.config._id,o);if(!s.ok){s.error instanceof Z?nc():(console.error(`Failed to disable webhook: ${q(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function nc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function rc(){let{values:{help:t,repo:n=await Y(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all webhooks in a Prismic repository.
2344
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){bl();return}let i=await dc(n);if(!i.ok){i.error instanceof Q?bl():(console.error(`Failed to disable webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!a.config.active){console.info(`Webhook already disabled: ${r}`);return}let o=structuredClone(a.config);o.active=!1;let s=await dl(n,a.config._id,o);if(!s.ok){s.error instanceof Q?bl():(console.error(`Failed to disable webhook: ${J(s.value)}`),process.exitCode=1);return}console.info(`Webhook disabled: ${r}`)}function bl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function xl(){let{values:{help:t,repo:n=await X(),json:r}}=e({args:process.argv.slice(4),options:{json:{type:`boolean`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!1});if(t){console.info(`List all webhooks in a Prismic repository.
2230
2345
 
2231
2346
  By default, this command reads the repository from prismic.config.json at the
2232
2347
  project root.
@@ -2240,7 +2355,7 @@ FLAGS
2240
2355
  -h, --help Show help for command
2241
2356
 
2242
2357
  LEARN MORE
2243
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){ic();return}let i=await $(n);if(!i.ok){i.error instanceof Z?ic():M(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${q(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${q(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(q(a.map(e=>e.config)));else{if(a.length===0){console.info(`No webhooks configured.`);return}for(let e of a){let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;console.info(`${e.config.url}${n} [${t}]`)}}}function ic(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function ac(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a webhook from a Prismic repository.
2358
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Sl();return}let i=await dc(n);if(!i.ok){i.error instanceof Q?Sl():A(i.error)?(console.error(`Failed to list webhooks: Invalid response: ${J(i.error.issues)}`),process.exitCode=1):(console.error(`Failed to list webhooks: ${J(i.value)}`),process.exitCode=1);return}let a=i.value;if(r)console.info(J(a.map(e=>e.config)));else{if(a.length===0){console.info(`No webhooks configured.`);return}for(let e of a){let t=e.config.active?`enabled`:`disabled`,n=e.config.name?` (${e.config.name})`:``;console.info(`${e.config.url}${n} [${t}]`)}}}function Sl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Cl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Delete a webhook from a Prismic repository.
2244
2359
 
2245
2360
  By default, this command reads the repository from prismic.config.json at the
2246
2361
  project root.
@@ -2256,7 +2371,7 @@ FLAGS
2256
2371
  -h, --help Show help for command
2257
2372
 
2258
2373
  LEARN MORE
2259
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){sc();return}let i=await $(n);if(!i.ok){i.error instanceof Z?sc():(console.error(`Failed to remove webhook: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await oc(n,a.config._id);if(!o.ok){o.error instanceof Z?sc():(console.error(`Failed to remove webhook: ${q(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function oc(e,t){return await X(new URL(`/app/settings/webhooks/${t}/delete`,await V(e)),{method:`POST`})}function sc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function cc(){let{values:{help:t,repo:n=await Y()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom HTTP header from a webhook.
2374
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Tl();return}let i=await dc(n);if(!i.ok){i.error instanceof Q?Tl():(console.error(`Failed to remove webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await wl(n,a.config._id);if(!o.ok){o.error instanceof Q?Tl():(console.error(`Failed to remove webhook: ${J(o.value)}`),process.exitCode=1);return}console.info(`Webhook removed: ${r}`)}async function wl(e,t){return await Z(new URL(`/app/settings/webhooks/${t}/delete`,await z(e)),{method:`POST`})}function Tl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function El(){let{values:{help:t,repo:n=await X()},positionals:[r,i]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Remove a custom HTTP header from a webhook.
2260
2375
 
2261
2376
  By default, this command reads the repository from prismic.config.json at the
2262
2377
  project root.
@@ -2273,7 +2388,7 @@ FLAGS
2273
2388
  -h, --help Show help for command
2274
2389
 
2275
2390
  LEARN MORE
2276
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){lc();return}let a=await $(n);if(!a.ok){a.error instanceof Z?lc():(console.error(`Failed to remove header: ${q(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===r);if(!o){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!(i in o.config.headers)){console.error(`Header not found: ${i}`),process.exitCode=1;return}let s=structuredClone(o.config);delete s.headers[i];let c=await qs(n,o.config._id,s);if(!c.ok){c.error instanceof Z?lc():(console.error(`Failed to remove header: ${q(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function lc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const uc=Object.values(Jo);async function dc(){let{values:{help:t,repo:n=await Y(),trigger:r},positionals:[i]}=e({args:process.argv.slice(4),options:{trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update which events trigger a webhook.
2391
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!i){console.error(`Missing required argument: <key>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Dl();return}let a=await dc(n);if(!a.ok){a.error instanceof Q?Dl():(console.error(`Failed to remove header: ${J(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===r);if(!o){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}if(!(i in o.config.headers)){console.error(`Header not found: ${i}`),process.exitCode=1;return}let s=structuredClone(o.config);delete s.headers[i];let c=await dl(n,o.config._id,s);if(!c.ok){c.error instanceof Q?Dl():(console.error(`Failed to remove header: ${J(c.value)}`),process.exitCode=1);return}console.info(`Header removed: ${i}`)}function Dl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const Ol=Object.values(sc);async function kl(){let{values:{help:t,repo:n=await X(),trigger:r},positionals:[i]}=e({args:process.argv.slice(4),options:{trigger:{type:`string`,multiple:!0,short:`t`},repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Update which events trigger a webhook.
2277
2392
 
2278
2393
  By default, this command reads the repository from prismic.config.json at the
2279
2394
  project root.
@@ -2298,7 +2413,7 @@ TRIGGERS
2298
2413
  tag.deleted When a tag is deleted
2299
2414
 
2300
2415
  LEARN MORE
2301
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!r||r.length===0){console.error(`Missing required option: --trigger`),process.exitCode=1;return}for(let e of r)if(!uc.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${uc.join(`, `)}`),process.exitCode=1;return}if(!await H()){fc();return}let a=await $(n);if(!a.ok){a.error instanceof Z?fc():(console.error(`Failed to update webhook triggers: ${q(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===i);if(!o){console.error(`Webhook not found: ${i}`),process.exitCode=1;return}let s=!(r.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of r){let[t]=Object.entries(Jo).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await qs(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof Z?fc():(console.error(`Failed to update webhook triggers: ${q(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function fc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function pc(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Show the enabled/disabled status of a webhook.
2416
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!i){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!r||r.length===0){console.error(`Missing required option: --trigger`),process.exitCode=1;return}for(let e of r)if(!Ol.includes(e)){console.error(`Invalid trigger: ${e}`),console.error(`Valid triggers: ${Ol.join(`, `)}`),process.exitCode=1;return}if(!await B()){Al();return}let a=await dc(n);if(!a.ok){a.error instanceof Q?Al():(console.error(`Failed to update webhook triggers: ${J(a.value)}`),process.exitCode=1);return}let o=a.value.find(e=>e.config.url===i);if(!o){console.error(`Webhook not found: ${i}`),process.exitCode=1;return}let s=!(r.length>0),c={documentsPublished:s,documentsUnpublished:s,releasesCreated:s,releasesUpdated:s,tagsCreated:s,tagsDeleted:s};for(let e of r){let[t]=Object.entries(sc).find(([,t])=>e===t)??[];t&&(c[t]=!0)}let l=await dl(n,o.config._id,{...o.config,...c});if(!l.ok){l.error instanceof Q?Al():(console.error(`Failed to update webhook triggers: ${J(l.value)}`),process.exitCode=1);return}console.info(`Webhook triggers updated: ${r.join(`, `)}`)}function Al(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function jl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Show the enabled/disabled status of a webhook.
2302
2417
 
2303
2418
  By default, this command reads the repository from prismic.config.json at the
2304
2419
  project root.
@@ -2314,7 +2429,7 @@ FLAGS
2314
2429
  -h, --help Show help for command
2315
2430
 
2316
2431
  LEARN MORE
2317
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){mc();return}let i=await $(n);if(!i.ok){i.error instanceof Z?mc():(console.error(`Failed to get webhook status: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=a.config.active?`enabled`:`disabled`;console.info(o)}function mc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function hc(){let{values:{help:t,repo:n=await Y()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Trigger a test webhook in a Prismic repository.
2432
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Ml();return}let i=await dc(n);if(!i.ok){i.error instanceof Q?Ml():(console.error(`Failed to get webhook status: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=a.config.active?`enabled`:`disabled`;console.info(o)}function Ml(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Nl(){let{values:{help:t,repo:n=await X()},positionals:[r]}=e({args:process.argv.slice(4),options:{repo:{type:`string`,short:`r`},help:{type:`boolean`,short:`h`}},allowPositionals:!0});if(t){console.info(`Trigger a test webhook in a Prismic repository.
2318
2433
 
2319
2434
  By default, this command reads the repository from prismic.config.json at the
2320
2435
  project root.
@@ -2330,7 +2445,7 @@ FLAGS
2330
2445
  -h, --help Show help for command
2331
2446
 
2332
2447
  LEARN MORE
2333
- Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await H()){_c();return}let i=await $(n);if(!i.ok){i.error instanceof Z?_c():(console.error(`Failed to test webhook: ${q(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await gc(n,a.config._id);if(!o.ok){o.error instanceof Z?_c():(console.error(`Failed to test webhook: ${q(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function gc(e,t){return await X(new URL(`/app/settings/webhooks/${t}/trigger`,await V(e)),{method:`POST`})}function _c(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function vc(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await rc();break;case`create`:await Qs();break;case`view`:await Yo();break;case`remove`:await ac();break;case`test`:await hc();break;case`enable`:await Ks();break;case`disable`:await tc();break;case`status`:await pc();break;case`add-header`:await Ys();break;case`remove-header`:await cc();break;case`set-triggers`:await dc();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
2448
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.`);return}if(!r){console.error(`Missing required argument: <url>`),process.exitCode=1;return}if(!n){console.error(`Missing prismic.config.json or --repo option`),process.exitCode=1;return}if(!await B()){Fl();return}let i=await dc(n);if(!i.ok){i.error instanceof Q?Fl():(console.error(`Failed to test webhook: ${J(i.value)}`),process.exitCode=1);return}let a=i.value.find(e=>e.config.url===r);if(!a){console.error(`Webhook not found: ${r}`),process.exitCode=1;return}let o=await Pl(n,a.config._id);if(!o.ok){o.error instanceof Q?Fl():(console.error(`Failed to test webhook: ${J(o.value)}`),process.exitCode=1);return}console.info(`Test webhook triggered: ${r}`)}async function Pl(e,t){return await Z(new URL(`/app/settings/webhooks/${t}/trigger`,await z(e)),{method:`POST`})}function Fl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}async function Il(){let{positionals:[t]}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}},allowPositionals:!0,strict:!1});switch(t){case`list`:await xl();break;case`create`:await gl();break;case`view`:await cc();break;case`remove`:await Cl();break;case`test`:await Nl();break;case`enable`:await ul();break;case`disable`:await yl();break;case`status`:await jl();break;case`add-header`:await pl();break;case`remove-header`:await El();break;case`set-triggers`:await kl();break;default:t&&(console.error(`Unknown webhook subcommand: ${t}\n`),process.exitCode=1),console.info(`Manage webhooks in a Prismic repository.
2334
2449
 
2335
2450
  USAGE
2336
2451
  prismic webhook <command> [flags]
@@ -2352,7 +2467,7 @@ FLAGS
2352
2467
  -h, --help Show help for command
2353
2468
 
2354
2469
  LEARN MORE
2355
- Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function yc(){let{values:{help:t}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t){console.info(`Show the currently logged in user.
2470
+ Use \`prismic webhook <command> --help\` for more information about a command.`)}}async function Ll(){let{values:{help:t}}=e({args:process.argv.slice(3),options:{help:{type:`boolean`,short:`h`}}});if(t){console.info(`Show the currently logged in user.
2356
2471
 
2357
2472
  USAGE
2358
2473
  prismic whoami [flags]
@@ -2361,7 +2476,7 @@ FLAGS
2361
2476
  -h, --help Show help for command
2362
2477
 
2363
2478
  LEARN MORE
2364
- Use \`prismic <command> --help\` for more information about a command.`);return}if(!await H()){xc();return}let n=await bc();if(!n.ok){n.error instanceof Z?xc():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function bc(){return await X(new URL(`profile`,await vn()),{schema:F({email:R()})})}function xc(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Sc,values:{version:Cc}}=e({options:{help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}},allowPositionals:!0,strict:!1});if(Cc)console.info(ee);else switch(Sc[0]){case`init`:await Qr();break;case`login`:await gi();break;case`logout`:await yi();break;case`whoami`:await yc();break;case`status`:await is();break;case`repo`:await po();break;case`locale`:await mi();break;case`page-type`:await da();break;case`custom-type`:await Fr();break;case`slice`:await Bo();break;case`pull`:await Ra();break;case`push`:await Va();break;case`codegen`:await Gn();break;case`docs`:await Vr();break;case`preview`:await La();break;case`token`:await Gs();break;case`webhook`:await vc();break;default:Sc[0]&&(console.error(`Unknown command: ${Sc[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
2479
+ Use \`prismic <command> --help\` for more information about a command.`);return}if(!await B()){zl();return}let n=await Rl();if(!n.ok){n.error instanceof Q?zl():console.error(`Failed to fetch user profile.`),process.exitCode=1;return}console.info(n.value.email)}async function Rl(){return await Z(new URL(`profile`,await Sn()),{schema:N({email:I()})})}function zl(){console.error("Not logged in. Run `prismic login` first."),process.exitCode=1}const{positionals:Bl,values:{version:Vl}}=e({options:{help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`}},allowPositionals:!0,strict:!1});if(Vl)console.info(te);else switch(Bl[0]){case`init`:await pi();break;case`login`:await Mi();break;case`logout`:await Fi();break;case`whoami`:await Ll();break;case`status`:await Sc();break;case`repo`:await ns();break;case`locale`:await Ai();break;case`page-type`:await Za();break;case`custom-type`:await Ur();break;case`slice`:await oc();break;case`pull`:await To();break;case`push`:await Oo();break;case`codegen`:await Xn();break;case`docs`:await ni();break;case`preview`:await wo();break;case`token`:await ll();break;case`webhook`:await Il();break;default:Bl[0]&&(console.error(`Unknown command: ${Bl[0]}`),process.exitCode=1),console.info(`Prismic CLI for managing repositories and configurations.
2365
2480
 
2366
2481
  USAGE
2367
2482
  prismic <command> [flags]
@@ -2380,7 +2495,7 @@ COMMANDS
2380
2495
  pull Pull types and slices from Prismic
2381
2496
  push Push types and slices to Prismic
2382
2497
  codegen Generate code from Prismic models
2383
- docs Fetch documentation from Prismic
2498
+ docs Fetch and list documentation from Prismic
2384
2499
  preview Manage preview configurations
2385
2500
  token Manage API tokens in a repository
2386
2501
  webhook Manage webhooks in a repository