import{r as o,c as i,h as r}from"./p-b891c2f1.js";import{o as s}from"./p-494248b1.js";import{_ as t}from"./p-684c85b4.js";import"./p-aafd8ea4.js";import"./p-112455b1.js";const n=class{constructor(r){o(this,r),this.scApplyCoupon=i(this,"scApplyCoupon",7)}handleErrorsChange(){var o;const i=((null===(o=null==this?void 0:this.error)||void 0===o?void 0:o.additional_errors)||[]).find((o=>{var i;return"discount.promotion_code"===(null===(i=null==o?void 0:o.data)||void 0===i?void 0:i.attribute)}));this.errorMessage=(null==i?void 0:i.message)?null==i?void 0:i.message:""}render(){var o,i,s,n;return r("sc-coupon-form",{label:this.label,loading:this.loading&&!(null===(o=this.order)||void 0===o?void 0:o.id),busy:this.busy,error:this.errorMessage,discount:null===(i=null==this?void 0:this.order)||void 0===i?void 0:i.discount,currency:null===(s=null==this?void 0:this.order)||void 0===s?void 0:s.currency,"discount-amount":null===(n=null==this?void 0:this.order)||void 0===n?void 0:n.discount_amount},r("slot",null,t("Apply Coupon","surecart")))}static get watchers(){return{error:["handleErrorsChange"]}}};s(n,["loading","busy","order","error"],!1),n.style=":host{display:block}.coupon-form{position:relative}.form{opacity:0;visibility:hidden;height:0;transition:opacity var(--sc-transition-fast) ease-in-out}.coupon-form--is-open .form{opacity:1;visibility:visible;height:auto;margin-top:var(--sc-spacing-small);display:grid;gap:var(--sc-spacing-small)}.coupon-form--is-open .trigger{color:var(--sc-input-label-color)}.coupon-form--is-open .trigger:hover{text-decoration:none}.trigger{cursor:pointer;font-size:var(--sc-font-size-small);color:var(--sc-color-gray-500);user-select:none}.trigger:hover{text-decoration:underline}";export{n as sc_order_coupon_form}