1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4320],{49289:(e,t,r)=>{r.d(t,{Q:()=>a});var n=r(2125),s=r(35844);async function a({file:e,path:t}){let r=await s.u.postFile(n.PW.UPLOAD,e,t);return await r.json()}},74320:(e,t,r)=>{r.d(t,{X:()=>ef});var n=r(95155),s=r(12115),a=r(99003),l=r(33546),i=r(66088),o=r(42442),u=r(18460),d=r(91337);let c=(0,u.F)("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg_secondary text-secondary-foreground [a&]:hover:bg_secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function x({className:e,variant:t,asChild:r=!1,...s}){let a=r?o.DX:"span";return(0,n.jsx)(a,{"data-slot":"badge",className:(0,d.cn)(c({variant:t}),e),...s})}var h=r(23511),f=r(6296),m=r(94514);let p=/\b[A-Za-z0-9]+(?:['\u2019-][A-Za-z0-9]+)*\b/g,g=/(?<!\b(?:Mr|Mrs|Ms|Dr|Prof|Rev|Gen|Sen|Rep|St|Ave|Blvd|Rd))[.!?]+['")\]]*\s*|\n+/g;function v(e,t){switch(t){case"Word":let r=e.trim();if(!r)return 0;let n=r.match(p);return n?n.length:0;case"Sentence":return function(e){let t,r=e.trim();if(!r)return 0;let n=0,s=0,a=new RegExp(g);for(;null!==(t=a.exec(r));)r.slice(s,t.index).trim()&&n++,s=t.index+t[0].length,0===t[0].length&&a.lastIndex++;return r.slice(s).trim()&&n++,n}(e);default:return e.trim().length}}function b(e,t){let r=(e??"Character").toLowerCase();return`${r}${t>1?"s":""}`}function y(e,t,r,n){return 0===t&&null==r?"":t>0&&t>e?`${e}/${t} ${b(n,t)}`:null!=r&&r<e?`${e}/${r} ${b(n,r)}`:0===e?"":`${e} ${b(n,e)}`}var C=r(2693),j=r(82464);function I({customization:e,suffix:t,showPlaceholder:r=!1}){return e.Title?(0,n.jsxs)("div",{className:"flex items-stretch gap-2.5 px-0 pb-3",children:[(0,n.jsx)("div",{className:"w-[3px] shrink-0 rounded-full bg-emerald-500","aria-hidden":!0}),(0,n.jsxs)("div",{className:"flex-1 pr-5",children:[(0,n.jsx)("p",{className:"text-[17px] font-bold leading-snug text-foreground/50",children:e.Title}),r&&e.Placeholder&&(0,n.jsx)("p",{className:"mt-1 text-[12.6px] font-light leading-snug tracking-wide text-muted-foreground",children:e.Placeholder.split("\\n").map((e,t)=>(0,n.jsxs)("span",{children:[e,(0,n.jsx)("br",{})]},t))})]}),t]}):null}function w(e,t,r){if(!e||!r)return r;try{return new RegExp(e).test(r)?r:t}catch{return r}}function T({customization:e,value:t,onChange:r,error:s,readonly:a,saveStatus:l}){let i=(0,C.n)(e=>e.language),o=j.P[i],u=t.text,c=e.TextCountType??"Character",x=y(v(u.trim(),c),e.MinCount,e.MaxCount,c),h=u.trim().length>0;return(0,n.jsxs)("div",{children:[(0,n.jsx)(I,{customization:e}),(0,n.jsxs)("div",{className:(0,d.cn)("flex items-center gap-2.5 rounded-2xl border bg-muted px-4",s?"border-destructive":"border-border"),children:[(0,n.jsx)("input",{type:"text",disabled:a,value:u,onChange:n=>r({...t,text:w(e.TextFilterRegex,u,n.target.value)}),placeholder:e.Placeholder||o.productDetails.type_here_placeholder,className:"min-w-0 flex-1 bg-transparent !h-[52px] text-[1.5rem] md:text-[1.2rem] lg:text-[1.1rem] leading-none text-foreground placeholder:text-muted-foreground focus:outline-none"}),h&&("saving"===l?(0,n.jsx)(f.A,{size:15,className:"shrink-0 animate-spin text-muted-foreground"}):s?null:(0,n.jsx)(m.A,{size:14,className:"shrink-0 text-emerald-500"}))]}),(0,n.jsx)("div",{className:"mt-1 flex justify-end px-1",children:(0,n.jsx)("span",{className:(0,d.cn)("text-xs leading-snug",s?"text-destructive":"text-muted-foreground"),children:s?`*${s}`:x})})]})}function N({customization:e,value:t,onChange:r,error:s,readonly:a,saveStatus:l}){let i=(0,C.n)(e=>e.language),o=j.P[i],u=t.text,c=e.TextCountType??"Character",x=y(v(u.trim(),c),e.MinCount,e.MaxCount,c),h=u.trim().length>0;return(0,n.jsxs)("div",{children:[(0,n.jsx)(I,{customization:e}),(0,n.jsxs)("div",{className:(0,d.cn)("relative h-[200px] rounded-2xl border bg-muted px-4 py-3",s?"border-destructive":"border-border"),children:[(0,n.jsx)("textarea",{disabled:a,value:u,onChange:n=>r({...t,text:w(e.TextFilterRegex,u,n.target.value)}),placeholder:e.Placeholder||o.productDetails.write_message_placeholder,className:"h-full w-full resize-none bg-transparent text-[1.5rem] md:text-[1.2rem] lg:text-[1.1rem] leading-snug text-foreground placeholder:text-muted-foreground focus:outline-none"}),h&&(0,n.jsx)("div",{className:"absolute right-3 top-3",children:"saving"===l?(0,n.jsx)(f.A,{size:15,className:"animate-spin text-muted-foreground"}):s?null:(0,n.jsx)(m.A,{size:14,className:"text-emerald-500"})})]}),(0,n.jsx)("div",{className:"mt-1 flex justify-end px-1",children:(0,n.jsx)("span",{className:(0,d.cn)("text-xs leading-snug",s?"text-destructive":"text-muted-foreground"),children:s?`*${s}`:x})})]})}var P=r(24338),k=r(21628),M=r(62489),U=r(2125),z=r(35844);async function S(e){try{let t=await z.u.get(`${U.pQ}?uId=${encodeURIComponent(e)}`);return await t.json()}catch(e){throw e}}let $=new Map;var _=r(52760);let A=new Map;
1function R(e){let[t,r]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(!e?.Path||!e?.Title)return void r(!1);let t=!1;r(!1);let n=A.get(e.Title);return n||(n=new FontFace(e.Title,`url(${(0,_.X)(e.Path)})`).load().then(e=>(document.fonts.add(e),e)),A.set(e.Title,n)),n.then(()=>{t||r(!0)}).catch(()=>{A.delete(e.Title),t||r(!1)}),()=>{t=!0}},[e?.Path,e?.Title]),t}function F({font:e,isSelected:t,text:r,showBorder:s=!1,onSelect:a}){let l=R(e),i=r.trim()?r:"Type Here .";return(0,n.jsxs)("button",{type:"button",disabled:!l,onClick:a,className:(0,d.cn)("relative flex py-3 gap-2 w-full items-center justify-center px-3 transition-opacity cursor-pointer hover:bg-white/10 rounded-xl",l?"opacity-100":"opacity-20 cursor-wait",s&&"border-b border-border"),children:[t&&(0,n.jsx)("span",{className:"text-blue-500",children:(0,n.jsx)(m.A,{size:24})}),(0,n.jsx)("span",{className:"max-w-full truncate text-foreground",style:{fontFamily:l?e.Title:void 0,fontSize:e.Size??27},children:i})]})}var E=r(28183);function O({customization:e,value:t,onChange:r,error:a,readonly:l,saveStatus:i,multiline:o}){let u=(0,C.n)(e=>e.language),c=j.P[u],x=(0,E.B)(e=>e.openAppModal),h=t.text,p=R(t.font),g=e.TextCountType??"Character",b=y(v(h.trim(),g),e.MinCount,e.MaxCount,g),T=h.trim().length>0,{fonts:N,loading:U}=function(e){let[t,r]=(0,s.useState)([]),[n,a]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(!e)return void r([]);let t=!1;a(!0);let n=$.get(e);return n||(n=S(e),$.set(e,n)),n.then(e=>{t||r(e)}).catch(()=>{$.delete(e),t||r([])}).finally(()=>{t||a(!1)}),()=>{t=!0}},[e]),{fonts:t,loading:n}}(e.FontGroupUId),[z,_]=(0,s.useState)(!1),A=o?"textarea":"input";return(0,n.jsxs)("div",{children:[(0,n.jsx)(I,{customization:e,suffix:(0,n.jsxs)(M.AM,{open:z,onOpenChange:_,children:[(0,n.jsx)(M.Wv,{asChild:!0,children:(0,n.jsxs)("button",{type:"button",disabled:l||U||0===N.length,className:"cursor-pointer hover:bg-white/5 flex shrink-0 items-center gap-1.5 rounded-full border border-border px-6 py-4 lg:px-4 md:py-2 text-[12.8px] font-semibold text-foreground disabled:opacity-40",children:[(0,n.jsx)(P.A,{size:13}),t.font?.Title??"Font"]})}),(0,n.jsxs)(M.hl,{align:"end",className:"max-h-80 w-64 overflow-y-auto p-1 z-[1000001] bg-black/15 backdrop-blur-sm border border-white/10 rounded-2xl shadow-xl custom-scrollbar-visible",children:[N.map(e=>(0,n.jsx)(F,{font:e,text:h,isSelected:t.font?.Id===e.Id,showBorder:!0,onSelect:()=>r({...t,font:e})},e.Id)),(0,n.jsxs)("button",{type:"button",onClick:()=>{_(!1),x()},className:"relative flex py-3 gap-2 w-full items-center justify-center px-3 cursor-pointer hover:bg-white/10 rounded-xl text-sm font-semibold text-white/70 hover:text-foreground transition-colors",children:[c.productDetails.more_fonts_in_app," ",(0,n.jsx)(k.A,{size:12})]})]})]})}),(0,n.jsxs)("div",{className:(0,d.cn)("relative rounded-2xl border bg-muted px-4",o?"h-[200px] py-3":"flex items-center gap-2.5 py-2.5",a?"border-destructive":"border-border"),children:[(0,n.jsx)(A,{disabled:l,value:h,onChange:n=>{var s;return s=n.target.value,void r({...t,text:w(e.TextFilterRegex,h,s)})},placeholder:e.Placeholder||c.productDetails.type_here_placeholder,className:(0,d.cn)("w-full min-w-0 flex-1 bg-transparent leading-snug text-foreground placeholder:text-muted-foreground focus:outline-none",o&&"h-full resize-none"),style:{fontFamily:p?t.font?.Title:void 0,fontSize:t.font?.Size??19}}),T&&("saving"===i?(0,n.jsx)(f.A,{size:15,className:(0,d.cn)("shrink-0 animate-spin text-muted-foreground",o&&"absolute right-3 top-3")}):a?null:(0,n.jsx)(m.A,{size:14,className:(0,d.cn)("shrink-0 text-emerald-500",o&&"absolute right-3 top-3")}))]}),(0,n.jsx)("div",{className:"mt-1 flex justify-end px-1",children:(0,n.jsx)("span",{className:(0,d.cn)("text-xs leading-snug",a?"text-destructive":"text-muted-foreground"),children:a?`*${a}`:b})})]})}function q(e){return(0,n.jsx)(O,{...e,multiline:!1})}function D(e){return(0,n.jsx)(O,{...e,multiline:!0})}var B=r(30234),Y=r(48368),L=r(13545),Q=r(33210);function G({variant:e,status:t,previewUrl:r,fileName:s,onRemove:a,onRetry:l,className:i}){return(0,n.jsxs)("div",{className:(0,d.cn)("group relative flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-xl border bg-muted","error"===t?"border-destructive":"border-border",i),children:["image"===e&&r?(0,n.jsx)("img",{src:r,alt:s??"Uploaded image",className:"h-full w-full object-cover"}):(0,n.jsxs)("div",{className:"flex flex-col items-center gap-1 px-2 text-center",children:[(0,n.jsx)(Y.A,{size:20,className:"text-muted-foreground"}),(0,n.jsx)("span",{className:"w-full truncate text-[10px] text-muted-foreground",children:s})]}),"uploading"===t&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/60",children:(0,n.jsx)(f.A,{size:18,className:"animate-spin text-muted-foreground"})}),"error"===t&&(0,n.jsxs)("button",{type:"button",onClick:l,className:"absolute inset-0 flex flex-col items-center justify-center gap-1 bg-background/80 text-destructive",title:"Upload failed â tap to retry",children:[(0,n.jsx)(L.A,{size:16}),(0,n.jsx)("span",{className:"text-[10px]",children:"Retry"})]}),(0,n.jsx)("button",{type:"button",onClick:a,"aria-label":"Remove",className:"absolute right-1 top-1 flex h-5 w-5 items-center justify-center rounded-full bg-background/90 text-foreground opacity-0 shadow-sm transition-opacity group-hover:opacity-100",children:(0,n.jsx)(Q.A,{size:12})})]})}var X=r(49289),Z=r(37002);function J({customization:e,value:t,onChange:r,error:a,readonly:l}){let i=(0,C.n)(e=>
1e.language),o=j.P[i],u=(0,s.useRef)(null),[d,c]=(0,s.useState)([]),x=null!=e.MaxCount&&t.filePaths.length>=e.MaxCount,[h,f]=(0,s.useState)([]);async function m(e){c(t=>t.map(t=>t.key===e.key?{...t,status:"uploading"}:t));try{let n=Z.useGlobalStore.getState().current_user?.Id,s=await (0,X.Q)({file:e.file,path:`UserUploads/${n??"Guest"}`}),a=s.UploadedFile?.FilePath;if(!s.Success||!a)throw Error(s.Message??"Upload failed");f(e=>[...e,a]),r({...t,filePaths:[...t.filePaths,a]}),c(t=>t.filter(t=>t.key!==e.key))}catch{c(t=>t.map(t=>t.key===e.key?{...t,status:"error"}:t))}}return(0,n.jsxs)("div",{children:[(0,n.jsx)(I,{customization:e,showPlaceholder:!0}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-3",children:[t.filePaths.map(e=>(0,n.jsx)(G,{variant:"image",status:"done",className:"w-[109px] h-[109px] rounded-[20px]",previewUrl:(0,_.X)(e,h.includes(e)?void 0:"md"),onRemove:()=>r({...t,filePaths:t.filePaths.filter(t=>t!==e)})},e)),d.map(e=>(0,n.jsx)(G,{variant:"image",status:e.status,className:"w-[109px] h-[109px] rounded-[20px]",previewUrl:e.previewUrl,onRemove:()=>c(t=>t.filter(t=>t.key!==e.key)),onRetry:()=>m(e)},e.key)),!l&&!x&&(0,n.jsxs)("button",{type:"button",onClick:()=>u.current?.click(),className:"cursor-pointer flex w-[109px] h-[109px] bg-white/10 shrink-0 flex-col items-center justify-center gap-1 rounded-[20px] border border-dashed border-border text-muted-foreground transition-colors hover:border-foreground
1/40 hover:text-foreground",children:[(0,n.jsx)(B.A,{size:18}),(0,n.jsx)("span",{className:"font-semibold text-lg",children:o.productDetails.add_more})]})]}),(0,n.jsx)("input",{ref:u,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:r=>(function(r){if(!r||0===r.length)return;let n=null!=e.MaxCount?e.MaxCount-t.filePaths.length-d.length:1/0;for(let e of Array.from(r).slice(0,Math.max(n,0))){let t={key:`${e.name}-${e.size}-${Date.now()}-${Math.random()}`,file:e,previewUrl:URL.createObjectURL(e),status:"uploading"};c(e=>[...e,t]),m(t)}u.current&&(u.current.value="")})(r.target.files)}),a&&(0,n.jsxs)("p",{className:"mt-1.5 px-1 text-xs text-destructive",children:["*",a]})]})}var W=r(78256);function H({customization:e,value:t,onChange:r,error:a,readonly:l}){let i=(0,C.n)(e=>e.language),o=j.P[i],u=(0,s.useRef)(null),[d,c]=(0,s.useState)([]),x=null!=e.MaxCount&&t.filePaths.length>=e.MaxCount,h=e.AllowedFileFormats?.length?e.AllowedFileFormats.join(","):void 0;async function f(e){c(t=>t.map(t=>t.key===e.key?{...t,status:"uploading"}:t));try{let n=Z.useGlobalStore.getState().current_user?.Id,s=await (0,X.Q)({file:e.file,path:`UserUploads/${n??"Guest"}`}),a=s.UploadedFile?.FilePath;if(!s.Success||!a)throw Error(s.Message??"Upload failed");r({...t,filePaths:[...t.filePaths,a]}),c(t=>t.filter(t=>t.key!==e.key))}catch{c(t=>t.map(t=>t.key===e.key?{...t,status:"error"}:t))}}return(0,n.jsxs)("div",{children:[(0,n.jsx)(I,{customization:e,showPlaceholder:!0}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-3",children:[t.filePaths.map(e=>(0,n.jsx)(G,{variant:"file",status:"done",fileName:e.split("/").pop()??e,onRemove:()=>r({...t,filePaths:t.filePaths.filter(t=>t!==e)})},e)),d.map(e=>(0,n.jsx)(G,{variant:"file",status:e.status,fileName:e.file.name,onRemove:()=>c(t=>t.filter(t=>t.key!==e.key)),onRetry:()=>f(e)},e.key)),!l&&!x&&(0,n.jsxs)("button",{type:"button",onClick:()=>u.current?.click(),className:"flex h-20 w-20 shrink-0 flex-col items-center justify-center gap-1 rounded-xl border border-dashed border-border text-muted-foreground transition-colors hover:border-foreground
1/40 hover:text-foreground",children:[(0,n.jsx)(W.A,{size:18}),(0,n.jsx)("span",{className:"text-[10px]",children:o.productDetails.add_more})]})]}),(0,n.jsx)("input",{ref:u,type:"file",accept:h,multiple:!0,hidden:!0,onChange:r=>(function(r){if(!r||0===r.length)return;let n=null!=e.MaxCount?e.MaxCount-t.filePaths.length-d.length:1/0;for(let e of Array.from(r).slice(0,Math.max(n,0))){let t={key:`${e.name}-${e.size}-${Date.now()}-${Math.random()}`,file:e,status:"uploading"};c(e=>[...e,t]),f(t)}u.current&&(u.current.value="")})(r.target.files)}),a&&(0,n.jsxs)("p",{className:"mt-1.5 px-1 text-xs text-destructive",children:["*",a]})]})}function K({customization:e,value:t,onChange:r,error:s,readonly:a}){let l=e.Choices??[];if(0===l.length)return null;let i="MultipleChoice"!==e.Type||1==e.MaxCount,o=new Set(t.choices.map(e=>e.UId));function u(n){a||(o.has(n.UId)?r({...t,choices:t.choices.filter(e=>e.UId!==n.UId)}):i?r({...t,choices:[{UId:n.UId,Title:n.Title,CoverPath:n.CoverPath,cost:n.Cost}]}):null!=e.MaxCount&&t.choices.length>=e.MaxCount||r({...t,choices:[...t.choices,{UId:n.UId,Title:n.Title,CoverPath:n.CoverPath,cost:n.Cost}]}))}return(0,n.jsxs)("div",{children:[(0,n.jsx)(I,{customization:e,showPlaceholder:!0}),s&&(0,n.jsxs)("p",{className:"mb-2 px-1 text-xs text-destructive",children:["*",s]}),(0,n.jsx)("div",{className:"flex gap-2.5 overflow-x-auto pb-1",children:l.map(t=>{let r=o.has(t.UId);return e.ChoiceWithCover?(0,n.jsxs)("button",{type:"button",onClick:()=>u(t),className:"flex shrink-0 flex-col items-center gap-2",children:[(0,n.jsx)("div",{className:(0,d.cn)("h-[85px] w-[85px] overflow-hidden rounded-2xl border-2",r?"border-blue-500!":"border-transparent"),children:t.CoverPath&&(0,n.jsx)("img",{src:(0,_.X)(t.CoverPath,"md"),alt:t.Title??"",className:"h-full w-full object-cover"})}),t.Title&&(0,n.jsx)("span",{className:(0,d.cn)("max-w-[75px] truncate text-center text-xs font-semibold",r?"text-foreground":"text-muted-foreground"),children:t.Title})]},t.UId):(0,n.jsxs)("button",{type:"button",onClick:()=>u(t),className:(0,d.cn)("cursor-pointer flex shrink-0 items-center gap-1.5 rounded-full border px-6 py-4 lg:px-4 lg:py-2 text-[12.8px] font-semibold transition-colors hover:bg-white/5",r?"border-blue-500! border-2 text-blue-500":"border-border text-muted-foreground"),children:[r&&(0,n.jsx)(m.A,{size:12}),t.Title?.trim()]},t.UId)})})]})}var V=r(76348);async function ee(e){return(await z.u.post(U.qZ.UPDATE_DATA,e)).json()}async function et(e,t){let r=(0,V.B)({basketId:t.basketId,storeOrderItemId:t.storeOrderItemId});return(await z.u.post(`${U.qZ.CREATE_DATA}${r}`,e)).json()}async function er(e){let t=(0,V.B)({basketId:e});return(await z.u.get(`${U.qZ.GET_DATA_BY_BASKET}${t}`)).json()}function en(e,t,r,n,s,a){return{Id:n??0,ItemOrderBasketId:s??null,CustomizationId:e.Id,CustomizationUId:e.UId,QuantityIndex:t,Text:r.text||null,FilePaths:r.filePaths,Font:r.font??null,Choices:r.choices.map(e=>({UId:e.UId,Title:e.Title,CoverPath:e.CoverPath})),OrderExtra:{CustomizationType:e.Type,StoreOrderItemId:a??null,SortOrder:null,CustomizationTitle:e.Title??null,CustomizationPlaceholder:e.Placeholder??null,CostType:e.CostType??null,TextCountType:e.TextCountType??null}}}function es(e){let{customization:t,control:r}=e;return(0,n.jsx)(a.xI,{name:t.UId,control:r,render:({field:t})=>(0,n.jsx)(ea,{...e,field:t})})}function ea({customization:e,errors:t,quantityIndex:r,readonly:a,basketId:l,storeOrderItemId:i,existingData:o,onSavedId:u,field:d}){let c=t[e.UId],x=c?.text?.message??c?.filePaths?.message??c?.choices?.message,h=function({customization:e,quantityIndex:t,value:r,enabled:n,basketId:a,storeOrderItemId:l,existingId:i,onSavedId:o,debounceMs:u=500}){let[d,c]=(0,s.useState)("idle"),x=(0,s.useRef)(null),h=(0,s.useRef)(i);h.current=i;let f=JSON.stringify(r);return(0,s.useEffect)(()=>{if(n)return(x.current&&clearTimeout(x.current),r.text?.trim()||r.filePaths.length>0||r.choices.length>0)?(x.current=setTimeout(async()=>{c("saving");try{let n=h.current;if(n)await ee(en(e,t,r,n,a,l));else{let n=await et(en(e,t,r,void 0,a,l),{basketId:a,storeOrderItemId:l}),s=n?.Id??n?.Data?.Id;s&&o(s)}c("saved")}catch{c("error")}},u),()=>{x.current&&clearTimeout(x.current)}):void c("idle")},[n,f,a,l,u]),d}({customization:e,quantityIndex:r,value:d.value,enabled:!!l&&!a,basketId:l,storeOrderItemId:i,existingId:o?.Id,onSavedId:t=>u(e.UId,t)}
1),f={customization:e,value:d.value,onChange:d.onChange,error:x,readonly:a};switch(e.Type){case"ShortText":return(0,n.jsx)(T,{...f,saveStatus:h});case"LongText":return(0,n.jsx)(N,{...f,saveStatus:h});case"ShortFontText":return(0,n.jsx)(q,{...f,saveStatus:h});case"LongFontText":return(0,n.jsx)(D,{...f,saveStatus:h});case"Image":return(0,n.jsx)(J,{...f});case"File":return(0,n.jsx)(H,{...f});case"Choice":case"MultipleChoice":return(0,n.jsx)(K,{...f});default:return null}}var el=r(27240),ei=r(7899);let eo=el.Ik({Id:el.ai(),Title:el.Yj(),Path:el.Yj(),Size:el.ai().nullish()}).nullable().optional(),eu=el.Ik({UId:el.Yj(),Title:el.Yj().nullish(),CoverPath:el.Yj().nullish(),cost:el.ai().nullish()}),ed=el.Ik({text:el.Yj().default(""),filePaths:el.YO(el.Yj()).default([]),choices:el.YO(eu).default([]),font:eo});function ec(e){let t={};for(let r of e)t[r.UId]=function(e){var t;return"ShortText"===(t=e.Type)||"LongText"===t||"ShortFontText"===t||"LongFontText"===t?ed.superRefine((t,r)=>{let n=t.text.trim();if(e.IsRequired&&!n)return void r.addIssue({code:ei.eq.custom,message:"This field is required.",path:["text"]});if(!n)return;let s=v(n,e.TextCountType??"Character"),a=(e.TextCountType??"Character").toLowerCase();e.MinCount>0&&s<e.MinCount&&r.addIssue({code:ei.eq.custom,message:`At least ${e.MinCount} ${a}${e.MinCount>1?"s":""} needed`,path:["text"]}),null!=e.MaxCount&&s>e.MaxCount&&r.addIssue({code:ei.eq.custom,message:`Maximum ${e.MaxCount} ${a}${e.MaxCount>1?"s":""} allowed`,path:["text"]})}):"Image"===e.Type||"File"===e.Type?ed.superRefine((t,r)=>{let n=t.filePaths.length;e.IsRequired&&0===n?r.addIssue({code:ei.eq.custom,message:"This field is required.",path:["filePaths"]}):0!==n&&(e.MinCount>0&&n<e.MinCount&&r.addIssue({code:ei.eq.custom,message:`At least ${e.MinCount} file${e.MinCount>1?"s":""} needed`,path:["filePaths"]}),null!=e.MaxCount&&n>e.MaxCount&&r.addIssue({code:ei.eq.custom,message:`Maximum ${e.MaxCount} file${e.MaxCount>1?"s":""} allowed`,path:["filePaths"]}))}):ed.superRefine((t,r)=>{let n=t.choices.length;e.IsRequired&&0===n?r.addIssue({code:ei.eq.custom,message:"This field is required.",path:["choices"]}):"MultipleChoice"!==e.Type||(0!==e.MinCount||null!=e.MaxCount)&&(e.MinCount>0&&n<e.MinCount&&r.addIssue({code:ei.eq.custom,message:`At least ${e.MinCount} choice${e.MinCount>1?"s":""} needed (${n} selected)`,path:["choices"]}),null!=e.MaxCount&&n>e.MaxCount&&r.addIssue({code:ei.eq.custom,message:`Maximum ${e.MaxCount} choice${e.MaxCount>1?"s":""} allowed (${n} selected)`,path:["choices"]}))})}(r);return el.Ik(t)}function ex(e,t){let r={},n=e=>{for(let s of e){let e=t.find(e=>e.CustomizationUId===s.UId);r[s.UId]=e?{text:e.Text??"",filePaths:e.FilePaths??[],choices:(e.Choices??[]).map(e=>({UId:e.UId,Title:e.Title,CoverPath:e.CoverPath,cost:e.cost})),font:e.Font??null}:{text:"",filePaths:[],choices:[],font:null},("Choice"===s.Type||"MultipleChoice"===s.Type)&&(s.Choices??[]).forEach(e=>n(e.SubCustomizations??[]))}};return n(e),r}let eh=(0,s.forwardRef)(function({quantityIndex:e,customizations:t,basketId:r,storeOrderItemId:o,existingData:u,readonly:c,title:h,isExpanded:f,onToggle:m,onCostChange:p,transparentUI:g},b){let y,I=(0,C.n)(e=>e.language),w=j.P[I],[T,N]=(0,s.useState)(()=>Object.fromEntries(u.map(e=>[e.CustomizationUId,e]))),P=(0,s.useRef)(!1);(0,s.useEffect)(()=>{P.current||0===u.length||(P.current=!0,N(Object.fromEntries(u.map(e=>[e.CustomizationUId,e]))))},[u]);let k=(0,s.useCallback)((t,r)=>{N(n=>({...n,[t]:{...n[t]??{CustomizationId:0,CustomizationUId:t,QuantityIndex:e,FilePaths:[]},Id:r}}))},[e]),M=(0,s.useMemo)(()=>ex(t,u),[t]),U=(0,s.useRef)(ec([])),z=(0,s.useRef)((...e)=>(0,l.u)(U.current)(...e)).current,{control:S,watch:$,formState:{errors:_},trigger:A,getValues:R,reset:F}=(0,a.mN)({defaultValues:M,mode:"onTouched",resolver:z}),E=$(),O=(y=JSON.stringify(E),(0,s.useMemo)(()=>{let e=[],r=t=>{for(let n of t){if(e.push(n),"Choice"!==n.Type&&"MultipleChoice"!==n.Type)continue;let t=new Set((E[n.UId]?.choices??[]).map(e=>e.UId)),s=(n.Choices??[]).filter(e=>t.has(e.UId)).flatMap(e=>e.SubCustomizations??[]);s.length>0&&r(s)}};return r(t),e},[t,y])),q=(0,s.useMemo)(()=>ec(O),[O]);(0,s.useEffect)(()=>{U.current=q},[q]);let D=(0,s.useRef)(!1);(0,s.useEffect)(()=>{D.current||0===u.length||(D.current=!0,F(ex(t,u)))},[u,t,F]);let B=JSON.stringify(E),Y=JSON.stringify(O.map(e=>e.UId));(0,s.useEffect)(()=>{p(function(e,t){let r=0;
1for(let n of e){let e=t[n.UId];if(e){if("Choice"===n.Type||"MultipleChoice"===n.Type)for(let t of e.choices)t.cost&&(r+=t.cost);else if(("Image"===n.Type||"File"===n.Type)&&n.Cost&&n.Cost>0){let t=e.filePaths.length;t>0&&(r+="PerCount"===n.CostType?n.Cost*t:n.Cost)}else if(n.Cost&&n.Cost>0){let t=v(e.text.trim(),n.TextCountType??"Character");t>0&&(r+="PerCount"===n.CostType?n.Cost*t:n.Cost)}}}return r}(O,E))},[B,Y]);let L=(0,s.useRef)(O);L.current=O;let Q=(0,s.useRef)(T);Q.current=T;let G=(0,s.useRef)(r);G.current=r;let X=(0,s.useRef)(o);return X.current=o,(0,s.useImperativeHandle)(b,()=>({validate:async()=>!!U.current.safeParse(R()).success||(await A(),!1),getPayload:()=>(function(e,t,r,n,s,a){let l=[];for(let i of e){let e=t[i.UId];e&&(e.text?.trim()||e.filePaths.length>0||e.choices.length>0)&&l.push({Id:a[i.UId]?.Id??0,ItemOrderBasketId:n??null,CustomizationId:i.Id,CustomizationUId:i.UId,QuantityIndex:r,Text:e.text||null,FilePaths:e.filePaths,Font:e.font??null,Choices:e.choices.map(e=>({UId:e.UId,Title:e.Title,CoverPath:e.CoverPath})),OrderExtra:{CustomizationType:i.Type,StoreOrderItemId:s??null,SortOrder:null,CustomizationTitle:i.Title??null,CustomizationPlaceholder:i.Placeholder??null,CostType:i.CostType??null,TextCountType:i.TextCountType??null}})}return l})(L.current,R(),e,G.current,X.current,Q.current)}),[]),(0,n.jsxs)("div",{className:(0,d.cn)("overflow-hidden",f?"mb-4":"mb-0",g?"":"border border-white/5 bg_black_25 rounded-[25px]"),children:[!g&&(0,n.jsxs)("div",{className:(0,d.cn)("flex items-center justify-between px-4 py-2 rounded-t-[25px] border-b border-white/5 bg_black_25",f&&"mb-4"),children:[(0,n.jsxs)("div",{className:"flex items-center gap-x-2 flex-1",children:[(0,n.jsx)("h3",{className:"text-[14px] !font-medium text_gray_40 font-bricolage uppercase whitespace-nowrap",children:h}),(0,n.jsx)(x,{className:"h-5 rounded-full bg_white_5 text_gray_40 border border-white/5 flex items-center justify-center p-0 px-1.5 text-[14px] font-semibold",children:e+1}),(0,n.jsx)("div",{className:"flex-1 h-[1px] bg-white/10 ml-6 mr-4"})]}),(0,n.jsxs)("button",{type:"button",onClick:m,className:"cursor-pointer h-[30px] px-3 flex items-center justify-center gap-1.5 hover:bg-white/10 transition-colors text-[14px] font-medium text_gray_40 uppercase rounded-full",children:[f?w.productDetails.hide:w.productDetails.show,(0,n.jsx)(i.A,{size:20,className:(0,d.cn)("transition-transform duration-300 ease-in-out",f?"rotate-180":"rotate-0")})]})]}),(0,n.jsx)("div",{className:`${g?"":"px-4"} mb-4`,children:(0,n.jsx)("div",{className:(0,d.cn)("transition-all duration-300 overflow-hidden space-y-12 md:space-y-6",f?"opacity-100":"max-h-0 opacity-0"),children:O.map(t=>(0,n.jsx)(es,{customization:t,control:S,errors:_,quantityIndex:e,readonly:c,basketId:r,storeOrderItemId:o,existingData:T[t.UId],onSavedId:k},t.UId))})})]})}),ef=(0,s.forwardRef)(function({customizations:e,quantity:t,basketId:r,storeOrderItemId:a,readonly:l,slotTitle:i="Customizations",bottomText:o,onCostChange:u,transparentUI:d},c){let[x,f]=(0,s.useState)({0:!0}),[m,p]=(0,s.useState)({}),[g,v]=(0,s.useState)(!1),b=(0,s.useRef)({}),y=(0,s.useRef)({});(0,s.useEffect)(()=>{f(e=>{let r={};for(let n=0;n<t;n++)r[n]=e[n]??!0;return r})},[t]),(0,s.useEffect)(()=>{if(!r)return void p({});let e=!1;return v(!0),er(r).then(t=>{if(e)return;let r={};for(let e of t){let t=e.QuantityIndex??0;(r[t]??=[]).push(e)}p(r),v(!1)}).catch(()=>{e||v(!1)}),()=>{e=!0}},[r]);let C=(0,s.useCallback)((e,t)=>{y.current[e]=t,u(Object.values(y.current).reduce((e,t)=>e+t,0))},[u]);return((0,s.useImperativeHandle)(c,()=>({validate:async()=>{let e=await Promise.all(Array.from({length:t},(e,t)=>b.current[t]?.validate()??!0)),r=e.every(Boolean);return r||f(t=>{let r={...t};return e.forEach((e,t)=>{e||(r[t]=!0)}),r}),r},getApiPayload:()=>{let e=[];for(let r=0;r<t;r++)e.push(...b.current[r]?.getPayload()??[]);return e}})),e.length)?g?(0,n.jsx)("div",{className:"space-y-4 p-4",children:e.map((e,t)=>(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(h.E,{className:"h-5 w-1/3 rounded bg-white/5 animate-[pulse_0.6s_ease-in-out_infinite]"}),(0,n.jsx)(h.E,{className:"h-4 w-16 rounded bg-white/5 animate-[pulse_0.6s_ease-in-out_infinite]"})]}),(0,n.jsx)(h.E,{className:"h-14 w-full rounded-xl bg-white/5 animate-[pulse_0.6s_ease-in-out_infinite]"})]},t))}):(0,n.jsxs)("div",{children:[Array.from({length:t},(t,s)=>(0,n.jsx)(eh,{ref:e=>{b.current[s]=e},quantityIndex:s,customizations:e,basketId:r,storeOrderItemId:a,existingData:m[s]??[],readonly:l,title:i,isExpanded:x[s]??!0,onToggle:()=>f(e=>({...e,[s]:!e[s]})),onCostChange:e=>C(s,e),transparentUI:d},s)),o&&(0,n.jsx)("p",{className:"text-xl md:text-sm text_gray_50 text-center mt-2",children:o})]}):null})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.