1import{r as p,j as e}from"./module-g4nfU4qS.js";import{a as P,aw as U,u as Ve,az as I,aF as ce,j as w,F as Q,p as t,P as F,ap as H,e as X,U as je,aC as _e,b$ as we,bo as Te,M as G,aa as J,J as pe,c0 as De,b as $e,O as Ze,G as qe,au as Ke,R as ve,b3 as Ye,c1 as Je,H as Qe}from"../index-GoPR9YK3.js";import{ah as ee,a5 as re,f as fe,ai as q,x as Xe}from"./module-D6su07SI.js";import{h as ue}from"./module-CLsn7ldt.js";import"./module-D2RLwbSq.js";import{l as Ae}from"./module-kEjItqhR.js";import"./module-ClTBx2Nk.js";import"./module-B0vxmspb.js";import"./module-BnWCsivz.js";import{R as ye,c as R,b as es,d as Ce}from"./module-BRy6BJs6.js";import{u as ss}from"./module-CP88euwI.js";import{S as se,a as oe,b as te,T as ts,F as is}from"./module-Bpz6fRsg.js";import{H as Re}from"./module-CNVTF9TH.js";import{bY as Ne,bW as Me,bV as Ie,n as ie,o as L,ae as E,m as le,l as z,r as as,i as M,ba as be,ac as Pe,h as ns,aq as Oe,B as V,N as me,ar as rs,E as os}from"./module-D-Q9SAo8.js";import{M as ze}from"./module-B2Ei-mKv.js";import{a as ls}from"./module-BzM7VDfa.js";import"./module-CkAgo4Og.js";import"./module-BndIsuim.js";import"./module-CLuAD4R5.js";import"./module-DYLXRpC5.js";import"./module-DHVO85nS.js";import"./module-BSPv5tIW.js";import"./module-BHCKjyDG.js";import"./module-M2MMyV6m.js";import"./module-AkyW2Ruw.js";import"./module-BBruC8m-.js";import"./module-CpA3Gb_i.js";import"./module-arTw0fVe.js";import"./module-CYrDBt6T.js";import"./module-DCoKLf-v.js";import"./module-DFeDTf4p.js";import"./module-YfaRQf3K.js";import"./module-duNjR6wQ.js";import"./module-tV3IJ5Y1.js";import"./module-C4TimWWB.js";import"./module-CZPcUW2s.js";import"./module-DHRHeQUK.js";import"./module-DkegjUUZ.js";import"./module-v-CXq_RL.js";import"./module-BDscFCCP.js";import"./module-aXdEWYlg.js";import"./module-B4SPueXG.js";import"./module-ubDpl0_R.js";import"./module-B_AESZ67.js";import"./module-C2S2-HMR.js";import"./module-JW1JAliT.js";import"./module-Dz8i_Leu.js";import"./module-CVphjg2G.js";import"./module-BJwyIH4s.js";import"./module-CbyKh5Um.js";import"./module-DtACTtM6.js";import"./module-BaA5LyCG.js";import"./module-D0mFdbeO.js";import"./module-Dk6e9ee8.js";import"./module-CDjUV5Ju.js";import"./module-BkD7Hj8s.js";import"./module-Cp8br37W.js";import"./module-CzD4bSOQ.js";import"./module-9lF95FHy.js";import"./module-BtzVbTB5.js";import"./module-D28oVHB0.js";import"./module-CimkQT29.js";import"./module-BUHjN4Hc.js";import"./module-BZ4M8-NE.js";import"./module-DMW1B1t5.js";import"./module-v8jY9nGA.js";import"./module-8JwjhRSi.js";import"./module-JSaEjBuK.js";import"./module-UTIhDGpo.js";import"./module-YKhy6aow.js";import"./module-BZ17SRdx.js";import"./module-BEIsiqOv.js";import"./module-fFtbNF-F.js";import"./module-DEtA-KhA.js";import"./module-CPh8vZck.js";import"./module-DKECUIcb.js";import"./module-Cxv9J64N.js";import"./module-BINVifEP.js";import"./module-B1TVd3K4.js";import"./module-BiI3u42N.js";import"./module-B-dksMZM.js";import"./module-B3BJzVxn.js";import"./module-BjfZYBMc.js";import"./module-CeFpPFS8.js";import"./module-CIkNpHNz.js";import"./module-BI5bqnt8.js";import"./module-DiCIOLtz.js";import"./module-BK4nBkK6.js";import"./module-xvpIGbSh.js";import"./module-vs-8EVL6.js";import"./module-DKNNaWzV.js";import"./module-B57D9Y1u.js";import"./module-DsmTx7if.js";import"./module-6E4L_h32.js";import"./module-B5iLQXnX.js";import"./module-eWZP5eA7.js";import"./module-C-FQGDW9.js";import"./module-4S-c4oHJ.js";import"./module-DfWnE5ms.js";import"./module-WX_comao.js";import"./module-BJMi48_2.js";import"./module-MyE73HNZ.js";import"./module-D6GhiVEH.js";import"./module-Cl3hj7Sz.js";import"./module-FxXdmyPN.js";import"./module-FqpXQuLt.js";import"./module-D7zKsYo2.js";import"./module-C1gvLhAf.js";import"./module-B_b8ryxu.js";import"./module-Cv-JDcMf.js";import"./module-DYCwc-sD.js";import"./module-Ch_qCilz.js";import"./module-DWCyG3-x.js";import"./module-D4_bCcMT.js";import"./module-CNs1qBpV.js";import"./module-DI2Ne2_A.js";import"./module-C3-224fz.js";import"./module-C9ANKk3v.js";import"./module-CpL0MGZq.js";import"./module-DbIWH81b.js";import"./module-DrRIdSP-.js";import"./module-BSLCDnTV.js";import"./module-DjYUzTuj.js";import"./module-vcVAUzeC.js";import"./module-GAKWmy7o.js";import"./module-PQCKh0dx.js";import"./module-CEEhGtWX.js";import"./module-B7hx6Bgd.js";import"./module-BJwr7tuA.js";import"./module-BQobnMtX.js";import"./module-BMgpUYTo.js";import"./module-DbKNfynz.js";import"./module-C_aolqmU.js";
1import"./module-Cjxe2-Wq.js";import"./module-ZLXBeeQ1.js";import"./module--gfxRhYI.js";import"./module-Dsow35wU.js";import"./module-60F3QETU.js";import"./module-D8znQY54.js";import"./module-CPveMqlj.js";import"./module-D1zfnBJe.js";import"./module-D9KQvrmg.js";import"./module-FjFE2uWm.js";import"./module-xMQ5YY98.js";import"./module-Bx45xMUt.js";import"./module-DD3iYX1K.js";import"./module-D5ZndoG6.js";import"./module-DMkqpeS_.js";import"./module-CWBJcU5N.js";import"./module-D4Wp6AEg.js";import"./module-BgBfM8ME.js";import"./module-D46m5wfe.js";import"./module-DOgs_Y3Z.js";import"./module-CH9fmmFv.js";import"./module-7ux2xnsv.js";import"./module-CqnTjJDb.js";import"./module-DjKU-xAz.js";import"./module-C0ijFVsX.js";import"./module-B6B9y572.js";import"./module-DhTU8B_4.js";import"./module-5eLbDUjv.js";import"./module-c2V3InAJ.js";import"./module-SNETSEGx.js";import"./module-Qe-ESUUc.js";import"./module-Cj9qKt6Q.js";import"./module-B7EQxdU6.js";import"./module-DvhhVmnL.js";import"./module-CLQgGlmV.js";import"./module-CtXnX3Xp.js";import"./module-DZ4MRfGb.js";import"./module-BXLLueiB.js";import"./module-Bh5dGB7-.js";import"./module-ChDEcKkm.js";import"./module-viLe5jBK.js";import"./module-DYRc1myh.js";import"./module-D-CCuB3j.js";import"./module-C-Y3moQM.js";import"./module-BmLAdfv_.js";import"./module-CQoQLGZn.js";import"./module-CsOSqbjs.js";import"./module-DpV-RknM.js";import"./module-BtHhgq7k.js";import"./module-aFQBCvBX.js";import"./module-CCzXKaxK.js";import"./module-Cgx2k5hB.js";import"./module-CFxIfOSP.js";const We=f=>{const{listData:j=[],valueData:r=[],onChange:i,labelTextField:k="",placeholder:v="",listboxProps:h={},textFieldProps:x={},comboboxProps:g={},style:S={},className:o="",disabled:c,minItems:_=0,disableOptions:N,useSelectedSummary:C=!1}=f,y=[...j].map(T=>({value:T.value+"",label:T.label})),n=y,[a,d]=p.useState([]),[m,s]=p.useState(""),[l,b]=p.useState([...n]);p.useEffect(()=>{if(r){const T=r.map(A=>A+"");d(T)}},[r]);const u=p.useCallback(T=>{if(s(T),T===""){b(n);return}const A=new RegExp(T,"i"),D=n.filter(ge=>ge.label.match(A));b(D)},[n]);p.useEffect(()=>{const T=j.map(A=>({value:A.value+"",label:A.label}));b(T)},[j]);const O=p.useCallback(T=>{if(!N?.(T,a)){if(a.includes(T)){const A=a.filter(D=>D!==T);d(A),i(A)}else{const A=[...a,T];d(A),i(A)}u("")}},[N,l,a,u]),W=p.useCallback(T=>()=>{const A=[...a];A.splice(A.indexOf(T),1),d(A),i(A)},[a]),Z=T=>{let A="";const D=y.find(ge=>ge.value===T);return D&&(A=D.label),A},B=a.length,K=B>0?a[B-1]:"",de=Z(K),xe=B>1?B-1:0,He=B===0?"":xe>0?`${de} ${xe>0?`and +${xe}`:""}`:de,Ge=a.map(T=>y.find(A=>A.value===T)?e.jsx(Ne,{onRemove:c||a.length<=_?void 0:W(T),children:Z(T)},`option-${T}`):null),ke=l.length>0?l.map(T=>{const{label:A,value:D}=T;return e.jsx(Me.Option,{value:D,selected:a.includes(D),accessibilityLabel:A,disabled:(N?.(D,a)??!1)||a.includes(D)&&a.length<=_,children:A},`${D}`)}):null;return e.jsxs("div",{style:S,className:o,children:[e.jsx(Ie,{allowMultiple:!0,...g,activator:e.jsx(Ie.TextField,{disabled:c,autoComplete:"off",label:k,labelHidden:!0,placeholder:v,...x,value:C?m||He:m,onChange:u}),children:ke?e.jsx(Me,{...h,onSelect:O,children:ke}):null}),!C&&a.length>0&&e.jsx("div",{className:"msui-mt-2",children:e.jsx(ie,{gap:"100",children:Ge})})]})},ae=ye({key:"automationWritingState",default:{conditions:[{key:"product_source",value:"aliexpress,ebay,amazon,unlinked"},{key:"product_status",value:"active"}],actions:[{key:"rewrite_language",value:"en"},{key:"rewrite_content",style:"highlight",tone:"persuasive",value:"recommend_style_tone",custom_instruction:""},{key:"generate_meta_description",value:!1},{key:"delete_supplier_images_description",value:!1}],is_enable:!0}}),ne=ye({key:"automationImageState",default:{conditions:[{key:"product_source",value:"aliexpress,ebay,amazon,unlinked"},{key:"product_status",value:"active"}],actions:[{key:"enhance_product_media",value:"product_thumbnail",enhance_list:["resize_ratio_1_1","boost_resolution","convert_to_webp","cleanup_background"]}],is_enable:!0}}),ds=ye({key:"isFetchingAutomationState",default:!1});function Ee({enableInitFetch:f=!0}={}){const{t:j}=P(),[r,i]=p.useState(!1),[k,v]=R(ae),[h,x]=R(ds),[g,S]=p.useState(),[o,c]=R(ne),[_,N]=p.useState(),{cancel:C,token:y}=U(),n=Ve(),a=async()=>{x(!0),x(!1)},d=async()=>{try{i(!0);const{status:O}=await I.putUpdateStatusAutomationWriting({is_enable:k.is_enable},y),{status:W}=await I.putAutomationWriting(k,y);i(!1),W===ce.OK&&O===ce.OK&&(n.success(j("AutomationSaved")),a())}catch{}},m=()=>{v(g)},s=async()=>{try{i(!0);const{status:O}=await I.putUpdateStatusAutomationImage({is_enable:o.is_enable},y),{status:W}=await I.putAutomationImage({...o,actions:[{...o.actions?.[0]}]},y);i(!1),(W===ce.OK||O===ce.OK)&&(n.success(j("AutomationSaved")),a())}catch{}},l=()=>{c(_)},b=p.useMemo(()=>g?!Ae.isEqual(g,k):!1,[k,g]),u=p.useMemo(()=>_?!Ae.isEqual(_,o):!1,[o,_]);return{automationWriting:k,automationImage:o,isChangeDataAutoWriting:b,isChangeDataAutoImage:u,saveLoading:r,isFetching:h,fetchAutomationProduct:a,handleSaveAutoWritingChanges:d,handleDiscardAutoWritingChanges:m,handleSaveAutoImageChanges:s,handleDiscardAutoImageChanges:l}}function Fe({className:f,setLoading:j,onClose:r}){const{t:i}=P(),{token:k}=U(),[v,h]=R(ne),x=p.useRef(null),g=p.useCallback(async o=>{x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{j(!0);
1try{await I.putAutomationImage(o,k)}catch{}finally{j(!1)}},1e3)},[v]),S=p.useCallback(o=>{g(o)},[g]);return e.jsx("div",{className:w("min-h-full overflow-hidden border border-border-secondary rounded-tl-xl bg-bg-surface",f),children:e.jsxs("div",{className:"h-full animate-slide-left",children:[e.jsxs("div",{className:w("flex items-start gap-3 p-4",r&&"items-center"),children:[r&&e.jsx(Q,{variant:"tertiary",onClick:r,icon:L}),e.jsx(se,{className:"size-6"}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("Action")}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:i("ActionDesc")})]})]}),e.jsx(E,{}),e.jsxs("div",{className:"flex flex-col h-full gap-3 p-4",children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("Then").toUpperCase()}),e.jsx("div",{className:"grid gap-3 p-3 border rounded-lg bg-bg-surface-secondary border-border",children:e.jsx(ee,{permissions:[F.VIEW_ACTION_AUTOMATION_FORMAT_PRODUCT_IMAGES],children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("EnhanceProductMedia")}),e.jsx(H,{disabled:v.actions?.[0]?.enhance_list.length===1&&v.actions?.[0]?.enhance_list.includes("cleanup_background"),label:i("CleanUpBackground"),checked:v.actions?.[0]?.enhance_list.includes("cleanup_background"),onChange:o=>{h(c=>{const _={...c,actions:[{...c.actions[0],enhance_list:o?[...c.actions?.[0]?.enhance_list,"cleanup_background"]:c.actions?.[0]?.enhance_list.filter(N=>N!=="cleanup_background")}]};return S(_),_})}}),e.jsx(H,{disabled:v.actions?.[0]?.enhance_list.length===1&&v.actions?.[0]?.enhance_list.includes("resize_ratio_1_1"),label:i("ResizeTo11"),checked:v.actions?.[0]?.enhance_list.includes("resize_ratio_1_1"),onChange:()=>{h(o=>{const c={...o,actions:[{...o.actions[0],enhance_list:o.actions?.[0]?.enhance_list.includes("resize_ratio_1_1")?o.actions?.[0]?.enhance_list.filter(_=>_!=="resize_ratio_1_1"):[...o.actions?.[0]?.enhance_list,"resize_ratio_1_1"]}]};return S(c),c})}}),e.jsx(H,{disabled:v.actions?.[0]?.enhance_list.length===1&&v.actions?.[0]?.enhance_list.includes("convert_to_webp"),label:i("ConvertToWebP"),checked:v.actions?.[0]?.enhance_list.includes("convert_to_webp"),onChange:()=>{h(o=>{const c={...o,actions:[{...o.actions[0],enhance_list:o.actions?.[0]?.enhance_list.includes("convert_to_webp")?o.actions?.[0]?.enhance_list.filter(_=>_!=="convert_to_webp"):[...o.actions?.[0]?.enhance_list,"convert_to_webp"]}]};return S(c),c})}}),e.jsx(H,{disabled:v.actions?.[0]?.enhance_list.length===1&&v.actions?.[0]?.enhance_list.includes("boost_resolution"),label:i("BoostResolution"),checked:v.actions?.[0]?.enhance_list.includes("boost_resolution"),onChange:()=>{h(o=>{const c={...o,actions:[{...o.actions[0],enhance_list:o.actions?.[0]?.enhance_list.includes("boost_resolution")?o.actions?.[0]?.enhance_list.filter(_=>_!=="boost_resolution"):[...o.actions?.[0]?.enhance_list,"boost_resolution"]}]};return S(c),c})}})]})})})]})]})})}function he({className:f,onClose:j}){const{t:r}=P();return e.jsx("div",{className:w("border border-border-secondary rounded-tl-xl overflow-hidden min-h-full bg-bg-surface",f),children:e.jsxs("div",{className:"h-full animate-slide-left",children:[e.jsxs("div",{className:w("flex items-start gap-3 p-4",j&&"items-center"),children:[j&&e.jsx(Q,{variant:"tertiary",onClick:j,icon:L}),e.jsx(oe,{className:"size-6"}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(t,{as:"p",variant:"headingMd",children:r("Trigger")}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:r("TriggerDesc")})]})]}),e.jsx(E,{}),e.jsxs("div",{className:"flex flex-col gap-3 p-4 h-full",children:[e.jsx(t,{as:"p",variant:"headingMd",children:r("When").toUpperCase()}),e.jsxs("div",{className:"p-3 border bg-bg-surface-secondary border-border rounded-lg grid gap-1",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:r("NewProductIsAddedToZopiPC")}),e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("ProductThatIsAddedToPC")})]})]})]})})}const $=f=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"352",height:"122",fill:"none",viewBox:"0 0 352 122",...f,children:e.jsx("path",{fill:"#005BD3",d:"M341.167 6a5.333 5.333 0 1 0 10.666 0 5.333 5.333 0 1 0-10.666 0m-301.5 110a5.333 5.333 0 1 0 10.666 0 5.333 5.333 0 1 0-10.666 0M346.5 6h-1v28h2V6zm-24 52v-1H25v2h297.5zM1 82H0v10h2V82zm24 34v1h20v-2H25zM1 92H0c0 13.807 11.
1193 25 25 25v-2c-12.702 0-23-10.297-23-23zm24-34v-1C11.193 57 0 68.193 0 82h2c0-12.702 10.298-23 23-23zm321.5-24h-1c0 12.703-10.297 23-23 23v2c13.807 0 25-11.193 25-25z"})}),Y=[{label:"Aliexpress",value:"aliexpress"},{label:"eBay",value:"ebay"},{label:"Amazon",value:"amazon"},{label:"Unlinked (no supplier linked)",value:"unlinked"}];function Ue({className:f,setLoading:j,onClose:r}){const{t:i}=P(),{token:k}=U(),{isMobile:v}=X(),[h,x]=R(ne),[g,S]=p.useState(!1),o=[{label:"is All",value:"all"},{label:"is Published",value:"active"},{label:"is Draft",value:"draft"}],c=p.useRef(null),_=p.useCallback(async n=>{c.current&&clearTimeout(c.current),c.current=setTimeout(async()=>{j(!0);try{await I.putAutomationImage(n,k)}catch{}finally{j(!1)}},1e3)},[h]),N=p.useCallback(n=>{_(n)},[_]),C=()=>{const n=h.conditions?.find(a=>a.key==="product_source")?.value?.split(",")||[];return e.jsx(ze,{style:{maxHeight:"300px"},children:e.jsx(le,{padding:"200",children:e.jsx(z,{gap:"200",children:Y.map(a=>e.jsx(H,{label:a.label,checked:n.includes(a.value),disabled:n.length===1&&n.includes(a.value),onChange:d=>{x(m=>{const s={...m,conditions:m.conditions?.map(l=>l.key==="product_source"?{...l,value:d?[...n,a.value].join(","):n.filter(b=>b!==a.value).join(",")}:l)};return N(s),s})}},a.value))})})})},y=()=>{const n=h.conditions?.find(a=>a.key==="product_source")?.value?.split(",")||[];return e.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(a=>e.jsx(Ne,{onRemove:n.length>1?()=>{x(d=>{const m={...d,conditions:d.conditions?.map(s=>s.key==="product_source"?{...s,value:n.filter(l=>l!==a).join(",")}:s)};return N(m),m})}:void 0,children:Y.find(d=>d.value===a)?.label},`option-${a}`))})};return e.jsx("div",{className:w("min-h-full overflow-hidden border border-border-secondary rounded-tl-xl bg-bg-surface",f),children:e.jsxs("div",{className:"h-full animate-slide-left",children:[e.jsxs("div",{className:w("flex items-start gap-3 p-4",r&&"items-center"),children:[r&&e.jsx(Q,{variant:"tertiary",onClick:r,icon:L}),e.jsx(te,{className:"size-6"}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("Condition")}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:i("ConditionDesc")})]})]}),e.jsx(E,{}),e.jsx(ee,{permissions:[F.VIEW_ACTION_AUTOMATION_FORMAT_PRODUCT_IMAGES],children:e.jsxs("div",{className:"flex flex-col h-full gap-3 p-4",children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("If").toUpperCase()}),e.jsxs("div",{className:"grid gap-3 p-3 border rounded-lg bg-bg-surface-secondary border-border",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("ApplyToProductOfSupplier")}),v?e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"Polaris-Labelled--hidden cursor-pointer",onClick:()=>S(n=>!n),children:e.jsxs("div",{className:w("Polaris-Select"),children:[e.jsxs("div",{className:"Polaris-Select__Content","aria-hidden":"true",children:[e.jsx("span",{className:"Polaris-Select__SelectedOption",children:i("SelectASupplier")}),e.jsx("span",{className:"Polaris-Select__Icon",children:e.jsx("span",{className:"Polaris-Icon",children:e.jsxs("svg",{viewBox:"0 0 20 20",className:"Polaris-Icon__Svg",focusable:"false","aria-hidden":"true",children:[e.jsx("path",{d:"M10.884 4.323a1.25 1.25 0 0 0-1.768 0l-2.646 2.647a.75.75 0 0 0 1.06 1.06l2.47-2.47 2.47 2.47a.75.75 0 1 0 1.06-1.06l-2.646-2.647Z"}),e.jsx("path",{d:"m13.53 13.03-2.646 2.647a1.25 1.25 0 0 1-1.768 0l-2.646-2.647a.75.75 0 0 1 1.06-1.06l2.47 2.47 2.47-2.47a.75.75 0 0 1 1.06 1.06Z"})]})})})]}),e.jsx("div",{className:"Polaris-Select__Backdrop"})]})}),e.jsx("div",{children:y()}),e.jsx(je,{zIndex:178,visible:g,placement:"bottom",onClose:()=>S(!1),title:i("SelectASupplier"),children:C()})]}):e.jsx(We,{minItems:1,valueData:h.conditions?.find(n=>n.key==="product_source")?.value?h.conditions?.find(n=>n.key==="product_source")?.value?.split(",")||[]:[],onChange:n=>{x(a=>{const d={...a,conditions:a.conditions?.map(m=>m.key==="product_source"?{...m,value:n.join(",")}:m)};return N(d),d})},listData:Y,placeholder:i("SelectASupplier")},"supplier")]}),e.jsx(t,{as:"p",variant:"headingMd",children:i("And").toUpperCase()}),e.jsxs("div",{className:"grid gap-3 p-3 border rounded-lg bg-bg-surface-secondary border-border",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("ProductListingStatus")}),e.jsx(re,{options:o,label:"",labelHidden:!0,onChange:n=>{h.conditions?.find(a=>a.key==="product_status")?x(a=>{const d={...a,conditions:a.conditions?.map(m=>m.key==="product_status"?{...m,value:n}:m)};return N(d),d}):x(a=>{const d={...a,conditions:[...a.conditions||[],{key:"product_status",value:n}]};return N(d),d})},value:h.conditions?.find(n=>n.key==="product_status")?.value||""})]})]})})]})})}function cs({message:f,fieldId:j}){const{t:r}
1=P();return e.jsx("div",{className:`relative [&_.Polaris-TextField--error_.Polaris-TextField\\_\\_Backdrop]:!border-border-info 2 [&_.Polaris-TextField--error_.Polaris-TextField\\_\\_Backdrop]:!bg-bg-surface-info 3 [&_.Polaris-InlineError]:!text-text-info-secondary 4 [&_.Polaris-InlineError]:!fill-text-info-secondary`,children:e.jsx(as,{message:r(f),fieldID:j})})}function Le({className:f,setLoading:j,onClose:r}){const{t:i}=P(),{token:k}=U(),{isMobile:v}=X(),h=p.useRef(null),[x,g]=p.useState(!1),[S,o]=R(ae),c=S?.actions||[],_=S.actions?.find(s=>s.key==="delete_supplier_images_description")?.value,N=S.actions?.find(s=>s.key==="generate_meta_description")?.value,C=S.actions?.find(s=>s.key==="generate_meta_title")?.value,y=S.actions?.find(s=>s.key==="rewrite_content"),n=s=>{o(l=>{const b=l.actions||[],u=s.reduce((W,Z)=>{const B=W.findIndex(K=>K.key===Z.key);return B>-1?W.map((K,de)=>de===B?{...K,...Z.value}:K):[...W,{key:Z.key,...Z.value}]},b),O={...l,actions:u};return m(O),O}),g(!1)},a=p.useRef(null),d=p.useCallback(async s=>{a.current&&clearTimeout(a.current),a.current=setTimeout(async()=>{j(!0);try{await I.putAutomationWriting(s,k)}catch{}finally{j(!1)}},1e3)},[S]),m=p.useCallback(s=>{if(s.actions.find(l=>l.key==="rewrite_content")?.value==="custom_style"&&!s.actions.find(l=>l.key==="rewrite_content")?.custom_instruction){d({...s,actions:s.actions.map(l=>l.key==="rewrite_content"?{...l,value:"recommend_style_tone"}:l)});return}d(s)},[d]);return e.jsx("div",{className:w("min-h-full border bg-bg-surface border-border-secondary rounded-tl-xl",f),children:e.jsxs("div",{className:"h-full animate-slide-left",children:[e.jsxs("div",{className:w("flex items-start gap-3 p-4",r&&"items-center"),children:[r&&e.jsx(Q,{variant:"tertiary",onClick:r,icon:L}),e.jsx(se,{className:"size-6"}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("Action")}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:i("ActionDesc")})]})]}),e.jsx(E,{}),e.jsx(ee,{permissions:[F.VIEW_ACTION_AUTOMATION_REWRITE_PRODUCT_CONTENT],children:e.jsxs("div",{className:"flex flex-col h-[calc(100%-72px)] overflow-auto",children:[e.jsxs("div",{className:"flex flex-col gap-3 p-4 pb-0",children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("Then").toUpperCase()}),e.jsxs("div",{className:"grid gap-3 p-3 border rounded-lg bg-bg-surface-secondary border-border",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("RewriteProductTitle")}),e.jsx(re,{label:"",labelHidden:!0,value:c?.find(s=>s.key==="rewrite_language")?.value||"en",options:_e.map(s=>({label:s.name,value:s.language})),onChange:s=>{o(l=>{const b={...l,actions:l.actions?.find(u=>u.key==="rewrite_language")?l.actions?.map(u=>u.key==="rewrite_language"?{...u,value:s}:u):[...l.actions||[],{key:"rewrite_language",value:s}]};return m(b),b})}})]}),_&&e.jsxs(e.Fragment,{children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("And").toUpperCase()}),e.jsxs("div",{className:"grid gap-1 p-3 border rounded-lg bg-bg-surface-secondary border-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("DeleteAllSupplierImages")}),e.jsx(M,{icon:be,variant:"tertiary",onClick:()=>{o(s=>{const l={...s,actions:s.actions?.filter(b=>b.key!=="delete_supplier_images_description")};return m(l),l})}})]}),e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("DeleteAllSupplierImagesDesc")})]})]}),!!y&&e.jsxs(e.Fragment,{children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("And").toUpperCase()}),e.jsx("div",{className:"grid gap-3 p-3 border rounded-lg bg-bg-surface-secondary border-border",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("EditProductTitleAndDesc")}),e.jsx(M,{icon:be,variant:"tertiary",onClick:()=>{o(s=>{const l={...s,actions:s.actions?.filter(b=>b.key!=="rewrite_content")};return m(l),l})}})]}),e.jsx(Pe,{label:i("ApplyZopiQuickStyling"),checked:c?.find(s=>
4s.key==="rewrite_content")?.value==="recommend_style_tone",id:"recommend",name:"toneType",onChange:()=>{o(s=>{const l={...s,actions:s.actions?.map(b=>b.key==="rewrite_content"?{...b,value:"recommend_style_tone"}:b)};return m(l),l})}}),c?.find(s=>s.key==="rewrite_content")?.value==="recommend_style_tone"&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"grid gap-1",children:[e.jsx(t,{as:"p",variant:"bodyMd",children:i("Style")}),e.jsx(re,{label:"",labelHidden:!0,value:c?.find(s=>s.key==="rewrite_content")?.style||we[0].value,options:we.map(s=>({label:s.label,value:s.value})),onChange:s=>{o(l=>{const b={...l,actions:l.actions?.map(u=>u.key==="rewrite_content"?{...u,style:s}:u)};return m(b),b})}})]}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(t,{as:"p",variant:"bodyMd",children:i("Tone")}),e.jsx(re,{label:"",labelHidden:!0,value:c?.find(s=>s.key==="rewrite_content")?.tone||Te[0].value,options:Te.map(s=>({label:s.label,value:s.value})),onChange:s=>{o(l=>{const b={...l,actions:l.actions?.map(u=>u.key==="rewrite_content"?{...u,tone:s}:u)};return m(b),b})}})]})]}),e.jsx(Pe,{label:i("UseCustomStyle"),checked:c?.find(s=>s.key==="rewrite_content")?.value==="custom_style",id:"custom_instruction",name:"toneType",onChange:()=>{o(s=>{const l={...s,actions:s.actions?.map(b=>b.key==="rewrite_content"?{...b,value:"custom_style"}:b)};return s.actions.find(b=>b.key==="rewrite_content")?.custom_instruction&&m(l),l})}}),c?.find(s=>s.key==="rewrite_content")?.value==="custom_style"&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(ns,{label:"",multiline:5,autoComplete:"off",placeholder:i("InputYourContentOrInstructionHere"),value:c?.find(s=>s.key==="rewrite_content")?.custom_instruction||"",onChange:s=>{o(l=>{const b={...l,actions:l.actions?.map(u=>u.key==="rewrite_content"?{...u,custom_instruction:s.trim()}:u)};return s.trim()&&m(b),b})}}),!c?.find(s=>s.key==="rewrite_content")?.custom_instruction&&e.jsx(cs,{message:"EnhanceContentNoti",fieldId:"ai-content"})]})]})})]}),(C||N)&&e.jsxs("div",{className:"grid gap-1 p-3 border rounded-lg bg-bg-surface-secondary border-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("GenerateSEOMetadata")}),e.jsx(M,{icon:be,variant:"tertiary",onClick:()=>{o(s=>{const l={...s,actions:s.actions?.filter(b=>b.key!=="generate_meta_description"&&b.key!=="generate_meta_title")};return m(l),l})}})]}),e.jsxs("div",{className:"grid",children:[e.jsx(H,{label:i("MetaTitle"),checked:!!c?.find(s=>s.key==="generate_meta_title")?.value,onChange:s=>{o(l=>{const b={...l,actions:l.actions?.map(u=>u.key==="generate_meta_title"?{...u,value:s}:u)};return m(b),b})}}),e.jsx(H,{label:i("MetaDescription"),checked:!!c?.find(s=>s.key==="generate_meta_description")?.value,onChange:s=>{o(l=>{const b={...l,actions:l.actions?.map(u=>u.key==="generate_meta_description"?{...u,value:s}:u)};return m(b),b})}})]})]})]}),e.jsx("div",{className:"flex items-center gap-2 p-4 pb-6",ref:h,children:e.jsx(M,{onClick:()=>g(!0),disabled:(!!C||!!N)&&!!_&&!!y,children:i("AddAction")})}),v?e.jsxs(je,{visible:x,onClose:()=>g(!1),zIndex:178,children:[e.jsx("div",{className:"p-3 border bg-bg-surface-secondary border-border",children:e.jsxs("div",{className:"flex items-center justify-start gap-1 w-fit",children:[e.jsx(G,{source:Oe}),e.jsx(t,{as:"p",variant:"bodyMd",children:"Product based"})]})}),e.jsxs("div",{className:w("p-3 grid gap-1 cursor-pointer hover:bg-bg-surface-secondary",!!y&&"opacity-50 pointer-events-none"),onClick:()=>n([{key:"rewrite_content",value:{value:"recommend_style_tone",tone:"persuasive",style:"highlight"}}]),children:[e.jsxs(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:["Edit product title & description"," "]}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:"Rewrite the product title and description in a high-converting style and tone."})]}),e.jsx(E,{}),e.jsxs("div",{className:w("p-3 grid gap-1 cursor-pointer hover:bg-bg-surface-secondary",(N||C)&&"opacity-50 pointer-events-none"),onClick:()=>n([{key:"generate_meta_description",value:{value:!0}},{key:"generate_meta_title",value:{value:!0}}]),children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:"Generate meta description"}
4),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:"Generate SEO optimized meta description"})]}),e.jsx(E,{}),e.jsxs("div",{className:w("p-3 grid gap-1 cursor-pointer hover:bg-bg-surface-secondary",_&&"opacity-50 pointer-events-none"),onClick:()=>n([{key:"delete_supplier_images_description",value:{value:!0}}]),children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:"Delete all supplierâs images in description"}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:"Delete all supplierâs images in the description to make it clean and professional"})]})]}):e.jsxs(ts,{targetRef:h,anchorRef:h,visible:x,onClose:()=>g(!1),title:i("AddAction"),children:[e.jsx("div",{className:"p-3 border bg-bg-surface-secondary border-border",children:e.jsxs("div",{className:"flex items-center justify-start gap-1 w-fit",children:[e.jsx(G,{source:Oe}),e.jsx(t,{as:"p",variant:"bodyMd",children:"Product based"})]})}),e.jsxs("div",{className:w("p-3 grid gap-1 cursor-pointer hover:bg-bg-surface-secondary",!!y&&"opacity-50 pointer-events-none"),onClick:()=>n([{key:"rewrite_content",value:{value:"recommend_style_tone",tone:"persuasive",style:"highlight"}}]),children:[e.jsxs(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:["Edit product title & description"," "]}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:"Rewrite the product title and description in a high-converting style and tone."})]}),e.jsx(E,{}),e.jsxs("div",{className:w("p-3 grid gap-1 cursor-pointer hover:bg-bg-surface-secondary",(N||C)&&"opacity-50 pointer-events-none"),onClick:()=>n([{key:"generate_meta_description",value:{value:!0}},{key:"generate_meta_title",value:{value:!0}}]),children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:"Generate meta description"}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:"Generate SEO optimized meta description"})]}),e.jsx(E,{}),e.jsxs("div",{className:w("p-3 grid gap-1 cursor-pointer hover:bg-bg-surface-secondary",_&&"opacity-50 pointer-events-none"),onClick:()=>n([{key:"delete_supplier_images_description",value:{value:!0}}]),children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:"Delete all supplierâs images in description"}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:"Delete all supplierâs images in the description to make it clean and professional"})]})]})]})})]})})}function Be({className:f,setLoading:j,onClose:r}){const{t:i}=P(),{token:k}=U(),{isMobile:v}=X(),[h,x]=R(ae),g=p.useRef(null),[S,o]=p.useState(!1),c=p.useCallback(async n=>{g.current&&clearTimeout(g.current),g.current=setTimeout(async()=>{j(!0);try{await I.putAutomationWriting(n,k)}catch{}finally{j(!1)}},1e3)},[h]),_=p.useCallback(n=>{if(n.actions.find(a=>a.key==="rewrite_content")?.value==="custom_style"&&!n.actions.find(a=>a.key==="rewrite_content")?.custom_instruction){c({...n,actions:n.actions.map(a=>a.key==="rewrite_content"?{...a,value:"recommend_style_tone"}:a)});return}c(n)},[c]),N=[{label:"is All",value:"all"},{label:"is Published",value:"active"},{label:"is Draft",value:"draft"}],C=()=>{const n=h.conditions?.find(a=>a.key==="product_source")?.value?.split(",")||[];return e.jsx(ze,{style:{maxHeight:"300px"},children:e.jsx(le,{padding:"200",children:e.jsx(z,{gap:"200",children:Y.map(a=>e.jsx(H,{label:a.label,checked:n.includes(a.value),disabled:n.length===1&&n.includes(a.value),onChange:d=>{x(m=>{const s={...m,conditions:m.conditions?.map(l=>l.key==="product_source"?{...l,value:d?[...n,a.value].join(","):n.filter(b=>b!==a.value).join(",")}:l)};return _(s),s})}},a.value))})})})},y=()=>{const n=h.conditions?.find(a=>a.key==="product_source")?.value?.split(",")||[];return e.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(a=>e.jsx(Ne,{onRemove:n.length>1?()=>{x(d=>{const m={...d,conditions:d.conditions?.map(s=>s.key==="product_source"?{...s,value:n.filter(l=>l!==a).join(",")}:s)};return _(m),m})}:void 0,children:Y.find(d=>d.value===a)?.label},`option-${a}`))})};return e.jsx("div",{className:w("min-h-full overflow-hidden border border-border-secondary rounded-tl-xl bg-bg-surface",f),children:e.jsxs("div",{className:"h-full animate-slide-left",children:[e.jsxs("div",{className:w("flex items-start gap-3 p-4",r&&"items-center"),children:[r&&e.jsx(Q,{variant:"tertiary",onClick:r,icon:L}),e.jsx(te,{className:"size-6"}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("Condition")}
4),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:i("ConditionDesc")})]})]}),e.jsx(E,{}),e.jsx(ee,{permissions:[F.VIEW_ACTION_AUTOMATION_REWRITE_PRODUCT_CONTENT],children:e.jsxs("div",{className:"flex flex-col h-full gap-3 p-4",children:[e.jsx(t,{as:"p",variant:"headingMd",children:i("If").toUpperCase()}),e.jsxs("div",{className:"grid gap-3 p-3 border rounded-lg bg-bg-surface-secondary border-border",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("ApplyToProductOfSupplier")}),v?e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"Polaris-Labelled--hidden cursor-pointer",onClick:()=>o(n=>!n),children:e.jsxs("div",{className:w("Polaris-Select"),children:[e.jsxs("div",{className:"Polaris-Select__Content","aria-hidden":"true",children:[e.jsx("span",{className:"Polaris-Select__SelectedOption",children:i("SelectASupplier")}),e.jsx("span",{className:"Polaris-Select__Icon",children:e.jsx("span",{className:"Polaris-Icon",children:e.jsxs("svg",{viewBox:"0 0 20 20",className:"Polaris-Icon__Svg",focusable:"false","aria-hidden":"true",children:[e.jsx("path",{d:"M10.884 4.323a1.25 1.25 0 0 0-1.768 0l-2.646 2.647a.75.75 0 0 0 1.06 1.06l2.47-2.47 2.47 2.47a.75.75 0 1 0 1.06-1.06l-2.646-2.647Z"}),e.jsx("path",{d:"m13.53 13.03-2.646 2.647a1.25 1.25 0 0 1-1.768 0l-2.646-2.647a.75.75 0 0 1 1.06-1.06l2.47 2.47 2.47-2.47a.75.75 0 0 1 1.06 1.06Z"})]})})})]}),e.jsx("div",{className:"Polaris-Select__Backdrop"})]})}),e.jsx("div",{children:y()}),e.jsx(je,{zIndex:178,visible:S,placement:"bottom",onClose:()=>o(!1),title:i("SelectASupplier"),children:C()})]}):e.jsx(We,{minItems:1,valueData:h.conditions?.find(n=>n.key==="product_source")?.value?h.conditions?.find(n=>n.key==="product_source")?.value?.split(",")||[]:[],onChange:n=>{x(a=>{const d={...a,conditions:a.conditions?.map(m=>m.key==="product_source"?{...m,value:n.join(",")}:m)};return _(d),d})},listData:Y,placeholder:i("SelectASupplier")},"supplier")]}),e.jsx(t,{as:"p",variant:"headingMd",children:i("And").toUpperCase()}),e.jsxs("div",{className:"grid gap-3 p-3 border rounded-lg bg-bg-surface-secondary border-border",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("ProductListingStatus")}),e.jsx(re,{options:N,label:"",labelHidden:!0,onChange:n=>{h.conditions?.find(a=>a.key==="product_status")?x(a=>{const d={...a,conditions:a.conditions?.map(m=>m.key==="product_status"?{...m,value:n}:m)};return _(d),d}):x(a=>{const d={...a,conditions:[...a.conditions||[],{key:"product_status",value:n}]};return _(d),d})},value:h.conditions?.find(n=>n.key==="product_status")?.value||""})]})]})})]})})}function us({open:f,loading:j,onClose:r}){const{t:i}=P(),{token:k}=U(),[v,h]=p.useState(!1),[x,g]=p.useState(""),[S,o]=p.useState(!1),[c,_]=R(ae),N=c.actions?.find(s=>s.key==="rewrite_content"),C=c.actions?.find(s=>s.key==="rewrite_language"),y=c.actions?.find(s=>s.key==="generate_meta_description")?.value,n=c.actions?.find(s=>s.key==="generate_meta_title")?.value,a=c.actions?.find(s=>s.key==="delete_supplier_images_description")?.value,d=async s=>{o(!0),await I.putUpdateStatusAutomationWriting({is_enable:s},k),o(!1)},m=async()=>{const s={conditions:[{key:"product_source",value:"aliexpress,zopi,ebay,amazon,unlinked"},{key:"product_status",value:"all"}],actions:[{key:"rewrite_language",value:"en"},{key:"rewrite_content",style:"highlight",tone:"persuasive",value:"recommend_style_tone"},{key:"generate_meta_description",value:!0},{key:"generate_meta_title",value:!0}],is_enable:!1};_(s),h(!0),await I.putAutomationWriting(s,k),h(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(J,{width:1072,zIndex:176,className:"msui-drawer__notification",visible:f,onClose:()=>{g(""),r()},children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs(Se,{className:"px-4 py-3 flex gap-2 items-center bg-white",children:[e.jsx(M,{icon:L,onClick:()=>{g(""),r()},variant:"tertiary"}),e.jsx(t,{as:"h3",variant:"headingMd",children:i("RewriteProductContent")}),c.is_enable?e.jsx(V,{tone:"success",children:i("Active")}):e.jsx(V,{children:i("Inactive")}),e.jsx("div",{className:"ml-auto",children:e.jsxs(ie,{align:"center",gap:"050",blockAlign:"center",children:[S||j?e.jsx(pe,{size:"small"}):e.jsx(G,{source:me,tone:"subdued"}),e.jsx(t,{as:"span",tone:"subdued",children:S||j?"Saving...":"Saved"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-[72px] items-center mb-6 py-4 pl-6 min-h-[calc(100vh-129px)] overflow-auto",children:[e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>g("trigger"),children:[e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[300px]",x==="trigger"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("StartWhen")}),e.jsx(oe,{})]}),e.jsx("div",{className:"p-3 bg-bg-surface-secondary rounded-xl",children:e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("NewProductIsAddedToPC")})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("Then")})})]}),e.jsx($,{width:290,className:"right-7 absolute bottom-[-105px] z-[3]"})]}),e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>g("condition"),children:[e.jsx("div",{className:"w-full h-full absolute top-0 left-0 z-[4]"}),e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[300px] relative z-[2]",x==="condition"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between ml-3",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("CheckIf")}),e.jsx(te,{})]}),e.jsxs("div",{className:"p-3 bg-bg-surface-secondary rounded-xl",children:[e.jsx(t,{as:"p",variant:"bodyMd",children:i("ApplyToProductOfSupplier")}),e.jsx("div",{className:"capitalize",children:e.jsx(t,{as:"p",variant:"bodyMd",children:c.conditions?.[0].value.split(",").filter(s=>s!=="zopi").map(s=>s.trim()).join(", ")})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("Then")})})]}),e.jsx($,{width:290,className:"right-7 absolute bottom-[-105px] z-[3]"})]}),e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>g("action"),children:[e.jsx("div",{className:"w-full h-full absolute top-0 left-0 z-[4]"}),e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[300px]",x==="action"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between ml-3",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("DoThis")}),e.jsx(se,{})]}),e.jsxs("div",{className:"grid gap-4 p-3 bg-bg-surface-secondary rounded-xl",children:[e.jsxs("div",{children:[e.jsx(t,{as:"p",variant:"bodyMd",children:i("Re
4writeProductTitle")}),e.jsxs("div",{className:"capitalize",children:[e.jsxs(t,{as:"span",variant:"bodyMd",children:[i("Language"),": ",_e.find(s=>s.language===C?.value)?.name]}),!!N&&e.jsxs(t,{as:"span",variant:"bodyMd",children:[", ",i("Style"),": ",N?.style,", ",i("Tone"),": ",N?.tone]})]})]}),!!a&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:"AND"}),e.jsx(t,{as:"p",variant:"bodyMd",children:"Delete all supplierâs images in description"})]}),!!y&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:"AND"}),e.jsx(t,{as:"p",variant:"bodyMd",children:"Generate meta description"})]}),!!n&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:"AND"}),e.jsx(t,{as:"p",variant:"bodyMd",children:"Generate meta title"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("Finish")})})]})]})]}),e.jsx("div",{className:"h-full bg-white flex items-end",children:e.jsxs("div",{className:"items-end flex gap-4 px-4 py-3 *:!flex-1 flex-1 border-t border-border",children:[e.jsx(M,{variant:"secondary",loading:v,disabled:v,onClick:m,children:i("ResetToDefault")}),e.jsx(M,{variant:"primary",onClick:()=>{_(s=>{const l={...s,is_enable:!s.is_enable};return d(!s.is_enable),l})},children:i(c.is_enable?"TurnOffFlow":"TurnOnFlow")})]})})]})}),e.jsxs(J,{width:1072,zIndex:177,className:"msui-drawer__notification",visible:!!x,onClose:()=>g(""),children:[x==="trigger"&&e.jsx(he,{className:"rounded-tl-none",onClose:()=>g("")}),x==="condition"&&e.jsx(Be,{className:"rounded-tl-none",setLoading:o,onClose:()=>g("")}),x==="action"&&e.jsx(Le,{className:"rounded-tl-none",setLoading:o,onClose:()=>g("")})]})]})}const ps=p.forwardRef(({onClose:f},j)=>{const{t:r}=P(),{token:i}=U(),{isMobile:k}=X(),[v,h]=p.useState(!1),[x,g]=p.useState("trigger"),[S,o]=p.useState(!1),[c,_]=p.useState(!1),[N,C]=R(ae),y=N.actions?.find(u=>u.key==="rewrite_content"),n=N.actions?.find(u=>u.key==="rewrite_language"),a=N.actions?.find(u=>u.key==="generate_meta_description")?.value,d=N.actions?.find(u=>u.key==="generate_meta_title")?.value,m=N.actions?.find(u=>u.key==="delete_supplier_images_description")?.value,s=()=>{requestAnimationFrame(()=>{h(!1),f?.()})};p.useImperativeHandle(j,()=>({onOpen:()=>{h(!0)}}));const l=async u=>{o(!0),await I.putUpdateStatusAutomationWriting({is_enable:u},i),o(!1)},b=async()=>{const u={conditions:[{key:"product_source",value:"aliexpress,ebay,amazon,unlinked"},{key:"product_status",value:"all"}],actions:[{key:"rewrite_language",value:"en"},{key:"rewrite_content",style:"highlight",tone:"persuasive",value:"recommend_style_tone"},{key:"generate_meta_description",value:!0},{key:"generate_meta_title",value:!0}],is_enable:!1};C(u),_(!0),await I.putAutomationWriting(u,i),_(!1)};return k?e.jsx(us,{open:v,loading:S,onClose:()=>{h(!1),f?.()}}):e.jsxs(J,{width:1072,zIndex:176,className:"msui-drawer__notification",visible:v,onClose:s,children:[e.jsx(Se,{children:e.jsxs("div",{className:"flex items-start justify-between px-4 py-6 border bg-bg-surface border-border",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(M,{icon:L,onClick:s,variant:"tertiary"}),e.jsxs("div",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(t,{as:"p",variant:"headingLg",fontWeight:"semibold",children:r("RewriteProductContent")}),N.is_enable?e.jsx(V,{tone:"success",children:r("Active")}):e.jsx(V,{children:r("Inactive")})]}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:r("SystemPrebuilt")})]})]}),e.jsx(ee,{permissions:[F.VIEW_ACTION_AUTOMATION_REWRITE_PRODUCT_CONTENT],children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ie,{align:"center",gap:"050",blockAlign:"center",children:[S?e.jsx(pe,{size:"small"}):e.jsx(G,{source:me,tone:"subdued"}),e.jsx(t,{as:"span",tone:"subdued",children:S?"Saving...":"Saved"})]}),e.jsx(M,{variant:"secondary",loading:c,disabled:c,onClick:b,children:r("ResetToDefault")}),e.jsx(M,{variant:"primary",onClick:()=>{C(u=>{const O={...u,is_enable:!u.is_enable};return l(!u.is_enable),O})},children:r(N.is_enable?"TurnOffFlow":"TurnOnFlow")})]})})]})}),e.jsx("div",{className:"pt-4 pl-4 h-[calc(100%-96px)]",children:e.jsxs("div",{className:"grid grid-cols-[1fr_460px] h-full",children:[e.jsxs("div",{className:"flex flex-col gap-[72px] items-center mb-6",children:[e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>g("trigger"),children:[e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[350px]",x==="trigger"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("StartWhen")}),e.jsx(oe,{})]}),e.jsx("div",{className:"p-3 bg-bg-surface-secondary rounded-xl",children:e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:r("NewProductIsAddedToPC")})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("Then")})})]}),e.jsx($,{className:"right-7 absolute bottom-[-105px] z-[3]"})]}),e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>g("condition"),children:[e.jsx("div",{className:"w-full h-full absolute top-0 left-0 z-[4]"}),e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[350px] relative z-[2]",x==="condition"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between ml-3",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("CheckIf")}),e.jsx(te,{})]}),e.jsxs("div",{className:"p-3 bg-bg-surface-secondary rounded-xl",children:[e.jsx(t,{as:"p",variant:"bodyMd",children:r("ApplyToProductOfSupplier")}),e.jsx("div",{className:"capitalize",children:e.jsx(t,{as:"p",variant:"bodyMd",children:N.conditions?.[0].value.split(",").filter(u=>u!=="zopi").map(u=>u.trim()).join(", ")})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("Then")})})]}),e.jsx($,{className:"right-7 absolute bottom-[-105px] z-[3]"})]}),e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>g("action"),children:[e.jsx("div",{className:"w-full h-full absolute top-0 left-0 z-[4]"}),e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[350px]",x==="action"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between ml-3",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("DoThis")}),e.jsx(se,{})]}),e.jsxs("div",{className:"grid gap-4 p-3 bg-bg-surface-secondary rounded-xl",children:[e.jsxs("div",{children:[e.jsx(t,{as:"p",variant:"bodyMd",children:r("RewriteProductTitle")}),e.jsxs("div",{className:"capitalize",children:[e.jsxs(t,{as:"span",variant:"bodyMd",children:[r("Language"),":"," ",_e.find(u=>
4u.language===(n?.value||"en"))?.name]}),y?y.value==="custom_style"&&y?.custom_instruction?e.jsxs(t,{as:"span",variant:"bodyMd",children:[", ",r("Style"),": ",y?.custom_instruction]}):e.jsxs(t,{as:"span",variant:"bodyMd",children:[", ",r("Style"),": ",y?.style,", ",r("Tone"),": ",y?.tone]}):null]})]}),!!m&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:"AND"}),e.jsx(t,{as:"p",variant:"bodyMd",children:"Delete all supplierâs images in description"})]}),!!a&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:"AND"}),e.jsx(t,{as:"p",variant:"bodyMd",children:"Generate meta description"})]}),!!d&&e.jsxs("div",{className:"grid gap-4",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:"AND"}),e.jsx(t,{as:"p",variant:"bodyMd",children:"Generate meta title"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("Finish")})})]})]})]}),x==="trigger"&&e.jsx(he,{}),x==="condition"&&e.jsx(Be,{setLoading:o}
4),x==="action"&&e.jsx(Le,{setLoading:o})]})})]})}),Se=Re.div` 5 & > .Polaris-Box:first-child { 6 position: sticky !important; 7 top: 0; 8 z-index: 199; 9 background-color: rgb(246, 246, 247); 10 } 11`;function ms({open:f,loading:j,onClose:r}){const{t:i}=P(),{token:k}=U(),[v,h]=p.useState(""),[x,g]=p.useState(!1),[S,o]=R(ne),[c,_]=p.useState(!1),N=async y=>{g(!0),await I.putUpdateStatusAutomationImage({is_enable:y},k),g(!1)},C=async()=>{const y={conditions:[{key:"product_source",value:"aliexpress,zopi,ebay,amazon,unlinked"},{key:"product_status",value:"all"}],actions:[{key:"enhance_product_media",value:"product_thumbnail",enhance_list:["resize_ratio_1_1","boost_resolution","convert_to_webp","cleanup_background"]}],is_enable:!1};o(y),_(!0),await I.putAutomationImage(y,k),_(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(J,{width:1072,zIndex:176,className:"msui-drawer__notification",visible:f,onClose:()=>{r(),h("")},children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs(Se,{className:"px-4 py-3 flex gap-2 items-center bg-white",children:[e.jsx(M,{icon:L,onClick:()=>{r(),h("")},variant:"tertiary"}),e.jsx(t,{as:"h3",variant:"headingMd",children:i("OptimizeProductImages")}),S.is_enable?e.jsx(V,{tone:"success",children:i("Active")}):e.jsx(V,{children:i("Inactive")}),e.jsx("div",{className:"ml-auto",children:e.jsxs(ie,{align:"center",gap:"050",blockAlign:"center",children:[x||j?e.jsx(pe,{size:"small"}):e.jsx(G,{source:me,tone:"subdued"}),e.jsx(t,{as:"span",tone:"subdued",children:x||j?"Saving...":"Saved"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-[72px] items-center py-4 pl-6 min-h-[calc(100vh-104px)] overflow-auto",children:[e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>h("trigger"),children:[e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[300px]",v==="trigger"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("StartWhen")}),e.jsx(oe,{})]}),e.jsx("div",{className:"p-3 bg-bg-surface-secondary rounded-xl",children:e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:i("NewProductIsAddedToPC")})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("Then")})})]}),e.jsx($,{width:290,className:"right-7 absolute bottom-[-105px] z-[3]"})]}),e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>h("condition"),children:[e.jsx("div",{className:"w-full h-full absolute top-0 left-0 z-[4]"}),e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[300px] relative z-[2]",v==="condition"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between ml-3",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("CheckIf")}),e.jsx(te,{})]}),e.jsxs("div",{className:"p-3 bg-bg-surface-secondary rounded-xl",children:[e.jsx(t,{as:"p",variant:"bodyMd",children:i("ApplyToProductOfSupplier")}),e.jsx("div",{className:"capitalize",children:e.jsx(t,{as:"p",variant:"bodyMd",children:S.conditions?.[0].value.split(",").filter(y=>y!=="zopi").map(y=>y.trim()).join(", ")})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("Then")})})]}),e.jsx($,{width:290,className:"right-7 absolute bottom-[-105px] z-[3]"})]}),e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>h("action"),children:[e.jsx("div",{className:"w-full h-full absolute top-0 left-0 z-[4]"}),e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[300px]",v==="action"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between ml-3",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("DoThis")}),e.jsx(se,{})]}),e.jsx("div",{className:"grid gap-4 p-3 bg-bg-surface-secondary rounded-xl",children:e.jsxs("div",{children:[e.jsx(t,{as:"p",variant:"bodyMd",children:"Enhance product media"}),e.jsx("div",{className:"capitalize",children:e.jsx(t,{as:"p",variant:"bodyMd",children:S.actions?.[0]?.enhance_list.map(y=>
11(y.charAt(0).toUpperCase()+y.slice(1).toLowerCase()).replaceAll("_"," ")).join(", ")})})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:i("Finish")})})]})]})]}),e.jsx("div",{className:"h-full bg-white flex items-end",children:e.jsxs("div",{className:"items-end flex gap-4 px-4 py-3 *:!flex-1 flex-1 border-t border-border",children:[e.jsx(M,{variant:"secondary",loading:c,disabled:c,onClick:C,children:i("ResetToDefault")}),e.jsx(M,{variant:"primary",onClick:()=>{o(y=>{const n={...y,is_enable:!y.is_enable};return N(!y.is_enable),n})},children:i(S.is_enable?"TurnOffFlow":"TurnOnFlow")})]})})]})}),e.jsxs(J,{width:1072,zIndex:177,className:"msui-drawer__notification",visible:!!v,onClose:()=>h(""),children:[v==="trigger"&&e.jsx(he,{className:"rounded-tl-none",onClose:()=>h("")}),v==="condition"&&e.jsx(Ue,{className:"rounded-tl-none",setLoading:g,onClose:()=>h("")}),v==="action"&&e.jsx(Fe,{className:"rounded-tl-none",setLoading:g,onClose:()=>h("")})]})]})}const hs=p.forwardRef(({onClose:f},j)=>{const{t:r}=P(),{token:i}=U(),{isMobile:k}=X(),[v,h]=p.useState(!1),[x,g]=p.useState("trigger"),[S,o]=p.useState(!1),[c,_]=p.useState(!1),[N,C]=R(ne),y=async d=>{o(!0),await I.putUpdateStatusAutomationImage({is_enable:d},i),o(!1)},n=async()=>{const d={conditions:[{key:"product_source",value:"aliexpress,ebay,amazon,unlinked"},{key:"product_status",value:"all"}],actions:[{key:"enhance_product_media",value:"product_thumbnail",enhance_list:["resize_ratio_1_1","boost_resolution","convert_to_webp","cleanup_background"]}],is_enable:!1};C(d),_(!0),await I.putAutomationImage(d,i),_(!1)},a=()=>{requestAnimationFrame(()=>{h(!1),f?.()})};return p.useImperativeHandle(j,()=>({onOpen:()=>{h(!0)}})),k?e.jsx(ms,{open:v,loading:S,onClose:a}):e.jsxs(J,{width:1072,zIndex:176,className:"msui-drawer__notification",visible:v,onClose:a,children:[e.jsx(xs,{children:e.jsxs("div",{className:"flex items-start justify-between px-4 py-6 border bg-bg-surface border-border",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(M,{icon:L,onClick:a,variant:"tertiary"}),e.jsxs("div",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(t,{as:"p",variant:"headingLg",fontWeight:"semibold",children:r("FormatProductImages")}),N.is_enable?e.jsx(V,{tone:"success",children:r("Active")}):e.jsx(V,{children:r("Inactive")})]}),e.jsx(t,{as:"p",variant:"bodySm",tone:"subdued",children:r("SystemPrebuilt")})]})]}),e.jsx(ee,{permissions:[F.VIEW_ACTION_AUTOMATION_FORMAT_PRODUCT_IMAGES],children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ie,{align:"center",gap:"050",blockAlign:"center",children:[S?e.jsx(pe,{size:"small"}):e.jsx(G,{source:me,tone:"subdued"}),e.jsx(t,{as:"span",tone:"subdued",children:S?"Saving...":"Saved"})]}),e.jsx(M,{variant:"secondary",loading:c,disabled:c,onClick:n,children:r("ResetToDefault")}),e.jsx(M,{variant:"primary",onClick:()=>{C(d=>{const m={...d,is_enable:!d.is_enable};return y(!d.is_enable),m})},children:r(N.is_enable?"TurnOffFlow":"TurnOnFlow")})]})})]})}),e.jsx("div",{className:"pt-4 pl-4 h-[calc(100%-96px)]",children:e.jsxs("div",{className:"grid grid-cols-[1fr_460px] h-full",children:[e.jsxs("div",{className:"flex flex-col gap-[72px] items-center",children:[e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>g("trigger"),children:[e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[350px]",x==="trigger"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("StartWhen")}),e.jsx(oe,{})]}),e.jsx("div",{className:"p-3 bg-bg-surface-secondary rounded-xl",children:e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:r("NewProductIsAddedToPC")})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("Then")})})]}),e.jsx($,{className:"right-7 absolute bottom-[-105px] z-[3]"})]}),e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>g("condition"),children:[e.jsx("div",{className:"w-full h-full absolute top-0 left-0 z-[4]"}),e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[350px] relative z-[2]",x==="condition"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between ml-3",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("CheckIf")}),e.jsx(te,{})]}),e.jsxs("div",{className:"p-3 bg-bg-surface-secondary rounded-xl",children:[e.jsx(t,{as:"p",variant:"bodyMd",children:r("ApplyToProductOfSupplier")}),e.jsx("div",{className:"capitalize",children:e.jsx(t,{as:"p",variant:"bodyMd",children:N.conditions?.[0].value.split(",").filter(d=>d!=="zopi").map(d=>d.trim()).join(", ")})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("Then")})})]}),e.jsx($,{className:"right-7 absolute bottom-[-105px] z-[3]"})]}),e.jsxs("div",{className:"relative cursor-pointer",onClick:()=>g("action"),children:[e.jsx("div",{className:"w-full h-full absolute top-0 left-0 z-[4]"}),e.jsxs("div",{className:w("p-4 border-2 border-border rounded-xl bg-bg-surface grid gap-3 w-[350px]",x==="action"&&"border-[#005BD3]"),children:[e.jsxs("div",{className:"flex items-center justify-between ml-3",children:[e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("DoThis")}),e.jsx(se,{})]}),e.jsx("div",{className:"grid gap-4 p-3 bg-bg-surface-secondary rounded-xl",children:e.jsxs("div",{children:[e.jsx(t,{as:"p",variant:"bodyMd",children:"Enhance product media"}),e.jsx("div",{className:"capitalize",children:e.jsx(t,{as:"p",variant:"bodyMd",children:N.actions?.[0]?.enhance_list.map(d=>(d.charAt(0).toUpperCase()+d.slice(1).toLowerCase()).replaceAll("_"," ")).join(", ")})})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:r("Finish")})})]})]})]}),x==="trigger"&&e.jsx(he,{}
11),x==="condition"&&e.jsx(Ue,{setLoading:o}),x==="action"&&e.jsx(Fe,{setLoading:o})]})})]})}),xs=Re.div` 12 & > .Polaris-Box:first-child { 13 position: sticky !important; 14 top: 0; 15 z-index: 199; 16 background-color: rgb(246, 246, 247); 17 } 18`,gs=()=>{const{t:f}=P(),[j]=ss(),{getSetting:r}=De(),i=r().automationFlow,{isFetching:k}=Ee(),{hasPermission:v}=$e(),[h,x]=p.useState();es(Ze),Ce(ne),Ce(ae);const g=p.useRef(null),S=p.useRef(null),o=p.useRef(null);p.useEffect(()=>{j.get("open")==="true"&&g.current&&g.current?.onOpen()},[j]);const c=v([F.VIEW_ACTION_AUTOMATION_FULFILL_PENDING_ORDERS]);v([F.VIEW_ACTION_AUTOMATION_REWRITE_PRODUCT_CONTENT]),v([F.VIEW_ACTION_AUTOMATION_FORMAT_PRODUCT_IMAGES]);const _=()=>c?e.jsxs(q.Row,{id:"1",position:1,onClick:()=>g.current?.onOpen(),children:[e.jsx(q.Cell,{children:e.jsxs(ie,{gap:"200",blockAlign:"center",children:[e.jsx(le,{children:e.jsx(G,{source:rs})}),e.jsxs(z,{children:[e.jsx(t,{as:"span",variant:"bodyMd",fontWeight:"medium",children:f("FulfillPendingOrders")}),e.jsx(t,{as:"span",variant:"bodySm",tone:"subdued",children:f("SystemPrebuilt")})]})]},"flow-name")}),e.jsx(q.Cell,{children:k?"-":e.jsx(qe,{tone:i.status?"success":void 0,children:`${i.status?f("Active"):f("Inactive")}`})}),e.jsx(q.Cell,{children:i.updated_at?`${ue(i.updated_at).format("MMM DD ")} at ${ue(i.updated_at).format("HH:mm")}`:"-"}),e.jsx(q.Cell,{children:i.last_activity_at?`${ue(i.last_activity_at).format("MMM DD ")} at ${ue(i.last_activity_at).format("HH:mm")}`:"-"}),e.jsx(q.Cell,{children:e.jsx(bs,{error:i.error})})]}):null;return e.jsxs(e.Fragment,{children:[e.jsx(fe,{padding:"0",children:e.jsx(q,{headings:[{id:"Flow",alignment:"start",title:f("Flow")},{id:"Status",alignment:"start",title:f("Status")},{id:"Last updated",alignment:"start",title:f("LastUpdated")},{id:"Last run",alignment:"start",title:f("LastRun")},{id:"",alignment:"start",title:""}],itemCount:1,selectable:!1,children:_()})}),e.jsx(ps,{ref:S}),e.jsx(hs,{ref:o}),e.jsx(is,{ref:g})]})},bs=({error:f})=>{const{t:j}=P(),[r,i]=p.useState(!1),k=ls(),v=()=>{switch(f){case"PAYMENT_METHOD_INVALID":return e.jsxs(z,{gap:"200",children:[e.jsx(t,{as:"p",variant:"bodyMd",fontWeight:"medium",children:j("PaymentMethodIsInvalid")}),e.jsx(t,{as:"p",variant:"bodySm",children:j("ThisCouldBeDueToIncorrectCardDetailsInsufficientFundsAnExpiredOrRestrictionsOnTheCurrentMethod")}),e.jsx(Q,{size:"slim",onClick:()=>k(ve.GENERAL_SETTING.SUBROUTES.WALLET.PATH),children:j("UpdatePaymentMethod")})]});default:return e.jsx(e.Fragment,{children:"Error"})}};return f?e.jsxs(Ke,{active:r,onClose:()=>i(!1),preferredPosition:"mostSpace",activator:e.jsx("div",{onClick:h=>{h.stopPropagation(),i(x=>!x)},children:e.jsx(G,{source:os,tone:"warning"})}),children:[" ",e.jsx(le,{width:"270px",padding:"400",children:v()})]}):e.jsx(e.Fragment,{})},vs=()=>{const{t:f}=P(),{isMobile:j}=X(),{fetchOrderAutomation:r}=De(),{fetchGetPaymentInfo:i}=Ye(),{fetchAutomationProduct:k}=Ee();return p.useEffect(()=>{r(),i(),k()},[]),e.jsxs(z,{...j?{gap:"0"}:{gap:"200"},children:[j&&e.jsx(Je,{title:f(ve.GENERAL_SETTING.SUBROUTES.AUTOMATION.TITLE),backUrl:ve.GENERAL_SETTING.PATH}),e.jsx(le,{...j?{padding:"400"}:{},children:e.jsxs(z,{gap:"400",children:[e.jsx(fe,{roundedAbove:"xs",children:e.jsxs(z,{gap:"400",children:[e.jsxs(z,{gap:"100",children:[e.jsx(t,{as:"span",variant:"headingSm",fontWeight:"semibold",children:f("AutomationInsideZopi")}),e.jsxs(t,{as:"span",variant:"bodyMd",tone:"subdued",children:[f("SaveTimeAndReduceManualWorkWithReadytouseAutomationsThatRunDirectlyInsideZopi")," ",e.jsx(Xe,{url:Qe.ORDER_AUTOMATION,target:"_blank",children:f("LearnMore")})]})]}),e.jsx(gs,{})]})}),e.jsx(fe,{roundedAbove:"xs",children:e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxs(z,{gap:"500",children:[e.jsxs(z,{gap:"200",children:[e.jsx(t,{as:"p",variant:"headingSm",fontWeight:"semibold",children:f("AutomationBeyondZopiViaShopifyFlow")}),e.jsx(t,{as:"p",variant:"bodyMd",tone:"subdued",children:f("TheseAutomationsConnectZopiWithShopifyFlowToAutomateActionsAcrossYourWholeStoreIdealForStreamliningFulfillmentAndProductOperations")})]}),e.jsx("div",{className:"w-fit",children:e.jsx(M,{variant:"secondary",disabled:!0,children:f("ComingSoon")})})]}),e.jsx("img",{src:"https://cdn.shopify.com/s/assets/admin/checkout/settings-customizecart-705f57c725ac05be5a34ec20c05b94298cb8afd10aac7bd9c7ad02030f48cfa0.svg",alt:"Shopify Flow",className:"w-[100px]"})]})})]})})]})},Ha=()=>e.jsx(vs,{});export{Ha as default};
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.