slice-machine-ui 2.18.2-alpha.jp-remove-shared-onboarding-experiment.1 → 2.18.2-beta.1

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 (36) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/{i632DEuY6Pn0ou44eYq-f → 7OUQL9pGJiLbv-sShLrNY}/_buildManifest.js +1 -1
  3. package/out/_next/static/chunks/04ad993f.d7f986af0f739cc9.js +28 -0
  4. package/out/_next/static/chunks/{248-84a5987f0499b074.js → 248-a9c33f7fbe2da2f1.js} +1 -1
  5. package/out/_next/static/chunks/{34-28725deef8b874b1.js → 34-50c64778da33cff6.js} +1 -1
  6. package/out/_next/static/chunks/{489-e4e2b7ea47c1f951.js → 489-a046ae0fa4f74435.js} +1 -1
  7. package/out/_next/static/chunks/630-eae75e90b30f201a.js +1 -0
  8. package/out/_next/static/chunks/{647-aa094286bc248d52.js → 647-4379a741c8d85d9e.js} +1 -1
  9. package/out/_next/static/chunks/{907-180eb33eefccc237.js → 907-445266211c48b1a5.js} +1 -1
  10. package/out/_next/static/chunks/pages/{_app-2338c00e4cd430c7.js → _app-4cae830590a43179.js} +196 -196
  11. package/out/_next/static/chunks/pages/{changelog-8514e0696e90a1b2.js → changelog-3901f2fc937d9648.js} +1 -1
  12. package/out/_next/static/chunks/pages/changes-c58a60af39167147.js +1 -0
  13. package/out/_next/static/chunks/pages/{labs-56fd818a63553497.js → labs-dd04033db23a58f3.js} +1 -1
  14. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-faeb6d2f77d97096.js → simulator-f237aaa755dc9a99.js} +1 -1
  15. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-e973a443d8b8a75d.js → [variation]-c8c3e7ffb898261c.js} +1 -1
  16. package/out/_next/static/chunks/pages/{slices-887783a5a2142ed7.js → slices-0aaae79dcc7b8c55.js} +1 -1
  17. package/out/_next/static/chunks/webpack-e0c07a2fe4908d81.js +1 -0
  18. package/out/changelog.html +1 -1
  19. package/out/changes.html +1 -1
  20. package/out/custom-types/[customTypeId].html +1 -1
  21. package/out/custom-types.html +1 -1
  22. package/out/index.html +1 -1
  23. package/out/labs.html +1 -1
  24. package/out/page-types/[pageTypeId].html +1 -1
  25. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  26. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  27. package/out/slices.html +1 -1
  28. package/package.json +6 -6
  29. package/src/features/onboarding/OnboardingGuide.tsx +5 -2
  30. package/src/features/onboarding/useOnboarding.ts +14 -1
  31. package/src/features/onboarding/useSharedOnboardingExperiment.ts +6 -0
  32. package/out/_next/static/chunks/630-fb5945894ef58200.js +0 -1
  33. package/out/_next/static/chunks/a6495ab1.00190ac98e794d8f.js +0 -28
  34. package/out/_next/static/chunks/pages/changes-e04382aa2eef790f.js +0 -1
  35. package/out/_next/static/chunks/webpack-24ddb02bea621501.js +0 -1
  36. /package/out/_next/static/{i632DEuY6Pn0ou44eYq-f → 7OUQL9pGJiLbv-sShLrNY}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[647],{77630:function(e,t,n){n.d(t,{AK:function(){return v},E3:function(){return p},EN:function(){return f},F$:function(){return x},H8:function(){return C},HO:function(){return h},L4:function(){return g},N3:function(){return c},Tr:function(){return d},Ue:function(){return I},eK:function(){return S},gR:function(){return b},j5:function(){return a},mf:function(){return m},vB:function(){return y},xS:function(){return j},y6:function(){return i}});var r=n(98863),o=n(88866);function i(e){var t;return null!==(t=e.format)&&void 0!==t?t:"custom"}function l(e){return Object.entries(e.json)}function s(e){return l(e).find(e=>{let[t,n]=e;return Object.values(n).some(e=>"UID"===e.type)})}function a(e){var t;let[n,r]=null!==(t=s(e))&&void 0!==t?t:[];return Object.entries(null!=r?r:{}).find(e=>{let[t,n]=e;return"UID"===n.type})}function c(e){var t,n;return null!==(n=null==e?void 0:null===(t=e.config)||void 0===t?void 0:t.label)&&void 0!==n?n:void 0}function u(e,t){let n=e.json[t];if(void 0!==n)return Object.entries(n).find(e=>{let[t,n]=e;return n.type===o.SlicesFieldType})}function d(e,t){if(function(e,t){var n;let r=u(e,t),[o,i]=null!=r?r:[];return null!==(n=null==i?void 0:i.config)&&void 0!==n?n:void 0}(e,t))return e;let n=function(e,t){let n;let r=l(e),i=r.findIndex(e=>{let[n]=e;return n===t}),s=r.flatMap(e=>{let[t,n]=e;return Object.keys(n).filter(e=>n[e].type===o.SlicesFieldType)}),a=i;do n="slices".concat(0!==a?a.toString():""),a++;while(s.includes(n));return n}(e,t);return{...e,json:{...e.json,[t]:{...e.json[t],[n]:{type:o.SlicesFieldType,fieldset:"Slice Zone"}}}}}function p(e,t){let n=e.json[t];if(void 0===n)return e;let i=Object.keys(n).find(e=>n[e].type===o.SlicesFieldType);if(void 0===i)return e;let l=(0,r.ud)(n,i);return{...e,json:{...e.json,[t]:l}}}function f(e){var t,n;let{customType:i,sectionId:l,sliceId:s}=e,a=i.json[l];if(void 0===a)return i;let c=Object.keys(a).find(e=>a[e].type===o.SlicesFieldType);if(void 0===c)return i;let u=a[c];if(u.type!==o.SlicesFieldType)return i;let d=(0,r.ud)(null!==(n=null===(t=u.config)||void 0===t?void 0:t.choices)&&void 0!==n?n:{},s);return{...i,json:{...i.json,[l]:{...a,[c]:{...u,config:{...u.config,choices:d}}}}}}function m(e){let t={...e,format:"page"},n=l(e)[0];if(n){let[e]=n;t=d(t,e)}return t}function y(e,t){return{...e,json:{...e.json,[t]:{}}}}function x(e,t){let n=(0,r.ud)(e.json,t);return{...e,json:n}}function h(e,t,n){if(t===n)return e;let r=Object.keys(e.json).reduce((r,o)=>(o===t?r[n]=e.json[o]:r[o]=e.json[o],r),{});return{...e,json:r}}function j(e){let{customType:t,sectionId:n,newField:r,newFieldId:i}=e,l=t.json[n],s=u(t,n),a={...Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),[i]:r};if(void 0!==s){let[e,t]=s;a[e]=t}return T({customType:t,sectionId:n,updatedSection:a})}function v(e){let{customType:t,sectionId:n,fieldId:o}=e,i=(0,r.ud)(t.json[n],o);return T({customType:t,sectionId:n,updatedSection:i})}function g(e){let{customType:t,sectionId:n,previousFieldId:r,newFieldId:o,newField:i}=e,l=w({fields:t.json[n],previousFieldId:r,newFieldId:o,newField:i});return T({customType:t,sectionId:n,updatedSection:l})}function b(e){let{customType:t,sectionId:n,sourceIndex:r,destinationIndex:i}=e,l=t.json[n],s=u(t,n),a=Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),c="page"===t.format&&t.repeatable,d=Object.fromEntries(Object.entries(a).filter(e=>{let[t,n]=e;return"UID"!==n.type})),p=function(e){let{fields:t,sourceIndex:n,destinationIndex:r}=e,o=Object.entries(t),[i]=o.splice(n,1);return o.splice(r,0,i),Object.fromEntries(o)}({fields:c?d:a,sourceIndex:r,destinationIndex:i});if(void 0!==s){let[e,t]=s;p[e]=t}let f=Object.entries(p),m=Object.entries(a).find(e=>{let[t,n]=e;return"UID"===n.type});m&&f.unshift(m);let y=Object.fromEntries(f);return T({customType:t,sectionId:n,updatedSection:c?y:p})}function C(e,t){let n=l(t)[0],[r]=null!=n?n:[];return void 0===r?t:j({customType:t,sectionId:r,newField:{type:"UID",config:{label:e}},newFieldId:"uid"})}function S(e,t){var n,r;let[o]=null!==(n=s(t))&&void 0!==n?n:[],[i,l]=null!==(r=a(t))&&void 0!==r?r:[];if(!l||void 0===i||void 0===o)return t;let c=w({fields:t.json[o],previousFieldId:i,newFieldId:i,newField:{...l,config:{...l.config,label:e}}});return T({customType:t,sectionId:o,updatedSection:c})}function T(e){let{customType:t,sectionId:n,updatedSection:r}=e;return{...t,json:{...t.json,[n]:r}}}function w(e){let{fields:t,previousFieldId:n,newFieldId:r,newField:o}=e;return Object.entries(t).reduce((e,t)=>{let[i,l]=t;return i===n?e[r]=o:i!==r&&(e[i]=l),e},{})}function I(e){let{id:t,label:n,repeatable:r,format:o}=e,i=!1===r&&"page"===o?{...O,...R}:!1===r?k:"page"===o?{...N,...R}:F;return{format:o,id:t,json:i,label:n,repeatable:r,status:!0}}let k={Main:{}},O={Main:{slices:{config:{choices:{}},fieldset:"Slice Zone",type:"Slices"}}},F={Main:{uid:{type:"UID",config:{label:"UID"}}}},N={Main:{...F.Main,...O.Main}},R={"SEO & Metadata":{meta_title:{config:{label:"Meta Title",placeholder:"A title of the page used for social media and search engines"},type:"Text"},meta_description:{config:{label:"Meta Description",placeholder:"A brief summary of the page"},type:"Text"},meta_image:{config:{constraint:{height:1260,width:2400},label:"Meta Image",thumbnails:[]},type:"Image"}}}},60867:function(e,t,n){n.d(t,{_:function(){return N}});var r=n(52322),o=n(11699),i=n(5632),l=n(2784),s=n(65186),a=n(59326),c=n(75289),u=n(88932),d=n(80148),p=n(98564);async function f(e){let{customType:t,onSuccess:n}=e,r=p.$[t.format];try{let{errors:e}=await d.managerClient.customTypes.deleteCustomType({id:t.id});if(e.length>0)throw e;n(),u.Am.success("".concat(r.name({start:!0,plural:!1})," deleted"))}catch(t){let e="Internal Error: ".concat(r.name({start:!0,plural:!1})," could not be deleted");console.error(e,t),u.Am.error(e)}}var m=n(33986),y=n(30527),x=n(55862),h=n(54597);let j=e=>{var t;let{customType:n,format:o,onClose:i,onDeleteCustomTypeSuccess:u}=e,d=p.$[o],[j,v]=(0,l.useState)(!1),{deleteCustomTypeSuccess:g}=(0,h.Z)(),b=async()=>{v(!0),await f({customType:n,onSuccess:()=>g(n.id)}),u()},{theme:C}=(0,a.B7)();return(0,r.jsx)(x.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:()=>i(),children:(0,r.jsx)(y.Z,{bodySx:{p:0,bg:"white",position:"relative",height:"100%",padding:16},footerSx:{position:"sticky",bottom:0,p:0},sx:{border:"none",overflow:"hidden"},borderFooter:!0,Header:(0,r.jsxs)(c.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",alignItems:"center",justifyContent:"space-between",borderBottom:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.borders))}},children:[(0,r.jsxs)(c.kC,{sx:{alignItems:"center"},children:[(0,r.jsx)(s.$vK,{size:20,color:null===(t=C.colors)||void 0===t?void 0:t.greyIcon}),(0,r.jsxs)(c.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:["Delete"," ",d.name({start:!1,plural:!1})]})]}),(0,r.jsx)(c.x8,{type:"button",onClick:()=>i()})]}),Footer:()=>(0,r.jsxs)(c.kC,{sx:{justifyContent:"flex-end",height:64,alignItems:"center",paddingRight:16,borderTop:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.darkBorders))},backgroundColor:"gray"},children:[(0,r.jsx)(m.z,{label:"Cancel",variant:"secondary",onClick:()=>i(),sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),void 0!==n&&(0,r.jsx)(m.z,{label:"Delete",variant:"danger",isLoading:j,onClick:()=>void b(),sx:{minHeight:39,minWidth:78}})]}),children:(0,r.jsxs)("div",{children:["This action will immediately make the following change:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Delete the"," ",(0,r.jsxs)(c.xv,{sx:{fontWeight:"bold"},children:["customtypes/",null==n?void 0:n.id,"/"]})," ","directory."]})}),"The next time you push your changes to Prismic, the following change will happen:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Remove the"," ",d.name({start:!1,plural:!1})," and any associated Documents from your repository."]})})]})})})};var v=n(56580);async function g(e){let{model:t,newLabel:n,onSuccess:r}=e,o=p.$[t.format];try{let e={...t,label:n},{errors:i}=await d.managerClient.customTypes.renameCustomType({model:e});if(i.length>0)throw i;r(e),u.Am.success("".concat(o.name({start:!0,plural:!1})," renamed"))}catch(t){let e="Internal Error: ".concat(o.name({start:!0,plural:!1})," could not be renamed");console.error(e,t),u.Am.error(e)}}var b=n(68968),C=n(78254),S=n(59532),T=n(46999);let w=e=>{var t,n;let{isChangesLocal:o,customType:i,format:s,onClose:a,setLocalCustomType:u}=e,d=null!==(t=null==i?void 0:i.label)&&void 0!==t?t:"",f=null!==(n=null==i?void 0:i.id)&&void 0!==n?n:"",{renameCustomTypeSuccess:m}=(0,h.Z)(),{syncChanges:y}=(0,b.g)(),[x,j]=(0,l.useState)(!1),w=async e=>{j(!0),o&&u?u({customType:{...i,label:e.customTypeName}}):await g({model:i,newLabel:e.customTypeName,onSuccess:e=>{m(e),y()}}),j(!1),a()},{customTypeLabels:I}=(0,v.v9)(e=>({customTypeLabels:(0,C.YS)(e)})),k=p.$[s];return(0,r.jsx)(S.Z,{isOpen:!0,testId:"rename-custom-type-modal",widthInPx:"530px",formId:"rename-custom-type-modal-".concat(f),buttonLabel:"Rename",close:a,onSubmit:e=>void w(e),initialValues:{customTypeName:d},isLoading:x,content:{title:"Rename a ".concat(k.name({start:!1,plural:!1}))},validate:e=>{let{customTypeName:t}=e,n={};return t&&t.length||(n.customTypeName="Cannot be empty."),void 0!=n.customTypeName&&I.includes(t)&&d!==t&&(n.customTypeName="".concat(k.name({start:!0,plural:!1})," name is already taken.")),["update","insert"].includes(t.toLowerCase())&&(n.customTypeName='Name "'.concat(t,'" is reserved for Slice Machine use.')),Object.keys(n).length>0?n:void 0},children:e=>{let{errors:t}=e;return(0,r.jsx)(c.xu,{children:(0,r.jsx)(T.W,{name:"customTypeName",label:"".concat(k.name({start:!0,plural:!1})," Name"),placeholder:"A display name for the ".concat(k.name({start:!1,plural:!1})),error:t.customTypeName,testId:"custom-type-name-input"})})}})};var I=n(94160),k=n(77630);async function O(e,t){let n=p.$[e.format];try{let r=(0,k.mf)(e),{errors:o}=await (0,I.KA)({customType:r});if(o.length>0)throw o;t(r),u.Am.success("".concat(n.name({start:!0,plural:!1})," converted to page type"))}catch(t){let e="Internal Error: ".concat(n.name({start:!0,plural:!1})," not converted to page type");console.error(e,t),u.Am.error(e)}}var F=n(59294);let N=e=>{let{format:t,customType:n,isChangesLocal:s,setLocalCustomType:a}=e,c=(0,i.useRouter)(),{saveCustomTypeSuccess:u}=(0,h.Z)(),[d,p]=(0,l.useState)(!1),[f,m]=(0,l.useState)(!1),[y,x]=(0,l.useState)(!1),v=async()=>{x(!0),await O(n,u);let e=F.cd.custom.getBuilderPagePathname(n.id);if(c.asPath===e){let e=F.cd.page.getBuilderPagePathname(n.id);c.replace(e),x(!1)}else x(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.ar,{children:[(0,r.jsx)(o.av,{disabled:y,children:(0,r.jsx)(o.aZ,{color:"grey","data-testid":"editDropdown",hiddenLabel:"Custom type actions",icon:"moreVert",loading:y,variant:"solid"})}),(0,r.jsxs)(o.as,{align:"end",children:[(0,r.jsx)(o.at,{startIcon:(0,r.jsx)(o.aX,{name:"edit"}),onSelect:()=>{m(!0)},children:"Rename"}),"custom"===t&&!s&&(0,r.jsx)(o.at,{startIcon:(0,r.jsx)(o.aX,{name:"driveFileMove"}),onSelect:()=>void v(),children:"Convert to page type"}),(0,r.jsx)(o.at,{color:"tomato",startIcon:(0,r.jsx)(o.aX,{name:"delete"}),onSelect:()=>{p(!0)},children:"Remove"})]})]}),d?(0,r.jsx)(j,{format:t,customType:n,onClose:()=>p(!1),onDeleteCustomTypeSuccess:()=>{var e;let{tablePagePathname:t}=F.cd[null!==(e=n.format)&&void 0!==e?e:"custom"];c.asPath!==t?c.replace(t):p(!1)}}):null,f?(0,r.jsx)(w,{format:t,customType:n,isChangesLocal:s,onClose:()=>m(!1),setLocalCustomType:a}):null]})}},50477:function(e,t,n){n.d(t,{NG:function(){return a},xU:function(){return l}});var r=n(18566),o=n(2784),i=n(80148);function l(e){let t=(0,o.useCallback)(t=>(0,r.VA)(s,[e],t),[e]);return{customTypes:(0,r.QT)(s,[e]),updateCustomTypes:t}}async function s(e){let{errors:t,models:n}=await i.managerClient.customTypes.readAllCustomTypes(e?{format:e}:void 0);if(t.length>0)throw t;return n.map(e=>{let{model:t}=e;return t})}function a(e){(0,r.gw)(s,[]),(0,r.gw)(s,[e])}},33986:function(e,t,n){n.d(t,{z:function(){return a}});var r=n(52322),o=n(2784),i=n(75289);let l=(e,t)=>e?"".concat(e,"-").concat(t):"",s=e=>{switch(e){case"white":case"secondaryMedium":case"secondarySmall":case"secondary":return"#1A1523";default:return"grey01"}},a=(0,o.forwardRef)((e,t)=>{let{label:n,Icon:o,type:a,form:c,isLoading:u=!1,disabled:d=!1,onClick:p,sx:f={},iconSize:m=16,iconFill:y,variant:x="primary",...h}=e;return(0,r.jsx)(i.zx,{ref:t,sx:{...f,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",...u?{cursor:"wait !important"}:{}},type:a,form:c,disabled:d||u,onClick:u?void 0:p,variant:x,...h,children:u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.$j,{size:m,color:s(x),"data-testid":l(h["data-testid"],"spinner")}),o&&n]}):(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(o,{size:m,fill:y,"data-testid":l(h["data-testid"],"icon")}),n]})})})},46999:function(e,t,n){n.d(t,{W:function(){return l}});var r=n(52322),o=n(63397);n(2784);var i=n(75289);let l=e=>{let{name:t,label:n,placeholder:l,error:s,testId:a,onChange:c}=e;return(0,r.jsxs)(i.xu,{mb:3,children:[(0,r.jsx)(i.__,{htmlFor:t,mb:2,children:n}),(0,r.jsx)(o.gN,{name:t,type:"text",placeholder:l,as:i.II,autoComplete:"off",...c?{onChange:c}:null,...a?{"data-testid":a}:null}),s?(0,r.jsx)(i.xv,{"data-testid":a?"".concat(a,"-error"):"input-error",sx:{color:"error",mt:1},children:s}):null]})}},59532:function(e,t,n){var r=n(52322),o=n(63397),i=n(37149),l=n.n(i),s=n(75289),a=n(33986),c=n(55862),u=n(30527);function d(e){let{children:t}=e,n=(0,u.W)();return(0,r.jsx)(s.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",pl:4,bg:"headSection",alignItems:"center",justifyContent:"space-between",borderTopLeftRadius:n,borderTopRightRadius:n,borderBottom:e=>{var t;return"1px solid ".concat(null===(t=e.colors)||void 0===t?void 0:t.borders)}},children:t})}t.Z=function(e){let{children:t,close:n,isOpen:i,formId:p,validate:f,onSubmit:m,widthInPx:y,initialValues:x,content:{title:h},cardProps:j,omitFooter:v=!1,isLoading:g=!1,buttonLabel:b="Save",testId:C,actionMessage:S}=e;return l().setAppElement("#__next"),(0,r.jsx)(c.Z,{isOpen:i,shouldCloseOnOverlayClick:!0,onRequestClose:n,contentLabel:h,style:{content:{width:null!=y?y:"900px"}},children:(0,r.jsx)(o.J9,{initialValues:x,validate:e=>f?f(e):void 0,onSubmit:e=>{m(e)},children:e=>{let{isValid:i,isSubmitting:l,values:c,errors:f,touched:m,setFieldValue:y,setValues:x}=e;return(0,r.jsx)(o.l0,{id:p,...null!=C?{"data-testid":C}:null,children:(0,r.jsx)(u.Z,{borderFooter:!0,footerSx:{p:3,position:"sticky",bottom:0,background:"gray"},bodySx:{px:4,py:4},sx:{border:"none"},...j,Header:(0,r.jsxs)(d,{children:[(0,r.jsx)(s.X6,{sx:{fontSize:"20px"},children:h}),(0,r.jsx)(s.x8,{type:"button",onClick:n})]}),Footer:v?null:(0,r.jsxs)(s.kC,{sx:{alignItems:"space-between"},children:[(0,r.jsx)(s.kC,{sx:{fontSize:"14px",alignItems:"center"},children:"function"==typeof S?S(e):S}),(0,r.jsxs)(s.kC,{sx:{ml:"auto"},children:[(0,r.jsx)(s.zx,{mr:2,type:"button",onClick:n,variant:"secondary",disabled:l||g,children:"Cancel"}),(0,r.jsx)(a.z,{label:b,form:p,type:"submit",disabled:!i||l||g,isLoading:l||g,sx:{fontWeight:"400",paddingBlock:"8px",paddingInline:"16px",fontSize:"14px",borderRadius:"4px"}})]})]}),children:t({isValid:i,isSubmitting:l,values:c,errors:f,touched:m,setFieldValue:y,setValues:x})})})}})})}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[647],{77630:function(e,t,n){n.d(t,{AK:function(){return v},E3:function(){return p},EN:function(){return f},F$:function(){return x},H8:function(){return C},HO:function(){return h},L4:function(){return g},N3:function(){return c},Tr:function(){return d},Ue:function(){return I},eK:function(){return S},gR:function(){return b},j5:function(){return a},mf:function(){return m},vB:function(){return y},xS:function(){return j},y6:function(){return i}});var r=n(98863),o=n(88866);function i(e){var t;return null!==(t=e.format)&&void 0!==t?t:"custom"}function l(e){return Object.entries(e.json)}function s(e){return l(e).find(e=>{let[t,n]=e;return Object.values(n).some(e=>"UID"===e.type)})}function a(e){var t;let[n,r]=null!==(t=s(e))&&void 0!==t?t:[];return Object.entries(null!=r?r:{}).find(e=>{let[t,n]=e;return"UID"===n.type})}function c(e){var t,n;return null!==(n=null==e?void 0:null===(t=e.config)||void 0===t?void 0:t.label)&&void 0!==n?n:void 0}function u(e,t){let n=e.json[t];if(void 0!==n)return Object.entries(n).find(e=>{let[t,n]=e;return n.type===o.SlicesFieldType})}function d(e,t){if(function(e,t){var n;let r=u(e,t),[o,i]=null!=r?r:[];return null!==(n=null==i?void 0:i.config)&&void 0!==n?n:void 0}(e,t))return e;let n=function(e,t){let n;let r=l(e),i=r.findIndex(e=>{let[n]=e;return n===t}),s=r.flatMap(e=>{let[t,n]=e;return Object.keys(n).filter(e=>n[e].type===o.SlicesFieldType)}),a=i;do n="slices".concat(0!==a?a.toString():""),a++;while(s.includes(n));return n}(e,t);return{...e,json:{...e.json,[t]:{...e.json[t],[n]:{type:o.SlicesFieldType,fieldset:"Slice Zone"}}}}}function p(e,t){let n=e.json[t];if(void 0===n)return e;let i=Object.keys(n).find(e=>n[e].type===o.SlicesFieldType);if(void 0===i)return e;let l=(0,r.ud)(n,i);return{...e,json:{...e.json,[t]:l}}}function f(e){var t,n;let{customType:i,sectionId:l,sliceId:s}=e,a=i.json[l];if(void 0===a)return i;let c=Object.keys(a).find(e=>a[e].type===o.SlicesFieldType);if(void 0===c)return i;let u=a[c];if(u.type!==o.SlicesFieldType)return i;let d=(0,r.ud)(null!==(n=null===(t=u.config)||void 0===t?void 0:t.choices)&&void 0!==n?n:{},s);return{...i,json:{...i.json,[l]:{...a,[c]:{...u,config:{...u.config,choices:d}}}}}}function m(e){let t={...e,format:"page"},n=l(e)[0];if(n){let[e]=n;t=d(t,e)}return t}function y(e,t){return{...e,json:{...e.json,[t]:{}}}}function x(e,t){let n=(0,r.ud)(e.json,t);return{...e,json:n}}function h(e,t,n){if(t===n)return e;let r=Object.keys(e.json).reduce((r,o)=>(o===t?r[n]=e.json[o]:r[o]=e.json[o],r),{});return{...e,json:r}}function j(e){let{customType:t,sectionId:n,newField:r,newFieldId:i}=e,l=t.json[n],s=u(t,n),a={...Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),[i]:r};if(void 0!==s){let[e,t]=s;a[e]=t}return T({customType:t,sectionId:n,updatedSection:a})}function v(e){let{customType:t,sectionId:n,fieldId:o}=e,i=(0,r.ud)(t.json[n],o);return T({customType:t,sectionId:n,updatedSection:i})}function g(e){let{customType:t,sectionId:n,previousFieldId:r,newFieldId:o,newField:i}=e,l=w({fields:t.json[n],previousFieldId:r,newFieldId:o,newField:i});return T({customType:t,sectionId:n,updatedSection:l})}function b(e){let{customType:t,sectionId:n,sourceIndex:r,destinationIndex:i}=e,l=t.json[n],s=u(t,n),a=Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),c="page"===t.format&&t.repeatable,d=Object.fromEntries(Object.entries(a).filter(e=>{let[t,n]=e;return"UID"!==n.type})),p=function(e){let{fields:t,sourceIndex:n,destinationIndex:r}=e,o=Object.entries(t),[i]=o.splice(n,1);return o.splice(r,0,i),Object.fromEntries(o)}({fields:c?d:a,sourceIndex:r,destinationIndex:i});if(void 0!==s){let[e,t]=s;p[e]=t}let f=Object.entries(p),m=Object.entries(a).find(e=>{let[t,n]=e;return"UID"===n.type});m&&f.unshift(m);let y=Object.fromEntries(f);return T({customType:t,sectionId:n,updatedSection:c?y:p})}function C(e,t){let n=l(t)[0],[r]=null!=n?n:[];return void 0===r?t:j({customType:t,sectionId:r,newField:{type:"UID",config:{label:e}},newFieldId:"uid"})}function S(e,t){var n,r;let[o]=null!==(n=s(t))&&void 0!==n?n:[],[i,l]=null!==(r=a(t))&&void 0!==r?r:[];if(!l||void 0===i||void 0===o)return t;let c=w({fields:t.json[o],previousFieldId:i,newFieldId:i,newField:{...l,config:{...l.config,label:e}}});return T({customType:t,sectionId:o,updatedSection:c})}function T(e){let{customType:t,sectionId:n,updatedSection:r}=e;return{...t,json:{...t.json,[n]:r}}}function w(e){let{fields:t,previousFieldId:n,newFieldId:r,newField:o}=e;return Object.entries(t).reduce((e,t)=>{let[i,l]=t;return i===n?e[r]=o:i!==r&&(e[i]=l),e},{})}function I(e){let{id:t,label:n,repeatable:r,format:o}=e,i=!1===r&&"page"===o?{...O,...R}:!1===r?k:"page"===o?{...N,...R}:F;return{format:o,id:t,json:i,label:n,repeatable:r,status:!0}}let k={Main:{}},O={Main:{slices:{config:{choices:{}},fieldset:"Slice Zone",type:"Slices"}}},F={Main:{uid:{type:"UID",config:{label:"UID"}}}},N={Main:{...F.Main,...O.Main}},R={"SEO & Metadata":{meta_title:{config:{label:"Meta Title",placeholder:"A title of the page used for social media and search engines"},type:"Text"},meta_description:{config:{label:"Meta Description",placeholder:"A brief summary of the page"},type:"Text"},meta_image:{config:{constraint:{height:1260,width:2400},label:"Meta Image",thumbnails:[]},type:"Image"}}}},60867:function(e,t,n){n.d(t,{_:function(){return N}});var r=n(52322),o=n(14226),i=n(5632),l=n(2784),s=n(65186),a=n(59326),c=n(75289),u=n(88932),d=n(80148),p=n(98564);async function f(e){let{customType:t,onSuccess:n}=e,r=p.$[t.format];try{let{errors:e}=await d.managerClient.customTypes.deleteCustomType({id:t.id});if(e.length>0)throw e;n(),u.Am.success("".concat(r.name({start:!0,plural:!1})," deleted"))}catch(t){let e="Internal Error: ".concat(r.name({start:!0,plural:!1})," could not be deleted");console.error(e,t),u.Am.error(e)}}var m=n(33986),y=n(30527),x=n(55862),h=n(54597);let j=e=>{var t;let{customType:n,format:o,onClose:i,onDeleteCustomTypeSuccess:u}=e,d=p.$[o],[j,v]=(0,l.useState)(!1),{deleteCustomTypeSuccess:g}=(0,h.Z)(),b=async()=>{v(!0),await f({customType:n,onSuccess:()=>g(n.id)}),u()},{theme:C}=(0,a.B7)();return(0,r.jsx)(x.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:()=>i(),children:(0,r.jsx)(y.Z,{bodySx:{p:0,bg:"white",position:"relative",height:"100%",padding:16},footerSx:{position:"sticky",bottom:0,p:0},sx:{border:"none",overflow:"hidden"},borderFooter:!0,Header:(0,r.jsxs)(c.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",alignItems:"center",justifyContent:"space-between",borderBottom:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.borders))}},children:[(0,r.jsxs)(c.kC,{sx:{alignItems:"center"},children:[(0,r.jsx)(s.$vK,{size:20,color:null===(t=C.colors)||void 0===t?void 0:t.greyIcon}),(0,r.jsxs)(c.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:["Delete"," ",d.name({start:!1,plural:!1})]})]}),(0,r.jsx)(c.x8,{type:"button",onClick:()=>i()})]}),Footer:()=>(0,r.jsxs)(c.kC,{sx:{justifyContent:"flex-end",height:64,alignItems:"center",paddingRight:16,borderTop:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.darkBorders))},backgroundColor:"gray"},children:[(0,r.jsx)(m.z,{label:"Cancel",variant:"secondary",onClick:()=>i(),sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),void 0!==n&&(0,r.jsx)(m.z,{label:"Delete",variant:"danger",isLoading:j,onClick:()=>void b(),sx:{minHeight:39,minWidth:78}})]}),children:(0,r.jsxs)("div",{children:["This action will immediately make the following change:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Delete the"," ",(0,r.jsxs)(c.xv,{sx:{fontWeight:"bold"},children:["customtypes/",null==n?void 0:n.id,"/"]})," ","directory."]})}),"The next time you push your changes to Prismic, the following change will happen:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Remove the"," ",d.name({start:!1,plural:!1})," and any associated Documents from your repository."]})})]})})})};var v=n(56580);async function g(e){let{model:t,newLabel:n,onSuccess:r}=e,o=p.$[t.format];try{let e={...t,label:n},{errors:i}=await d.managerClient.customTypes.renameCustomType({model:e});if(i.length>0)throw i;r(e),u.Am.success("".concat(o.name({start:!0,plural:!1})," renamed"))}catch(t){let e="Internal Error: ".concat(o.name({start:!0,plural:!1})," could not be renamed");console.error(e,t),u.Am.error(e)}}var b=n(68968),C=n(78254),S=n(59532),T=n(46999);let w=e=>{var t,n;let{isChangesLocal:o,customType:i,format:s,onClose:a,setLocalCustomType:u}=e,d=null!==(t=null==i?void 0:i.label)&&void 0!==t?t:"",f=null!==(n=null==i?void 0:i.id)&&void 0!==n?n:"",{renameCustomTypeSuccess:m}=(0,h.Z)(),{syncChanges:y}=(0,b.g)(),[x,j]=(0,l.useState)(!1),w=async e=>{j(!0),o&&u?u({customType:{...i,label:e.customTypeName}}):await g({model:i,newLabel:e.customTypeName,onSuccess:e=>{m(e),y()}}),j(!1),a()},{customTypeLabels:I}=(0,v.v9)(e=>({customTypeLabels:(0,C.YS)(e)})),k=p.$[s];return(0,r.jsx)(S.Z,{isOpen:!0,testId:"rename-custom-type-modal",widthInPx:"530px",formId:"rename-custom-type-modal-".concat(f),buttonLabel:"Rename",close:a,onSubmit:e=>void w(e),initialValues:{customTypeName:d},isLoading:x,content:{title:"Rename a ".concat(k.name({start:!1,plural:!1}))},validate:e=>{let{customTypeName:t}=e,n={};return t&&t.length||(n.customTypeName="Cannot be empty."),void 0!=n.customTypeName&&I.includes(t)&&d!==t&&(n.customTypeName="".concat(k.name({start:!0,plural:!1})," name is already taken.")),["update","insert"].includes(t.toLowerCase())&&(n.customTypeName='Name "'.concat(t,'" is reserved for Slice Machine use.')),Object.keys(n).length>0?n:void 0},children:e=>{let{errors:t}=e;return(0,r.jsx)(c.xu,{children:(0,r.jsx)(T.W,{name:"customTypeName",label:"".concat(k.name({start:!0,plural:!1})," Name"),placeholder:"A display name for the ".concat(k.name({start:!1,plural:!1})),error:t.customTypeName,testId:"custom-type-name-input"})})}})};var I=n(94160),k=n(77630);async function O(e,t){let n=p.$[e.format];try{let r=(0,k.mf)(e),{errors:o}=await (0,I.KA)({customType:r});if(o.length>0)throw o;t(r),u.Am.success("".concat(n.name({start:!0,plural:!1})," converted to page type"))}catch(t){let e="Internal Error: ".concat(n.name({start:!0,plural:!1})," not converted to page type");console.error(e,t),u.Am.error(e)}}var F=n(59294);let N=e=>{let{format:t,customType:n,isChangesLocal:s,setLocalCustomType:a}=e,c=(0,i.useRouter)(),{saveCustomTypeSuccess:u}=(0,h.Z)(),[d,p]=(0,l.useState)(!1),[f,m]=(0,l.useState)(!1),[y,x]=(0,l.useState)(!1),v=async()=>{x(!0),await O(n,u);let e=F.cd.custom.getBuilderPagePathname(n.id);if(c.asPath===e){let e=F.cd.page.getBuilderPagePathname(n.id);c.replace(e),x(!1)}else x(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.ar,{children:[(0,r.jsx)(o.av,{disabled:y,children:(0,r.jsx)(o.aZ,{color:"grey","data-testid":"editDropdown",hiddenLabel:"Custom type actions",icon:"moreVert",loading:y,variant:"solid"})}),(0,r.jsxs)(o.as,{align:"end",children:[(0,r.jsx)(o.at,{startIcon:(0,r.jsx)(o.aX,{name:"edit"}),onSelect:()=>{m(!0)},children:"Rename"}),"custom"===t&&!s&&(0,r.jsx)(o.at,{startIcon:(0,r.jsx)(o.aX,{name:"driveFileMove"}),onSelect:()=>void v(),children:"Convert to page type"}),(0,r.jsx)(o.at,{color:"tomato",startIcon:(0,r.jsx)(o.aX,{name:"delete"}),onSelect:()=>{p(!0)},children:"Remove"})]})]}),d?(0,r.jsx)(j,{format:t,customType:n,onClose:()=>p(!1),onDeleteCustomTypeSuccess:()=>{var e;let{tablePagePathname:t}=F.cd[null!==(e=n.format)&&void 0!==e?e:"custom"];c.asPath!==t?c.replace(t):p(!1)}}):null,f?(0,r.jsx)(w,{format:t,customType:n,isChangesLocal:s,onClose:()=>m(!1),setLocalCustomType:a}):null]})}},50477:function(e,t,n){n.d(t,{NG:function(){return a},xU:function(){return l}});var r=n(18566),o=n(2784),i=n(80148);function l(e){let t=(0,o.useCallback)(t=>(0,r.VA)(s,[e],t),[e]);return{customTypes:(0,r.QT)(s,[e]),updateCustomTypes:t}}async function s(e){let{errors:t,models:n}=await i.managerClient.customTypes.readAllCustomTypes(e?{format:e}:void 0);if(t.length>0)throw t;return n.map(e=>{let{model:t}=e;return t})}function a(e){(0,r.gw)(s,[]),(0,r.gw)(s,[e])}},33986:function(e,t,n){n.d(t,{z:function(){return a}});var r=n(52322),o=n(2784),i=n(75289);let l=(e,t)=>e?"".concat(e,"-").concat(t):"",s=e=>{switch(e){case"white":case"secondaryMedium":case"secondarySmall":case"secondary":return"#1A1523";default:return"grey01"}},a=(0,o.forwardRef)((e,t)=>{let{label:n,Icon:o,type:a,form:c,isLoading:u=!1,disabled:d=!1,onClick:p,sx:f={},iconSize:m=16,iconFill:y,variant:x="primary",...h}=e;return(0,r.jsx)(i.zx,{ref:t,sx:{...f,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",...u?{cursor:"wait !important"}:{}},type:a,form:c,disabled:d||u,onClick:u?void 0:p,variant:x,...h,children:u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.$j,{size:m,color:s(x),"data-testid":l(h["data-testid"],"spinner")}),o&&n]}):(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(o,{size:m,fill:y,"data-testid":l(h["data-testid"],"icon")}),n]})})})},46999:function(e,t,n){n.d(t,{W:function(){return l}});var r=n(52322),o=n(63397);n(2784);var i=n(75289);let l=e=>{let{name:t,label:n,placeholder:l,error:s,testId:a,onChange:c}=e;return(0,r.jsxs)(i.xu,{mb:3,children:[(0,r.jsx)(i.__,{htmlFor:t,mb:2,children:n}),(0,r.jsx)(o.gN,{name:t,type:"text",placeholder:l,as:i.II,autoComplete:"off",...c?{onChange:c}:null,...a?{"data-testid":a}:null}),s?(0,r.jsx)(i.xv,{"data-testid":a?"".concat(a,"-error"):"input-error",sx:{color:"error",mt:1},children:s}):null]})}},59532:function(e,t,n){var r=n(52322),o=n(63397),i=n(37149),l=n.n(i),s=n(75289),a=n(33986),c=n(55862),u=n(30527);function d(e){let{children:t}=e,n=(0,u.W)();return(0,r.jsx)(s.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",pl:4,bg:"headSection",alignItems:"center",justifyContent:"space-between",borderTopLeftRadius:n,borderTopRightRadius:n,borderBottom:e=>{var t;return"1px solid ".concat(null===(t=e.colors)||void 0===t?void 0:t.borders)}},children:t})}t.Z=function(e){let{children:t,close:n,isOpen:i,formId:p,validate:f,onSubmit:m,widthInPx:y,initialValues:x,content:{title:h},cardProps:j,omitFooter:v=!1,isLoading:g=!1,buttonLabel:b="Save",testId:C,actionMessage:S}=e;return l().setAppElement("#__next"),(0,r.jsx)(c.Z,{isOpen:i,shouldCloseOnOverlayClick:!0,onRequestClose:n,contentLabel:h,style:{content:{width:null!=y?y:"900px"}},children:(0,r.jsx)(o.J9,{initialValues:x,validate:e=>f?f(e):void 0,onSubmit:e=>{m(e)},children:e=>{let{isValid:i,isSubmitting:l,values:c,errors:f,touched:m,setFieldValue:y,setValues:x}=e;return(0,r.jsx)(o.l0,{id:p,...null!=C?{"data-testid":C}:null,children:(0,r.jsx)(u.Z,{borderFooter:!0,footerSx:{p:3,position:"sticky",bottom:0,background:"gray"},bodySx:{px:4,py:4},sx:{border:"none"},...j,Header:(0,r.jsxs)(d,{children:[(0,r.jsx)(s.X6,{sx:{fontSize:"20px"},children:h}),(0,r.jsx)(s.x8,{type:"button",onClick:n})]}),Footer:v?null:(0,r.jsxs)(s.kC,{sx:{alignItems:"space-between"},children:[(0,r.jsx)(s.kC,{sx:{fontSize:"14px",alignItems:"center"},children:"function"==typeof S?S(e):S}),(0,r.jsxs)(s.kC,{sx:{ml:"auto"},children:[(0,r.jsx)(s.zx,{mr:2,type:"button",onClick:n,variant:"secondary",disabled:l||g,children:"Cancel"}),(0,r.jsx)(a.z,{label:b,form:p,type:"submit",disabled:!i||l||g,isLoading:l||g,sx:{fontWeight:"400",paddingBlock:"8px",paddingInline:"16px",fontSize:"14px",borderRadius:"4px"}})]})]}),children:t({isValid:i,isSubmitting:l,values:c,errors:f,touched:m,setFieldValue:y,setValues:x})})})}})})}}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[907],{91589:function(e,t,a){a.d(t,{S:function(){return h}});var r=a(52322),n=a(11699),i=a(2784),s=a(88932),l=a(94160),c=a(34166),o=a(98250),d=a(68968),u=a(80148),m=a(54597),p=a(62434);function g(e){let{slice:t}=e,a="uploading"===t.status||"generating"===t.status,i="uploadError"===t.status||"generateError"===t.status,s="generateError"===t.status||"generating"===t.status||"success"===t.status;return(0,r.jsxs)(p.Zb,{disabled:a,children:[s?(0,r.jsx)(p.ZB,{src:t.thumbnailUrl}):(0,r.jsx)(p.ZB,{component:"div"}),(0,r.jsx)(p.eW,{loading:a,startIcon:function(e){switch(e){case"uploadError":case"generateError":return"close";case"success":return"check";default:return}}(t.status),title:"success"===t.status?t.model.name:t.image.name,subtitle:function(e){switch(e){case"uploading":return"Uploading...";case"uploadError":return"Unable to upload image";case"generating":return"Generating...";case"generateError":return"Something went wrong";case"success":return"Generated"}}(t.status),error:i,action:i?(0,r.jsx)(n.E,{startIcon:"refresh",color:"grey",onClick:t.onRetry,children:"Retry"}):void 0})]})}function h(e){let{open:t,location:a,onSuccess:p,onClose:h}=e,[j,w]=(0,i.useState)([]),[b,C]=(0,i.useState)(!1),{syncChanges:v}=(0,d.g)(),{createSliceSuccess:I}=(0,m.Z)(),{completeStep:A}=(0,o.k)(),k=(0,i.useRef)(crypto.randomUUID()),E=e=>{let{index:t,slice:a}=e;w(e=>e.map((e,r)=>r===t?a(e):e))},U=e=>{if(e.length>10){s.Am.error("You can only upload ".concat(10," images at a time."));return}w(e.map(e=>({status:"uploading",image:e}))),e.forEach((e,t)=>N({index:t,image:e}))},N=e=>{let{index:t,image:a}=e,r=k.current;E({index:t,slice:e=>({...e,status:"uploading"})}),x({image:a}).then(e=>{r===k.current&&D({index:t,imageUrl:e})},()=>{r===k.current&&E({index:t,slice:e=>({...e,status:"uploadError",onRetry:()=>N({index:t,image:a})})})})},L=function(e){let{open:t}=e,a=(0,i.useRef)([]);return(0,i.useEffect)(()=>{t&&(a.current=[],u.managerClient.slices.readAllSlices().then(e=>{a.current=e.models.map(e=>{let{model:t}=e;return t})}).catch(()=>null))},[t]),a}({open:t}),D=e=>{let{index:t,imageUrl:a}=e,r=k.current;E({index:t,slice:e=>({...e,status:"generating",thumbnailUrl:a})}),u.managerClient.customTypes.inferSlice({imageUrl:a}).then(e=>{let{slice:n,langSmithUrl:i}=e;r===k.current&&w(e=>e.map((r,s)=>s===t?{...r,status:"success",thumbnailUrl:a,model:function(e){let{existingSlices:t,newSlices:a,slice:r}=e,n=new Set,i=new Set;for(let{id:e,name:a}of t)n.add(e),i.add(a.toLowerCase());for(let e of a)"success"===e.status&&(n.add(e.model.id),i.add(e.model.name.toLowerCase()));let s=r.id,l=2;for(;n.has(s);)s="".concat(r.id,"_").concat(l),l++;let c=r.name;for(l=2;i.has(c.toLowerCase());)c="".concat(r.name).concat(l),l++;return{...r,id:s,name:c}}({existingSlices:L.current,newSlices:e,slice:n}),langSmithUrl:i}:r))},()=>{r===k.current&&E({index:t,slice:e=>({...e,status:"generateError",thumbnailUrl:a,onRetry:()=>D({index:t,imageUrl:a})})})})},B=j.some(e=>"uploading"===e.status||"generating"===e.status),F=j.filter(e=>"success"===e.status),z=F.length>0;return(0,r.jsxs)(n.ae,{open:t,onOpenChange:e=>{e||b||(h(),k.current=crypto.randomUUID(),w([]))},children:[(0,r.jsx)(n.al,{title:"Generate from image"}),(0,r.jsxs)(n.aj,{gap:0,children:[(0,r.jsx)(n.ak,{hidden:!0,children:"Upload images to generate slices with AI"}),0===j.length?(0,r.jsx)(n.D,{padding:16,height:"100%",children:(0,r.jsx)(n.aF,{onFilesSelected:U,assetType:"image",maxFiles:10,overlay:(0,r.jsx)(f,{onFilesSelected:U,droppingFiles:!0}),children:(0,r.jsx)(f,{onFilesSelected:U})})}):(0,r.jsx)(n.bn,{stableScrollbar:!1,children:(0,r.jsx)(n.D,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:16,children:j.map((e,t)=>(0,r.jsx)(g,{slice:e},"slice-".concat(t)))})}),(0,r.jsxs)(n.ah,{children:[(0,r.jsx)(n.ai,{disabled:b}),(0,r.jsxs)(n.af,{disabled:!z||B,loading:b,onClick:()=>{let e=j.reduce((e,t)=>("success"===t.status&&e.push(t),e),[]);if(!e.length)return;let t=k.current;C(!0),y(e).then(async e=>{let{slices:r,library:n}=e;if(t===k.current)for(let{model:e,langSmithUrl:t}of(I((await (0,l.y0)()).libraries),v(),p({slices:r,library:n}),C(!1),k.current=crypto.randomUUID(),w([]),A("createSlice"),r))l.Xe.track({event:"slice:created",id:e.id,name:e.name,library:n,location:a,mode:"ai",langSmithUrl:t}),(0,c.nZ)({type:"model",library:n,sliceId:e.id,variationId:e.variations[0].id,langSmithUrl:t})}).catch(()=>{t===k.current&&(C(!1),s.Am.error("An unexpected error happened while adding slices."))})},children:[S(a)," (",F.length,")"]})]})]})]})}function f(e){let{droppingFiles:t=!1,onFilesSelected:a}=e;return(0,r.jsx)(n.D,{justifyContent:"center",flexDirection:"column",height:"100%",backgroundColor:t?"purple2":"grey2",border:!0,borderStyle:"dashed",borderColor:t?"purple9":"grey6",children:(0,r.jsxs)(n.s,{children:[(0,r.jsx)(n.x,{lineColor:"purple11",backgroundColor:"purple5",name:"cloudUpload",size:"large"}),(0,r.jsx)(n.z,{children:"Upload your design images."}),(0,r.jsx)(n.w,{children:"Once uploaded, you can generate slices automatically using AI."}),(0,r.jsx)(n.v,{children:(0,r.jsx)(n.aG,{startIcon:"attachFile",onFilesSelected:a,color:"grey",children:"Add images"})})]})})}async function x(e){let{image:t}=e,a=[await u.managerClient.project.getResolvedRepositoryName(),"shared-slices","prismic-inferred-slices",crypto.randomUUID()].join("/");await u.managerClient.screenshots.initS3ACL();let{url:r}=await u.managerClient.screenshots.uploadScreenshot({keyPrefix:a,data:t});return r}async function y(e){let{libraries:t=[]}=await u.managerClient.project.getSliceMachineConfig(),a=t[0];if(!a)throw Error("No library found in the config.");for(let{model:t}of e){let{errors:e}=await u.managerClient.slices.createSlice({libraryID:a,model:t});if(e.length)throw Error("Failed to create slice ".concat(t.id,"."))}let r=await Promise.all(e.map(async e=>{let{model:t,image:r,langSmithUrl:n}=e;return await u.managerClient.slices.updateSliceScreenshot({libraryID:a,sliceID:t.id,variationID:t.variations[0].id,data:r}),{model:t,langSmithUrl:n}}));return{library:a,slices:r}}let S=e=>{switch(e){case"custom_type":return"Add to type";case"page_type":return"Add to page";case"slices":return"Add to slices"}}},27213:function(e,t,a){a.d(t,{F:function(){return i}});var r=a(52322),n=a(11699);let i=e=>{let{menuType:t}=e;return{fromImage:{BackgroundIcon:(0,r.jsx)(n.B,{name:"autoFixHigh",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"purple",variant:"solid",radius:6}),title:"Generate from image",description:"Build a slice based on your design image."},fromScratch:{BackgroundIcon:(0,r.jsx)(n.B,{name:"add",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Start from scratch",description:"Build a custom slice your way."},fromTemplate:{BackgroundIcon:(0,r.jsx)(n.B,{name:"contentCopy",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Use a template",description:"Choose from ready-made examples."},fromExisting:{BackgroundIcon:(0,r.jsx)(n.B,{name:"folder",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Reuse an existing slice",description:"Select from your created slices."}}}},6256:function(e,t,a){a.d(t,{c:function(){return S}});var r=a(52322),n=a(2784),i=a(36131),s=a(75289),l=a(94160),c=a(98250),o=a(88932),d=a(63908),u=a(358),m=a(80148);async function p(e){let{sliceName:t,libraryName:a,location:r,onSuccess:n}=e;try{let e=(0,d.fo)(t),{errors:i}=await m.managerClient.slices.createSlice({libraryID:a,model:e});if(i.length>0)throw i;l.Xe.track({event:"slice:created",id:(0,u.MP)(t),name:t,library:a,location:r,mode:"manual"}),await n(e)}catch(a){let e="An unexpected error happened while creating slice ".concat(t,".");console.error(e,a),o.Am.error(e)}}var g=a(68968),h=a(59532),f=a(54597),x=a(46999),y=a(63019);let S=e=>{let{onClose:t,onSuccess:a,localLibraries:o,location:d,remoteSlices:u}=e,{createSliceSuccess:m}=(0,f.Z)(),[S,j]=(0,n.useState)(!1),{syncChanges:w}=(0,g.g)(),{completeStep:b}=(0,c.k)(),C=async e=>{let t=e.sliceName,r=e.from;j(!0),await p({sliceName:t,libraryName:r,location:d,onSuccess:async e=>{m((await (0,l.y0)()).libraries),a(e,r),w(),b("createSlice")}})};return(0,r.jsx)(h.Z,{testId:"create-slice-modal",isOpen:!0,widthInPx:"530px",isLoading:S,formId:"create-new-slice",close:t,buttonLabel:"Create",onSubmit:e=>{C(e)},initialValues:{sliceName:"",from:o[0].name},validate:e=>(0,y.h)(e,o,u),content:{title:"Create a new slice"},children:e=>{let{touched:t,values:a,setFieldValue:n,errors:l}=e;return(0,r.jsxs)(s.xu,{children:[(0,r.jsx)(x.W,{name:"sliceName",label:"Slice name",placeholder:"Pascalised slice API ID (e.g. TextBlock)",error:t.sliceName?l.sliceName:void 0,testId:"slice-name-input"}),(0,r.jsx)(s.__,{htmlFor:"from",sx:{mb:2},children:"Target Library"}),(0,r.jsx)(i.ZP,{name:"from",options:o.map(e=>({value:e.name,label:e.name})),onChange:e=>e?void n("from",e.value):null,defaultValue:{value:a.from,label:a.from},styles:{option:e=>({...e,color:"#161618"})},theme:e=>({...e,colors:{...e.colors,primary:"#E9E8EA"}}),menuPortalTarget:document.body})]})}})}},63019:function(e,t,a){a.d(t,{h:function(){return c}});var r=a(96009),n=a.n(r),i=a(74600),s=a.n(i),l=a(7974);function c(e,t,a){let{sliceName:r}=e;return r?l.lS.includes(r.toLowerCase())?{sliceName:'Name "'.concat(r,'" is reserved for Slice Machine use.')}:l.xo.exec(r)?s()(n()(r)).replace(/\s/gm,"")!==r.trim()?{sliceName:"Value has to be PascalCased."}:r.match(/^\d/)?{sliceName:"Value cannot start with a number."}:[...t.flatMap(e=>e.components.map(e=>e.model.name)),...a.map(e=>e.name)].includes(r)?{sliceName:"Slice name is already taken."}:void 0:{sliceName:"No special characters allowed."}:{sliceName:"Cannot be empty"}}},21151:function(e,t,a){var r=a(52322),n=a(75289);t.Z=function(e){let{elems:t,renderElem:a,defineElementKey:i,gridTemplateMinPx:s="320px",gridGap:l="16px",sx:c}=e;return(0,r.jsx)(n.xu,{as:"section",sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(".concat(s,", 1fr))"),gridGap:l,pt:2,...c},children:t.map((e,t)=>e?(0,r.jsx)("span",{children:a(e,t)},"".concat(i(e),"-").concat(t+1)):null)})}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[907],{91589:function(e,t,a){a.d(t,{S:function(){return h}});var r=a(52322),n=a(14226),i=a(2784),s=a(88932),l=a(94160),c=a(34166),o=a(98250),d=a(68968),u=a(80148),m=a(54597),p=a(62434);function g(e){let{slice:t}=e,a="uploading"===t.status||"generating"===t.status,i="uploadError"===t.status||"generateError"===t.status,s="generateError"===t.status||"generating"===t.status||"success"===t.status;return(0,r.jsxs)(p.Zb,{disabled:a,children:[s?(0,r.jsx)(p.ZB,{src:t.thumbnailUrl}):(0,r.jsx)(p.ZB,{component:"div"}),(0,r.jsx)(p.eW,{loading:a,startIcon:function(e){switch(e){case"uploadError":case"generateError":return"close";case"success":return"check";default:return}}(t.status),title:"success"===t.status?t.model.name:t.image.name,subtitle:function(e){switch(e){case"uploading":return"Uploading...";case"uploadError":return"Unable to upload image";case"generating":return"Generating...";case"generateError":return"Something went wrong";case"success":return"Generated"}}(t.status),error:i,action:i?(0,r.jsx)(n.E,{startIcon:"refresh",color:"grey",onClick:t.onRetry,children:"Retry"}):void 0})]})}function h(e){let{open:t,location:a,onSuccess:p,onClose:h}=e,[j,w]=(0,i.useState)([]),[b,C]=(0,i.useState)(!1),{syncChanges:v}=(0,d.g)(),{createSliceSuccess:I}=(0,m.Z)(),{completeStep:A}=(0,o.k)(),k=(0,i.useRef)(crypto.randomUUID()),E=e=>{let{index:t,slice:a}=e;w(e=>e.map((e,r)=>r===t?a(e):e))},U=e=>{if(e.length>10){s.Am.error("You can only upload ".concat(10," images at a time."));return}w(e.map(e=>({status:"uploading",image:e}))),e.forEach((e,t)=>N({index:t,image:e}))},N=e=>{let{index:t,image:a}=e,r=k.current;E({index:t,slice:e=>({...e,status:"uploading"})}),x({image:a}).then(e=>{r===k.current&&D({index:t,imageUrl:e})},()=>{r===k.current&&E({index:t,slice:e=>({...e,status:"uploadError",onRetry:()=>N({index:t,image:a})})})})},L=function(e){let{open:t}=e,a=(0,i.useRef)([]);return(0,i.useEffect)(()=>{t&&(a.current=[],u.managerClient.slices.readAllSlices().then(e=>{a.current=e.models.map(e=>{let{model:t}=e;return t})}).catch(()=>null))},[t]),a}({open:t}),D=e=>{let{index:t,imageUrl:a}=e,r=k.current;E({index:t,slice:e=>({...e,status:"generating",thumbnailUrl:a})}),u.managerClient.customTypes.inferSlice({imageUrl:a}).then(e=>{let{slice:n,langSmithUrl:i}=e;r===k.current&&w(e=>e.map((r,s)=>s===t?{...r,status:"success",thumbnailUrl:a,model:function(e){let{existingSlices:t,newSlices:a,slice:r}=e,n=new Set,i=new Set;for(let{id:e,name:a}of t)n.add(e),i.add(a.toLowerCase());for(let e of a)"success"===e.status&&(n.add(e.model.id),i.add(e.model.name.toLowerCase()));let s=r.id,l=2;for(;n.has(s);)s="".concat(r.id,"_").concat(l),l++;let c=r.name;for(l=2;i.has(c.toLowerCase());)c="".concat(r.name).concat(l),l++;return{...r,id:s,name:c}}({existingSlices:L.current,newSlices:e,slice:n}),langSmithUrl:i}:r))},()=>{r===k.current&&E({index:t,slice:e=>({...e,status:"generateError",thumbnailUrl:a,onRetry:()=>D({index:t,imageUrl:a})})})})},B=j.some(e=>"uploading"===e.status||"generating"===e.status),F=j.filter(e=>"success"===e.status),z=F.length>0;return(0,r.jsxs)(n.ae,{open:t,onOpenChange:e=>{e||b||(h(),k.current=crypto.randomUUID(),w([]))},children:[(0,r.jsx)(n.al,{title:"Generate from image"}),(0,r.jsxs)(n.aj,{gap:0,children:[(0,r.jsx)(n.ak,{hidden:!0,children:"Upload images to generate slices with AI"}),0===j.length?(0,r.jsx)(n.D,{padding:16,height:"100%",children:(0,r.jsx)(n.aF,{onFilesSelected:U,assetType:"image",maxFiles:10,overlay:(0,r.jsx)(f,{onFilesSelected:U,droppingFiles:!0}),children:(0,r.jsx)(f,{onFilesSelected:U})})}):(0,r.jsx)(n.bn,{stableScrollbar:!1,children:(0,r.jsx)(n.D,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:16,children:j.map((e,t)=>(0,r.jsx)(g,{slice:e},"slice-".concat(t)))})}),(0,r.jsxs)(n.ah,{children:[(0,r.jsx)(n.ai,{disabled:b}),(0,r.jsxs)(n.af,{disabled:!z||B,loading:b,onClick:()=>{let e=j.reduce((e,t)=>("success"===t.status&&e.push(t),e),[]);if(!e.length)return;let t=k.current;C(!0),y(e).then(async e=>{let{slices:r,library:n}=e;if(t===k.current)for(let{model:e,langSmithUrl:t}of(I((await (0,l.y0)()).libraries),v(),p({slices:r,library:n}),C(!1),k.current=crypto.randomUUID(),w([]),A("createSlice"),r))l.Xe.track({event:"slice:created",id:e.id,name:e.name,library:n,location:a,mode:"ai",langSmithUrl:t}),(0,c.nZ)({type:"model",library:n,sliceId:e.id,variationId:e.variations[0].id,langSmithUrl:t})}).catch(()=>{t===k.current&&(C(!1),s.Am.error("An unexpected error happened while adding slices."))})},children:[S(a)," (",F.length,")"]})]})]})]})}function f(e){let{droppingFiles:t=!1,onFilesSelected:a}=e;return(0,r.jsx)(n.D,{justifyContent:"center",flexDirection:"column",height:"100%",backgroundColor:t?"purple2":"grey2",border:!0,borderStyle:"dashed",borderColor:t?"purple9":"grey6",children:(0,r.jsxs)(n.s,{children:[(0,r.jsx)(n.x,{lineColor:"purple11",backgroundColor:"purple5",name:"cloudUpload",size:"large"}),(0,r.jsx)(n.z,{children:"Upload your design images."}),(0,r.jsx)(n.w,{children:"Once uploaded, you can generate slices automatically using AI."}),(0,r.jsx)(n.v,{children:(0,r.jsx)(n.aG,{startIcon:"attachFile",onFilesSelected:a,color:"grey",children:"Add images"})})]})})}async function x(e){let{image:t}=e,a=[await u.managerClient.project.getResolvedRepositoryName(),"shared-slices","prismic-inferred-slices",crypto.randomUUID()].join("/");await u.managerClient.screenshots.initS3ACL();let{url:r}=await u.managerClient.screenshots.uploadScreenshot({keyPrefix:a,data:t});return r}async function y(e){let{libraries:t=[]}=await u.managerClient.project.getSliceMachineConfig(),a=t[0];if(!a)throw Error("No library found in the config.");for(let{model:t}of e){let{errors:e}=await u.managerClient.slices.createSlice({libraryID:a,model:t});if(e.length)throw Error("Failed to create slice ".concat(t.id,"."))}let r=await Promise.all(e.map(async e=>{let{model:t,image:r,langSmithUrl:n}=e;return await u.managerClient.slices.updateSliceScreenshot({libraryID:a,sliceID:t.id,variationID:t.variations[0].id,data:r}),{model:t,langSmithUrl:n}}));return{library:a,slices:r}}let S=e=>{switch(e){case"custom_type":return"Add to type";case"page_type":return"Add to page";case"slices":return"Add to slices"}}},27213:function(e,t,a){a.d(t,{F:function(){return i}});var r=a(52322),n=a(14226);let i=e=>{let{menuType:t}=e;return{fromImage:{BackgroundIcon:(0,r.jsx)(n.B,{name:"autoFixHigh",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"purple",variant:"solid",radius:6}),title:"Generate from image",description:"Build a slice based on your design image."},fromScratch:{BackgroundIcon:(0,r.jsx)(n.B,{name:"add",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Start from scratch",description:"Build a custom slice your way."},fromTemplate:{BackgroundIcon:(0,r.jsx)(n.B,{name:"contentCopy",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Use a template",description:"Choose from ready-made examples."},fromExisting:{BackgroundIcon:(0,r.jsx)(n.B,{name:"folder",size:"ActionList"===t?"small":"extraSmall",iconSize:"ActionList"===t?"medium":"small",color:"white",variant:"solid",radius:6}),title:"Reuse an existing slice",description:"Select from your created slices."}}}},6256:function(e,t,a){a.d(t,{c:function(){return S}});var r=a(52322),n=a(2784),i=a(36131),s=a(75289),l=a(94160),c=a(98250),o=a(88932),d=a(63908),u=a(358),m=a(80148);async function p(e){let{sliceName:t,libraryName:a,location:r,onSuccess:n}=e;try{let e=(0,d.fo)(t),{errors:i}=await m.managerClient.slices.createSlice({libraryID:a,model:e});if(i.length>0)throw i;l.Xe.track({event:"slice:created",id:(0,u.MP)(t),name:t,library:a,location:r,mode:"manual"}),await n(e)}catch(a){let e="An unexpected error happened while creating slice ".concat(t,".");console.error(e,a),o.Am.error(e)}}var g=a(68968),h=a(59532),f=a(54597),x=a(46999),y=a(63019);let S=e=>{let{onClose:t,onSuccess:a,localLibraries:o,location:d,remoteSlices:u}=e,{createSliceSuccess:m}=(0,f.Z)(),[S,j]=(0,n.useState)(!1),{syncChanges:w}=(0,g.g)(),{completeStep:b}=(0,c.k)(),C=async e=>{let t=e.sliceName,r=e.from;j(!0),await p({sliceName:t,libraryName:r,location:d,onSuccess:async e=>{m((await (0,l.y0)()).libraries),a(e,r),w(),b("createSlice")}})};return(0,r.jsx)(h.Z,{testId:"create-slice-modal",isOpen:!0,widthInPx:"530px",isLoading:S,formId:"create-new-slice",close:t,buttonLabel:"Create",onSubmit:e=>{C(e)},initialValues:{sliceName:"",from:o[0].name},validate:e=>(0,y.h)(e,o,u),content:{title:"Create a new slice"},children:e=>{let{touched:t,values:a,setFieldValue:n,errors:l}=e;return(0,r.jsxs)(s.xu,{children:[(0,r.jsx)(x.W,{name:"sliceName",label:"Slice name",placeholder:"Pascalised slice API ID (e.g. TextBlock)",error:t.sliceName?l.sliceName:void 0,testId:"slice-name-input"}),(0,r.jsx)(s.__,{htmlFor:"from",sx:{mb:2},children:"Target Library"}),(0,r.jsx)(i.ZP,{name:"from",options:o.map(e=>({value:e.name,label:e.name})),onChange:e=>e?void n("from",e.value):null,defaultValue:{value:a.from,label:a.from},styles:{option:e=>({...e,color:"#161618"})},theme:e=>({...e,colors:{...e.colors,primary:"#E9E8EA"}}),menuPortalTarget:document.body})]})}})}},63019:function(e,t,a){a.d(t,{h:function(){return c}});var r=a(96009),n=a.n(r),i=a(74600),s=a.n(i),l=a(7974);function c(e,t,a){let{sliceName:r}=e;return r?l.lS.includes(r.toLowerCase())?{sliceName:'Name "'.concat(r,'" is reserved for Slice Machine use.')}:l.xo.exec(r)?s()(n()(r)).replace(/\s/gm,"")!==r.trim()?{sliceName:"Value has to be PascalCased."}:r.match(/^\d/)?{sliceName:"Value cannot start with a number."}:[...t.flatMap(e=>e.components.map(e=>e.model.name)),...a.map(e=>e.name)].includes(r)?{sliceName:"Slice name is already taken."}:void 0:{sliceName:"No special characters allowed."}:{sliceName:"Cannot be empty"}}},21151:function(e,t,a){var r=a(52322),n=a(75289);t.Z=function(e){let{elems:t,renderElem:a,defineElementKey:i,gridTemplateMinPx:s="320px",gridGap:l="16px",sx:c}=e;return(0,r.jsx)(n.xu,{as:"section",sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(".concat(s,", 1fr))"),gridGap:l,pt:2,...c},children:t.map((e,t)=>e?(0,r.jsx)("span",{children:a(e,t)},"".concat(i(e),"-").concat(t+1)):null)})}}}]);