1import{j as e}from"./CheveronLeft-BLchON5X.js";import{r as s}from"./useCartUpsells-oN76HI6E.js";import{u as j}from"./CartContext-CPmp6VK2.js";import"./index-kA4PVysc.js";import"./ShopifyCart-LdCOHsRZ.js";import"./tenderCoupons-ClMQo-uT.js";import"./tenderCoupon-B4fpH8v8.js";import"./events-Dm1k7AS7.js";const z=()=>{const{note:a,updateNote:x}=j(),[o,f]=s.useState(!1),[c,d]=s.useState(a||""),[u,m]=s.useState(!1),[h,i]=s.useState(!1),t=s.useRef(null),r=s.useRef(null);s.useEffect(()=>{d(a||"")},[a]),s.useEffect(()=>()=>{t.current&&clearTimeout(t.current),r.current&&clearTimeout(r.current)},[]);const p=async n=>{if(n!==a){m(!0);try{await x(n),i(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{i(!1)},2e3)}catch(l){console.error("Failed to save gift note:",l)}finally{m(!1)}}},v=n=>{const l=n.target.value;d(l),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{p(l)},800)},g=()=>{f(!o),i(!1)};return e.jsxs("div",{className:"border-t border-black/10 px-6 py-4",children:[e.jsxs("button",{type:"button",onClick:g,className:"flex items-center justify-between w-full text-left group","aria-expanded":o,"aria-controls":"gift-note-form",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"})}),e.jsx("span",{className:"body-md font-medium",children:"Add a gift note"})]}),e.jsx("svg",{className:`w-4 h-4 transition-transform ${o?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),o&&e.jsxs("div",{id:"gift-note-form",className:"mt-4 space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{value:c,onChange:v,placeholder:"Add a personalized message to your order...",className:"w-full px-4 py-3 border border-black/20 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-black/20 body-sm",rows:"3",maxLength:"250"}),e.jsxs("div",{className:"absolute bottom-2 right-2 text-xs text-black/40",children:[c.length,"/250"]})]}),e.jsxs("div",{className:"h-5 flex items-center",children:[u&&e.jsxs("div",{className:"flex items-center gap-2 text-black/60",children:[e.jsxs("svg",{className:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),e.jsx("span",{className:"body-xs",children:"Saving..."})]}),h&&!u&&e.jsxs("div",{className:"flex items-center gap-2 text-moss animate-fade-in",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),e.jsx("span",{className:"body-xs",children:"Saved"})]})]})]})]})};export{z as G};
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.