slice-machine-ui 2.20.5-alpha.jp-import-slices-2.8 → 2.20.5-alpha.jp-import-slices-2.10

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.
package/out/404.html CHANGED
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/css/b30fbbc3ed00a725.css" as="style"/><link rel="stylesheet" href="/_next/static/css/b30fbbc3ed00a725.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-e986dd216b883a74.js" defer=""></script><script src="/_next/static/chunks/framework-ab7ddb551c23d05a.js" defer=""></script><script src="/_next/static/chunks/main-de87250a4e0c9fcf.js" defer=""></script><script src="/_next/static/chunks/pages/_app-2a5bb84572ac3f55.js" defer=""></script><script src="/_next/static/chunks/pages/_error-fedd2c6ebd3d27b9.js" defer=""></script><script src="/_next/static/spmKy_6GvIC8Xf-vl7NhM/_buildManifest.js" defer=""></script><script src="/_next/static/spmKy_6GvIC8Xf-vl7NhM/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"spmKy_6GvIC8Xf-vl7NhM","runtimeConfig":{"sentryEnvironment":"alpha"},"nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/css/b30fbbc3ed00a725.css" as="style"/><link rel="stylesheet" href="/_next/static/css/b30fbbc3ed00a725.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-e986dd216b883a74.js" defer=""></script><script src="/_next/static/chunks/framework-ab7ddb551c23d05a.js" defer=""></script><script src="/_next/static/chunks/main-de87250a4e0c9fcf.js" defer=""></script><script src="/_next/static/chunks/pages/_app-98876310c8b4c57c.js" defer=""></script><script src="/_next/static/chunks/pages/_error-fedd2c6ebd3d27b9.js" defer=""></script><script src="/_next/static/8kvbCRrdHWvL92unKorpE/_buildManifest.js" defer=""></script><script src="/_next/static/8kvbCRrdHWvL92unKorpE/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"8kvbCRrdHWvL92unKorpE","runtimeConfig":{"sentryEnvironment":"alpha"},"nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -1 +1 @@
1
- self.__BUILD_MANIFEST=function(s,c,a,t,e,i,b,d,n,u,h,f,k,j,l,p,g,o,r,m,_,y,I,N){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[s,e,o,r,"static/chunks/pages/index-0d8cb369de720a35.js"],"/_error":["static/chunks/pages/_error-fedd2c6ebd3d27b9.js"],"/changelog":[c,i,"static/chunks/870-a72b74312773efea.js","static/chunks/pages/changelog-bc83e25e8d316ca9.js"],"/changes":[c,b,"static/chunks/8eec4907-b712959d9f984b68.js",a,"static/chunks/125-00b909bdbab2ca15.js",t,n,"static/css/d98ebc475f8423a3.css","static/chunks/pages/changes-6f371ebe52dbe76a.js"],"/custom-types":[s,e,o,r,"static/chunks/pages/custom-types-5acd56959b60346f.js"],"/custom-types/[customTypeId]":[c,u,h,f,k,s,a,i,d,j,l,m,t,e,p,g,_,y,"static/chunks/pages/custom-types/[customTypeId]-02704945f838f3da.js"],"/labs":["static/chunks/pages/labs-16d118a80936d583.js"],"/page-types/[pageTypeId]":[c,u,h,f,k,s,a,i,d,j,l,m,t,e,p,g,_,y,"static/chunks/pages/page-types/[pageTypeId]-8f29474c7d2c5daa.js"],"/slices":[c,b,I,s,a,d,N,t,g,n,"static/css/efa5152b7c0f35c0.css","static/chunks/pages/slices-93fc784c443a996c.js"],"/slices/[lib]/[sliceName]/[variation]":[c,b,u,h,f,k,I,s,a,i,d,j,N,"static/chunks/484-3e011e79c41f0342.js",t,p,n,"static/css/e8e03c0d4003d1eb.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-0e9aa745ed9fe1ec.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[b,"static/chunks/72585f70-28b4d7d5384b3703.js",l,"static/chunks/429-e5d7e39160de9f5e.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-873c0c89aaf50b3c.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/397-e6c340070a3bcb41.js","static/chunks/59b4e022-ef680789f7cc9b11.js","static/chunks/66-d9d3bcb5d041cb6d.js","static/chunks/882-8ab59c0c72307c87.js","static/chunks/647-a29bee23cb9ac7a2.js","static/chunks/183-4ea255b867ff171b.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/344-b64f09e670634ed1.js","static/chunks/593-7ffd1197c3405ef8.js","static/chunks/f36c6662-1f3a854183168b10.js","static/chunks/4c744e84-480e426e4b1cfef3.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-09fb3b997ad1eb70.js","static/chunks/256-07f768a2b19b0a0e.js","static/chunks/130-e1a16d2f94fb2b64.js","static/chunks/630-4fe1e982234bd925.js","static/chunks/633-2d20c3e815c79c7f.js","static/chunks/248-2902bda47821f37b.js","static/css/4e475d945cf8a890.css","static/chunks/21-f3962d02eda0a46e.js","static/chunks/907-7a845d6591a5679d.js","static/css/56f2a6684a524374.css","static/chunks/52d4c156-89c6ec6efca0a0bb.js","static/chunks/444-d39213143f782fec.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
1
+ self.__BUILD_MANIFEST=function(s,c,a,t,e,i,b,d,n,u,h,f,k,j,l,p,g,o,r,m,_,y,I,N){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[s,e,o,r,"static/chunks/pages/index-0d8cb369de720a35.js"],"/_error":["static/chunks/pages/_error-fedd2c6ebd3d27b9.js"],"/changelog":[c,i,"static/chunks/870-a72b74312773efea.js","static/chunks/pages/changelog-bc83e25e8d316ca9.js"],"/changes":[c,b,"static/chunks/8eec4907-b712959d9f984b68.js",a,"static/chunks/125-00b909bdbab2ca15.js",t,n,"static/css/d98ebc475f8423a3.css","static/chunks/pages/changes-6f371ebe52dbe76a.js"],"/custom-types":[s,e,o,r,"static/chunks/pages/custom-types-5acd56959b60346f.js"],"/custom-types/[customTypeId]":[c,u,h,f,k,s,a,i,d,j,l,m,t,e,p,g,_,y,"static/chunks/pages/custom-types/[customTypeId]-02704945f838f3da.js"],"/labs":["static/chunks/pages/labs-16d118a80936d583.js"],"/page-types/[pageTypeId]":[c,u,h,f,k,s,a,i,d,j,l,m,t,e,p,g,_,y,"static/chunks/pages/page-types/[pageTypeId]-8f29474c7d2c5daa.js"],"/slices":[c,b,I,s,a,d,N,t,g,n,"static/css/efa5152b7c0f35c0.css","static/chunks/pages/slices-93fc784c443a996c.js"],"/slices/[lib]/[sliceName]/[variation]":[c,b,u,h,f,k,I,s,a,i,d,j,N,"static/chunks/484-3e011e79c41f0342.js",t,p,n,"static/css/e8e03c0d4003d1eb.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-0e9aa745ed9fe1ec.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[b,"static/chunks/72585f70-28b4d7d5384b3703.js",l,"static/chunks/429-e5d7e39160de9f5e.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-873c0c89aaf50b3c.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/397-e6c340070a3bcb41.js","static/chunks/59b4e022-ef680789f7cc9b11.js","static/chunks/66-d9d3bcb5d041cb6d.js","static/chunks/882-8ab59c0c72307c87.js","static/chunks/647-a29bee23cb9ac7a2.js","static/chunks/183-4ea255b867ff171b.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/344-b64f09e670634ed1.js","static/chunks/593-7ffd1197c3405ef8.js","static/chunks/f36c6662-1f3a854183168b10.js","static/chunks/4c744e84-480e426e4b1cfef3.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-09fb3b997ad1eb70.js","static/chunks/256-07f768a2b19b0a0e.js","static/chunks/130-e1a16d2f94fb2b64.js","static/chunks/630-4fe1e982234bd925.js","static/chunks/633-2d20c3e815c79c7f.js","static/chunks/248-2902bda47821f37b.js","static/css/4e475d945cf8a890.css","static/chunks/21-f3962d02eda0a46e.js","static/chunks/907-ac1fdbe5004e9b2e.js","static/css/56f2a6684a524374.css","static/chunks/52d4c156-89c6ec6efca0a0bb.js","static/chunks/444-d39213143f782fec.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[907],{61907:function(e,t,n){"use strict";n.d(t,{H:function(){return tm}});var i=n(52322),a=n(18337),l=n(97729),o=n.n(l),r=n(5632),s=n(2784),c=n(56580),d=n(43388),m=n(77630),u=n(23094),h=n(59294),p=n(58446),f=n(74217),g=n(94160),x=n(68968),b=n(23710),y=n(54597),v=n(98564);let j=(0,s.createContext)(void 0);function S(e){let{children:t,initialCustomType:n}=e,[a,l]=(0,s.useState)(n),o=(0,m.y6)(a),r=v.$[o],{actionQueueStatus:c,setNextAction:d}=(0,b.c)({errorMessage:r.autoSaveFailed}),{refreshState:u}=(0,y.Z)(),h=(0,f.R9)(u),{syncChanges:p}=(0,x.g)(),S=(0,s.useCallback)(e=>{let{customType:t,onSaveCallback:n,updateMeta:i}=e;l(t),d(async()=>{let{errors:e}=await (0,g.KA)({customType:t,updateMeta:i});if(e.length>0)throw e;h(await (0,g.y0)()),p(),null==n||n()})},[d,h,p]),w=(0,s.useMemo)(()=>({actionQueueStatus:c,customType:a,setCustomType:S}),[c,a,S]);return(0,i.jsx)(j.Provider,{value:w,children:"function"==typeof t?t(w):t})}function w(){let e=(0,s.useContext)(j);if(!e)throw Error("CustomTypeProvider not found");return e}var C=n(30195);function I(){var e;let[t,n]=(0,s.useState)(!1),{customType:l,setCustomType:o}=w(),[r,c]=null!==(e=(0,m.j5)(l))&&void 0!==e?e:[],d=c?(0,m.N3)(c):"",[u,h]=(0,s.useState)(null!=d?d:""),[p,g]=(0,s.useState)();(0,f.pQ)(t,()=>{t||(h(null!=d?d:""),g(void 0))});let x=(0,s.useCallback)(()=>(0,i.jsx)(a.aX,{name:c?"language":"add",size:"small",color:"grey11"}),[c]);return(0,i.jsxs)(a.ae,{open:t,onOpenChange:n,size:"small",trigger:(0,i.jsx)(a.E,{color:"grey",textColor:"placeholder",textWeight:"normal",renderStartIcon:x,sx:{marginInline:"auto"},children:c?d:"Add an UID"}),children:[(0,i.jsx)(a.al,{title:"Edit the UID label"}),(0,i.jsx)(a.aj,{children:(0,i.jsxs)(a.aJ,{onSubmit:function(){p||(o({customType:c?(0,m.eK)(u,l):(0,m.H8)(u,l)}),n(!1))},children:[(0,i.jsx)(a.D,{flexDirection:"column",padding:16,gap:4,children:(0,i.jsx)(a.aM,{type:"text",label:"Label *",placeholder:"UID",value:u,onValueChange:function(e){h(e),g(function(e){let t=D.safeParse(e,{errorMap:T});if(t.error)return t.error.errors[0].message}(e))},error:p,description:"A label for the UID"})}),(0,i.jsxs)(a.ah,{children:[(0,i.jsx)(a.ai,{size:"medium"}),(0,i.jsx)(a.af,{type:"submit",size:"medium",disabled:!!p,children:"Save"})]})]})})]})}let D=C.z.string().max(35).min(1),T=e=>{switch(e.code){case C.z.ZodIssueCode.too_big:return{message:"The label can't be longer than ".concat(e.maximum," characters")};case C.z.ZodIssueCode.too_small:return{message:"This field is required"};default:return{message:"Invalid value"}}};var k=n(94840),_=n(59532),A=n(63397),E=n(75289);let L=e=>{let{name:t,label:n,placeholder:a,error:l,...o}=e;return(0,i.jsxs)(E.xu,{mb:3,children:[(0,i.jsx)(E.__,{htmlFor:t,mb:2,children:n}),(0,i.jsx)(A.gN,{name:t,type:"text",placeholder:a,as:E.II,autoComplete:"off",...o}),l?(0,i.jsx)(E.xv,{sx:{color:"error",mt:1},children:l}):null]})};var z=e=>{let{isOpen:t,onSubmit:n,close:a,tabIds:l}=e;return(0,i.jsx)(_.Z,{isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,onSubmit:e=>{n(e),a()},initialValues:{id:""},validate:e=>{let{id:t}=e;return t?l.includes(t.toLowerCase())?{id:"Tab exists already"}:void 0:{id:"Tab ID is required"}},content:{title:"Add Tab"},children:e=>{let{errors:t}=e;return(0,i.jsx)(L,{name:"id",label:"New Tab ID",placeholder:"A label for selecting the tab (i.e. not used in the API)",error:t.id})}})},N=e=>{let{isOpen:t,onSubmit:n,close:a}=e;return(0,i.jsx)(_.Z,{omitFooter:!0,isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,cardProps:{bodySx:{p:0}},onSubmit:e=>{n(e),a()},initialValues:{},content:{title:"Remove Tab"},children:()=>(0,i.jsxs)(E.xu,{sx:{px:4,py:4},children:[(0,i.jsx)(E.X6,{as:"h4",children:"Remove this tab?"}),(0,i.jsx)(E.xv,{as:"p",color:"textClear",sx:{mt:2},children:"This action cannot be undone."}),(0,i.jsx)(E.zx,{type:"button",variant:"buttons.actionDelete",sx:{mt:3},onClick:()=>{n({}),a()},children:"Yes, remove tab"})]})})},P=e=>{let{isOpen:t,onSubmit:n,close:a,tabIds:l,initialTabKey:o}=e;return(0,i.jsx)(_.Z,{omitFooter:!0,isOpen:t,widthInPx:"530px",formId:"create-tab",close:a,cardProps:{bodySx:{p:0}},onSubmit:e=>{n(e),a()},initialValues:{id:o},validate:e=>{let{id:t}=e;return t?l.includes(t.toLowerCase())?{id:"Tab exists already"}:void 0:{id:"Tab ID is required"}},content:{title:"Rename Tab"},children:e=>{let{errors:t,values:l,setFieldValue:o,isValid:r}=e;return(0,i.jsxs)(E.xu,{sx:{px:4,py:4},children:[(0,i.jsx)(L,{name:"id",label:"Rename Tab ID",placeholder:"A label for selecting the tab (i.e. not used in the API)",error:t.id,onBlur:e=>{l.id!==e.target.value&&o("id",e.target.value.trim())},onChange:e=>{o("id",e.target.value)}}),(0,i.jsx)(E.zx,{type:"button",sx:{mt:3,width:"100%"},disabled:!r,onClick:()=>{l.id&&l.id.length&&n({id:l.id.trim()}),a()},children:"Save"})]})}})},F=n(28316),M=n(88932),O=n(35289),U=n(87446),Z=n(45440),G=n(16086),B=n(358),R=n(5495),H=n(39302),K=n(3285),V=n(40141),X=n(65077),q=n(21446),W=n(80148),Y=n(98250);let $=(e,t)=>{switch(e){case"custom_type":case"page_type":return"Add to ".concat(t)}};function J(e){let{totalSelected:t,onSubmit:n,isSubmitting:l,location:o,typeName:r}=e;return(0,i.jsxs)(a.ah,{children:[(0,i.jsx)(a.ai,{disabled:l,size:"medium"}),(0,i.jsxs)(a.af,{disabled:0===t,loading:l,onClick:()=>void n(),size:"medium",children:[$(o,r)," (",t,")"]})]})}function Q(e){let{children:t,selected:n}=e;return n?(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:t}):(0,i.jsx)(a.D,{display:"none",minHeight:0,children:t})}function ee(e){let{selectedTab:t,onSelectTab:n,rightContent:l}=e;return(0,i.jsxs)(a.D,{justifyContent:"space-between",padding:16,border:{bottom:!0},children:[(0,i.jsxs)(a.D,{gap:8,children:[(0,i.jsx)(a.bD,{selected:"local"===t,onClick:()=>n("local"),children:"Local Slices"}),(0,i.jsx)(a.bD,{selected:"library"===t,onClick:()=>n("library"),children:"Library Slices"})]}),l]})}var et=n(74686),en=n(88866);async function ei(e,t,n){let i=Array(e.length),a=0,l=Array(Math.min(t,e.length)).fill(null).map(async()=>{for(;;){let t=a++;if(t>=e.length)break;i[t]=await n(e[t],t)}});return await Promise.all(l),i}class ea{getHeaders(){let e={Accept:"application/vnd.github.v3+json"};return void 0!==this.token&&(e.Authorization="Bearer ".concat(this.token)),e}async request(e,t){let n="".concat(this.baseUrl).concat(e),i=await fetch(n,{...t,headers:{...this.getHeaders(),...null==t?void 0:t.headers}});if(!i.ok)throw Error("GitHub API request failed: ".concat(i.status," ").concat(i.statusText));return i.json()}async getDefaultBranch(){let e=await this.request("/repos/".concat(this.owner,"/").concat(this.repo));return C.z.object({default_branch:C.z.string()}).parse(e).default_branch}async getFileContents(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/").concat(e,"?ref=").concat(t)),a=C.z.object({content:C.z.string(),encoding:C.z.string()}).parse(i);if("base64"!==a.encoding)throw Error("Unexpected encoding for ".concat(e,": ").concat(a.encoding));let l=atob(a.content.replace(/\s/g,""));if(!n)return l;{let e=new Uint8Array(l.length);for(let t=0;t<l.length;t++)e[t]=l.charCodeAt(t);return e.buffer}}async getDirectoryContents(e){let t=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/").concat(e));return C.z.array(C.z.object({name:C.z.string(),type:C.z.string(),path:C.z.string()})).parse(t)}async searchCode(e){let{path:t,filename:n}=e,i=[];void 0!==t&&i.push("path:".concat(t)),void 0!==n&&i.push("filename:".concat(n)),i.push("repo:".concat(this.owner,"/").concat(this.repo));let a="/search/code?q=".concat(encodeURIComponent(i.join(" "))),l=await this.request(a);return C.z.object({items:C.z.array(C.z.object({path:C.z.string(),name:C.z.string()})).optional(),total_count:C.z.number().optional()}).parse(l)}async getSliceLibraries(e){let t=await this.request("/repos/".concat(this.owner,"/").concat(this.repo,"/contents/slicemachine.config.json?ref=").concat(e)),n=C.z.object({content:C.z.string().optional(),encoding:C.z.string().optional()}).parse(t);if("string"==typeof n.content){let e=atob(n.content.replace(/\s/g,""));return C.z.object({libraries:C.z.array(C.z.string())}).parse(JSON.parse(e)).libraries}throw Error("No content found in slicemachine.config.json")}constructor(e){this.baseUrl="https://api.github.com",this.owner=e.owner,this.repo=e.repo,this.token=e.token}}let el=e=>{let t=e.match(/github\.com\/([^\/]+)\/([^\/]+)(?:\/|$)/);if(!t)throw Error("Invalid GitHub URL format");let[,n,i]=t;return{owner:n,repo:i.replace(/\.git$/,"")}},eo=async e=>{let{owner:t,repo:n}=e;return new ea({owner:t,repo:n}).getDefaultBranch()},er=async e=>{let{owner:t,repo:n,branch:i}=e;return new ea({owner:t,repo:n}).getSliceLibraries(i)},es=async e=>{let{owner:t,repo:n,branch:i,libraries:a}=e,l=new ea({owner:t,repo:n}),o=[];for(let e of(console.log("Fetching slices from ".concat(a.length," library/libraries:"),a),a)){let t=e.replace(/^\.\//,""),n=[],a=!1;try{n=(await l.getDirectoryContents(t)).filter(e=>"dir"===e.type).map(e=>({name:e.name,path:e.path}))}catch(n){a=!0;let t=n instanceof Error?n.message:String(n);t.includes("403")?console.warn("GitHub API returned 403 for ".concat(e,", trying direct discovery...")):console.warn("GitHub API error for ".concat(e,", trying direct discovery..."),t)}if(a&&0===n.length){console.log("Attempting to discover slices using GitHub Search API for ".concat(e,"..."));try{let i=await l.searchCode({path:t,filename:"model.json"});if(i.items&&i.items.length>0){let a=new Set;for(let e of i.items){let t=e.path.split("/");if(t.length>=2){let e=t[t.length-2];e&&!a.has(e)&&a.add(e)}}n=Array.from(a).map(e=>({name:e,path:"".concat(t,"/").concat(e)})),console.log("Discovered ".concat(n.length," slice(s) via GitHub Search API for library ").concat(e))}else console.warn("GitHub Search API found no model.json files in ".concat(e))}catch(n){let t=n instanceof Error?n.message:String(n);t.includes("403")?console.warn("GitHub Search API also returned 403. Cannot discover slices without API access."):console.warn("Error using GitHub Search API for ".concat(e,":"),t)}}if(0===n.length){console.warn("No slices found in library ".concat(e,". The repository may be private or require authentication."));continue}console.log("Processing ".concat(n.length," slice(s) in library ").concat(e));let r=async e=>{try{let t,n,a,r;let s=await l.getFileContents("".concat(e.path,"/model.json"),i,!1);if("string"!=typeof s){console.warn("Failed to fetch model.json for slice: ".concat(e.name," - unexpected content type"));return}let c=en.SharedSlice.decode(JSON.parse(s));if("Left"===c._tag){console.warn("Failed to decode model.json for slice: ".concat(e.name));return}let d=c.right,m=[];try{m=await ec({api:l,branch:i,directoryPath:e.path}),console.log("Fetched ".concat(m.length," file(s) for slice ").concat(e.name,":"),m.map(e=>"".concat(e.path).concat(e.isBinary?" (binary)":"")))}catch(t){console.warn("Failed to fetch files for slice ".concat(e.name,":"),t instanceof Error?t.message:String(t))}for(let i of m)if(void 0===t&&i.path.match(/^index\.(tsx?|jsx?|vue|svelte)$/)&&"string"==typeof i.contents&&(t=i.contents),"mocks.json"===i.path&&"string"==typeof i.contents)try{let t=et.SharedSliceContent.decode(JSON.parse(i.contents));if("Left"===t._tag)console.warn("Failed to decode mocks.json for slice: ".concat(e.name));else{let e=t.right;Array.isArray(e)&&e.length>0&&(n=e)}}catch(t){console.warn("Failed to decode mocks.json for slice: ".concat(e.name))}let u={};void 0!==d.variations&&d.variations.length>0&&(await Promise.allSettled(d.variations.map(async t=>{try{let n="".concat(e.path,"/screenshot-").concat(t.id,".png"),o=await l.getFileContents(n,i,!0);if(o instanceof ArrayBuffer){let e=new Blob([o],{type:"image/png"}),n=new File([e],"screenshot-".concat(t.id,".png"),{type:"image/png"});u[t.id]=n,void 0===a&&void 0!==d.variations[0]&&t.id===d.variations[0].id&&(a=URL.createObjectURL(e),r=n)}}catch(e){console.warn("Failed to fetch screenshot for variation ".concat(t.id,":"),e instanceof Error?e.message:String(e))}}))).forEach((e,t)=>{if("rejected"===e.status){var n;console.warn("Failed to fetch screenshot for variation ".concat(null===(n=d.variations[t])||void 0===n?void 0:n.id,":"),e.reason instanceof Error?e.reason.message:String(e.reason))}});let h=null!=r?r:new File([],"".concat(d.name,".json"),{type:"application/json"}),p={image:h,thumbnailUrl:null!=a?a:URL.createObjectURL(h),model:d,files:m,componentContents:t,mocks:n,screenshots:Object.keys(u).length>0?u:void 0};o.push(p)}catch(t){console.warn("Error fetching slice ".concat(e.name,":"),t instanceof Error?t.message:String(t))}};await ei(n,6,r)}return o},ec=async e=>{let{api:t,branch:n,directoryPath:i}=e,a=[],l=!1;try{let e=await t.getDirectoryContents(i);l=!0;let o=e.filter(e=>"file"===e.type),r=e.filter(e=>"dir"===e.type);for(let e of(await ei(o,8,async e=>{if("model.json"===e.name)return null;try{let i=[".png",".jpg",".jpeg",".gif",".svg",".ico",".webp"].some(t=>e.name.toLowerCase().endsWith(t)),a=await t.getFileContents(e.path,n,i);return{path:e.name,contents:a,isBinary:i}}catch(t){return console.warn("Failed to fetch file ".concat(e.path,":"),t instanceof Error?t.message:String(t)),null}})))e&&a.push(e);for(let e of r)for(let i of(await ec({api:t,branch:n,directoryPath:e.path})))a.push({...i,path:"".concat(e.name,"/").concat(i.path)})}catch(e){console.warn("GitHub API failed for directory ".concat(i,", trying Search API..."),e instanceof Error?e.message:String(e))}if(!l)try{console.log("Using GitHub Search API to find all files in ".concat(i,"..."));let e=await t.searchCode({path:i});if(e.items&&e.items.length>0){for(let l of(console.log("Found ".concat(e.items.length," file(s) via Search API for ").concat(i)),await ei(e.items,8,async e=>{try{if("model.json"===e.name)return null;let a=e.path.startsWith(i+"/")?e.path.slice(i.length+1):e.name,l=[".png",".jpg",".jpeg",".gif",".svg",".ico",".webp",".woff",".woff2",".ttf",".eot",".otf",".pdf",".zip",".gz"].some(t=>e.name.toLowerCase().endsWith(t)),o=await t.getFileContents(e.path,n,l);return{path:a,contents:o,isBinary:l}}catch(t){return console.warn("Error fetching file ".concat(e.path,":"),t instanceof Error?t.message:String(t)),null}})))l&&a.push(l);console.log("Fetched ".concat(a.length," file(s) from ").concat(i," via Search API"))}else console.warn("GitHub Search API found no files in ".concat(i))}catch(t){let e=t instanceof Error?t.message:String(t);e.includes("403")?console.warn("GitHub Search API returned 403 for ".concat(i,". Cannot fetch files without API access.")):console.warn("Error using GitHub Search API for ".concat(i,":"),e)}return a};class ed extends Error{constructor(e){super(e),this.name="GitHubImportError"}}var em=n(62434);function eu(e){let{thumbnailUrl:t,model:n,selected:l=!0,onSelectedChange:o}=e,r=(0,i.jsxs)(i.Fragment,{children:[void 0!==t&&t?(0,i.jsx)(em.ZB,{src:t}):(0,i.jsx)(em.ZB,{component:"div"}),(0,i.jsx)(em.eW,{title:n.name,action:(0,i.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,i.jsx)(a.U,{checked:l,onCheckedChange:o})})})]});return(0,i.jsx)(em.Zb,{interactive:!0,onClick:()=>{o(!l)},checked:l,size:"small","data-testid":"slice-card",children:r})}async function eh(e){let{libraries:t=[]}=await W.managerClient.project.getSliceMachineConfig(),n=t[0];if(!n)throw Error("No library found in the config.");await ei(e,3,async e=>{let{errors:t}=await W.managerClient.slices.createSlice({libraryID:n,model:e.model,componentContents:e.componentContents});if(t.length)throw Error("Failed to create slice ".concat(e.model.id,"."))});let i=await ei(e,3,async e=>{let{model:t,image:i,langSmithUrl:a,mocks:l,files:o,screenshots:r}=e;if(l&&Array.isArray(l)&&l.length>0){let{errors:e}=await W.managerClient.slices.updateSliceMocks({libraryID:n,sliceID:t.id,mocks:l});e.length&&console.warn("Failed to update mocks for slice ".concat(t.id,":"),e)}return r&&Object.keys(r).length>0?await Promise.all(Object.entries(r).map(async e=>{let[i,a]=e;a.size>0&&await W.managerClient.slices.updateSliceScreenshot({libraryID:n,sliceID:t.id,variationID:i,data:a})})):i.size>0&&void 0!==t.variations&&t.variations.length>0&&await W.managerClient.slices.updateSliceScreenshot({libraryID:n,sliceID:t.id,variationID:t.variations[0].id,data:i}),console.log("About to write files for slice ".concat(t.id,":"),o?"".concat(o.length," file(s) - ").concat(o.map(e=>e.path).join(", ")):"no files"),o&&o.length>0?await ep({libraryID:n,sliceID:t.id,files:o}):console.warn("No files to write for slice ".concat(t.id,". Files:"),o),{model:t,langSmithUrl:a}});return{library:n,slices:i}}async function ep(e){let{libraryID:t,sliceID:n,files:i}=e;if(0===i.length)return;let a=i.filter(e=>"mocks.json"!==e.path&&!e.path.startsWith("screenshot-")&&!e.path.match(/^index\.(tsx?|jsx?|vue|svelte)$/));if(console.log("Writing ".concat(a.length," additional file(s) for slice ").concat(n,":"),a.map(e=>e.path)),0!==a.length)try{let e=a.map(e=>{if(e.isBinary)return{path:e.path,contents:e.contents,isBinary:!0};if("string"==typeof e.contents)return{path:e.path,contents:e.contents,isBinary:!1};throw Error("Unexpected file contents type for ".concat(e.path))}),i=await W.managerClient.slices.writeSliceFiles({libraryID:t,sliceID:n,files:e});i.errors.length>0?console.error("Errors writing files for slice ".concat(n,":"),i.errors.map(e=>{var t;return null!==(t=e.message)&&void 0!==t?t:String(e)})):console.log("Successfully wrote ".concat(a.length," file(s) for slice ").concat(n))}catch(e){console.error("Error writing files for slice ".concat(n,":"),e instanceof Error?e.message:String(e))}}function ef(e){let{open:t,location:n,typeName:l,onSelectTab:o,onSuccess:r,selected:c}=e,[d,m]=(0,s.useState)(""),[u,h]=(0,s.useState)(!1),[p,b]=(0,s.useState)([]),{isLoadingSlices:v,handleImportFromGithub:j,slices:S,resetSlices:w}=function(){let[e,t]=(0,s.useState)(!1),[n,i]=(0,s.useState)([]);return{isLoadingSlices:e,slices:n,resetSlices:()=>{i([]),t(!1)},handleImportFromGithub:async e=>{try{let n;t(!0);let{owner:a,repo:l}=el(e);if(!a||!l)throw new ed("Invalid GitHub URL format");let o=await eo({owner:a,repo:l});try{n=await er({owner:a,repo:l,branch:o})}catch(e){throw new ed("\n Failed to fetch slicemachine.config.json: ".concat(e instanceof Error?e.message:"Unknown error","\n "))}if(0===n.length)throw new ed("No libraries were found in the SM config.");let r=await es({owner:a,repo:l,branch:o,libraries:n});if(0===r.length)throw new ed("No slices were found in the libraries.");return i(r),M.Am.success("Found ".concat(r.length," slice(s) from ").concat(n.length," library/libraries")),r}catch(e){return e instanceof ed?M.Am.error(e.message):M.Am.error("Failed to import from GitHub: ".concat(e instanceof Error?e.message:"Unknown error")),[]}finally{t(!1)}}}}(),C=(0,y.Z)(),I=function(e){let{open:t}=e,n=(0,s.useRef)([]);return(0,s.useEffect)(()=>{t&&(n.current=[],W.managerClient.slices.readAllSlices().then(e=>{n.current=e.models.map(e=>{let{model:t}=e;return t})}).catch(()=>null))},[t]),n}({open:t}),{syncChanges:D}=(0,x.g)(),{completeStep:T}=(0,Y.k)(),k=(0,s.useRef)(crypto.randomUUID());(0,f.Ng)(()=>{t||(b([]),w(),m(""),k.current=crypto.randomUUID())},[t]);let _=()=>{j(d)},A=e=>{b(t=>t.some(t=>t.model.id===e.model.id)?t.filter(t=>t.model.id!==e.model.id):[...t,e])},E=async()=>{if(0===p.length){M.Am.error("Please select at least one slice");return}let e=p.map(e=>({image:e.image,model:e.model,files:e.files,componentContents:e.componentContents,mocks:e.mocks,screenshots:e.screenshots})),t=[];for(let n of e){let e=function(e){let{existingSlices:t,newSlices:n,slice:i}=e,a=new Set,l=new Set;for(let{id:e,name:n}of t)a.add(e),l.add(n.toLowerCase());for(let e of n)a.add(e.model.id),l.add(e.model.name.toLowerCase());let o=i.id,r=2;for(;a.has(o);)o="".concat(i.id,"_").concat(r),r++;let s=i.name;for(r=2;l.has(s.toLowerCase());)s="".concat(i.name).concat(r),r++;return{...i,id:o,name:s}}({existingSlices:I.current,newSlices:t,slice:n.model});t.push({...n,model:e})}let i=k.current;h(!0);try{let{slices:a,library:l}=await eh(t);if(i!==k.current)throw Error("Modal instance changed");await new Promise(e=>setTimeout(e,100));let o=(await (0,g.y0)()).libraries.map(e=>e.name!==l?e:{...e,components:e.components.map(e=>{let n=t.find(t=>t.model.id===e.model.id),i=e.mocks&&e.mocks.length>0?e.mocks:null==n?void 0:n.mocks;return{...e,mocks:null!=i?i:e.mocks}})});for(let t of(C.createSliceSuccess(o),e))t.mocks&&Array.isArray(t.mocks)&&t.mocks.length>0&&C.updateSliceMockSuccess({libraryID:l,sliceID:t.model.id,mocks:t.mocks});for(let{model:e}of(D(),h(!1),w(),T("createSlice"),a))g.Xe.track({event:"slice:created",id:e.id,name:e.name,library:l,location:n,mode:"import"});r({slices:a,library:l})}catch(e){if(i!==k.current)throw e;throw h(!1),M.Am.error("An unexpected error happened while adding slices."),e}},L=S.every(e=>p.some(t=>t.model.id===e.model.id)),z=S.some(e=>p.some(t=>t.model.id===e.model.id)),N="Select all slices";return L?N="Selected all slices (".concat(p.length,")"):z&&(N="".concat(p.length," of ").concat(S.length," selected")),(0,i.jsxs)(Q,{selected:c,children:[(0,i.jsx)(ee,{selectedTab:"library",onSelectTab:o,rightContent:"<repo-select>"}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:S.length>0?(0,i.jsxs)(a.D,{flexDirection:"column",flexGrow:1,minHeight:0,children:[(0,i.jsx)(a.D,{padding:{block:12,inline:16},alignItems:"center",gap:8,children:(0,i.jsx)(a.aR,{value:N,children:(0,i.jsx)(a.U,{checked:L,indeterminate:z&&!L,onCheckedChange:e=>{b(e?S:[])}})})}),(0,i.jsx)(a.bn,{stableScrollbar:!1,children:(0,i.jsx)(a.D,{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,padding:{inline:16,bottom:16},children:S.map(e=>{let t=p.some(t=>t.model.id===e.model.id);return(0,i.jsx)(eu,{model:e.model,thumbnailUrl:e.thumbnailUrl,selected:t,onSelectedChange:()=>A(e)},e.model.id)})})})]}):(0,i.jsx)(a.D,{padding:16,height:"100%",flexDirection:"column",gap:16,children:(0,i.jsx)(a.D,{flexDirection:"column",gap:8,children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:8,padding:16,border:!0,borderRadius:8,children:[(0,i.jsx)(a.bL,{color:"grey11",children:"Import from GitHub"}),(0,i.jsx)(a.bN,{placeholder:"https://github.com/username/repository",value:d,onValueChange:m}),(0,i.jsx)(a.E,{onClick:()=>void _(),disabled:!d.trim()||v,loading:v,color:"purple",children:v?"Loading slices...":"Import from GitHub"})]})})})}),(0,i.jsx)(J,{totalSelected:p.length,onSubmit:()=>void E(),isSubmitting:u,location:n,typeName:l})]})}function eg(e){let{open:t,location:n,typeName:l,onSelectTab:o,onSuccess:r,availableSlices:c=[],selected:d}=e,[m,u]=(0,s.useState)([]);(0,s.useEffect)(()=>{t||u([])},[t]);let h=e=>{u(t=>t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):[...t,e])};return(0,i.jsxs)(Q,{selected:d,children:[(0,i.jsx)(ee,{selectedTab:"local",onSelectTab:o}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",flexGrow:1,minHeight:0,children:c.length>0?(0,i.jsx)(a.bn,{stableScrollbar:!1,children:(0,i.jsx)(a.D,{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:16,flexGrow:1,padding:16,minHeight:0,children:c.map(e=>{let t=m.some(t=>t.id===e.id);return(0,i.jsx)(eu,{model:e,thumbnailUrl:e.thumbnailUrl,selected:t,onSelectedChange:()=>h(e)},e.id)})})}):(0,i.jsx)(a.D,{padding:16,height:"100%",flexDirection:"column",gap:16,children:(0,i.jsx)(a.D,{flexDirection:"column",gap:8,children:(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",gap:8,padding:16,alignItems:"center",justifyContent:"center",children:"No local slices available"})})})}),(0,i.jsx)(J,{totalSelected:m.length,onSubmit:()=>{if(0===m.length){M.Am.error("Please select at least one slice");return}r({slices:m.map(e=>({model:e}))})},location:n,typeName:l})]})}function ex(e){let{open:t,availableSlices:n=[],onClose:l,...o}=e,[r,c]=(0,s.useState)("local");return(0,i.jsxs)(a.ae,{open:t,onOpenChange:e=>{e||(l(),setTimeout(()=>c("local"),250))},children:[(0,i.jsx)(a.al,{title:"Reuse an existing slice"}),(0,i.jsxs)(a.aj,{gap:0,children:[(0,i.jsx)(a.ak,{hidden:!0,children:"Select existing slices or import slices from a GitHub repository"}),(0,i.jsx)(eg,{...o,open:t,selected:"local"===r,onSelectTab:c,availableSlices:n,onClose:l}),(0,i.jsx)(ef,{...o,open:t,selected:"library"===r,onSelectTab:c,onClose:l})]})]})}var eb=n(27213);let ey=e=>{let{openCreateSliceModal:t,openCreateSliceFromImageModal:n,openUpdateSliceZoneModal:l,openSlicesTemplatesModal:o,isSlicesTemplatesSupported:r}=e,s=(0,eb.F)({menuType:"ActionList"});return(0,i.jsxs)(a.s,{"data-testid":"slice-zone-blank-slate",sx:{width:648},children:[(0,i.jsx)(a.x,{lineColor:"purple9",backgroundColor:"purple5",name:"add",size:"large"}),(0,i.jsx)(a.z,{size:"big",children:"Add slices"}),(0,i.jsx)(a.w,{children:"Slices are reusable website sections. You can use them on different pages and write unique content for each. Each slice has its own component in your code."}),(0,i.jsx)(a.v,{children:(0,i.jsxs)(a.A,{children:[(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromImage.BackgroundIcon,onClick:n,description:s.fromImage.description,children:s.fromImage.title}),(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromScratch.BackgroundIcon,onClick:t,description:s.fromScratch.description,children:s.fromScratch.title}),r&&(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromTemplate.BackgroundIcon,onClick:o,description:s.fromTemplate.description,children:s.fromTemplate.title}),(0,i.jsx)(a.b,{renderStartIcon:()=>s.fromExisting.BackgroundIcon,onClick:l,description:s.fromExisting.description,children:s.fromExisting.title})]})})]})};function ev(e){let{customType:t,tabId:n,slices:i}=e,a={...t};return i.forEach(e=>{a={...a,tabs:a.tabs.map(t=>t.key===n&&t.sliceZone?{...t,sliceZone:{key:t.sliceZone.key,value:[{key:e.id,value:e},...t.sliceZone.value]}}:t)}}),g.Xe.track({event:"custom-type:slice-zone-updated",customTypeId:t.id}),a}var ej=n(18566);async function eS(){try{let{templates:e,errors:t}=await W.managerClient.sliceTemplateLibrary.readLibrary({});if(t.length>0)throw t;return e.map(e=>({model:e.model,screenshots:Object.fromEntries(Object.entries(e.screenshots).map(e=>{let[t,n]=e;return[t,URL.createObjectURL(n)]}))}))}catch(e){return[]}}var ew=n(6256),eC=n(39204),eI=n(26109),eD=n(7723),eT=n(33986),ek=n(30527),e_=n(55862);let eA=e=>{let{deleteSliceZone:t,closeDeleteSliceZoneModal:n}=e;return(0,i.jsx)(e_.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:n,children:(0,i.jsx)(ek.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,i.jsxs)(E.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,i.jsx)(E.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:"Do you really want to delete Slice Zone?"}),(0,i.jsx)(E.x8,{type:"button",onClick:n})]}),Footer:()=>(0,i.jsxs)(E.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,i.jsx)(eT.z,{label:"Cancel",variant:"secondary",onClick:n,sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),(0,i.jsx)(eT.z,{label:"Delete",variant:"danger",onClick:t,sx:{minHeight:39,minWidth:78}})]}),children:(0,i.jsx)(E.nv,{children:"You're about to delete Slice Zone."})})})};var eE=n(84879),eL=n(63908),ez=n(63019),eN=n(65375),eP=n.n(eN);let eF=e=>{var t;let{isOpen:n,close:l,onSubmit:o,isLoading:r,slice:d,libraries:m}=e,{remoteSlices:u}=(0,c.v9)(e=>({remoteSlices:(0,eD.sT)(e)})),h={from:null===(t=m[0])||void 0===t?void 0:t.name,sliceName:(0,B.MP)(d.key)},[p,g]=(0,s.useState)(h),[x,b]=(0,s.useState)();function y(e){g(e),b((0,ez.h)(e,m,u))}return(0,f.pQ)(n,()=>{n||(g(h),b(void 0))}),(0,i.jsxs)(a.ae,{open:n,onOpenChange:e=>!e&&l(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.al,{title:"Upgrade slice"}),(0,i.jsx)(a.aj,{children:(0,i.jsx)(a.aJ,{onSubmit:function(){x&&Object.keys(x).length>0||o({libraryID:p.from,sliceID:p.sliceName})},children:(0,i.jsxs)(a.D,{flexDirection:"column",children:[(0,i.jsxs)(a.bn,{className:eP().scrollArea,children:[(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"This will create a new slice with the same fields. The new slice will replace the legacy slice in all of your types, and the existing slice content will be re-mapped to the new slice."}),(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"This will not migrate your component. You will need to do that manually."}),(0,i.jsxs)(a.D,{flexDirection:"column",gap:4,children:[(0,i.jsx)(a.aM,{label:"Slice name *",placeholder:"Pascalised Slice API ID (e.g. ".concat((0,B.MP)(d.key),")"),error:null==x?void 0:x.sliceName,value:p.sliceName,onValueChange:e=>y({...p,sliceName:e.slice(0,30)}),"data-testid":"slice-name-input"}),(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"A display name for the slice"})]}),(0,i.jsxs)(a.D,{flexDirection:"column",gap:4,children:[(0,i.jsx)("label",{className:eP().label,children:(0,i.jsx)(a.bL,{variant:"bold",children:"Slice library *"})}),(0,i.jsx)(a.bq,{size:"medium",color:"grey",startIcon:"folder",flexContent:!0,value:p.from,onValueChange:e=>{e&&y({...p,from:e})},children:m.map(e=>(0,i.jsx)(a.bt,{value:e.name,children:e.name},e.name))}),(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"The library where we'll store your slice"})]})]}),(0,i.jsxs)(a.ah,{children:[(0,i.jsx)(a.ai,{size:"medium"}),(0,i.jsx)(a.af,{type:"submit",size:"medium",loading:r,disabled:x&&Object.keys(x).length>0,children:"Upgrade"})]})]})})})]})};var eM=n(96009),eO=n.n(eM);let eU=e=>{var t,n;let{isOpen:l,close:o,onSubmit:r,isLoading:c,slice:d,sliceName:m,libraries:u,localSharedSlices:h}=e,p={libraryID:null===(t=h[0])||void 0===t?void 0:t.from,sliceID:null===(n=h[0])||void 0===n?void 0:n.model.id,variationID:eO()(d.key),variationName:m},[g,x]=(0,s.useState)(!0),[b,y]=(0,s.useState)(p),[v,j]=(0,s.useState)({});function S(e){y(e),j(eZ(e,u))}return(0,f.pQ)(l,()=>{l||(y(p),j({}))}),(0,i.jsxs)(a.ae,{open:l,onOpenChange:e=>!e&&o(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.al,{title:"Convert to slice variation"}),(0,i.jsx)(a.aj,{children:(0,i.jsx)(a.aJ,{onSubmit:function(){Object.keys(v).length>0||r(b)},children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,i.jsxs)(a.bn,{className:eP().scrollArea,children:[(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"If you have multiple slices that are similar, you can combine them as variations of the same slice."}),(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,i.jsxs)("label",{className:eP().label,children:[(0,i.jsx)(a.bL,{variant:"bold",children:"Target slice *"}),"string"==typeof v.libraryID?(0,i.jsx)(a.bL,{variant:"small",color:"tomato10",children:v.libraryID}):null,"string"==typeof v.sliceID?(0,i.jsx)(a.bL,{variant:"small",color:"tomato10",children:v.sliceID}):null]}),(0,i.jsx)(a.bq,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:"".concat(b.libraryID,"::").concat(b.sliceID),onValueChange:e=>{if(e){let[t,n]=e.split("::");S({...b,libraryID:t,sliceID:n})}},children:h.map(e=>(0,i.jsxs)(a.bt,{value:"".concat(e.from,"::").concat(e.model.id),children:[e.from," ",">"," ",e.model.name," (",e.model.id,")"]},"".concat(e.from,"::").concat(e.model.id)))}),(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"Choose the slice to which you would like to add this variation."})]}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",gap:4,children:(0,i.jsx)(a.aM,{label:"Variation name *",placeholder:m,error:v.variationName,value:b.variationName,onValueChange:e=>{let t={...b,variationName:e.slice(0,30)};g&&(t.variationID=eO()(t.variationName)),S(t)},"data-testid":"variation-name-input"})}),(0,i.jsx)(a.D,{display:"flex",flexDirection:"column",gap:4,children:(0,i.jsx)(a.aM,{label:"ID *",placeholder:eO()(d.key),error:v.variationID,value:b.variationID,onValueChange:e=>{x(!1),S({...b,variationID:e.slice(0,30)})},"data-testid":"variation-id-input"})})]}),(0,i.jsxs)(a.ah,{children:[(0,i.jsx)(a.ai,{size:"medium"}),(0,i.jsx)(a.af,{type:"submit",size:"medium",loading:c,disabled:Object.keys(v).length>0,children:"Convert"})]})]})})})]})},eZ=(e,t)=>{let n={};e.libraryID||(n.libraryID="Cannot be empty.");let i=t.find(t=>t.path===e.libraryID);n.libraryID||i||(n.libraryID="Does not exist."),e.sliceID||(n.sliceID="Cannot be empty.");let a=null==i?void 0:i.components.find(t=>t.model.id===e.sliceID);if(n.sliceID||a||(n.sliceID="Does not exist."),e.variationName||(n.variationName="Cannot be empty."),e.variationID){var l;(null!==(l=null==a?void 0:a.model.variations.map(e=>e.id))&&void 0!==l?l:[]).includes(e.variationID)&&(n.variationID="Slice variation ID is already taken.")}else n.variationID="Cannot be empty.";return n},eG=e=>{var t,n;let{isOpen:l,close:o,onSubmit:r,isLoading:c,identicalSlices:d}=e,m=null!==(n=null===(t=d[0])||void 0===t?void 0:t.path)&&void 0!==n?n:"",[u,h]=(0,s.useState)(m),[p,g]=(0,s.useState)();return(0,f.pQ)(l,()=>{l||(h(m),g(void 0))}),(0,i.jsxs)(a.ae,{open:l,onOpenChange:e=>!e&&o(),size:{width:448,height:"auto"},children:[(0,i.jsx)(a.al,{title:"Merge with an existing slice"}),(0,i.jsx)(a.aj,{children:(0,i.jsx)(a.aJ,{onSubmit:function(){if(p)return;let[e,t,n]=u.split("::");r({libraryID:e,sliceID:t,variationID:n})},children:(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",children:[(0,i.jsxs)(a.bn,{className:eP().scrollArea,children:[(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"If you have multiple identical slices, you can merge them. All of your content will be remapped to the target slice."}),(0,i.jsxs)(a.D,{display:"flex",flexDirection:"column",gap:4,children:[(0,i.jsxs)("label",{className:eP().label,children:[(0,i.jsx)(a.bL,{variant:"bold",children:"Target slice*"}),"string"==typeof p?(0,i.jsx)(a.bL,{variant:"small",color:"tomato10",children:p}):null]}),(0,i.jsx)(a.bq,{size:"medium",color:"grey",startIcon:"viewDay",flexContent:!0,value:u,onValueChange:function(e){h(e),e||g("Cannot be empty.")},children:d.map(e=>(0,i.jsx)(a.bt,{value:e.path,children:e.path.split("::").join(" > ")},e.path))}),(0,i.jsx)(a.bL,{variant:"normal",color:"grey11",children:"Choose a slice that you would like to merge this into."})]})]}),(0,i.jsxs)(a.ah,{children:[(0,i.jsx)(a.ai,{size:"medium"}),(0,i.jsx)(a.af,{type:"submit",size:"medium",loading:c,disabled:!!p,children:"Merge"})]})]})})})]})},eB=e=>{var t;let{slice:n,path:l}=e,{refreshState:o}=(0,y.Z)(),[r,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(),{setCustomType:h}=w(),{libraries:p}=(0,c.v9)(e=>({libraries:(0,eD.Sd)(e)})),f="Slice"===n.value.type&&null!==(t=n.value.fieldset)&&void 0!==t?t:n.key,x=p.filter(e=>e.isLocal),b=x.map(e=>e.components).flat(),v=eR(n,f,b),j=async e=>{var t,i,a;if(!m)return;d(!0),g.Xe.track({event:"legacy-slice:converted",id:e.sliceID,variation:null!==(t=e.variationID)&&void 0!==t?t:"default",library:e.libraryID,conversionType:m});let{errors:r}=await W.managerClient.slices.convertLegacySliceToSharedSlice({model:n.value,src:{...l,sliceID:n.key},dest:{libraryID:e.libraryID,sliceID:e.sliceID,variationName:null!==(i=e.variationName)&&void 0!==i?i:"Default",variationID:null!==(a=e.variationID)&&void 0!==a?a:"default"}});if(r.length)throw console.error("Could not convert slice `".concat(f,"`"),r),M.Am.error("Could not convert slice `".concat(f,"`")),r;let{model:s,errors:c}=await W.managerClient.customTypes.readCustomType({id:l.customTypeID});if(c.length||!s){console.error("Could not refresh custom type view `".concat(l.customTypeID,"`"),c),M.Am.error("Could not refresh custom type view `".concat(l.customTypeID,"`"));return}switch(o(await (0,g.y0)()),d(!1),u(void 0),m){case"as_new_slice":M.Am.success("".concat(f," has been upgraded to a new slice ").concat(e.libraryID," > ").concat(e.sliceID));break;case"as_new_variation":M.Am.success("".concat(f," has been converted as a variation of ").concat(e.libraryID," > ").concat(e.sliceID));break;default:M.Am.success("".concat(f," has been merged with ").concat(e.libraryID," > ").concat(e.sliceID))}h({customType:s})},S={path:l,slice:n,sliceName:f,libraries:x,localSharedSlices:b,identicalSlices:v,close:()=>u(void 0),onSubmit:j,isLoading:r};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.ar,{children:[(0,i.jsx)(a.av,{children:(0,i.jsx)(a.E,{"data-testid":"convert-legacy-slice",startIcon:"refresh",endIcon:"arrowDropDown",size:"medium",color:"grey",children:"Migrate legacy slice"})}),(0,i.jsxs)(a.as,{align:"start",children:[(0,i.jsx)(a.at,{startIcon:(0,i.jsx)(a.aX,{name:"folder",size:"large"}),description:"Use it with new types",onSelect:()=>u("as_new_slice"),children:"Upgrade slice"}),(0,i.jsx)(a.at,{startIcon:(0,i.jsx)(a.aX,{name:"viewDay",size:"large"}),description:"Add it to another slice",onSelect:()=>u("as_new_variation"),disabled:!b.length,children:"Convert to slice variation"}),(0,i.jsx)(a.at,{startIcon:(0,i.jsx)(a.aX,{name:"driveFileMove",size:"large"}),description:"Combine identical slices",onSelect:()=>u("merge_with_identical"),disabled:!v.length,children:"Merge with another slice"})]})]}),(0,i.jsx)(eF,{...S,isOpen:"as_new_slice"===m}),(0,i.jsx)(eU,{...S,isOpen:"as_new_variation"===m}),(0,i.jsx)(eG,{...S,isOpen:"merge_with_identical"===m})]})},eR=(e,t,n)=>(0,s.useMemo)(()=>{let i=[],a=(0,eL.ux)(e.value,t);for(let e of n)for(let t of e.model.variations){let n=(0,eL.ux)(t,e.model.name);a.primary===n.primary&&a.items===n.items&&i.push({libraryID:e.from,sliceID:e.model.id,variationID:t.id,path:"".concat(e.from,"::").concat(e.model.id,"::").concat(t.id)})}return i},[e,t,n]),eH=e=>{let{slice:t,path:n}=e,[l]=(0,eE.E)("legacySliceUpgrader"),o=l.enabled?"This Slice was created with the Legacy Builder. It needs to be converted first to be used within Slice Machine.":"This Slice was created with the Legacy Builder, and is incompatible with Slice Machine. You cannot edit, push, or delete it in Slice Machine. In order to proceed, manually remove the Slice from your type model. Then create a new Slice with the same fields using Slice Machine.";return(0,i.jsxs)(em.Zb,{children:[(0,i.jsx)(em.ZB,{component:"div",children:(0,i.jsx)(a.D,{alignItems:"center",justifyContent:"center",children:(0,i.jsx)(a.bL,{color:"grey11",component:"span",children:"No screenshot available"})})}),(0,i.jsxs)(em.T$,{children:[(0,i.jsx)(a.c3,{content:o,side:"bottom",children:(0,i.jsx)(a.m,{color:"purple",title:"Legacy Slice"})}),l.enabled?(0,i.jsx)(eB,{slice:t,path:n}):null]}),(0,i.jsx)(em.eW,{subtitle:"1 variation",title:(0,eL.Dj)(t.value)})]})};var eK=n(51507),eV=n(21151);let eX=e=>{let{slices:t,format:n,path:a,onRemoveSharedSlice:l}=e,o=t.some(e=>"SharedSlice"!==e.type),r=v.$[n],[c]=(0,eE.E)("legacySliceUpgrader");return(0,s.useEffect)(()=>{o&&(c.enabled?M.Am.info("This ".concat(r.name({start:!1,plural:!1})," contains legacy slices that can be upgraded.")):M.Am.warning("This ".concat(r.name({start:!1,plural:!1})," contains slices that are incompatible.")))},[o]),(0,i.jsx)(eV.Z,{elems:t,defineElementKey:e=>"SharedSlice"!==e.type?e.payload.key:e.payload.model.name,renderElem:e=>{if("SharedSlice"!==e.type){let t=e.payload;return(0,i.jsx)(eH,{slice:t,path:a})}{let t=e.payload;return(0,i.jsx)(eK.b,{action:{type:"remove",onRemove:()=>{l(t.model.id)}},mode:"navigation",slice:t,variant:"solid"})}},sx:{padding:"16px"}})};async function eq(e){try{let{templateIDs:t,localLibrariesNames:n,location:i,onSuccess:a}=e,{data:l,errors:o}=await W.managerClient.sliceTemplateLibrary.createSlices({templateIDs:t});if(o.length>0||void 0===l)throw o;l.sliceIDs.forEach((e,a)=>{g.Xe.track({event:"slice:created",id:e,name:e,library:n[0],location:i,mode:"template",sliceTemplate:t[a]})}),await a(l.sliceIDs)}catch(t){let e="Internal Error: Slice(s) not created";console.error(e,t),M.Am.error(e)}}var eW=e=>{let{availableSlices:t,values:n}=e;return(0,i.jsx)(A.F2,{name:"sliceKeys",render:e=>(0,i.jsx)(eV.Z,{gridTemplateMinPx:"200px",elems:t,defineElementKey:e=>"".concat(e.from,"-").concat(e.model.name),renderElem:t=>{let a=n.sliceKeys.includes(t.model.id);return(0,i.jsx)(eK.b,{action:{type:"checkbox"},mode:"selection",onSelectedChange:i=>{i?e.push(t.model.id):e.remove(n.sliceKeys.indexOf(t.model.id))},selected:a,slice:t,variant:"outlined"})}})})};let eY=e=>{let{formId:t,close:n,onSuccess:a,availableSlicesTemplates:l,localLibraries:o,location:r}=e,{createSliceSuccess:s}=(0,y.Z)();return(0,i.jsx)(_.Z,{isOpen:!0,buttonLabel:"Add",formId:t,close:n,onSubmit:e=>{let{sliceKeys:t}=e;eq({templateIDs:t,localLibrariesNames:o.map(e=>e.name),location:r,onSuccess:async e=>{s((await (0,g.y0)()).libraries),a(await Promise.all(e.map(async e=>(await W.managerClient.slices.readSlice({libraryID:o[0].name,sliceID:e})).model).filter(e=>void 0!==e)))}})},initialValues:{sliceKeys:[]},content:{title:"Use template slices"},validate:e=>{if(0===e.sliceKeys.length)return{sliceKeys:"Select at least one template to add"}},actionMessage:e=>{let{errors:t}=e;return void 0!==t.sliceKeys?(0,i.jsx)(E.xv,{sx:{color:"error"},children:t.sliceKeys}):void 0},children:e=>{let{values:t}=e;return(0,i.jsx)(eW,{values:t,availableSlices:l.map(e=>({extension:"",fileName:"",from:"",href:"",pathToSlice:"",model:eI.id.toSM(e.model),screenshots:Object.entries(e.screenshots).reduce((e,t)=>({...e,[t[0]]:{url:t[1]}}),{})}))})}})},e$=(e,t)=>{let n=(t||[]).reduce((e,t)=>[...e,...t.components],[]),{slicesInSliceZone:i,notFound:a}=e.value.reduce((e,t)=>{let{key:i,value:a}=t;if("SharedSlice"===a.type){let t=n.find(e=>e.model.id===i);return t?{...e,slicesInSliceZone:[...e.slicesInSliceZone,{type:"SharedSlice",payload:t}]}:{...e,notFound:[...e.notFound,{key:i}]}}return{...e,slicesInSliceZone:[...e.slicesInSliceZone,{type:"Slice",payload:{key:i,value:a}}]}},{slicesInSliceZone:[],notFound:[]});return{availableSlices:n,slicesInSliceZone:i,notFound:a}};var eJ=e=>{var t,n;let{customType:l,onCreateSliceZone:o,onDeleteSliceZone:r,onRemoveSharedSlice:d,sliceZone:m,tabId:u}=e,h=(0,ej.QT)(eS,[]),[p,f]=(0,s.useState)(!1),[x,b]=(0,s.useState)(!1),[v,j]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!1),{remoteSlices:I,libraries:D}=(0,c.v9)(e=>({remoteSlices:(0,eD.sT)(e),libraries:(0,eD.Sd)(e),slices:(0,eD.xC)(e)})),{setCustomType:T}=w(),{completeStep:_}=(0,Y.k)(),{openLoginModal:A}=(0,y.Z)(),E=(0,eb.F)({menuType:"Dropdown"}),L=D.filter(e=>e.isLocal),{availableSlices:z,slicesInSliceZone:N,notFound:P}=(0,s.useMemo)(()=>m?e$(m,D):{availableSlices:[],slicesInSliceZone:[],notFound:[]},[m,D]),[F,U]=(0,s.useState)(!1);(0,s.useEffect)(()=>{(null==P?void 0:P.length)&&P.forEach(e=>{let{key:t}=e;d(t)})},[P]);let Z=N.filter(e=>"SharedSlice"===e.type).map(e=>e.payload),G=z.filter(e=>!Z.some(t=>t.model.id===e.model.id)),B=()=>{b(!0)},R=()=>{j(!0)},H=async()=>{await W.managerClient.user.checkIsLoggedIn()?C(!0):A()},K=()=>{f(!0),g.Xe.track({event:"custom-type:open-add-from-templates",customTypeId:l.id,customTypeFormat:l.format})},V=()=>{b(!1)},$=()=>{j(!1)},J=()=>{C(!1)},Q=()=>{f(!1)};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(O.Bu,{actions:m?(0,i.jsxs)(a.ar,{children:[(0,i.jsx)(a.av,{children:(0,i.jsx)(a.E,{color:"purple",startIcon:"add","data-testid":"add-new-slice-dropdown",children:"Add"})}),(0,i.jsxs)(a.as,{align:"end",children:[(0,i.jsx)(a.at,{renderStartIcon:()=>E.fromImage.BackgroundIcon,onSelect:()=>void H(),description:E.fromImage.description,children:E.fromImage.title}),(0,i.jsx)(a.at,{renderStartIcon:()=>E.fromScratch.BackgroundIcon,onSelect:R,description:E.fromScratch.description,children:E.fromScratch.title}),h.length>0?(0,i.jsx)(a.at,{onSelect:K,renderStartIcon:()=>E.fromTemplate.BackgroundIcon,description:E.fromTemplate.description,children:E.fromTemplate.title}):void 0,(0,i.jsx)(a.at,{onSelect:B,renderStartIcon:()=>E.fromExisting.BackgroundIcon,description:E.fromExisting.description,children:E.fromExisting.title})]})]}):void 0,toggle:"page"!==l.format||"Main"!==u?(0,i.jsx)(a.bC,{checked:!!m,onCheckedChange:e=>{e?o():U(!0)},size:"small","data-testid":"slice-zone-switch"}):void 0,children:"Slices"}),m?N.length>0?(0,i.jsx)(X.xR,{children:(0,i.jsx)(eX,{slices:N,format:l.format,path:{customTypeID:l.id,tabID:u,sliceZoneID:null!==(t=null==m?void 0:m.key)&&void 0!==t?t:""},onRemoveSharedSlice:d})}):(0,i.jsx)(a.D,{flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center",padding:{block:32},children:(0,i.jsx)(ey,{openUpdateSliceZoneModal:B,openCreateSliceModal:R,openCreateSliceFromImageModal:()=>void H(),openSlicesTemplatesModal:K,projectHasAvailableSlices:G.length>0,isSlicesTemplatesSupported:h.length>0})}):void 0,(0,i.jsx)(ex,{open:x,location:"".concat(l.format,"_type"),typeName:null!==(n=l.label)&&void 0!==n?n:l.id,availableSlices:G.map(e=>{var t;return{...eI.id.fromSM(e.model),thumbnailUrl:null===(t=Object.values(e.screenshots)[0])||void 0===t?void 0:t.url}}),onSuccess:e=>{let{slices:t}=e,n=ev({customType:l,tabId:u,slices:t.map(e=>e.model)});T({customType:k.Dc.fromSM(n),onSaveCallback:()=>{M.Am.success("Slices successfully added")}}),_("createSlice"),V()},onClose:V}),p&&(0,i.jsx)(eY,{formId:"tab-slicezone-form-".concat(u),availableSlicesTemplates:h,localLibraries:L,location:"".concat(l.format,"_type"),onSuccess:e=>{let t=ev({customType:l,tabId:u,slices:e});T({customType:k.Dc.fromSM(t),onSaveCallback:()=>{M.Am.success((0,i.jsx)(eC.GX,{message:"Slice template(s) added to slice zone and created at: ",path:"".concat(L[0].name,"/")}))}}),_("createSlice"),Q()},close:Q}),F&&(0,i.jsx)(eA,{closeDeleteSliceZoneModal:()=>{U(!1)},deleteSliceZone:()=>{r(),U(!1)}}),(null==L?void 0:L.length)!==0&&v&&(0,i.jsx)(ew.c,{onSuccess:e=>{let t=ev({customType:l,tabId:u,slices:[e]});T({customType:k.Dc.fromSM(t),onSaveCallback:()=>{M.Am.success((0,i.jsx)(eC.GX,{message:"New slice added to slice zone and created at: ",path:"".concat(L[0].name,"/")}))}}),$()},localLibraries:L,location:"".concat(l.format,"_type"),remoteSlices:I,onClose:$}),(0,i.jsx)(q.S,{open:S,location:"".concat(l.format,"_type"),onSuccess:e=>{let{slices:t,library:n}=e,a=ev({customType:l,tabId:u,slices:t});T({customType:k.Dc.fromSM(a),onSaveCallback:()=>{M.Am.success((0,i.jsx)(eC.GX,{message:"Slice(s) added to slice zone and created at: ",path:n}))}}),J()},onClose:J})]})};let eQ=[Z.C.UID,Z.C.Image,Z.C.Text,Z.C.StructuredText,Z.C.Link,Z.C.Select,Z.C.Boolean,Z.C.Number,Z.C.Color,Z.C.Date,Z.C.Table,Z.C.Embed,Z.C.Timestamp,Z.C.GeoPoint,Z.C.ContentRelationship,Z.C.LinkToMedia,Z.C.Group,Z.C.NestedGroup];var e0=e=>{var t,n,l,o;let{tabId:r}=e,{customType:c,setCustomType:d}=w(),u=k.Dc.toSM(c),h=null===(t=u.tabs.find(e=>e.key===r))||void 0===t?void 0:t.sliceZone,p=null!==(l=null===(n=u.tabs.find(e=>e.key===r))||void 0===n?void 0:n.value)&&void 0!==l?l:[],f="page"===u.format&&u.repeatable?p.filter(e=>"uid"!==e.key):p,g=u.tabs.reduce((e,t)=>[...e,...t.value],[]),x=e=>{var t;let{apiId:n,value:i}=e,a=null===(t=i.config)||void 0===t?void 0:t.label;if((0,G.Ss)(Z.C,i.type)||null==a)return;if("Range"===i.type||"IntegrationFields"===i.type||"Separator"===i.type)throw Error("Unsupported Field Type: ".concat(i.type));let l=Z.C[i.type];try{l.schema.validateSync(i,{stripUnknown:!1})}catch(e){throw Error('Add field: Model is invalid for field "'.concat(i.type,'".'))}let o=k.L$.fromSM(i);d({customType:(0,m.xS)({customType:c,newField:o,newFieldId:n,sectionId:r}),onSaveCallback:()=>{M.Am.success("".concat("Group"===i.type?"Group":"Field"," added"))}}),(0,R.V)({id:n,field:o})},b=e=>{let{apiId:t,newKey:n,value:i,inGroupFieldAction:a,updateMeta:l}=e;if((0,G.Ss)(Z.C,i.type))return;let o=k.L$.fromSM(i);d({customType:(0,m.L4)({customType:c,previousFieldId:t,newFieldId:n,newField:o,sectionId:r}),onSaveCallback:()=>{"add"===a&&M.Am.success("Field added")},updateMeta:l}),a||(0,H.Z)({previousId:t,id:n,field:o})};return(0,i.jsx)(U.h,{children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsx)(a.D,{padding:32,children:(0,i.jsx)(a.bg,{})}),children:(0,i.jsxs)(O.aV,{border:!1,style:{flexGrow:1},children:[(0,i.jsx)(V.Z,{zoneType:"customType",zoneTypeFormat:null!==(o=c.format)&&void 0!==o?o:"custom",tabId:r,title:"Static zone",dataTip:"",fields:f,poolOfFieldsToCheck:g,showHints:!0,EditModal:K.Z,widgetsArray:eQ,onDeleteItem:e=>{d({customType:(0,m.AK)({customType:c,fieldId:e,sectionId:r})})},onSave:e=>""===e.apiId?x({...e,apiId:e.newKey}):b(e),onDragEnd:e=>{if((0,G.uS)(e))return;let{source:t,destination:n}=e;if(!n)return;let i=(0,m.gR)({customType:c,sourceIndex:t.index,destinationIndex:n.index,sectionId:r});(0,F.flushSync)(()=>d({customType:i}))},renderHintBase:e=>{let{item:t}=e;return"data".concat((0,B.Ti)(t.key))},renderFieldAccessor:e=>"data".concat((0,B.Ti)(e)),testId:"static-zone-content",isRepeatableCustomType:c.repeatable}),(0,i.jsx)(eJ,{customType:u,tabId:r,sliceZone:h,onRemoveSharedSlice:e=>{d({customType:(0,m.EN)({customType:c,sectionId:r,sliceId:e})})},onCreateSliceZone:()=>{d({customType:(0,m.Tr)(c,r)})},onDeleteSliceZone:()=>{d({customType:(0,m.E3)(c,r)})}})]})})})};let e1=()=>{var e,t,n;let{customType:l,setCustomType:o}=w(),r=k.Dc.toSM(l),[c,d]=(0,s.useState)(null===(e=r.tabs[0])||void 0===e?void 0:e.key),[u,h]=(0,s.useState)(),p=(null===(n=r.tabs.find(e=>e.key===c))||void 0===n?void 0:null===(t=n.sliceZone)||void 0===t?void 0:t.value.length)===0;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(a.c9,{sx:p?{flexGrow:1}:void 0,children:["page"===l.format?(0,i.jsx)(a.ca,{title:l.repeatable?(0,i.jsx)(I,{}):void 0}):void 0,(0,i.jsxs)(a.cb,{onValueChange:d,value:c,children:[(0,i.jsx)(a.cd,{onAddNewTab:()=>{h({type:"CREATE_CUSTOM_TYPE_TAB"})},children:r.tabs.map(e=>(0,i.jsx)(a.ce,{menu:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.at,{onSelect:()=>{h({type:"UPDATE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,i.jsx)(a.aX,{name:"edit"}),children:"Rename"}),(0,i.jsx)(a.at,{color:"tomato",disabled:function(e){if(r.tabs.length<=1)return!0;let t=r.tabs.find(e=>e.value.find(e=>"uid"===e.key));return"page"===l.format&&l.repeatable&&(null==t?void 0:t.key)===e}(e.key),onSelect:()=>{h({type:"DELETE_CUSTOM_TYPE_TAB",tabKey:e.key})},startIcon:(0,i.jsx)(a.aX,{name:"delete"}),children:"Remove"})]}),value:e.key,children:e.key},e.key))}),r.tabs.map(e=>(0,i.jsx)(a.cc,{value:e.key,children:(0,i.jsx)(e0,{tabId:e.key})},e.key))]})]}),(null==u?void 0:u.type)==="CREATE_CUSTOM_TYPE_TAB"?(0,i.jsx)(z,{close:()=>{h(void 0)},isOpen:!0,onSubmit:e=>{let{id:t}=e;o({customType:(0,m.vB)(l,t)}),d(t)},tabIds:r.tabs.map(e=>e.key.toLowerCase())}):void 0,(null==u?void 0:u.type)==="UPDATE_CUSTOM_TYPE_TAB"?(0,i.jsx)(P,{close:()=>{h(void 0)},initialTabKey:u.tabKey,isOpen:!0,onSubmit:e=>{let{id:t}=e;o({customType:(0,m.HO)(l,u.tabKey,t)}),c===u.tabKey&&d(t)},tabIds:r.tabs.filter(e=>e.key!==u.tabKey).map(e=>e.key.toLowerCase())}):void 0,(null==u?void 0:u.type)==="DELETE_CUSTOM_TYPE_TAB"?(0,i.jsx)(N,{close:()=>{h(void 0)},isOpen:!0,onSubmit:()=>{if(o({customType:(0,m.F$)(l,u.tabKey)}),c===u.tabKey){var e;let t=null===(e=r.tabs.find(e=>e.key!==u.tabKey))||void 0===e?void 0:e.key;void 0!==t&&d(t)}}}):void 0]})};var e4=n(16442),e6=n(78254),e8=n(60867),e2=n(11166),e3=n(34919),e5=n.n(e3);let e9=e=>{let{tabs:t,...n}=e;return(0,i.jsxs)(e2.fC,{...n,className:e5().root,defaultValue:t[0].label,orientation:"vertical",children:[(0,i.jsx)(e2.aV,{className:e5().list,"aria-label":"content tabs",children:t.map((e,t)=>{let{label:n}=e;return(0,i.jsx)(e2.xz,{className:e5().trigger,value:n,children:(0,i.jsx)(a.bL,{className:e5().triggerText,component:"span",color:"inherit",children:n})},"".concat(n,"-trig").concat(t+1))})}),t.map((e,t)=>{let{label:n,content:l}=e;return(0,i.jsx)(e2.VY,{className:e5().content,value:n,children:(0,i.jsx)(a.bn,{className:e5().scrollArea,children:l})},"".concat(n,"-content").concat(t+1))})]})};var e7=n(25661),te=n(88241),tt=n(32554),tn=n(44621),ti=n.n(tn);let ta=e=>{var t,n;let{inline:l,...o}=e,r=(0,tt.p)();if(!0===l)return(0,i.jsx)("code",{...o,className:ti().inlineCode});let s=(()=>{var e,t,n,i,a;if((null===(t=o.node)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.meta)!==void 0){let e=null===(i=o.node)||void 0===i?void 0:null===(n=i.data)||void 0===n?void 0:n.meta;return{fileName:e.substring(1,e.length-1),language:null===(a=o.className)||void 0===a?void 0:a.split("-")[1]}}return null})(),c=null===(t=/language-(\w+)/.exec(null!==(n=o.className)&&void 0!==n?n:""))||void 0===t?void 0:t[1];return(0,i.jsx)(a.W,{...o,onCopy:()=>{g.Xe.track({event:"page-type:copy-snippet",framework:r})},language:c,code:String(o.children).replace(/\n$/,""),title:null==s?void 0:s.fileName})},tl=e=>{let{markdown:t}=e;return(0,i.jsx)(e7.D,{children:t,linkTarget:"_blank",remarkPlugins:[te.Z],components:{code:e=>(0,i.jsx)(ta,{...e}),h1:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h1",variant:"h1"}),h2:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h2",variant:"h2"}),h3:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h3",variant:"h3"}),h4:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h4",variant:"h4"}),h5:e=>(0,i.jsx)(a.bL,{children:e.children,component:"h4",variant:"h4"}),p:e=>(0,i.jsx)(a.bL,{className:ti().section,children:e.children,component:"p",variant:"normal"}),pre:e=>(0,i.jsx)(a.bL,{className:ti().section,children:e.children,component:"pre",variant:"normal"})}})};async function to(e){let t=JSON.parse(e),{errors:n,documentation:i}=await W.managerClient.documentation.read({kind:t.kind,data:t.data});if(n.length>0)throw n;return i}var tr=n(65480),ts=n.n(tr);let tc=e=>{var t;let{model:n}=e,l=(0,tt.p)(),o=(t={kind:"PageSnippet",data:{model:n}},(0,ej.QT)(to,[JSON.stringify(t)])),{completeStep:r}=(0,Y.k)();return 0===o.length?null:(0,i.jsxs)(a.ae,{size:"small",trigger:(0,i.jsx)(a.E,{color:"grey",onClick:()=>{r("codePage"),g.Xe.track({event:"page-type:open-snippet",framework:l})},startIcon:"code",children:"Page snippet"}),children:[(0,i.jsx)(a.al,{icon:"code",title:"Page snippet"}),(0,i.jsx)("section",{className:ts().content,children:o.length>1?(0,i.jsx)(e9,{style:{flex:1},tabs:o.map((e,t)=>{let{label:n,content:a}=e;return{label:null!=n?n:"Tab ".concat(t+1),content:(0,i.jsx)(tl,{markdown:a})}})}):(0,i.jsx)(a.bn,{style:{flex:1,padding:16},children:(0,i.jsx)(tl,{markdown:o[0].content})})})]})},td=e=>{let{model:t}=e;return(0,i.jsx)("div",{children:(0,i.jsx)(U.h,{children:(0,i.jsx)(s.Suspense,{fallback:(0,i.jsx)(a.E,{color:"grey",startIcon:"code",children:"Page snippet"}),children:(0,i.jsx)(tc,{model:t})})})})},tm=()=>{let e=(0,r.useRouter)(),{selectedCustomType:t}=(0,c.v9)(t=>({selectedCustomType:(0,e6.Jk)(t,(0,h.Ag)(e.query))}));return((0,s.useEffect)(()=>{t&&(0,e4.TG)(t)||e.replace("/")},[t,e]),t&&(0,e4.TG)(t))?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(o(),{children:(0,i.jsxs)("title",{children:[t.local.label," - Slice Machine"]})}),(0,i.jsx)(tu,{customType:t.local})]}):(0,i.jsx)(p.LN,{})},tu=e=>{let{customType:t}=e;return null===t?(0,i.jsx)(p.LN,{}):(0,i.jsx)(p.LN,{children:(0,i.jsx)(S,{initialCustomType:k.Dc.fromSM(t),children:e=>{var n;let{actionQueueStatus:l,customType:o,setCustomType:r}=e,s=(0,m.y6)(o),c=h.cd[t.format],f=v.$[t.format];return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(p.wd,{children:[(0,i.jsx)(p.Xq,{url:c.tablePagePathname}),(0,i.jsxs)(p.Cx,{children:[(0,i.jsx)(d.g,{children:f.name({start:!0,plural:!0})}),(0,i.jsx)(d.g,{active:!0,children:null!==(n=o.label)&&void 0!==n?n:o.id})]}),(0,i.jsxs)(p.K2,{children:[(0,i.jsx)(u.X,{status:l}),"page"===o.format?(0,i.jsx)(td,{model:o}):void 0,(0,i.jsx)(e8._,{isChangesLocal:!0,format:s,customType:o,setLocalCustomType:r})]})]}),(0,i.jsx)(p.RN,{children:(0,i.jsx)(a.D,{flexDirection:"column",minWidth:0,children:(0,i.jsx)(e1,{})})})]})}})})}},84879:function(e,t,n){"use strict";n.d(t,{E:function(){return o}});var i=n(18566),a=n(80148);async function l(){return a.managerClient.project.getSliceMachineConfig()}function o(e){var t,n;let[o,r]=[(0,i.QT)(l,[]),async e=>{await a.managerClient.project.writeSliceMachineConfig({config:e}),(0,i.VA)(l,[],e)}],s=async t=>{let n={...o,labs:{...o.labs}};t?n.labs[e]=t:e in n.labs&&delete n.labs[e],0===Object.keys(n.labs).length&&delete n.labs,await r(n)};return[{enabled:null!==(n=null==o?void 0:null===(t=o.labs)||void 0===t?void 0:t[e])&&void 0!==n&&n},s]}},34919:function(e){e.exports={flex:"ContentTabs_flex__T21Oc",column:"ContentTabs_column__1f8b8 ContentTabs_flex__T21Oc",root:"ContentTabs_root__Gn3Zg ContentTabs_column__1f8b8 ContentTabs_flex__T21Oc",list:"ContentTabs_list__rAZtl ContentTabs_flex__T21Oc",trigger:"ContentTabs_trigger__cTyPN ContentTabs_column__1f8b8 ContentTabs_flex__T21Oc",triggerText:"ContentTabs_triggerText__p_ZBl",content:"ContentTabs_content__H1Stj ContentTabs_column__1f8b8 ContentTabs_flex__T21Oc",scrollArea:"ContentTabs_scrollArea__DuDcQ"}},65480:function(e){e.exports={content:"PageSnippetDialog_content__jIN6d"}},44621:function(e){e.exports={section:"MarkdownRenderer_section__uNS1M",inlineCode:"MarkdownRenderer_inlineCode__lmGTi"}},65375:function(e){e.exports={scrollArea:"ConvertLegacySliceButton_scrollArea__xf3vM",label:"ConvertLegacySliceButton_label__BK0Gd"}}}]);