1"use strict";(globalThis.__LOADABLE_LOADED_CHUNKS__=globalThis.__LOADABLE_LOADED_CHUNKS__||[]).push([[7166,8290],{7297(e,r,i){i.d(r,{Pq:()=>a,QK:()=>s,iS:()=>n,k4:()=>d});const o={dtg:["png"],dtf:["png","pdf"],embroidery:["dst"],engraving:["png"],screen_printing:["png","pdf"]},t={dtg:"DTG",dtf:"DTF",embroidery:"Embroidery",engraving:"Engraving",screen_printing:"Screen Print"},s=e=>String(null!=e?e:"").trim().toLowerCase(),l=e=>{const r=s(e);return r&&r in o?o[r]:null},a=e=>String((null==e?void 0:e.file_display_name)||(null==e?void 0:e.file_name)||""),n=(e,r)=>{const i=l(e);if(null===i)return console.error(`Unknown decoration type: ${e}`),!1;const o=(e=>{var r;const i=s(e);return i.includes(".")&&null!==(r=i.split(".").pop())&&void 0!==r?r:""})(r);return""!==o&&i.includes(o)},d=(e,r)=>{const i=l(e);if(null===i)return`Unknown decoration type: ${e}`;const o=String(null!=r?r:"").trim(),a=t[s(e)],d=(e=>{const r=e.map(e=>e.toUpperCase());return 2>=r.length?r.join(" or "):`${r.slice(0,-1).join(", ")}, or ${r[r.length-1]}`})(i);return o?n(e,o)?null:`${a} requires a ${d} file. The file you uploaded isn't ${d}. Please upload a ${d} file to continue.`:`${a} requires a ${d} file. Please upload a ${d} file to continue.`}},38638(e,r,i){i.r(r),i.d(r,{TBD_FILE_ID:()=>g,default:()=>w});var o=i(41594),t=i(98483),s=i(3602),l=i(39913),a=i(12021),n=i(89861),d=i(46592),c=i(58199),m=i(30596),p=i(22078),h=i(28027),u=i(4439),_=i(63988);const g="00000000-0000-0000-0000-000000000000";class x extends o.Component{constructor(e){super(e),this.state={folder_id:""}}onClickFolder(e){this.setState({folder_id:e})}render(){var e;const{folders:r,files:i,onClosePopup:o,onUploadFile:t,onSelectFile:l,loading:a,item:n,onUpdateItem:d,index:c,popupClassName:m="reveal large",popupBaseZIndex:x}=this.props,w=null!=x?x+c:null,b=null!=x?x+c+1:h.z+(c||0),k=null!==(e=this.props.popupStyle)&&void 0!==e?e:{display:"block",zIndex:b};return(0,_.jsxs)(_.Fragment,{children:[null!=w?(0,_.jsx)("div",{className:"reveal-overlay",style:{display:"block",position:"fixed",inset:0,zIndex:w},onClick:o,"aria-hidden":"true"}):null,(0,_.jsxs)("div",{id:"artwork-library-modal",className:m,style:k,role:"dialog",children:[(0,_.jsxs)("div",{className:"row popup-content",children:[(0,_.jsx)("div",{className:"small-12 columns",children:(0,_.jsx)("h3",{children:"Select Artwork"})}),(0,_.jsxs)("div",{className:"small-12 columns popup-size-limit",children:[(0,_.jsxs)("div",{className:"small-12 medium-3 columns",style:{paddingLeft:"0px"},children:[(0,_.jsxs)("div",{className:"row",style:{display:"inline"},children:[(0,_.jsx)("h4",{style:{float:"left"},children:"Library"}),(0,_.jsx)("a",{className:"button",style:{float:"right"},children:(0,_.jsx)(s.Dropzone,{onDrop:t(this.state.folder_id),style:{border:"none"},multiple:!1,children:(0,_.jsx)(_.Fragment,{children:a?(0,_.jsxs)("div",{className:"small-12 text-center",children:[(0,_.jsx)("br",{}),(0,_.jsx)("img",{src:"/images/gears.gif"}),(0,_.jsx)("br",{})]}):"Upload Image"})})})]}),(0,_.jsx)("div",{className:"row",children:(0,_.jsx)("ul",{className:"tabs vertical",children:r.map(e=>(0,_.jsx)("li",{className:(e.key===this.state.folder_id?"is-active ":"")+"tabs-title",onClick:r=>this.onClickFolder(e.key),children:(0,_.jsxs)("a",{"aria-selected":e.key===this.state.folder_id,children:[(0,_.jsx)("i",{className:"fi-folder",children:"Â Â "}),(0,_.jsx)("span",{children:e.value})]})},e.key))})})]}),(0,_.jsx)("div",{className:"small-12 medium-9 columns",children:(0,_.jsxs)("div",{className:"row small-up-1 medium-up-2 large-up-3",children:[this.state.folder_id?void 0:(0,_.jsxs)("div",{className:"column",children:[(0,_.jsx)("img",{className:"thumbnail",style:{height:"150px",marginTop:"1rem",marginBottom:"0"},src:"/images/404.png",alt:"TBD",onClick:e=>l(g)}),(0,_.jsx)("br",{}),(0,_.jsx)("span",{children:"TBD"})]}),i.filter(e=>e.folder_id===this.state.folder_id).map((e,r,i)=>(0,_.jsxs)("div",{className:"column",children:[(0,_.jsx)(u.A,{className:"thumbnail",style:{height:"150px",marginTop:"1rem",marginBottom:"0"},src:(0,p.AE)(e,"small"),alt:e.file_display_name,onClick:r=>{n?d(n.item_id,"image_id",n.image_id)(e.file_id):l(e.file_id)}}),(0,_.jsx)("br",{}),(0,_.jsx)("span",{style:{wordWrap:"break-word"},children:e.file_display_name})]},e.file_id))]})})]})]}),(0,_.jsx)("button",{className:"close-button","aria-label":"Close modal",type:"button",onClick:e=>{e.preventDefault(),o()},children:(0,_.jsx)("span",{"aria-hidden":"true",children:"Ã"})})]})]})}}
1const w=(0,t.Ng)((e,r)=>({folders:[{key:"",value:"Artwork"}].concat((0,m.xv)(e)),files:Object.values(e.entities.files).filter(e=>1==e.active&&e.parent_id===r.account_id).sort((e,r)=>r.date_created-e.date_created),loading:e.display.loading.upload_file}),(e,r)=>{const i=(0,c._Wv)("item",{request:d.c9,success:d.Qk,failure:d.$y,failure_message:"Unable to update item"}),o=r.onClosePopup?r.onClosePopup:()=>e((0,l.fs)());return{onClosePopup:o,onUploadFile:i=>o=>{e((0,a.K7)(r.account_id,r.account_type,o[0],i))},onSelectFile:i=>{r.onSelectFile?r.onSelectFile(i):e((0,n.Qg)(r.register,i)),o()},onUpdateItem:(r,t,s)=>l=>{e(i(r,t,s,l)),o()}}})(x)},35167(e,r,i){i.r(r),i.d(r,{default:()=>H});var o=i(22224),t=i.n(o),s=i(41594),l=i.n(s),a=i(98483),n=i(23652),d=i(3602),c=i(93940),m=i(95858),p=i(71739),h=i(30596),u=i(39913),_=i(82963),g=i(58199),x=i(61536),w=i(89861),b=i(22078),k=i(38638),f=i(7297);const y=e=>(0,f.iS)("embroidery",(0,f.Pq)(e));var j=i(33872),v=i(4439),C=i(51347),S=i(97728),A=i(28027),D=i(63988);const F=[{value:"CIRCLE",label:(0,D.jsxs)("span",{children:[(0,D.jsx)(C.A,{}),"Circle"]})},{value:"RECTANGLE",label:(0,D.jsxs)("span",{children:[(0,D.jsx)(C.A,{}),"Rectangle"]})},{value:"OTHER",label:(0,D.jsxs)("span",{children:[(0,D.jsx)(C.A,{}),"Other"]})}],P=[{value:"Inches",label:(0,D.jsxs)("span",{children:[(0,D.jsx)(C.A,{}),"Inches"]})},{value:"cm",label:(0,D.jsxs)("span",{children:[(0,D.jsx)(C.A,{}),"cm"]})}],N=(e,r)=>{let{id:i,validateFormCallback:o,locked:t,decoration:l}=e;const a=(0,s.useMemo)(()=>({artwork_dimension_id:"",dimension_geometry:l.geometry,dimension_use_max:0,dimension_width:"",dimension_height:"",dimension_diameter:"",dimension_uom:l.uom}),[l.geometry,l.uom]),n=parseFloat(l.decoration_diameter).toFixed(4),c=parseFloat(l.decoration_width).toFixed(4),m=parseFloat(l.decoration_height).toFixed(4),[p,h]=(l.geometry.toLowerCase(),(0,s.useState)(a)),[u,_]=(0,s.useState)(a),[g]=function(e,r,i,t){const[l,a]=(0,s.use
1State)(r),n=(0,s.useCallback)(async e=>{let r=null;if(l){if(!e.artwork_dimension_id)return;r=await(0,b.oD)("PUT","artwork-dimension",e)}else r=await(0,b.oD)("POST","artwork-dimension",e);a(r.json.artwork_dimension.artwork_dimension_id),t(r.json.artwork_dimension)},[l,t]);return(0,s.useEffect)(()=>{let i=!1;return(async()=>{if(!r)return n(e);const t=await(0,b.oD)("GET","artwork-dimension",{id:r});var s;i||(s=t.json.artwork_dimension,h(s),o(s,k(s,!1)))})(),()=>{i=!0}},[r]),[n]}(a,i,0,e=>{h(e),o(e,k(e,!1))}),x=(0,s.useCallback)(e=>{const r=e.target;h(e=>({...e,[r.name]:r.value}))},[]),w=(0,s.useCallback)((e,r,i,o)=>{const t=e[r];return""===t||(isNaN(parseFloat(t))||parseFloat(t)<0?(o&&_(e=>({...e,[r]:"Invalid value"})),!1):(o&&_(e=>({...e,[r]:""})),!0))},[]),k=(0,s.useCallback)((e,r)=>{let i=!0;return"circle"===e.dimension_geometry.toLowerCase()?0==e.dimension_use_max&&(w(e,"dimension_diameter",n,r)||(i=!1)):0==e.dimension_use_max&&(w(e,"dimension_width",c,r)||(i=!1),w(e,"dimension_height",m,r)||(i=!1)),i},[n,m,c,w]),f=(0,s.useCallback)(e=>{if(!k(e,!0))return!1;g(e)},[g,k]);(0,s.useImperativeHandle)(r,()=>({isValid:()=>k(p,!0)}),[p,k]);const y=(e,r)=>{let i=p[e],o=null;return i?(o=r.find(e=>e.value===i),o||(o={value:i,label:(0,D.jsxs)("span",{children:[(0,D.jsx)(C.A,{}),i]})},r.push(o))):i=null,(0,D.jsx)(d.LabeledSelect,{"data-test-name":"ArtworkFormDimension.getSelect",isDisabled:t,name:e,value:o,options:r,onChange:r=>{x({target:{name:e,value:r.value}}),f({...p,[e]:r.value})}})},j=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=""!==u[e],t="0.0000"===String(p[e])?"":p[e];return(0,D.jsxs)("div",{"data-test-name":"ArtworkFormDimension.getInput",style:{padding:"0 0.25em"},children:[(0,D.jsx)(d.LabeledIconInput,{name:e,value:t,onChange:x,onBlur:()=>{f(p)},Icon:(0,D.jsx)("div",{children:r})}),i?(0,D.jsx)("div",{children:i}):null,o?(0,D.jsx)("span",{style:{color:"red"},children:u[e]}):""]})},v="circle"===p.dimension_geometry.toLowerCase()?(0,D.jsx)(d.Col,{sm:12,children:(0,D.jsxs)(d.Row,{children:[(0,D.jsx)(d.Col,{sm:12,md:4,children:(0,D.jsx)("label",{style:{fontSize:"initial"}})}),(0,D.jsx)(d.Col,{sm:12,md:8,style:{paddingRight:"0.75em"},children:j("dimension_diameter","D",`Maximum ${n}`)})]})}):(0,D.jsx)(d.Col,{sm:12,children:(0,D.jsxs)(d.Row,{children:[(0,D.jsx)(d.Col,{sm:12,md:4,children:(0,D.jsx)("label",{style:{fontSize:"initial"}})}),(0,D.jsx)(d.Col,{sm:12,md:4,children:j("dimension_width","W",`Maximum ${c}`)}),(0,D.jsx)(d.Col,{sm:12,md:4,style:{paddingRight:"0.75em"},children:j("dimension_height","H",`Maximum ${m}`)})]})});return(0,D.jsxs)(d.Row,{style:{border:"2px solid #00A0B6",borderRadius:"10px",marginBottom:"0.75em"},children:[(0,D.jsx)(d.Col,{sm:12,style:{background:"#00A0B6",padding:"0.5em 1em",borderRadius:"8px 8px 0 0"},children:(0,D.jsxs)(d.Row,{children:[(0,D.jsx)(d.Col,{sm:12,md:4,children:(0,D.jsx)("label",{style:{fontSize:"initial",color:"white"},children:"Geometry"})}),(0,D.jsx)(d.Col,{sm:12,md:8,children:y("dimension_geometry",F)})]})}),(0,D.jsxs)(d.Col,{sm:12,children:[(0,D.jsxs)(d.Row,{style:{margin:"0.75em 0"},children:[(0,D.jsx)(d.Col,{sm:12,style:{padding:"0.5em 1em"},children:(0,D.jsxs)(d.Row,{children:[(0,D.jsx)(d.Col,{sm:12,md:4,children:(0,D.jsx)("label",{style:{fontSize:"initial"},children:"Size"})}),(0,D.jsx)(d.Col,{sm:12,md:8,children:(0,D.jsxs)(d.Toggle,{children:[(0,D.jsx)(d.ToggleLink,{id:"0",selected:0==p.dimension_use_max,onClick:e=>{e.preventDefault(),x({target:{name:"dimension_use_max",value:0}}),f({...p,dimension_use_max:0})},children:"Choose Size"}),(0,D.jsx)(d.ToggleLink,{id:"1",selected:1==p.dimension_use_max,onClick:e=>{e.preventDefault(),x({target:{name:"dimension_use_max",value:1}}),f({...p,dimension_use_max:1})},children:"Set to Maximum Size"})]})})]})}),1==p.dimension_use_max?null:v]}),1==p.dimension_use_max?null:(0,D.jsx)(d.Row,{children:(0,D.jsx)(d.Col,{sm:12,style:{padding:"0.5em 1em"},children:(0,D.jsxs)(d.Row,{children:[(0,D.jsx)(d.Col,{sm:12,md:4,children:(0,D.jsx)("label",{style:{fontSize:"initial"},children:"Unit"})}),(0,D.jsx)(d.Col,{sm:12,md:8,children:y("dimension_uom",P)})]})})})]})]})},I=(0,s.forwardRef)(N);var L=i(84685),$=i(67564);const E=(e,r)=>{if(!r)return[];const i=[],o=new Set;
1return(e||[]).forEach(e=>{[e,...t().get(e,"substitutions")||[]].forEach(e=>{if(e.brand!==r||!e.code)return;const t=`${e.brand}:${e.code}`;o.has(t)||(o.add(t),i.push(e))})}),i},T=e=>`${e.brand||""}::${e.code||""}`,z=e=>{let{threadColor:r}=e;const i=`${t().get(r,"hex_code")||""}`.trim(),o=(e=>{const r=`${t().get(e,"code")||""}`.trim(),i=t().get(e,"description"),o=null==i||""===i?"":`${i}`.trim();return r&&o?`${r} - ${o}`:r||o})(r);return(0,D.jsxs)("span",{"data-test-name":"ThreadColorOptionLabel",style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,D.jsx)("span",{"aria-hidden":"true",style:{width:16,height:16,borderRadius:2,backgroundColor:i||"#ffffff",border:"1px solid #d0d0d0",flexShrink:0}}),(0,D.jsx)("span",{children:o})]})},B="artwork_file_id",U=(0,n.default)(j.A)` 2 &&&&& { 3 .has-error .field-control { 4 border: 1px solid ${d.colors.errors[60]}; 5 border-radius: 5px; 6 } 7 .field-error { 8 font-size: small; 9 font-weight: 600; 10 margin: -12px 0 10px; 11 text-align: start; 12 color: ${d.colors.errors[60]}; 13 } 14 } 15`,R=(0,n.default)(e=>{let{className:r,...i}=e;return(0,D.jsx)(j.A.Textarea,{...i,className:r})})` 16 &&&.has-error { 17 textarea { 18 border: 3px solid ${d.colors.errors[50]}; 19 animation: logoColorBorderChange 300ms forwards linear; 20 } 21 } 22 23 @keyframes logoColorBorderChange { 24 0%, 66% { border: 3px solid ${d.colors.errors[50]}; } 25 100% { border: 1px solid ${d.colors.errors[60]}; } 26 } 27`,O=n.default.div` 28 margin-top: -1rem; 29 margin-bottom: 1rem; 30 font-size: small; 31`,q=n.default.div` 32 color: ${d.colors.errors[60]}; 33 margin-bottom: 1rem; 34 padding-top: 8px; 35 text-align: left; 36`,M=e=>{let{label:r,field:i,value:o,max:s,maxLabel:l,disabled:a,onDimensionChange:n}=e;return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(j.A.TextInput,{label:r,field:i,labelStyle:{whiteSpace:"nowrap"},value:o,disabled:a,onChange:e=>n(e,i),onFieldChange:t().identity,onFieldBlur:t().identity,onFieldFocus:t().identity}),null!=s?(0,D.jsx)("div",{className:"row",children:(0,D.jsx)("div",{className:"small-12 medium-8 medium-push-4 columns",children:(0,D.jsx)(O,{children:`Max ${l} = ${s}"`})})}):null]})};class Z extends s.Component{constructor(e){super(e);const r=(0,m.pc)(t().get(e,"item.copied_from")),i=this.parsePodArtworkSize(t().get(e,"artwork.artwork_size","")),o=r?{...e.artwork,pod_logo_height:i.height,pod_logo_width:i.width}:{...e.artwork},s=r?(e=>{if(t().isPlainObject(e)&&Array.isArray(e.colors))return e;if(!t().isString(e)||!e.trim())return null;try{const r=JSON.parse(e);return Array.isArray(t().get(r,"colors"))?r:null}catch(e){return null}})(t().get(e,"artwork.artwork_dst")):null,a={};s&&(a.embroidery_color_brand=s.color_brand||"",(s.colors||[]).forEach((e,r)=>{a[`embroidery_color_${r}`]=e.brand&&e.code?T(e):""})),this.state={artwork:{...o,...a},embroideryColor:s,embroideryPreviewDataUrl:null,embroideryProcessing:!1,embroideryError:null,podArtworkFileError:null},this.artworkDimensionRef=l().createRef(),this._initialArtworkFileId=t().get(e,"artwork.artwork_file_id")||null,this._processedEmbroideryFileId=s?t().get(e,"artwork.artwork_file_id"):null,t().bindAll(this,["onFormRef","handleUpdateArtwork","handleFieldChange","handleEmbroideryBrandChange","handleEmbroideryStopChange"])}componentDidMount(){("ps-products"===this.props.item.copied_from||(0,m.pc)(this.props.item.copied_from))&&this.loadProductConfigurations()}UNSAFE_componentWillReceiveProps(e){const{artwork_file_id:r,image:i,imprint_id:o}=e.artwork,s=r&&r!==this.state.artwork.artwork_file_id;s&&(this._processedEmbroideryFileId=null);const l={artwork:Object.assign({},this.state.artwork,{artwork_file_id:r,image:i,imprint_id:this.state.artwork.imprint_id||o})};s&&(l.embroideryPreviewDataUrl=null,l.embroideryColor=null,l.podArtworkFileError=null);const a=(0,m.pc)(e.item.copied_from),n=t().get(this.props,"artwork.artwork_size",""),d=t().get(e,"artwork.artwork_size","");if(a&&`${n}`!=`${d}`){const e=this.parsePodArtworkSize(d);l.artwork={...l.artwork,pod_logo_height:e.height,pod_logo_width:e.width}}else if(!a){const{pod_logo_height:e,pod_logo_width:r,...i}=l.artwork;l.artwork=i}this.setState(l)}componentDidUpdate(e,r){"ps-products"!==this.props.item.copied_from&&!(0,m.pc)(this.props.item.copied_from)||e.product||!this.props.product||this.loadProductConfigurations(),this.maybeProcessEmbroideryDst(e,r)}isPoDEmbroidery(){const{decoration:e,podImageType:r}=this.state,i=(0,m.pc)(t().get(this.props,"item.copied_from")),o=`${t().get(e,"name","")}`.toLowerCase(),s=`${t().get(this.props,"item_decoration.ext_decoration_id","")}`.toLowerCase();return i&&("embroidery"===`${r||""}`.toLowerCase()||"embroidery"===o||s.includes("embroidery"))}async maybeProcessEmbroideryDst(e,r){if(!this.isPoDEmbroidery())return;const i=t().get(this.props,"artwork.artwork_file_id"),o=t().get(this.props,"artwork.image");if(!i||!o||!y(o)||k.TBD_FILE_ID===i)return;if(i===this._processedEmbroideryFileId||this.state.embroideryProcessing)return;if(!this.state.decoration&&!this.state.getDecorationFailed&&!this.state.podImageType)return;const s=i!==t().get(e,"artwork.artwork_file_id"),l=!r.decoration&&!!this.state.decoration;if(s||l||!this.state.embroideryColor){this._processedEmbroideryFileId=i,this.setState({embroideryProcessing:!0,embroideryError:null});try{const{json:e}=await(0,_.bJ)({item_id:this.props.item.item_id,file_id:i,imprint_id:t().get(this.state,"artwork.imprint_id")||t().get(this.props,"artwork.imprint_id"),item_decoration_id:t().get(this.props,"artwork.item_decoration_id")});if(!e.processed)return void this.setState({embroideryProcessing:!1,embroideryColor:null,embroideryPreviewDataUrl:null});this.setState({embroideryProcessing:!1,embroideryColor:e.artwork_dst,embroideryPreviewDataUrl:e.preview_png_base64?`data:image/png;base64,${e.preview_png_base64}`:null,artwork:{...this.state.artwork,artwork_file_id:i,image:o,artwork_color:"",...this.embroideryFormFields(e.artwork_dst)}})}catch(e){this._processedEmbroideryFileId=null,this.setState({embroideryProcessing:!1,embroideryError:t().get(e,"json.error")||"Unable to process embroidery DST file."})}}else this._processedEmbroideryFileId=i}embroideryFormFields(e){const r={embroidery_color_brand:t().get(e,"color_brand")||""};
36return(t().get(e,"colors")||[]).forEach((e,i)=>{r[`embroidery_color_${i}`]=e.brand&&e.code?T(e):""}),r}async handleEmbroideryBrandChange(e){const{embroideryColor:r}=this.state;if(!r)return;const i={...r,color_brand:e||null,colors:(r.colors||[]).map(e=>({...e,code:null,brand:null,hex_code:null,description:null}))};this.setState({embroideryColor:i,artwork:{...this.state.artwork,artwork_color:"",...this.embroideryFormFields(i)}})}async handleEmbroideryStopChange(e,r){const{embroideryColor:i,decoration:o}=this.state;if(!i)return;const s=t().get(o,"options.thread_colors",[]),l=E(s,i.color_brand).find(e=>T(e)===r),a=(i.colors||[]).map((r,i)=>i!==e?r:l?{code:l.code||null,brand:l.brand||null,hex_code:l.hex_code||null,description:l.description||null}:{code:null,brand:null,hex_code:null,description:null}),n={...i,colors:a};this.setState({embroideryColor:n,artwork:{...this.state.artwork,artwork_color:"",...this.embroideryFormFields(n)},embroideryProcessing:!0,embroideryError:null});const d=t().get(this.state,"artwork.artwork_file_id")||t().get(this.props,"artwork.artwork_file_id");try{const{json:e}=await(0,_.rq)({item_id:this.props.item.item_id,file_id:d,artwork_dst:n,imprint_id:t().get(this.state,"artwork.imprint_id")||t().get(this.props,"artwork.imprint_id"),item_decoration_id:t().get(this.props,"artwork.item_decoration_id")});if(!e.processed)return void this.setState({embroideryProcessing:!1});this.setState({embroideryProcessing:!1,embroideryColor:e.artwork_dst,embroideryPreviewDataUrl:e.preview_png_base64?`data:image/png;base64,${e.preview_png_base64}`:null,artwork:{...this.state.artwork,artwork_color:"",...this.embroideryFormFields(e.artwork_dst)}})}catch(e){this.setState({embroideryProcessing:!1,embroideryError:t().get(e,"json.error")||"Unable to refresh embroidery preview."})}}async loadProductConfigurations(){return"ps-products"===this.props.item.copied_from?this.loadPSProductConfigurations():(0,m.pc)(this.props.item.copied_from)?this.loadPoDProductConfigurations():null}async loadPSProductConfigurations(){const{product:e,item_location:r,item_decoration:i,item:o,getProduct:s}=this.props;if(!e)return void s(o.parent_id);const l=t().get(r,"ext_location_id"),a=t().get(i,"ext_decoration_id");let n;try{n=await(0,c.Xb)({productId:e.ext_product_id})||!1}catch(e){n=!1}const d=n?(0,p.rB)(n,l,a):null;d?(this.setState({getDecorationFailed:!1}),this.setState({decoration:d})):this.setState({getDecorationFailed:!0})}async loadPoDProductConfigurations(){const{product:e,item_location:r,item_decoration:i,item:o,getProduct:s}=this.props;if(!e)return void s(o.parent_id);const l=t().get(r,"ext_location_id"),a=t().get(i,"ext_decoration_id");let n;try{n=await(0,m.d8)({extProductId:e.ext_product_id,divisionId:o.division_id})||!1}catch(e){n=!1}const d=t().find(t().get(n,"locations"),e=>{let{pod_location_id:r}=e;return`${r}`==`${l}`}),c=t().find(t().get(d,"decorations"),e=>{let{pod_decoration_id:r}=e;return`${r}`==`${a}`});c?this.setState({getDecorationFailed:!1,decoration:c,podImageType:t().get(d,"image_type",null)}):this.setState({getDecorationFailed:!0,podImageType:null})}componentWillUnmount(){this.props.onCleanUp()}onFormRef(e){this._form=e}handleUpdateArtwork(e,r){if((0,m.pc)(this.props.item.copied_from)){const r=((e,r)=>e?r.artwork_file_id&&y(r.image)?null:(0,f.k4)("embroidery",(0,f.Pq)(r.image)):null)(this.isPoDEmbroidery(),e);if(r)return void this.setState({podArtworkFileError:r});if(k.TBD_FILE_ID!==e.artwork_file_id){const r=t().get(this.props,"item_decoration.ext_decoration_id"),i=(0,f.k4)(r,(0,f.Pq)(e.image));if(i)return void this.setState({podArtworkFileError:i})}this.setState({podArtworkFileError:null})}if(!t().every(r,e=>null===e))return;const{pod_logo_height:i,pod_logo_width:o,...s}=e;let l=t().omitBy(s,(e,r)=>`${r}`.startsWith("embroidery_color"));if((0,m.pc)(this.props.item.copied_from)){const{decoration:e}=this.state,{maxLogoHeightIn:r,maxLogoWidthIn:t}=this.getPoDLogoSizeLimits(e),s=this.normalizePoDLogoDimension(i,r),a=this.normalizePoDLogoDimension(o,t);l={...l,artwork_size:this.composePoDArtworkSize(s,a)}}let a=null;const{embroideryColor:n}=this.state;if(n&&this.isPoDEmbroidery()){var d,c;const e=n.colors||[],r=e.some(e=>!e.brand||!e.code);
36if(!n.color_brand||r)return void this.setState({embroideryError:"Select a color sequence and a color for every stop before saving."});l={...l,artwork_color:"",artwork_dst:{color_brand:n.color_brand||null,preview_file_id:null,stop_count:null!==(d=n.stop_count)&&void 0!==d?d:e.length,stitch_count:null!==(c=n.stitch_count)&&void 0!==c?c:null,colors:e}};const i=t().get(this.props,"artwork.item_decoration_id"),o=Number(t().get(this.props.item_decoration,["decoration_uom.Stitches"])||0),s=Number(n.stitch_count)||0,m=!!l.artwork_file_id&&l.artwork_file_id!==this._initialArtworkFileId;i&&s>0&&(!o||m)&&(a={itemDecorationId:i,stitches:s})}this.props.onUpdateArtwork(l,this.props.copy,a)}handleFieldChange(e,r){this.setState({artwork:{...this.state.artwork,[r]:e}})}parsePodArtworkSize(e){const r=`${e||""}`.trim();if(!r)return{height:"",width:""};const i=r.match(/^([0-9]*\.?[0-9]+)\s*(?:"|in)?\s*[xX]\s*([0-9]*\.?[0-9]+)\s*(?:"|in)?$/);if(i)return{height:i[1],width:i[2]};const o=r.match(/^[xX]\s*([0-9]*\.?[0-9]+)\s*(?:"|in)?$/);if(o)return{height:"",width:o[1]};const t=r.match(/([0-9]*\.?[0-9]+)/);return t?{height:t[1],width:""}:{height:"",width:""}}normalizePoDLogoDimension(e,r){const i=`${e||""}`.trim();if(!i)return"";const o=Number(i);return Number.isNaN(o)||o<0?"":`${r>0?Math.min(o,r):o}`}composePoDArtworkSize(e,r){return e||r?e&&r?`${e}" x ${r}"`:e?`${e}"`:`x ${r}"`:""}getPoDLogoSizeLimits(e){const r=t().get(e,"options.embroidery_limits",{}),i=Number(r.max_logo_height_in),o=Number(r.max_logo_width_in);return{maxLogoHeightIn:Number.isFinite(i)&&i>0?i:null,maxLogoWidthIn:Number.isFinite(o)&&o>0?o:null}}getPopupZIndexes(){const{index:e,popupBaseZIndex:r}=this.props;return{backdropZIndex:null!=r?r+e:null,dialogZIndex:null!=r?r+e+1:A.z+(e||0)}}renderLoading(){const{copy:e,locked:r,onClosePopup:i}=this.props,{artwork:o}=this.state,{backdropZIndex:t,dialogZIndex:s}=this.getPopupZIndexes();return(0,D.jsxs)(D.Fragment,{children:[null!=t?(0,D.jsx)("div",{className:"reveal-overlay",style:{display:"block",position:"fixed",inset:0,zIndex:t},onClick:i,"aria-hidden":"true"}):null,(0,D.jsxs)("div",{id:"add-art-modal",className:"reveal large",style:{display:"block",zIndex:s},"aria-labelledby":"modalTitle",role:"dialog",children:[(0,D.jsx)("div",{className:"row",children:(0,D.jsx)("div",{className:"small-12 columns",children:(0,D.jsx)("h3",{id:"modalTitle",children:o.artwork_id&&!e?r?"Artwork":"Update Artwork":"Add Artwork"})})}),(0,D.jsx)("div",{className:"row popup-content",children:(0,D.jsx)("div",{className:"small-12 columns",children:(0,D.jsx)(S.A,{})})})]})]})}render(){const{locked:e,copy:r,imprints:i,proofs:o,account_id:s,is_project:l,is_catalog:a,job_id:n,quirks:c,item:h,onClosePopup:u,onDeleteArtwork:_,onOpenArtworkLibrary:g,onCreateSelectFilePopup:x}=this.props,{backdropZIndex:w,dialogZIndex:f}=this.getPopupZIndexes(),{artwork:y,decoration:C,getDecorationFailed:A,podImageType:F,embroideryColor:P,embroideryPreviewDataUrl:N,embroideryProcessing:L,embroideryError:$,podArtworkFileError:O}=this.state,Z=t().get(P,"preview_file_id"),W=y.image,H=N||(Z?(0,b.AE)({file_id:Z,s3:1},"original"):(0,b.AE)(W,"medium")),G=!!N,J=!e&&!y.item_decoration_id,K=!!JSON.parse(h.is_3rd_party_decorator),Q=!1===A&&(0,p.BL)(c,h.division_id)&&"ps-products"===h.copied_from&&!K,X=!1===A&&"ps-products"===h.copied_from&&!K,V=(0,m.pc)(h.copied_from),Y=`${t().get(C,"name","")}`.toLowerCase(),ee=V&&("embroidery"===`${F||""}`.toLowerCase()||"embroidery"===Y),{maxLogoHeightIn:re,maxLogoWidthIn:ie}=this.getPoDLogoSizeLimits(C),oe=t().get(C,"options.thread_colors",[]),te=ee&&!!P,se=[{key:"",value:"Please select a color sequence..."},...(e=>{const r=new Set;return(e||[]).forEach(e=>{e.brand&&r.add(e.brand),(t().get(e,"substitutions")||[]).forEach(e=>{e.brand&&r.add(e.brand)})}),Array.from(r)})(oe).map(e=>({key:e,value:e}))],le=[{key:"",value:"Please select a thread color..."},...E(oe,t().get(P,"color_brand")).map(e=>({key:T(e),value:(0,D.jsx)(z,{threadColor:e})}))],ae=!e&&!r&&J&&!!y.artwork_id&&!y.catalog_artwork_id,ne=e?{position:"fixed",right:"1rem",top:"1rem"}:{position:"fixed",right:ae?"9.8rem":"5rem",top:"1rem"};return(0,D.jsxs)(D.Fragment,{children:[null!=w?(0,D.jsx)("div",{className:"reveal-overlay",style:{display:"block",position:"fixed",inset:0,zIndex:w},onClick:u,"aria-hidden":"true"}):null,(0,D.jsxs)("div",{id:"add-art-modal",className:"reveal large",style:{display:"block",zIndex:f},"aria-labelledby":"modalTitle",role:"dialog",children:[(0,D.jsx)("div",{className:"row",children:(0,D.jsx)("div",{className:"small-12 columns",children:(0,D.jsx)("h3",{id:"modalTitle",children:y.artwork_id&&!r?e?"Artwork":"Update Artwork":"Add Artwork"})})}),(0,D.jsxs)(U,{className:"row popup-content form",object:y,ref:this.onFormRef,errorPosition:"bottom",errorClassName:"small-12 medium-8 columns",onSubmit:this.handleUpdateArtwork,onFieldChange:this.handleFieldChange,children:[(0,D.jsxs)("div",{className:"small-12 medium-6 columns",children:[(0,D.jsx)(j.A.Select,{label:"Imprint Type",field:"imprint_id",required:!0,options:i,disabled:!J||!!y.catalog_artwork_id,withMarginBottom:!0}),!V&&(0,D.jsx)(j.A.Select,{label:"Proof Required",field:"proof_id",required:!0,options:o,disabled:e,withMarginBottom:!0}),(0,D.jsx)(j.A.Textarea,{label:"Logo Name",field:"artwork_title",required:!0,disabled:e||!!y.catalog_artwork_id}),Q?C?(0,D.jsx)(I,{ref:this.artworkDimensionRef,id:y.artwork_dimension_id,decoration:C,locked:!0,validateFormCallback:(e,r)=>{r&&this.setState(r=>({...r,artwork:{...r.artwork,artwork_dimension_id:e.artwork_dimension_id}}))}}):(0,D.jsx)(S.A,{}):V&&!ee?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(M,{label:"Logo Height (optional)",field:"pod_logo_height",value:y.pod_logo_height||"",max:re,maxLabel:"height",disabled:e||!!y.catalog_artwork_id,onDimensionChange:this.handleFieldChange}),(0,D.jsx)(M,{label:"Logo Width (optional)",field:"pod_logo_width",value:y.pod_logo_width||"",max:ie,maxLabel:"width",disabled:e||!!y.catalog_artwork_id,onDimensionChange:this.handleFieldChange})]}):V?null:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(j.A.TextInput,{label:"Logo Size",field:"artwork_size",required:!0,disabled:e||!!y.catalog_artwork_id}),!!C&&(0,D.jsx)("div",{className:"row",children:(0,D.jsx)("div",{className:"small-12 medium-8 medium-push-4 columns",style:{marginTop:"-0.5rem",marginBottom:"1rem",fontSize:"small"},children:C.geometry})})]}),te?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(j.A.Select,{label:"Color Sequence",field:"embroidery_color_brand",required:!0,disabled:e||!!y.catalog_artwork_id||L,options:se,onChange:e=>this.handleEmbroideryBrandChange(e),withMarginBottom:!0}),(P.colors||[]).map((r,i)=>(0,D.jsx)(j.A.Select,{label:`Color #${i+1}`,field:`embroidery_color_${i}`,required:!0,disabled:e||!!y.catalog_artwork_id||L||!P.color_brand,options:le,onChange:e=>this.handleEmbroideryStopChange(i,e),withMarginBottom:!0},`embroidery-stop-${i}`)),$?(0,D.jsx)("div",{className:"row",children:(0,D.jsx)("div",{className:"small-12 medium-8 medium-push-4 columns",style:{color:d.colors.errors[60],marginBottom:"1rem"},children:$})}):null]}):ee?$?(0,D.jsx)("div",{className:"row",children:(0,D.jsx)("div",{className:"small-12 medium-8 medium-push-4 columns",style:{color:d.colors.errors[60],marginBottom:"1rem"},children:$})}):null:(0,D.jsx)(R,{label:"Logo Color",field:"artwork_color",required:!0,disabled:e||!!y.catalog_artwork_id,onChange:e=>{X&&setTimeout(()=>{this._form.validateField("artwork_color",e)})},validate:(e,r,i)=>{const o="a0068b9b-1980-4dcb-93d4-9deba3e72f18"===h.division_id?16:64;
36return i||(X&&t().size(e)>o?{message:`Max ${o} characters. Use Supplier Notes for longer text.`}:null)}}),!V&&(0,D.jsx)(j.A.Select,{label:"Repeat Logo?",field:"artwork_repeat",disabled:e||!!y.catalog_artwork_id,withMarginBottom:!0,options:[{key:0,value:"No"},{key:1,value:"Yes"}]}),!V&&(0,D.jsx)(j.A.Textarea,{label:"Supplier Notes",field:"artwork_notes",disabled:e||!!y.catalog_artwork_id})]}),(0,D.jsx)("div",{className:"small-12 medium-6 columns",children:s?(0,D.jsxs)(j.A.BaseField,{field:"artwork_file_id",Control:"div",displayLabel:!1,validate:()=>ee||y.image||y.artwork_file_id===k.TBD_FILE_ID?null:{message:"Image is required"},onClick:r=>{e||y.catalog_artwork_id||(l?x(B,n,"JOB",s):a?x(B,s,"CATALOG",s,{closeOnSelect:!0}):g(B)),this._form&&this._form.cleanFieldError("artwork_file_id")},children:[(0,D.jsx)("div",{className:"art-placeholder",style:{marginBottom:"1em"},children:L?(0,D.jsx)(S.A,{}):N||W||Z?G?(0,D.jsx)("img",{src:H,alt:"Embroidery preview"}):(0,D.jsx)(v.A,{src:H,max_attempts:Z?1:void 0,attempt_interval:Z?1e3:void 0}):k.TBD_FILE_ID===y.artwork_file_id?(0,D.jsx)("img",{src:"/images/404.png"}):e?"No Image":"Select Image"}),O?(0,D.jsx)(q,{children:O}):null]}):(0,D.jsx)("div",{className:"art-placeholder",style:{marginBottom:"1em"},children:"Client will select image"})})]}),(0,D.jsx)("a",{className:"alert button",style:ne,onClick:e=>{e.preventDefault(),u()},children:e?"Done":"Cancel"}),ae?(0,D.jsx)("a",{className:"warning button",style:{position:"fixed",right:"5rem",top:"1rem"},onClick:e=>{e.preventDefault(),_(y.artwork_id)},children:"Delete"}):null,e?null:(0,D.jsx)("a",{className:"button",style:{position:"fixed",right:"1rem",top:"1rem"},onClick:e=>{var r;e.preventDefault(),(!Q||null!==(r=this.artworkDimensionRef.current)&&void 0!==r&&r.isValid()&&y.artwork_dimension_id)&&this._form&&this._form.submit()},children:"Save"})]})]})}}const W=(0,L.y)((0,a.Ng)((e,r)=>{var i;const o=(0,$.Cj)(),s=(0,h.lM)(o)||[],l=(0,h.Pu)(o)||[],a=(0,h.lM)(e),n=(0,h.Pu)(e),d=(a.length?a:s).sort((e,r)=>e.ext_artwork_id&&!r.ext_artwork_id?-1:r.ext_artwork_id&&!e.ext_artwork_id?1:e.imprint_name<r.imprint_name?-1:r.imprint_name<e.imprint_name?1:0),c=e.temp[B],m=e.entities.files[c],p=void 0!==c?{artwork_file_id:c,image:m}:{},u=[{key:"",value:"Please select a proof type..."}].concat(n.length?n:l),_={proof_id:u[0].key,artwork_title:"",artwork_size:"",artwork_color:"",artwork_repeat:0,artwork_notes:"",artwork_dimension_id:""},g=Object.assign({},_,r.artwork,p),x=r.locked,w=e.entities.items[g.item_id],b=t().get(e.entities.products,w.parent_id),k=t().get(e.entities.item_locations,g.item_location_id),f=t().get(e.entities.item_decorations,g.item_decoration_id),y=t().get(f,"imprint_id"),j=t().get(e.entities.imprints,y)||t().get(o,["entities","imprints",y])||{},v=t().get(j,"tenant_id"),S=[{key:"",value:"Please select an imprint type..."}].concat("PROMOSTANDARDS"===v?[{key:j.imprint_id,value:(0,D.jsxs)("span",{children:[(0,D.jsx)(C.A,{}),j.imprint_name]})}]:"POD"===v?[{key:j.imprint_id,value:(0,D.jsxs)("span",{children:[(0,D.jsx)("strong",{style:{marginRight:".35rem"},children:"POD"}),null===(i=j.imprint_name)||void 0===i?void 0:i.toUpperCase()]})}]:d.filter(e=>!e.ext_artwork_id).map(e=>({key:e.imprint_id,value:e.imprint_name})));let A=null;const F=/\/project\//.test(r.router.location.pathname);return F&&(A=Object.keys(e.entities.projects)[0]),{imprints:S,proofs:u,artwork:{...g,imprint_id:g.imprint_id||S[0].key||j.imprint_id},locked:x,item:w,product:b,item_location:k,item_decoration:f,is_project:F,is_catalog:"CATALOG"===r.order_type,job_id:A,quirks:e.entities.promostandards_quirks}},(e,r)=>({getProduct:r=>{e((0,x.m3)(r))},onCleanUp:()=>{e((0,w.mA)(B))},onClosePopup:()=>{e((0,u.fs)())},onUpdateArtwork:function(r,i){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const t=r.artwork_id&&!i?e((0,_.aU)(r)):e((0,_.ui)(r));e((0,u.fs)()),Promise.resolve(t).then(()=>o?e((0,g.brR)(o.itemDecorationId,"decoration_uom",{Stitches:[]},{Stitches:o.stitches})):null)},onDeleteArtwork:r=>{e((0,_.c6)(r)).catch(e=>console.error("Unable to delete artwork: ",e)),e((0,u.fs)())},onOpenArtworkLibrary:i=>{e((0,u.Il)(i,null,r.account_id,r.account_type))},onCreateSelectFilePopup:function(r,i,o,t){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e((0,u.LA)(r,i,o,t,!0,s))}}))(Z)),H=W}}]); 37//# sourceMappingURL=components-EditArtworkPopup.f457a656.chunk.js.map
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.