@foxy.io/elements 1.23.0-beta.3 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/shared-2756a4f0.js +64 -0
- package/dist/cdn/shared-79d0699c.js +1 -0
- package/dist/cdn/translations/template-config-form/en.json +1 -1
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js +2 -0
- package/dist/elements/public/EmailTemplateForm/EmailTemplateForm.js.map +1 -1
- package/dist/elements/public/QueryBuilder/QueryBuilder.js +9 -2
- package/dist/elements/public/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/elements/public/QueryBuilder/components/Input.js +12 -9
- package/dist/elements/public/QueryBuilder/components/Input.js.map +1 -1
- package/dist/elements/public/QueryBuilder/utils/parse.js +2 -0
- package/dist/elements/public/QueryBuilder/utils/parse.js.map +1 -1
- package/dist/elements/public/QueryBuilder/utils/stringify.js +31 -9
- package/dist/elements/public/QueryBuilder/utils/stringify.js.map +1 -1
- package/dist/elements/public/TemplateForm/TemplateForm.js +2 -0
- package/dist/elements/public/TemplateForm/TemplateForm.js.map +1 -1
- package/dist/utils/serialize-date.d.ts +1 -1
- package/dist/utils/serialize-date.js +7 -6
- package/dist/utils/serialize-date.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-29aa4bca.js +0 -64
- package/dist/cdn/shared-bc7f58ef.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-cb6f2388.js";import"./shared-ca58ef47.js";import"./shared-e28f16db.js";import{L as t,h as e}from"./shared-7f33a83a.js";import{T as a,S as s,a as r}from"./shared-16b542bc.js";import{c as i}from"./shared-4e709717.js";import{p as n,W as o}from"./shared-380db651.js";import{s as d}from"./shared-
|
|
1
|
+
import"./shared-cb6f2388.js";import"./shared-ca58ef47.js";import"./shared-e28f16db.js";import{L as t,h as e}from"./shared-7f33a83a.js";import{T as a,S as s,a as r}from"./shared-16b542bc.js";import{c as i}from"./shared-4e709717.js";import{p as n,W as o}from"./shared-380db651.js";import{s as d}from"./shared-79d0699c.js";import"./shared-0479553e.js";import"./foxy-spinner.js";import"./shared-86768244.js";import"./shared-c40d85dc.js";import"./shared-6f465111.js";import"./shared-ee13d1a6.js";import"./shared-9e60ef60.js";import"./shared-6b53ef85.js";import"./shared-aeec3cab.js";import"./shared-b95ef318.js";import"./shared-f3f5e87e.js";import"./shared-068480a3.js";import"./shared-0543c6e0.js";import{G as l}from"./shared-08ff9a8d.js";import"./shared-4c9f96ec.js";import{C as h}from"./shared-de790de9.js";import{N as c}from"./shared-eb900735.js";import{i as m}from"./shared-d3bf9ac0.js";import"./shared-7a290f36.js";import"./shared-98755831.js";import"./shared-a8cf402a.js";import"./shared-64657919.js";import"./shared-e5c19ea3.js";import"./shared-11c2efc8.js";import"./shared-a89cb472.js";import"./shared-509a2f52.js";import"./shared-cd096e97.js";import"./shared-4db2c7b1.js";import"./shared-d6276c83.js";let u,p,g,f,b,v=t=>t;class _ extends(a(t)){constructor(){super(...arguments),this.checkAvailability=()=>!0,this.readonly=!1,this.disabled=!1,this.value="",this.start="",this.lang=""}static get properties(){return{checkAvailability:{attribute:!1},readonly:{type:Boolean,reflect:!0},disabled:{type:Boolean,reflect:!0},value:{type:String},start:{type:String},lang:{type:String}}}render(){var t,a;const s=new Date(null!==(a=null!==(t=this.__startAsDate)&&void 0!==t?t:this.__valueAsDate)&&void 0!==a?a:Date.now()),r=new Date(s),n=new Date(s),o=this.lang||navigator.language;return r.setMonth(r.getMonth()-1),n.setMonth(n.getMonth()+1),e(u||(u=v` <div class="text-m text-body font-lumo leading-m"> <div class="grid p-xs" style="grid-template:auto/max-content auto max-content"> <vaadin-button data-testid="prev" aria-label="${0}" theme="icon tertiary" class="px-xs" ?disabled="${0}" @click="${0}"> <iron-icon icon="icons:chevron-left"></iron-icon> </vaadin-button> <span data-testid="month" class="${0}"> ${0} </span> <vaadin-button data-testid="next" aria-label="${0}" theme="icon tertiary" class="px-xs" ?disabled="${0}" @click="${0}"> <iron-icon icon="icons:chevron-right"></iron-icon> </vaadin-button> </div> ${0} </div> `),r.toLocaleString(o,{year:"numeric",month:"long"}),this.disabled,this.__handlePrevButtonClick,i({"text-center self-center font-medium":!0,"text-disabled":this.disabled}),s.toLocaleDateString(o,{month:"long",year:"numeric"}),n.toLocaleString(o,{year:"numeric",month:"long"}),this.disabled,this.__handleNextButtonClick,this.__renderMonth(s.getMonth(),s.getFullYear()))}get __valueAsDate(){return n(this.value)}set __valueAsDate(t){this.value=t?d(t):""}get __startAsDate(){return n(this.start)}set __startAsDate(t){this.start=t?d(t):""}__renderMonth(t,a){var s,r,n;const o=this.lang||navigator.language,d=new Date(a,t,1,0,0,0,0),l=[];for(let t=0;t<7;++t){const a=new Date;for(;a.getDay()!==t;)a.setDate(a.getDate()+1);l.push(e(p||(p=v` <span class="${0}"> ${0} </span> `),i({"self-center text-xxs uppercase font-medium tracking-wider":!0,"text-secondary":!this.disabled,"text-disabled":this.disabled}),a.toLocaleString(o,{weekday:"short"})))}for(;d.getMonth()===t;){const i=d.getFullYear()===(null===(s=this.__valueAsDate)||void 0===s?void 0:s.getFullYear())&&d.getMonth()===(null===(r=this.__valueAsDate)||void 0===r?void 0:r.getMonth())&&d.getDate()===(null===(n=this.__valueAsDate)||void 0===n?void 0:n.getDate());l.push(e(g||(g=v` <div style="grid-column:${0}" data-testclass="day-of-month"> ${0} </div> `),d.getDay()+1,this.__renderDate(d.getDate(),t,a,i))),d.setDate(d.getDate()+1)}return e(f||(f=v` <form data-testid="grid" class="grid gap-s p-s text-center" style="grid-template:auto/repeat(7,1fr)"> ${0} </form> `),l)}__renderDate(t,a,s,r=!1){const n=this.disabled||this.readonly||!this.checkAvailability(new Date(s,a,t));return e(b||(b=v` <label class="${0}"> <input name="date" type="radio" value="${0}" class="sr-only" ?disabled="${0}" @change="${0}"> ${0} </label> `),i({"font-tnum select-none relative flex h-m items-center justify-center rounded":!0,"cursor-pointer focus-within-ring-2 focus-within-ring-primary-50":!n,"bg-contrast-5 hover-bg-contrast-10":!r&&!n,"bg-primary text-primary-contrast":r&&!n,"border border-dashed border-contrast-20 text-disabled":!r&&n,"border border-dashed border-primary text-primary":r&&n}),t,this.readonly||this.disabled||n,(()=>{this.__valueAsDate=new Date(s,a,t),this.dispatchEvent(new CustomEvent("change"))}),t)}__handlePrevButtonClick(){var t;const e=null!==(t=this.__startAsDate)&&void 0!==t?t:new Date;this.__startAsDate=new Date(e.setMonth(e.getMonth()-1))}__handleNextButtonClick(){var t;const e=null!==(t=this.__startAsDate)&&void 0!==t?t:new Date;this.__startAsDate=new Date(e.setMonth(e.getMonth()+1))}}customElements.define("foxy-internal-calendar",_);let y,x,$,D,j=t=>t;const w=s(a(h(r(c,"cancellation-form"))));class S extends w{constructor(){super(...arguments),this.templates={},this.__renderWarning=()=>{const{lang:t,ns:a}=this;return e(y||(y=j` <div> ${0} <x-warning> <foxy-i18n data-testid="warning" class="${0}" lang="${0}" key="end_subscription_explainer" ns="${0}"> </foxy-i18n> </x-warning> ${0} </div> `),this.renderTemplateOrSlot("warning:before"),i({"text-disabled":!this.in({idle:"snapshot"})}),t,a,this.renderTemplateOrSlot("warning:after"))},this.__renderEndDate=()=>{var t,a;const{constructor:s,lang:r,ns:n}=this,o=s.__tomorrow.getTime(),d=this.in({idle:"snapshot"});return e(x||(x=j` <div> ${0} <x-group frame> <foxy-i18n data-testid="end-date-label" class="${0}" slot="header" lang="${0}" key="end_date" ns="${0}"> </foxy-i18n> <foxy-internal-calendar data-testid="end-date" .checkAvailability="${0}" ?disabled="${0}" ?readonly="${0}" value="${0}" lang="${0}" @change="${0}"> </foxy-internal-calendar> </x-group> ${0} </div> `),this.renderTemplateOrSlot("end-date:before"),i({"text-disabled":!d}),r,n,(t=>t.getTime()>=o),!d||this.disabledSelector.matches("end-date",!0),!!(null===(t=this.data)||void 0===t?void 0:t.end_date)||this.readonlySelector.matches("end-date",!0),m(null!==(a=this.form.end_date)&&void 0!==a?a:void 0),r,(t=>{this.edit({end_date:t.target.value})}),this.renderTemplateOrSlot("end-date:after"))},this.__renderSubmit=()=>{const t=this.in({idle:{snapshot:{clean:"valid"}}})||this.in({idle:{snapshot:{dirty:"valid"}}});return e($||($=j` <div> ${0} <vaadin-button data-testid="submit" ?disabled="${0}" theme="primary error" class="w-full" @click="${0}"> <foxy-i18n ns="${0}" lang="${0}" key="end_subscription"></foxy-i18n> </vaadin-button> ${0} </div> `),this.renderTemplateOrSlot("submit:before"),!t||this.disabledSelector.matches("submit",!0),(()=>this.submit()),this.ns,this.lang,this.renderTemplateOrSlot("submit:after"))}}static get scopedElements(){return{"foxy-internal-calendar":customElements.get("foxy-internal-calendar"),"foxy-internal-sandbox":customElements.get("foxy-internal-sandbox"),"vaadin-button":customElements.get("vaadin-button"),"foxy-spinner":customElements.get("foxy-spinner"),"foxy-i18n":customElements.get("foxy-i18n"),"x-warning":o,"x-group":l}}static get v8n(){return[({end_date:t})=>!!t||"end_date_required"]}render(){var t,a;const s=this.hiddenSelector,r=this.in("busy"),n=this.in("fail");return e(D||(D=j` <div class="space-y-l font-lumo text-m text-body leading-m relative"> ${0} ${0} ${0} <div data-testid="spinner" class="${0}"> <foxy-spinner layout="vertical" class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l" state="${0}" lang="${0}" ns="${0} ${0}"> </foxy-spinner> </div> </div> `),s.matches("warning",!0)?"":this.__renderWarning(),s.matches("end-date",!0)?"":this.__renderEndDate(),s.matches("submit",!0)?"":this.__renderSubmit(),i({"transition duration-500 ease-in-out absolute inset-0 flex":!0,"opacity-0 pointer-events-none":!r&&!n}),n?"error":r?"busy":"empty",this.lang,this.ns,null!==(a=null===(t=customElements.get("foxy-spinner"))||void 0===t?void 0:t.defaultNS)&&void 0!==a?a:"")}submit(){if(!this.form.end_date){const t=this.constructor;this.edit({end_date:d(t.__tomorrow)})}super.submit()}static get __tomorrow(){const t=new Date;return t.setDate(t.getDate()+1),t.setHours(0,0,0,0),t}}customElements.define("foxy-cancellation-form",S);export{S as CancellationForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-23923638.js";import"./shared-03b39ec4.js";import"./shared-3a82d3f5.js";import{I as e}from"./shared-6fb923d5.js";import"./shared-1e5292a1.js";import"./foxy-applied-coupon-code-card.js";import"./foxy-applied-coupon-code-form.js";import"./foxy-custom-field-card.js";import"./foxy-custom-field-form.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-discount-card.js";import"./foxy-item-card.js";import"./foxy-item-form.js";import"./shared-86768244.js";import{I as t}from"./shared-5dd31b4e.js";import{_ as o,$ as i}from"./shared-98755831.js";import{c as r}from"./shared-4e709717.js";import{h as s}from"./shared-7f33a83a.js";import{R as n,a as l}from"./shared-16b542bc.js";import{i as a}from"./shared-d3bf9ac0.js";import{s as d}from"./shared-c7f56c90.js";import"./shared-0543c6e0.js";import"./shared-c40d85dc.js";import"./shared-7a290f36.js";import"./shared-4c9f96ec.js";import"./shared-4db2c7b1.js";import"./shared-e28f16db.js";import"./shared-b95ef318.js";import"./shared-0c02b4ee.js";import"./shared-509a2f52.js";import"./shared-64657919.js";import"./shared-cb6f2388.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-ca58ef47.js";import"./shared-a8cf402a.js";import"./shared-de790de9.js";import"./shared-eb900735.js";import"./shared-d6276c83.js";import"./shared-a89cb472.js";import"./shared-d519a301.js";import"./shared-11c2efc8.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./shared-0dc1d012.js";import"./shared-9e60ef60.js";import"./foxy-pagination.js";import"./shared-49d978e1.js";import"./shared-3a252ccd.js";import"./shared-c3c67413.js";import"./shared-dcbaa1c5.js";import"./shared-d493355a.js";import"./shared-0479553e.js";import"./shared-6f465111.js";import"./shared-ee13d1a6.js";import"./shared-aeec3cab.js";import"./shared-f3f5e87e.js";import"./shared-e5c19ea3.js";import"./shared-068480a3.js";import"./shared-6b53ef85.js";import"./shared-cd096e97.js";import"./shared-7bf46d6d.js";import"./shared-08ff9a8d.js";import"./shared-b88e35b7.js";import"./shared-939fc890.js";import"./shared-61a510d8.js";import"./foxy-discount-detail-card.js";import"./foxy-coupon-detail-card.js";import"./foxy-item-option-card.js";import"./foxy-item-option-form.js";import"./foxy-coupon-card.js";import"./foxy-discount-builder.js";import"./shared-e6f3e9f0.js";import"./shared-fbfb0943.js";import"./shared-9048c076.js";import"./shared-bc7f58ef.js";import"./shared-380db651.js";import"./foxy-subscription-card.js";import"./shared-bb009254.js";import"./foxy-subscription-form.js";import"./foxy-cancellation-form.js";import"./foxy-transaction-card.js";import"./foxy-customer-card.js";import"./shared-daf52401.js";import"./shared-b5517c1b.js";import"./shared-bfdbd733.js";let c,f,p=e=>e;customElements.define("foxy-internal-cart-form-view-as-customer-control",class extends t{constructor(){super(...arguments),this.__loader=null}static get properties(){return o(o({},super.properties),{},{__loader:{attribute:!1}})}renderControl(){var e,t;const o=null===(e=this.__loader)||void 0===e?void 0:e.state,i=null===(t=this.__loader)||void 0===t?void 0:t.result;return i?s(c||(c=p` <a target="_blank" class="flex h-m px-m rounded font-medium transition-colors text-body bg-contrast-5 hover-bg-contrast-10 items-center justify-center focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}"> <foxy-i18n infer="" key="state_idle"></foxy-i18n> </a> `),i):s(f||(f=p` <div class="${0}"> <foxy-i18n infer="" key="${0}"> </foxy-i18n> </div> `),r({"flex h-m px-m rounded items-center justify-center":!0,"transition-colors bg-contrast-5 font-medium":!0,"text-tertiary":"fail"!==o,"text-error":"fail"===o}),"fail"===o?"state_fail":"state_busy")}updated(e){var t;super.updated(e);const o=this.nucleon,i=null==o?void 0:o.data,r=null!==(t=null==i?void 0:i._links["fx:create_session"].href)&&void 0!==t?t:null;this.__reloadSessionHref(r)}async __reloadSessionHref(e){var t;if((null===(t=this.__loader)||void 0===t?void 0:t.href)===e)return;const o=this.nucleon;if(o)if(e){const t={result:null,state:"busy",href:e},i=new o.constructor.API(this);this.__loader=t;try{const o=await i.fetch(e,{method:"POST"});if(!o.ok)throw new Error;t.result=(await o.json()).cart_link,t.state="idle"}catch(e){t.state="fail"}finally{this.requestUpdate()}}else this.__loader=null}});let u,h,_,m,y,g,x,v,b,j,$,L,S,H=e=>e;const k=n(l(e,"cart-form"));class R extends k{constructor(){super(...arguments),this.itemCategories=null,this.templateSets=null,this.localeCodes=null,this.customers=null,this.countries=null,this.templates={},this.regions=null,this.coupons=null,this.__defaultTemplateSetLoaderId="defaultTemplateSetLoader",this.__localeCodesHelperLoaderId="localeCodesLoader",this.__shippingRegionsLoaderId="shippingRegionsLoader",this.__billingRegionsLoaderId="billingRegionsLoader",this.__templateSetLoaderId="templateSetLoader",this.__countriesHelperLoaderId="countriesHelperLoader",this.__discountsLoaderId="discountsLoader",this.__customerLoaderId="customerLoader",this.__storeLoaderId="storeLoader",this.__customerTypeGetValue=()=>{var e;return this.form.customer_uri?(null===(e=this.__customer)||void 0===e?void 0:e.is_anonymous)?"guest":"regular":"new"},this.__customerTypeSetValue=e=>{this.edit({customer_uri:"",customer_email:""}),this.__isGuestMode="guest"===e},this.__customerTypeOptions=[{label:"option_new",value:"new"},{label:"option_guest",value:"guest"},{label:"option_regular",value:"regular"}],this.__customerGetValue=()=>this.form.customer_uri||this.form.customer_email,this.__customerSetValue=e=>{try{new URL(e);const t={},r=this.data,s=this.form;for(const e in this.form){if("customer_email"===e)continue;const o=i(s,e);i(r,e)!==o&&d(t,e,o)}this.undo(),this.edit(o(o({},t),{},{customer_uri:e}))}catch(t){this.edit({customer_uri:"",customer_email:e})}},this.__isGuestMode=!1}static get properties(){return o(o({},super.properties),{},{itemCategories:{attribute:"item-categories"},templateSets:{attribute:"template-sets"},localeCodes:{attribute:"locale-codes"},customers:{},countries:{},regions:{},coupons:{},__isGuestMode:{attribute:!1}})}static get v8n(){return[({billing_first_name:e})=>!e||e.length<=50||"billing-first-name:v8n_too_long",({billing_last_name:e})=>!e||e.length<=50||"billing-last-name:v8n_too_long",({billing_region:e})=>!e||e.length<=50||"billing-region:v8n_too_long",({billing_city:e})=>!e||e.length<=50||"billing-city:v8n_too_long",({billing_phone:e})=>!e||e.length<=50||"billing-phone:v8n_too_long",({billing_company:e})=>!e||e.length<=50||"billing-company:v8n_too_long",({billing_address2:e})=>!e||e.length<=100||"billing-address-two:v8n_too_long",({billing_address1:e})=>!e||e.length<=100||"billing-address-one:v8n_too_long",({billing_postal_code:e})=>!e||e.length<=50||"billing-postal-code:v8n_too_long",({shipping_first_name:e})=>!e||e.length<=50||"shipping-first-name:v8n_too_long",({shipping_last_name:e})=>!e||e.length<=50||"shipping-last-name:v8n_too_long",({shipping_region:e})=>!e||e.length<=50||"shipping-region:v8n_too_long",({shipping_city:e})=>!e||e.length<=50||"shipping-city:v8n_too_long",({shipping_phone:e})=>!e||e.length<=50||"shipping-phone:v8n_too_long",({shipping_company:e})=>!e||e.length<=50||"shipping-company:v8n_too_long",({shipping_address2:e})=>!e||e.length<=100||"shipping-address-two:v8n_too_long",({shipping_address1:e})=>!e||e.length<=100||"shipping-address-one:v8n_too_long",({shipping_postal_code:e})=>!e||e.length<=50||"shipping-postal-code:v8n_too_long"]}renderBody(){var e,t,o,i,r,n,l,d,c,f,p,g;const x=Object.values(null!==(e=this.__shippingRegions)&&void 0!==e?e:{}),v=Object.values(null!==(t=this.__billingRegions)&&void 0!==t?t:{}),b=Object.values(null!==(o=this.__countriesHelper)&&void 0!==o?o:{}),j=x.map((e=>({label:e.default,value:e.code}))),$=v.map((e=>({label:e.default,value:e.code}))),L=b.map((e=>({label:e.default,value:e.cc2}))),S=null===(i=this.__customer)||void 0===i?void 0:i._links["fx:customer_addresses"].href,k=this.__store,R=k?k.use_international_currency_symbol?"code":"symbol":void 0;let I=null;if(this.form.currency_code)I=this.form.currency_code;else{const e=this.__localeCodesHelper,t=null===(n=null!==(r=this.__templateSet)&&void 0!==r?r:this.__defaultTemplateSet)||void 0===n?void 0:n.locale_code,o=t?null==e?void 0:e.values[t]:void 0;o&&(I=null!==(d=null===(l=/Currency: ([A-Z]{3})/g.exec(o))||void 0===l?void 0:l[1])&&void 0!==d?d:null)}return s(_||(_=H` <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <div class="grid sm-grid-cols-2 gap-l"> <div class="sm-col-span-2"> <foxy-i18n class="text-l font-medium leading-s block" infer="" key="order_section_title"> </foxy-i18n> <foxy-i18n class="text-s text-secondary leading-s block" infer="" key="order_section_description"> </foxy-i18n> </div> <foxy-internal-select-control infer="customer-type" .getValue="${0}" .setValue="${0}" .options="${0}" @update="${0}"> </foxy-internal-select-control> <foxy-internal-async-combo-box-control item-label-path="email" item-value-path="_links.self.href" item-id-path="_links.self.href" first="${0}" infer="customer" allow-custom-value .selectedItem="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-async-combo-box-control> <foxy-internal-async-combo-box-control item-label-path="description" item-value-path="_links.self.href" item-id-path="_links.self.href" first="${0}" class="sm-col-span-2" infer="template-set-uri" .selectedItem="${0}"> </foxy-internal-async-combo-box-control> <foxy-internal-async-list-control infer="items" class="min-w-0 sm-col-span-2" first="${0}" limit="5" .item="${0}" .form="${0}"> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="applied-coupon-codes" class="min-w-0 sm-col-span-2" first="${0}" limit="5" item="foxy-applied-coupon-code-card" form="${0}" alert> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="custom-fields" class="min-w-0" first="${0}" limit="5" item="foxy-custom-field-card" form="${0}" alert> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="attributes" class="min-w-0" first="${0}" limit="5" item="foxy-attribute-card" form="${0}" alert> </foxy-internal-async-list-control> <div class="grid gap-l"> <div> <foxy-i18n class="text-l font-medium leading-s block" infer="" key="billing_section_title"> </foxy-i18n> <foxy-i18n class="text-s text-secondary leading-s block" infer="" key="billing_section_description"> </foxy-i18n> </div> <div class="grid grid-cols-2 gap-m"> <foxy-internal-text-control infer="billing-first-name"></foxy-internal-text-control> <foxy-internal-text-control infer="billing-last-name"></foxy-internal-text-control> <foxy-internal-text-control infer="billing-company"></foxy-internal-text-control> <foxy-internal-text-control infer="billing-phone"></foxy-internal-text-control> <foxy-internal-text-control property="billing_address1" infer="billing-address-one" class="col-span-2"> </foxy-internal-text-control> <foxy-internal-text-control property="billing_address2" infer="billing-address-two" class="col-span-2"> </foxy-internal-text-control> <foxy-internal-select-control infer="billing-country" .options="${0}"> </foxy-internal-select-control> <foxy-internal-select-control infer="billing-region" .options="${0}"> </foxy-internal-select-control> <foxy-internal-text-control infer="billing-city"></foxy-internal-text-control> <foxy-internal-text-control infer="billing-postal-code"></foxy-internal-text-control> </div> </div> <div class="grid gap-l"> <div> <foxy-i18n class="text-l font-medium leading-s block" infer="" key="shipping_section_title"> </foxy-i18n> <foxy-i18n class="text-s text-secondary leading-s block" infer="" key="shipping_section_description"> </foxy-i18n> </div> <div class="grid grid-cols-2 gap-m"> <foxy-internal-text-control infer="shipping-first-name"></foxy-internal-text-control> <foxy-internal-text-control infer="shipping-last-name"></foxy-internal-text-control> <foxy-internal-text-control infer="shipping-company"></foxy-internal-text-control> <foxy-internal-text-control infer="shipping-phone"></foxy-internal-text-control> <foxy-internal-text-control property="shipping_address1" infer="shipping-address-one" class="col-span-2"> </foxy-internal-text-control> <foxy-internal-text-control property="shipping_address2" infer="shipping-address-two" class="col-span-2"> </foxy-internal-text-control> <foxy-internal-select-control infer="shipping-country" .options="${0}"> </foxy-internal-select-control> <foxy-internal-select-control infer="shipping-region" .options="${0}"> </foxy-internal-select-control> <foxy-internal-text-control infer="shipping-city"></foxy-internal-text-control> <foxy-internal-text-control infer="shipping-postal-code"></foxy-internal-text-control> </div> </div> <div class="leading-m sm-col-span-2"> <div class="text-xl font-medium mb-s"> ${0} </div> <div class="border-t border-contrast-10 mb-s"></div> ${0} ${0} </div> ${0} </div> `),a(this.__shippingRegionsHref),this.__shippingRegionsLoaderId,(()=>this.requestUpdate()),a(this.__billingRegionsHref),this.__billingRegionsLoaderId,(()=>this.requestUpdate()),a(this.__countriesHref),this.__countriesHelperLoaderId,(()=>this.requestUpdate()),a(this.__customerHref),this.__customerLoaderId,(()=>this.requestUpdate()),a(this.__discountsHref),this.__discountsLoaderId,(()=>this.requestUpdate()),a(this.__defaultTemplateSetHref),this.__defaultTemplateSetLoaderId,(()=>this.requestUpdate()),a(this.__localeCodesHelperHref),this.__localeCodesHelperLoaderId,(()=>this.requestUpdate()),a(this.__templateSetHref),this.__templateSetLoaderId,(()=>this.requestUpdate()),a(this.__storeHref),this.__storeLoaderId,(()=>this.requestUpdate()),this.__customerTypeGetValue,this.__customerTypeSetValue,this.__customerTypeOptions,(()=>this.requestUpdate()),a(this.__customersHref),this.__customer,this.__customerGetValue,this.__customerSetValue,a(this.templateSets),null!==(c=this.__templateSet)&&void 0!==c?c:null,a(this.__itemsHref),(e=>s(h||(h=H` <foxy-item-card locale-codes="${0}" parent="${0}" infer="" href="${0}" .related="${0}"> </foxy-item-card> `),this.localeCodes,e.parent,e.href,e.related)),this.data?e=>{var t,o,i;return s(u||(u=H` <foxy-item-form customer-addresses="${0}" item-categories="${0}" locale-codes="${0}" coupons="${0}" parent="${0}" href="${0}" infer="" id="form" .related="${0}" @fetch="${0}" @update="${0}"> </foxy-item-form> `),a(null!=S?S:void 0),a(null!==(t=this.itemCategories)&&void 0!==t?t:void 0),a(null!==(o=this.localeCodes)&&void 0!==o?o:void 0),a(null!==(i=this.coupons)&&void 0!==i?i:void 0),e.dialog.parent,e.dialog.href,e.dialog.related,e.handleFetch,e.handleUpdate)}:null,a(null===(f=this.data)||void 0===f?void 0:f._links["fx:applied_coupon_codes"].href),a(this.data?"foxy-applied-coupon-code-form":void 0),a(null===(p=this.data)||void 0===p?void 0:p._links["fx:custom_fields"].href),a(this.data?"foxy-custom-field-form":void 0),a(null===(g=this.data)||void 0===g?void 0:g._links["fx:attributes"].href),a(this.data?"foxy-attribute-form":void 0),L,$,L,j,this.__renderTotalOrder(I,R),this.__renderTotals(I,R),this.__renderDiscounts(I,R),this.data?s(m||(m=H` <div class="grid gap-s sm-grid-cols-2 sm-gap-l sm-col-span-2"> <foxy-internal-cart-form-view-as-customer-control infer="view-as-customer"> </foxy-internal-cart-form-view-as-customer-control> <foxy-internal-delete-control infer="delete"></foxy-internal-delete-control> </div> `)):s(y||(y=H`<foxy-internal-create-control infer="create"></foxy-internal-create-control>`)))}get __defaultTemplateSetHref(){var e,t,o;if(""===(null===(e=this.data)||void 0===e?void 0:e.template_set_uri))try{const e=new URL(null!==(o=null===(t=this.__store)||void 0===t?void 0:t._links["fx:template_sets"].href)&&void 0!==o?o:"");return e.searchParams.set("code","DEFAULT"),e.toString()}catch(e){}}get __localeCodesHelperHref(){var e;if(this.__defaultTemplateSetHref||this.__templateSetHref)return null!==(e=this.localeCodes)&&void 0!==e?e:void 0}get __shippingRegionsHref(){var e;try{const t=new URL(null!==(e=this.regions)&&void 0!==e?e:""),o=this.form.shipping_country;return o&&t.searchParams.set("country_code",o),t.toString()}catch(e){}}get __billingRegionsHref(){var e;try{const t=new URL(null!==(e=this.regions)&&void 0!==e?e:""),o=this.form.billing_country;return o&&t.searchParams.set("country_code",o),t.toString()}catch(e){}}get __templateSetHref(){return this.form.template_set_uri||void 0}get __customersHref(){var e;try{const t=new URL(null!==(e=this.customers)&&void 0!==e?e:"");return t.searchParams.set("is_anonymous",this.__isGuestMode?"1":"0"),t.toString()}catch(e){}}get __countriesHref(){var e;return null!==(e=this.countries)&&void 0!==e?e:void 0}get __discountsHref(){var e,t;try{const o=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:discounts"].href)&&void 0!==t?t:"");return o.searchParams.set("limit","300"),o.toString()}catch(e){}}get __customerHref(){return this.form.customer_uri||void 0}get __itemsHref(){var e,t;try{const o=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:items"].href)&&void 0!==t?t:"");return o.searchParams.set("zoom","item_options"),o.toString()}catch(e){}}get __storeHref(){var e,t;return null===(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:store"])||void 0===t?void 0:t.href}get __defaultTemplateSet(){var e,t;const o=`#${this.__defaultTemplateSetLoaderId}`,i=this.renderRoot.querySelector(o);return null!==(t=null===(e=null==i?void 0:i.data)||void 0===e?void 0:e._embedded["fx:template_sets"][0])&&void 0!==t?t:null}get __localeCodesHelper(){var e,t;const o=`#${this.__localeCodesHelperLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(o))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __shippingRegions(){var e;const t=this.renderRoot.querySelector(`#${this.__shippingRegionsLoaderId}`);return null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.values}get __billingRegions(){var e;const t=this.renderRoot.querySelector(`#${this.__billingRegionsLoaderId}`);return null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.values}get __templateSet(){var e,t;const o=`#${this.__templateSetLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(o))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __discounts(){return this.renderRoot.querySelector(`#${this.__discountsLoaderId}`)}get __countriesHelper(){var e;const t=this.renderRoot.querySelector(`#${this.__countriesHelperLoaderId}`);return null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.values}get __customer(){var e;return null===(e=this.renderRoot.querySelector(`#${this.__customerLoaderId}`))||void 0===e?void 0:e.data}get __store(){var e,t;const o=`#${this.__storeLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(o))||void 0===e?void 0:e.data)&&void 0!==t?t:null}__renderTotalOrder(e,t){const o=this.data;if(!o||!e||!t)return s(g||(g=H`--`));const i={amount:`${o.total_order} ${e}`,currencyDisplay:t};return s(x||(x=H`<foxy-i18n infer="totals" key="total_order" .options="${0}"></foxy-i18n>`),i)}__renderTotals(e,t){const o=this.data,i=o&&e&&t;return["total_item_price","total_shipping","total_tax"].map((r=>{const n={amount:`${null==o?void 0:o[r]} ${e}`,currencyDisplay:t};return s(v||(v=H` <div data-testid="${0}" class="flex justify-between text-m text-secondary"> <foxy-i18n key="${0}" infer="totals"></foxy-i18n> ${0} </div> `),r,r,i?s(b||(b=H`<foxy-i18n infer="totals" key="price" .options="${0}"></foxy-i18n>`),n):s(j||(j=H`<span>--</span>`)))}))}__renderDiscounts(e,t){var o,i;const r=null===(i=null===(o=this.__discounts)||void 0===o?void 0:o.data)||void 0===i?void 0:i._embedded["fx:discounts"],n=e&&t;return null==r?void 0:r.map((o=>{const i={amount:`${o.amount} ${e}`,currencyDisplay:t};return s($||($=H` <div data-testclass="discount" class="flex justify-between text-m text-secondary"> <span>${0} • ${0}</span> ${0} </div> `),o.name,o.code,n?s(L||(L=H`<foxy-i18n infer="totals" key="price" .options="${0}"></foxy-i18n>`),i):s(S||(S=H`<span>--</span>`)))}))}}customElements.define("foxy-cart-form",R);export{R as CartForm};
|
|
1
|
+
import"./shared-23923638.js";import"./shared-03b39ec4.js";import"./shared-3a82d3f5.js";import{I as e}from"./shared-6fb923d5.js";import"./shared-1e5292a1.js";import"./foxy-applied-coupon-code-card.js";import"./foxy-applied-coupon-code-form.js";import"./foxy-custom-field-card.js";import"./foxy-custom-field-form.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-discount-card.js";import"./foxy-item-card.js";import"./foxy-item-form.js";import"./shared-86768244.js";import{I as t}from"./shared-5dd31b4e.js";import{_ as o,$ as i}from"./shared-98755831.js";import{c as r}from"./shared-4e709717.js";import{h as s}from"./shared-7f33a83a.js";import{R as n,a as l}from"./shared-16b542bc.js";import{i as a}from"./shared-d3bf9ac0.js";import{s as d}from"./shared-c7f56c90.js";import"./shared-0543c6e0.js";import"./shared-c40d85dc.js";import"./shared-7a290f36.js";import"./shared-4c9f96ec.js";import"./shared-4db2c7b1.js";import"./shared-e28f16db.js";import"./shared-b95ef318.js";import"./shared-0c02b4ee.js";import"./shared-509a2f52.js";import"./shared-64657919.js";import"./shared-cb6f2388.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-ca58ef47.js";import"./shared-a8cf402a.js";import"./shared-de790de9.js";import"./shared-eb900735.js";import"./shared-d6276c83.js";import"./shared-a89cb472.js";import"./shared-d519a301.js";import"./shared-11c2efc8.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./shared-0dc1d012.js";import"./shared-9e60ef60.js";import"./foxy-pagination.js";import"./shared-49d978e1.js";import"./shared-3a252ccd.js";import"./shared-c3c67413.js";import"./shared-dcbaa1c5.js";import"./shared-d493355a.js";import"./shared-0479553e.js";import"./shared-6f465111.js";import"./shared-ee13d1a6.js";import"./shared-aeec3cab.js";import"./shared-f3f5e87e.js";import"./shared-e5c19ea3.js";import"./shared-068480a3.js";import"./shared-6b53ef85.js";import"./shared-cd096e97.js";import"./shared-7bf46d6d.js";import"./shared-08ff9a8d.js";import"./shared-b88e35b7.js";import"./shared-939fc890.js";import"./shared-61a510d8.js";import"./foxy-discount-detail-card.js";import"./foxy-coupon-detail-card.js";import"./foxy-item-option-card.js";import"./foxy-item-option-form.js";import"./foxy-coupon-card.js";import"./foxy-discount-builder.js";import"./shared-e6f3e9f0.js";import"./shared-fbfb0943.js";import"./shared-9048c076.js";import"./shared-79d0699c.js";import"./shared-380db651.js";import"./foxy-subscription-card.js";import"./shared-bb009254.js";import"./foxy-subscription-form.js";import"./foxy-cancellation-form.js";import"./foxy-transaction-card.js";import"./foxy-customer-card.js";import"./shared-daf52401.js";import"./shared-b5517c1b.js";import"./shared-bfdbd733.js";let c,f,p=e=>e;customElements.define("foxy-internal-cart-form-view-as-customer-control",class extends t{constructor(){super(...arguments),this.__loader=null}static get properties(){return o(o({},super.properties),{},{__loader:{attribute:!1}})}renderControl(){var e,t;const o=null===(e=this.__loader)||void 0===e?void 0:e.state,i=null===(t=this.__loader)||void 0===t?void 0:t.result;return i?s(c||(c=p` <a target="_blank" class="flex h-m px-m rounded font-medium transition-colors text-body bg-contrast-5 hover-bg-contrast-10 items-center justify-center focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}"> <foxy-i18n infer="" key="state_idle"></foxy-i18n> </a> `),i):s(f||(f=p` <div class="${0}"> <foxy-i18n infer="" key="${0}"> </foxy-i18n> </div> `),r({"flex h-m px-m rounded items-center justify-center":!0,"transition-colors bg-contrast-5 font-medium":!0,"text-tertiary":"fail"!==o,"text-error":"fail"===o}),"fail"===o?"state_fail":"state_busy")}updated(e){var t;super.updated(e);const o=this.nucleon,i=null==o?void 0:o.data,r=null!==(t=null==i?void 0:i._links["fx:create_session"].href)&&void 0!==t?t:null;this.__reloadSessionHref(r)}async __reloadSessionHref(e){var t;if((null===(t=this.__loader)||void 0===t?void 0:t.href)===e)return;const o=this.nucleon;if(o)if(e){const t={result:null,state:"busy",href:e},i=new o.constructor.API(this);this.__loader=t;try{const o=await i.fetch(e,{method:"POST"});if(!o.ok)throw new Error;t.result=(await o.json()).cart_link,t.state="idle"}catch(e){t.state="fail"}finally{this.requestUpdate()}}else this.__loader=null}});let u,h,_,m,y,g,x,v,b,j,$,L,S,H=e=>e;const k=n(l(e,"cart-form"));class R extends k{constructor(){super(...arguments),this.itemCategories=null,this.templateSets=null,this.localeCodes=null,this.customers=null,this.countries=null,this.templates={},this.regions=null,this.coupons=null,this.__defaultTemplateSetLoaderId="defaultTemplateSetLoader",this.__localeCodesHelperLoaderId="localeCodesLoader",this.__shippingRegionsLoaderId="shippingRegionsLoader",this.__billingRegionsLoaderId="billingRegionsLoader",this.__templateSetLoaderId="templateSetLoader",this.__countriesHelperLoaderId="countriesHelperLoader",this.__discountsLoaderId="discountsLoader",this.__customerLoaderId="customerLoader",this.__storeLoaderId="storeLoader",this.__customerTypeGetValue=()=>{var e;return this.form.customer_uri?(null===(e=this.__customer)||void 0===e?void 0:e.is_anonymous)?"guest":"regular":"new"},this.__customerTypeSetValue=e=>{this.edit({customer_uri:"",customer_email:""}),this.__isGuestMode="guest"===e},this.__customerTypeOptions=[{label:"option_new",value:"new"},{label:"option_guest",value:"guest"},{label:"option_regular",value:"regular"}],this.__customerGetValue=()=>this.form.customer_uri||this.form.customer_email,this.__customerSetValue=e=>{try{new URL(e);const t={},r=this.data,s=this.form;for(const e in this.form){if("customer_email"===e)continue;const o=i(s,e);i(r,e)!==o&&d(t,e,o)}this.undo(),this.edit(o(o({},t),{},{customer_uri:e}))}catch(t){this.edit({customer_uri:"",customer_email:e})}},this.__isGuestMode=!1}static get properties(){return o(o({},super.properties),{},{itemCategories:{attribute:"item-categories"},templateSets:{attribute:"template-sets"},localeCodes:{attribute:"locale-codes"},customers:{},countries:{},regions:{},coupons:{},__isGuestMode:{attribute:!1}})}static get v8n(){return[({billing_first_name:e})=>!e||e.length<=50||"billing-first-name:v8n_too_long",({billing_last_name:e})=>!e||e.length<=50||"billing-last-name:v8n_too_long",({billing_region:e})=>!e||e.length<=50||"billing-region:v8n_too_long",({billing_city:e})=>!e||e.length<=50||"billing-city:v8n_too_long",({billing_phone:e})=>!e||e.length<=50||"billing-phone:v8n_too_long",({billing_company:e})=>!e||e.length<=50||"billing-company:v8n_too_long",({billing_address2:e})=>!e||e.length<=100||"billing-address-two:v8n_too_long",({billing_address1:e})=>!e||e.length<=100||"billing-address-one:v8n_too_long",({billing_postal_code:e})=>!e||e.length<=50||"billing-postal-code:v8n_too_long",({shipping_first_name:e})=>!e||e.length<=50||"shipping-first-name:v8n_too_long",({shipping_last_name:e})=>!e||e.length<=50||"shipping-last-name:v8n_too_long",({shipping_region:e})=>!e||e.length<=50||"shipping-region:v8n_too_long",({shipping_city:e})=>!e||e.length<=50||"shipping-city:v8n_too_long",({shipping_phone:e})=>!e||e.length<=50||"shipping-phone:v8n_too_long",({shipping_company:e})=>!e||e.length<=50||"shipping-company:v8n_too_long",({shipping_address2:e})=>!e||e.length<=100||"shipping-address-two:v8n_too_long",({shipping_address1:e})=>!e||e.length<=100||"shipping-address-one:v8n_too_long",({shipping_postal_code:e})=>!e||e.length<=50||"shipping-postal-code:v8n_too_long"]}renderBody(){var e,t,o,i,r,n,l,d,c,f,p,g;const x=Object.values(null!==(e=this.__shippingRegions)&&void 0!==e?e:{}),v=Object.values(null!==(t=this.__billingRegions)&&void 0!==t?t:{}),b=Object.values(null!==(o=this.__countriesHelper)&&void 0!==o?o:{}),j=x.map((e=>({label:e.default,value:e.code}))),$=v.map((e=>({label:e.default,value:e.code}))),L=b.map((e=>({label:e.default,value:e.cc2}))),S=null===(i=this.__customer)||void 0===i?void 0:i._links["fx:customer_addresses"].href,k=this.__store,R=k?k.use_international_currency_symbol?"code":"symbol":void 0;let I=null;if(this.form.currency_code)I=this.form.currency_code;else{const e=this.__localeCodesHelper,t=null===(n=null!==(r=this.__templateSet)&&void 0!==r?r:this.__defaultTemplateSet)||void 0===n?void 0:n.locale_code,o=t?null==e?void 0:e.values[t]:void 0;o&&(I=null!==(d=null===(l=/Currency: ([A-Z]{3})/g.exec(o))||void 0===l?void 0:l[1])&&void 0!==d?d:null)}return s(_||(_=H` <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <div class="grid sm-grid-cols-2 gap-l"> <div class="sm-col-span-2"> <foxy-i18n class="text-l font-medium leading-s block" infer="" key="order_section_title"> </foxy-i18n> <foxy-i18n class="text-s text-secondary leading-s block" infer="" key="order_section_description"> </foxy-i18n> </div> <foxy-internal-select-control infer="customer-type" .getValue="${0}" .setValue="${0}" .options="${0}" @update="${0}"> </foxy-internal-select-control> <foxy-internal-async-combo-box-control item-label-path="email" item-value-path="_links.self.href" item-id-path="_links.self.href" first="${0}" infer="customer" allow-custom-value .selectedItem="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-async-combo-box-control> <foxy-internal-async-combo-box-control item-label-path="description" item-value-path="_links.self.href" item-id-path="_links.self.href" first="${0}" class="sm-col-span-2" infer="template-set-uri" .selectedItem="${0}"> </foxy-internal-async-combo-box-control> <foxy-internal-async-list-control infer="items" class="min-w-0 sm-col-span-2" first="${0}" limit="5" .item="${0}" .form="${0}"> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="applied-coupon-codes" class="min-w-0 sm-col-span-2" first="${0}" limit="5" item="foxy-applied-coupon-code-card" form="${0}" alert> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="custom-fields" class="min-w-0" first="${0}" limit="5" item="foxy-custom-field-card" form="${0}" alert> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="attributes" class="min-w-0" first="${0}" limit="5" item="foxy-attribute-card" form="${0}" alert> </foxy-internal-async-list-control> <div class="grid gap-l"> <div> <foxy-i18n class="text-l font-medium leading-s block" infer="" key="billing_section_title"> </foxy-i18n> <foxy-i18n class="text-s text-secondary leading-s block" infer="" key="billing_section_description"> </foxy-i18n> </div> <div class="grid grid-cols-2 gap-m"> <foxy-internal-text-control infer="billing-first-name"></foxy-internal-text-control> <foxy-internal-text-control infer="billing-last-name"></foxy-internal-text-control> <foxy-internal-text-control infer="billing-company"></foxy-internal-text-control> <foxy-internal-text-control infer="billing-phone"></foxy-internal-text-control> <foxy-internal-text-control property="billing_address1" infer="billing-address-one" class="col-span-2"> </foxy-internal-text-control> <foxy-internal-text-control property="billing_address2" infer="billing-address-two" class="col-span-2"> </foxy-internal-text-control> <foxy-internal-select-control infer="billing-country" .options="${0}"> </foxy-internal-select-control> <foxy-internal-select-control infer="billing-region" .options="${0}"> </foxy-internal-select-control> <foxy-internal-text-control infer="billing-city"></foxy-internal-text-control> <foxy-internal-text-control infer="billing-postal-code"></foxy-internal-text-control> </div> </div> <div class="grid gap-l"> <div> <foxy-i18n class="text-l font-medium leading-s block" infer="" key="shipping_section_title"> </foxy-i18n> <foxy-i18n class="text-s text-secondary leading-s block" infer="" key="shipping_section_description"> </foxy-i18n> </div> <div class="grid grid-cols-2 gap-m"> <foxy-internal-text-control infer="shipping-first-name"></foxy-internal-text-control> <foxy-internal-text-control infer="shipping-last-name"></foxy-internal-text-control> <foxy-internal-text-control infer="shipping-company"></foxy-internal-text-control> <foxy-internal-text-control infer="shipping-phone"></foxy-internal-text-control> <foxy-internal-text-control property="shipping_address1" infer="shipping-address-one" class="col-span-2"> </foxy-internal-text-control> <foxy-internal-text-control property="shipping_address2" infer="shipping-address-two" class="col-span-2"> </foxy-internal-text-control> <foxy-internal-select-control infer="shipping-country" .options="${0}"> </foxy-internal-select-control> <foxy-internal-select-control infer="shipping-region" .options="${0}"> </foxy-internal-select-control> <foxy-internal-text-control infer="shipping-city"></foxy-internal-text-control> <foxy-internal-text-control infer="shipping-postal-code"></foxy-internal-text-control> </div> </div> <div class="leading-m sm-col-span-2"> <div class="text-xl font-medium mb-s"> ${0} </div> <div class="border-t border-contrast-10 mb-s"></div> ${0} ${0} </div> ${0} </div> `),a(this.__shippingRegionsHref),this.__shippingRegionsLoaderId,(()=>this.requestUpdate()),a(this.__billingRegionsHref),this.__billingRegionsLoaderId,(()=>this.requestUpdate()),a(this.__countriesHref),this.__countriesHelperLoaderId,(()=>this.requestUpdate()),a(this.__customerHref),this.__customerLoaderId,(()=>this.requestUpdate()),a(this.__discountsHref),this.__discountsLoaderId,(()=>this.requestUpdate()),a(this.__defaultTemplateSetHref),this.__defaultTemplateSetLoaderId,(()=>this.requestUpdate()),a(this.__localeCodesHelperHref),this.__localeCodesHelperLoaderId,(()=>this.requestUpdate()),a(this.__templateSetHref),this.__templateSetLoaderId,(()=>this.requestUpdate()),a(this.__storeHref),this.__storeLoaderId,(()=>this.requestUpdate()),this.__customerTypeGetValue,this.__customerTypeSetValue,this.__customerTypeOptions,(()=>this.requestUpdate()),a(this.__customersHref),this.__customer,this.__customerGetValue,this.__customerSetValue,a(this.templateSets),null!==(c=this.__templateSet)&&void 0!==c?c:null,a(this.__itemsHref),(e=>s(h||(h=H` <foxy-item-card locale-codes="${0}" parent="${0}" infer="" href="${0}" .related="${0}"> </foxy-item-card> `),this.localeCodes,e.parent,e.href,e.related)),this.data?e=>{var t,o,i;return s(u||(u=H` <foxy-item-form customer-addresses="${0}" item-categories="${0}" locale-codes="${0}" coupons="${0}" parent="${0}" href="${0}" infer="" id="form" .related="${0}" @fetch="${0}" @update="${0}"> </foxy-item-form> `),a(null!=S?S:void 0),a(null!==(t=this.itemCategories)&&void 0!==t?t:void 0),a(null!==(o=this.localeCodes)&&void 0!==o?o:void 0),a(null!==(i=this.coupons)&&void 0!==i?i:void 0),e.dialog.parent,e.dialog.href,e.dialog.related,e.handleFetch,e.handleUpdate)}:null,a(null===(f=this.data)||void 0===f?void 0:f._links["fx:applied_coupon_codes"].href),a(this.data?"foxy-applied-coupon-code-form":void 0),a(null===(p=this.data)||void 0===p?void 0:p._links["fx:custom_fields"].href),a(this.data?"foxy-custom-field-form":void 0),a(null===(g=this.data)||void 0===g?void 0:g._links["fx:attributes"].href),a(this.data?"foxy-attribute-form":void 0),L,$,L,j,this.__renderTotalOrder(I,R),this.__renderTotals(I,R),this.__renderDiscounts(I,R),this.data?s(m||(m=H` <div class="grid gap-s sm-grid-cols-2 sm-gap-l sm-col-span-2"> <foxy-internal-cart-form-view-as-customer-control infer="view-as-customer"> </foxy-internal-cart-form-view-as-customer-control> <foxy-internal-delete-control infer="delete"></foxy-internal-delete-control> </div> `)):s(y||(y=H`<foxy-internal-create-control infer="create"></foxy-internal-create-control>`)))}get __defaultTemplateSetHref(){var e,t,o;if(""===(null===(e=this.data)||void 0===e?void 0:e.template_set_uri))try{const e=new URL(null!==(o=null===(t=this.__store)||void 0===t?void 0:t._links["fx:template_sets"].href)&&void 0!==o?o:"");return e.searchParams.set("code","DEFAULT"),e.toString()}catch(e){}}get __localeCodesHelperHref(){var e;if(this.__defaultTemplateSetHref||this.__templateSetHref)return null!==(e=this.localeCodes)&&void 0!==e?e:void 0}get __shippingRegionsHref(){var e;try{const t=new URL(null!==(e=this.regions)&&void 0!==e?e:""),o=this.form.shipping_country;return o&&t.searchParams.set("country_code",o),t.toString()}catch(e){}}get __billingRegionsHref(){var e;try{const t=new URL(null!==(e=this.regions)&&void 0!==e?e:""),o=this.form.billing_country;return o&&t.searchParams.set("country_code",o),t.toString()}catch(e){}}get __templateSetHref(){return this.form.template_set_uri||void 0}get __customersHref(){var e;try{const t=new URL(null!==(e=this.customers)&&void 0!==e?e:"");return t.searchParams.set("is_anonymous",this.__isGuestMode?"1":"0"),t.toString()}catch(e){}}get __countriesHref(){var e;return null!==(e=this.countries)&&void 0!==e?e:void 0}get __discountsHref(){var e,t;try{const o=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:discounts"].href)&&void 0!==t?t:"");return o.searchParams.set("limit","300"),o.toString()}catch(e){}}get __customerHref(){return this.form.customer_uri||void 0}get __itemsHref(){var e,t;try{const o=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:items"].href)&&void 0!==t?t:"");return o.searchParams.set("zoom","item_options"),o.toString()}catch(e){}}get __storeHref(){var e,t;return null===(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:store"])||void 0===t?void 0:t.href}get __defaultTemplateSet(){var e,t;const o=`#${this.__defaultTemplateSetLoaderId}`,i=this.renderRoot.querySelector(o);return null!==(t=null===(e=null==i?void 0:i.data)||void 0===e?void 0:e._embedded["fx:template_sets"][0])&&void 0!==t?t:null}get __localeCodesHelper(){var e,t;const o=`#${this.__localeCodesHelperLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(o))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __shippingRegions(){var e;const t=this.renderRoot.querySelector(`#${this.__shippingRegionsLoaderId}`);return null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.values}get __billingRegions(){var e;const t=this.renderRoot.querySelector(`#${this.__billingRegionsLoaderId}`);return null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.values}get __templateSet(){var e,t;const o=`#${this.__templateSetLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(o))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __discounts(){return this.renderRoot.querySelector(`#${this.__discountsLoaderId}`)}get __countriesHelper(){var e;const t=this.renderRoot.querySelector(`#${this.__countriesHelperLoaderId}`);return null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.values}get __customer(){var e;return null===(e=this.renderRoot.querySelector(`#${this.__customerLoaderId}`))||void 0===e?void 0:e.data}get __store(){var e,t;const o=`#${this.__storeLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(o))||void 0===e?void 0:e.data)&&void 0!==t?t:null}__renderTotalOrder(e,t){const o=this.data;if(!o||!e||!t)return s(g||(g=H`--`));const i={amount:`${o.total_order} ${e}`,currencyDisplay:t};return s(x||(x=H`<foxy-i18n infer="totals" key="total_order" .options="${0}"></foxy-i18n>`),i)}__renderTotals(e,t){const o=this.data,i=o&&e&&t;return["total_item_price","total_shipping","total_tax"].map((r=>{const n={amount:`${null==o?void 0:o[r]} ${e}`,currencyDisplay:t};return s(v||(v=H` <div data-testid="${0}" class="flex justify-between text-m text-secondary"> <foxy-i18n key="${0}" infer="totals"></foxy-i18n> ${0} </div> `),r,r,i?s(b||(b=H`<foxy-i18n infer="totals" key="price" .options="${0}"></foxy-i18n>`),n):s(j||(j=H`<span>--</span>`)))}))}__renderDiscounts(e,t){var o,i;const r=null===(i=null===(o=this.__discounts)||void 0===o?void 0:o.data)||void 0===i?void 0:i._embedded["fx:discounts"],n=e&&t;return null==r?void 0:r.map((o=>{const i={amount:`${o.amount} ${e}`,currencyDisplay:t};return s($||($=H` <div data-testclass="discount" class="flex justify-between text-m text-secondary"> <span>${0} • ${0}</span> ${0} </div> `),o.name,o.code,n?s(L||(L=H`<foxy-i18n infer="totals" key="price" .options="${0}"></foxy-i18n>`),i):s(S||(S=H`<span>--</span>`)))}))}}customElements.define("foxy-cart-form",R);export{R as CartForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-aeec3cab.js";import"./shared-b95ef318.js";import"./shared-f3f5e87e.js";import"./shared-9048c076.js";import"./shared-cb6f2388.js";import"./shared-ca58ef47.js";import"./shared-e28f16db.js";import"./shared-8349938a.js";import"./shared-0dc1d012.js";import"./shared-0479553e.js";import"./foxy-generate-codes-form.js";import"./foxy-coupon-codes-form.js";import"./foxy-copy-to-clipboard.js";import"./foxy-discount-builder.js";import"./foxy-coupon-code-form.js";import{T as e}from"./shared-29aa4bca.js";import"./foxy-pagination.js";import"./foxy-form-dialog.js";import"./foxy-spinner.js";import"./foxy-table.js";import"./shared-86768244.js";import{_ as t}from"./shared-98755831.js";import{h as s}from"./shared-7f33a83a.js";import{C as i,a as r}from"./shared-ad396f3c.js";import{C as o}from"./shared-de790de9.js";import{N as a}from"./shared-eb900735.js";import{S as n,T as l,a as d,R as c}from"./shared-16b542bc.js";import{i as u}from"./shared-d3bf9ac0.js";import{c as m}from"./shared-4e709717.js";import{E as p}from"./shared-7c5754a4.js";import{G as h}from"./shared-08ff9a8d.js";import{P as f}from"./shared-7bf46d6d.js";import{l as y}from"./shared-f3b35364.js";import{s as g}from"./shared-bc7f58ef.js";import"./shared-4c9f96ec.js";import"./shared-7a290f36.js";import"./shared-c40d85dc.js";import"./shared-0543c6e0.js";import"./shared-4db2c7b1.js";import"./shared-6b53ef85.js";import"./shared-cd096e97.js";import"./shared-ee13d1a6.js";import"./shared-6f465111.js";import"./shared-e5c19ea3.js";import"./shared-068480a3.js";import"./shared-a8cf402a.js";import"./shared-11c2efc8.js";import"./shared-a89cb472.js";import"./shared-0c02b4ee.js";import"./shared-5dd31b4e.js";import"./shared-d519a301.js";import"./shared-9e60ef60.js";import"./shared-509a2f52.js";import"./shared-64657919.js";import"./shared-d6276c83.js";import"./shared-e6f3e9f0.js";import"./shared-6eb7dc77.js";import"./foxy-nucleon-element.js";let x,$=e=>e;const _=o(n(l(a)));class b extends _{constructor(){super(...arguments),this.itemCategory="",this.coupon=""}static get scopedElements(){return{"x-checkbox":i}}static get properties(){return t(t({},super.properties),{},{itemCategory:{type:String,attribute:"item-category"},coupon:{type:String}})}render(){return s(x||(x=$` <div class="h-full flex items-center"> <x-checkbox data-testid="checkbox" ?disabled="${0}" ?readonly="${0}" ?checked="${0}" @change="${0}"> <slot></slot> </x-checkbox> </div> `),!this.in("idle")||this.disabled,this.readonly,!!this.data,(e=>{e.detail?(this.edit({item_category_uri:this.itemCategory,coupon_uri:this.coupon}),this.submit()):this.delete()}))}}let v,S=e=>e;const k=o(n(l(a)));class j extends k{constructor(){super(...arguments),this.itemCategory="",this.coupon=""}static get scopedElements(){return{"foxy-spinner":customElements.get("foxy-spinner"),"x-category-restrictions-page-item-content":b}}static get properties(){return t(t({},super.properties),{},{itemCategory:{type:String,attribute:"item-category"},coupon:{type:String}})}render(){var e;const t=null===(e=this.data)||void 0===e?void 0:e._embedded["fx:coupon_item_categories"][0],i=t?void 0:this.href,r=t?t._links.self.href:void 0;return s(v||(v=S` <x-category-restrictions-page-item-content item-category="${0}" data-testid="content" coupon="${0}" parent="${0}" class="h-full" group="${0}" href="${0}" ?disabled="${0}" ?readonly="${0}"> <slot></slot> </x-category-restrictions-page-item-content> `),this.itemCategory,this.coupon,u(i),this.group,u(r),!this.in("idle")||this.disabled,this.readonly)}}let w,T,E,O=e=>e;const R=o(n(l(d(a))));class C extends R{constructor(){super(...arguments),this.couponItemCategories="",this.coupon=""}static get scopedElements(){return{"foxy-spinner":customElements.get("foxy-spinner"),"x-category-restrictions-page-item":j}}static get properties(){return t(t({},super.properties),{},{couponItemCategories:{type:String,attribute:"coupon-item-categories"},coupon:{type:String}})}render(){var e,t,i,r,o;const a=null!==(t=null===(e=this.data)||void 0===e?void 0:e._embedded["fx:item_categories"])&&void 0!==t?t:[];let n=20;try{const e=parseInt(null!==(i=new URL(this.href).searchParams.get("limit"))&&void 0!==i?i:"");isNaN(e)||(n=e)}catch(e){}return s(w||(w=O` <div class="relative"> <div class="relative divide-y divide-contrast-10 ml-m"> ${0} </div> <div data-testid="spinner" class="${0}"> <foxy-spinner layout="vertical" state="${0}" class="m-auto p-m bg-base rounded-t-l rounded-b-l shadow-xs" lang="${0}" ns="${0} ${0}"> </foxy-spinner> </div> </div> `),new Array(n).fill(0).map(((e,t)=>{const i=a[t];let r;if(i)try{const e=new URL(this.couponItemCategories),t=new URL(i._links.self.href).pathname.split("/").pop();e.searchParams.set("item_category_id",t),e.searchParams.set("limit","1"),r=e.toString()}catch(e){}return r?s(E||(E=O` <x-category-restrictions-page-item data-testclass="item" item-category="${0}" coupon="${0}" class="h-l" group="${0}" href="${0}" ?disabled="${0}" ?readonly="${0}"> ${0} </x-category-restrictions-page-item> `),i._links.self.href,this.coupon,this.group,r,!this.in("idle")||this.disabled,this.readonly,null==i?void 0:i.name):s(T||(T=O`<div class="h-l"></div>`))})),m({"pointer-events-none absolute inset-0 flex transition-opacity":!0,"opacity-0":!!this.data}),this.in("fail")?"error":this.in({idle:"template"})?"empty":"busy",this.lang,this.ns,null!==(o=null===(r=customElements.get("foxy-spinner"))||void 0===r?void 0:r.defaultNS)&&void 0!==o?o:"")}}let q,N,P,D,U,V,z,I,J,Q,L,G,A,M,W,B,F,H,K,X,Y,Z,ee,te,se,ie,re,oe,ae=e=>e;const ne=n(l(o(c(d(a,"coupon-form")))));class le extends ne{constructor(){super(...arguments),this.__codesTableColumns=[{header:e=>s(q||(q=ae`<foxy-i18n lang="${0}" key="code" ns="${0}"></foxy-i18n>`),e.lang,e.ns),cell:e=>{const t=!this.in("idle")||this.disabledSelector.matches("codes",!0);return s(N||(N=ae` <div class="flex items-center gap-xs"> <vaadin-button theme="tertiary-inline contrast" class="p-0" ?disabled="${0}" @click="${0}"> <span class="font-tnum">${0}</span> </vaadin-button> <foxy-copy-to-clipboard ?disabled="${0}" text="${0}" lang="${0}" ns="${0} copy-to-clipboard"> </foxy-copy-to-clipboard> </div> `),t,(t=>{const s=this.renderRoot.querySelector("#code-dialog"),i=t.currentTarget;s.href=e.data._links.self.href,s.show(i)}),e.data.code,t,e.data.code,e.lang,e.ns)}},{header:e=>s(P||(P=ae`<foxy-i18n lang="${0}" key="date_created" ns="${0}"></foxy-i18n>`),e.lang,e.ns),cell:e=>s(D||(D=ae` <foxy-i18n options="${0}" class="text-tertiary" lang="${0}" key="date" ns="${0}"> </foxy-i18n> `),JSON.stringify({value:e.data.date_created}),e.lang,e.ns)},{hideBelow:"sm",header:e=>s(U||(U=ae`<foxy-i18n lang="${0}" key="date_modified" ns="${0}"></foxy-i18n>`),e.lang,e.ns),cell:e=>s(V||(V=ae` <foxy-i18n options="${0}" class="text-tertiary" lang="${0}" key="date" ns="${0}"> </foxy-i18n> `),JSON.stringify({value:e.data.date_modified}),e.lang,e.ns)},{header:e=>s(z||(z=ae`<foxy-i18n lang="${0}" key="used_codes" ns="${0}"></foxy-i18n>`),e.lang,e.ns),cell:e=>s(I||(I=ae`${0}`),e.data.number_of_uses_to_date)}],this.__customerSubscriptionRestrictionsGetValue=()=>{var e;const t=null===(e=this.form.customer_subscription_restrictions)||void 0===e?void 0:e.split(",").map((e=>e.trim())).filter(((e,t,s)=>!!e&&s.indexOf(e)===t)).map((e=>({value:e})));return null!=t?t:[]},this.__customerSubscriptionRestrictionsSetValue=e=>{this.edit({customer_subscription_restrictions:e.map((({value:e})=>e.trim())).filter(((e,t,s)=>!!e&&s.indexOf(e)===t)).join()}),this.edit({customer_auto_apply:!!this.form.customer_subscription_restrictions||!!this.form.customer_attribute_restrictions})},this.__codesTableQuery=null,this.__itemCategories=""}static get scopedElements(){return{"vaadin-integer-field":customElements.get("vaadin-integer-field"),"vaadin-date-picker":customElements.get("vaadin-date-picker"),"vaadin-text-field":customElements.get("vaadin-text-field"),"vaadin-button":customElements.get("vaadin-button"),"iron-dropdown":customElements.get("iron-dropdown"),"iron-icon":customElements.get("iron-icon"),"foxy-internal-editable-list-control":customElements.get("foxy-internal-editable-list-control"),"foxy-internal-confirm-dialog":customElements.get("foxy-internal-confirm-dialog"),"foxy-copy-to-clipboard":customElements.get("foxy-copy-to-clipboard"),"foxy-internal-sandbox":customElements.get("foxy-internal-sandbox"),"foxy-discount-builder":customElements.get("foxy-discount-builder"),"foxy-query-builder":customElements.get("foxy-query-builder"),"foxy-form-dialog":customElements.get("foxy-form-dialog"),"foxy-pagination":customElements.get("foxy-pagination"),"foxy-spinner":customElements.get("foxy-spinner"),"foxy-table":customElements.get("foxy-table"),"foxy-i18n":customElements.get("foxy-i18n"),"x-category-restrictions-page":C,"x-property-table":f,"x-editable-list":p,"x-checkbox":i,"x-group":h}}static get properties(){return t(t({},super.properties),{},{__codesTableQuery:{attribute:!1},__itemCategories:{attribute:!1}})}static get v8n(){return[({name:e})=>!!e||"name_required",({name:e})=>!e||e.length<=50||"name_too_long"]}render(){var e,t;const i=this.hiddenSelector;return s(J||(J=ae` <div class="relative space-y-l"> ${0} ${0} ${0} ${0} ${0} ${0} <foxy-internal-editable-list-control infer="customer-subscription-restrictions" .getValue="${0}" .setValue="${0}"> </foxy-internal-editable-list-control> ${0} ${0} ${0} ${0} ${0} <div data-testid="spinner" class="${0}"> <foxy-spinner layout="vertical" class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l" state="${0}" lang="${0}" ns="${0} ${0}"> </foxy-spinner> </div> </div> `),i.matches("name",!0)?"":this.__renderName(),i.matches("rules",!0)?"":this.__renderRules(),i.matches("codes",!0)||!this.data?"":this.__renderCodes(),i.matches("usage",!0)?"":this.__renderUsage(),i.matches("product-restrictions",!0)?"":this.__renderProductRestrictions(),i.matches("category-restrictions",!0)||!this.data?"":this.__renderCategoryRestrictions(),this.__customerSubscriptionRestrictionsGetValue,this.__customerSubscriptionRestrictionsSetValue,i.matches("customer-attribute-restrictions",!0)?"":this.__renderCustomerAttributeRestrictions(),i.matches("options",!0)?"":this.__renderOptions(),i.matches("timestamps",!0)?"":this.__renderTimestamps(),i.matches("create",!0)||this.data?"":this.__renderCreate(),i.matches("delete",!0)||!this.data?"":this.__renderDelete(),m({"transition duration-500 ease-in-out absolute inset-0 flex":!0,"opacity-0 pointer-events-none":this.in("idle")}),this.in("fail")?"error":this.in("busy")?"busy":"empty",this.lang,this.ns,null!==(t=null===(e=customElements.get("foxy-spinner"))||void 0===e?void 0:e.defaultNS)&&void 0!==t?t:"")}async _sendGet(){const e=await super._sendGet(),t=await super._fetch(e._links["fx:store"].href),s=new URL(t._links["fx:item_categories"].href);return s.searchParams.set("limit","5"),this.__itemCategories=s.toString(),e}__getErrorMessage(e){const t=this.errors.find((t=>t.startsWith(e)));return t?this.t(t.replace(e,"v8n")).toString():""}__getValidator(e){return()=>!this.errors.some((t=>t.startsWith(e)))}__renderName(){return s(Q||(Q=ae` <div> ${0} <vaadin-text-field error-message="${0}" helper-text="${0}" data-testid="name" class="w-full" label="${0}" .checkValidity="${0}" .value="${0}" ?disabled="${0}" ?readonly="${0}" required @keydown="${0}" @input="${0}"> </vaadin-text-field> ${0} </div> `),this.renderTemplateOrSlot("name:before"),this.__getErrorMessage("name"),this.t("coupon_name_helper_text"),this.t("name"),this.__getValidator("name"),this.form.name,!this.in("idle")||this.disabledSelector.matches("name",!0),this.readonlySelector.matches("name",!0),(e=>"Enter"===e.key&&this.submit()),(e=>{const t=e.currentTarget.value;this.edit({name:t})}),this.renderTemplateOrSlot("name:after"))}__renderRulesPreset(){const e=!this.in("idle")||this.disabledSelector.matches("rules",!0),i=this.readonlySelector.matches("rules",!0),r=this.form.coupon_discount_details,o=this.form.coupon_discount_type,a=[{type:"quantity_amount",details:"allunits|2-2"},{type:"quantity_percentage",details:"allunits|5-10|10-20"},{type:"quantity_amount",details:"incremental|3-5"},{type:"quantity_percentage",details:"incremental|11-10|51-15|101-20"},{type:"quantity_percentage",details:"repeat|2-100"},{type:"quantity_percentage",details:"repeat|4-50"},{type:"quantity_amount",details:"single|5-10"},{type:"price_percentage",details:"single|99.99-10"}],n=a.find((e=>e.details===r&&e.type===o));return s(L||(L=ae` <label data-testid="rules:preset" class="${0}"> <foxy-i18n class="sr-only" lang="${0}" key="preset" ns="${0}"></foxy-i18n> <span class="relative font-medium flex items-center"> <span class="truncate"> ${0} </span> <iron-icon class="icon-inline text-xl ml-xs -mr-xs" icon="icons:expand-more"></iron-icon> <select data-testclass="interactive editable" data-testid="rules:preset:select" class="opacity-0 absolute inset-0 focus-outline-none" ?disabled="${0}" @change="${0}"> ${0} <option value="custom" ?selected="${0}"> ${0} </option> </select> </span> </label> `),m({"whitespace-nowrap block ring-primary-50 rounded px-xs -mx-xs transition-colors":!0,"text-body hover-text-primary focus-within-ring-2":!e&&!i,"text-disabled":e,"text-secondary":i}),this.lang,this.ns,n?this.t("discount_summary",{params:t(t({},n),{},{ns:this.ns})}):this.t("custom_discount"),e||i,(e=>{var t,s;const i=e.currentTarget,r=a[i.selectedIndex];this.edit({coupon_discount_details:null!==(t=null==r?void 0:r.details)&&void 0!==t?t:"",coupon_discount_type:null!==(s=null==r?void 0:r.type)&&void 0!==s?s:"quantity_amount"})}),a.map((e=>s(G||(G=ae` <option value="${0}" ?selected="${0}"> ${0} </option> `),e.details,e===n,this.t("discount_summary",{params:t(t({},e),{},{ns:this.ns})})))),!n,this.t("custom_discount"))}__renderRulesUrlParameter(){var e,t,i;const r=null!==(e=this.form.name)&&void 0!==e?e:"",o=null!==(t=this.form.coupon_discount_type)&&void 0!==t?t:"quantity_amount",a=null!==(i=this.form.coupon_discount_details)&&void 0!==i?i:"",n=`discount_${o}=${encodeURIComponent(`${r}{${a}}`)}`,l=!this.in("idle")||this.disabledSelector.matches("rules",!0);return s(A||(A=ae` <div data-testid="rules:url" class="text-xs flex space-x-xs"> <span class="${0}"> <foxy-i18n lang="${0}" key="url_parameter" ns="${0}"></foxy-i18n>: </span> <code class="${0}"> ${0} </code> <foxy-copy-to-clipboard data-testid="rules:url:copy" text="${0}" lang="${0}" ns="${0} copy-to-clipboard" ?disabled="${0}"> </foxy-copy-to-clipboard> </div> `),m({"flex-shrink-0 transition-colors":!0,"text-tertiary":!l,"text-disabled":l}),this.lang,this.ns,m({"bg-contrast-5 transition-colors font-lumo truncate rounded-s px-xs":!0,"text-secondary":!l,"text-disabled":l}),n,n,this.lang,this.ns,l)}__renderRulesDescription(){var e,t;const i=null!==(e=this.form.coupon_discount_type)&&void 0!==e?e:"quantity_amount",r=null!==(t=this.form.coupon_discount_details)&&void 0!==t?t:"",o=!this.in("idle")||this.disabledSelector.matches("rules",!0);return s(M||(M=ae` <div data-testid="rules:description" class="text-xs leading-m"> <span class="transition-colors ${0}"> <foxy-i18n lang="${0}" key="description" ns="${0}"></foxy-i18n>: </span> <foxy-i18n options="${0}" class="transition-colors ${0}" lang="${0}" key="discount_summary" ns="${0}"> </foxy-i18n> </div> `),o?"text-disabled":"text-tertiary",this.lang,this.ns,JSON.stringify({params:{details:r,type:i,ns:this.ns}}),o?"text-disabled":"text-secondary",this.lang,this.ns)}__renderRules(){var e,t;const i=!this.in("idle")||this.disabledSelector.matches("rules",!0),r=this.readonlySelector.matches("rules",!0),o=null!==(e=this.form.coupon_discount_details)&&void 0!==e?e:"",a=null!==(t=this.form.coupon_discount_type)&&void 0!==t?t:"quantity_amount";return s(W||(W=ae` <div data-testid="rules"> ${0} <div> <div class="flex items-center justify-between space-x-m text-s mb-xs"> <foxy-i18n class="${0}" lang="${0}" key="rule_plural" ns="${0}"> </foxy-i18n> <div class="min-w-0">${0}</div> </div> <foxy-discount-builder data-testclass="interactive" lang="${0}" ns="${0}" ?readonly="${0}" ?disabled="${0}" .parsedValue="${0}" @change="${0}"> </foxy-discount-builder> <div class="space-y-xs mt-m"> ${0} ${0} </div> </div> ${0} </div> `),this.renderTemplateOrSlot("rules:before"),m({"transition-colors font-medium flex-1":!0,"text-secondary":!i,"text-disabled":i}),this.lang,this.ns,this.__renderRulesPreset(),this.lang,this.ns,r,i,{details:o,type:a,name:"Rules"},(e=>{const t=e.currentTarget.parsedValue;this.edit({coupon_discount_details:t.details,coupon_discount_type:t.type})}),this.__renderRulesUrlParameter(),this.__renderRulesDescription(),this.renderTemplateOrSlot("rules:after"))}__renderCodes(){var e,t,i,r,o;const{disabledSelector:a,group:n,data:l,lang:d,ns:c}=this,u=!this.in("idle")||a.matches("codes",!0),m=this.__codesTableQuery,p=new URL(l._links["fx:coupon_codes"].href);new URLSearchParams(null!=m?m:"").forEach(((e,t)=>p.searchParams.set(t,e))),p.searchParams.set("limit","5");const h=null===m?"filter":"clear_filters",f="icons:"+(null===m?"filter-list":"clear");return s(B||(B=ae` <div data-testid="codes"> <foxy-form-dialog disabledcontrols="${0}" readonlycontrols="${0}" hiddencontrols="save-button current-balance ${0}" related="${0}" header="generate" parent="${0}" group="${0}" lang="${0}" form="foxy-generate-codes-form" ns="${0}" id="generate-codes-dialog" alert .related="${0}"> </foxy-form-dialog> <foxy-form-dialog disabledcontrols="${0}" readonlycontrols="${0}" hiddencontrols="${0}" header="code" parent="${0}" group="${0}" lang="${0}" form="foxy-coupon-code-form" ns="${0}" id="code-dialog"> </foxy-form-dialog> <foxy-form-dialog disabledcontrols="${0}" readonlycontrols="${0}" hiddencontrols="save-button ${0}" header="import" parent="${0}" group="${0}" lang="${0}" form="foxy-coupon-codes-form" ns="${0}" id="import-dialog"> </foxy-form-dialog> ${0} <div class="flex items-center justify-between mb-xs space-x-s"> <foxy-i18n class="text-s font-medium text-secondary leading-none flex-1" lang="${0}" key="code_plural" ns="${0}"> </foxy-i18n> <vaadin-button data-testid="codes:generate-button" theme="success tertiary small" ?disabled="${0}" @click="${0}"> <foxy-i18n class="text-s" lang="${0}" key="generate" ns="${0}"></foxy-i18n> <iron-icon class="icon-inline text-s" icon="icons:add"></iron-icon> </vaadin-button> <vaadin-button data-testid="codes:import-button" theme="contrast tertiary small" ?disabled="${0}" @click="${0}"> <foxy-i18n class="text-s" lang="${0}" key="import" ns="${0}"></foxy-i18n> <iron-icon class="icon-inline text-s" icon="icons:open-in-browser"></iron-icon> </vaadin-button> <vaadin-button data-testid="codes:filter-button" theme="contrast ${0} small" ?disabled="${0}" @click="${0}"> <foxy-i18n class="text-s" lang="${0}" key="${0}" ns="${0}"></foxy-i18n> <iron-icon class="icon-inline text-s" icon="${0}"></iron-icon> </vaadin-button> </div> <foxy-query-builder class="my-s" lang="${0}" ns="${0} ${0}" ?disabled="${0}" ?hidden="${0}" .options="${0}" .value="${0}" @change="${0}"> </foxy-query-builder> <foxy-pagination first="${0}" lang="${0}" ns="${0} ${0}" ?disabled="${0}"> <foxy-table class="px-m mb-s border border-contrast-10 rounded" group="${0}" lang="${0}" ns="${0}" .columns="${0}"> </foxy-table> </foxy-pagination> ${0} </div> `),a.zoom("codes:generate:form").toString(),this.readonlySelector.zoom("codes:generate:form").toString(),this.hiddenSelector.zoom("codes:generate:form").toString(),JSON.stringify([p.toString()]),null!==(e=null==l?void 0:l._links["fx:generate_codes"].href)&&void 0!==e?e:"",n,d,c,[p.toString()],a.zoom("codes:form").toString(),this.readonlySelector.zoom("codes:form").toString(),this.hiddenSelector.zoom("codes:form").toString(),p.toString(),n,d,c,a.zoom("codes:import:form").toString(),this.readonlySelector.zoom("codes:import:form").toString(),this.hiddenSelector.zoom("codes:import:form").toString(),l._links["fx:coupon_codes"].href,n,d,c,this.renderTemplateOrSlot("codes:before"),d,c,u,(e=>{const t=this.renderRoot.querySelector("#generate-codes-dialog"),s=e.currentTarget;null==t||t.show(s)}),d,c,u,(e=>{const t=this.renderRoot.querySelector("#import-dialog"),s=e.currentTarget;null==t||t.show(s)}),d,c,null===m?"tertiary":"",u,(()=>this.__codesTableQuery=null===m?"":null),d,h,c,f,d,c,null!==(i=null===(t=customElements.get("foxy-query-builder"))||void 0===t?void 0:t.defaultNS)&&void 0!==i?i:"",u,null===m,le.__codesQueryOptions,m,(e=>{const t=e.currentTarget;this.__codesTableQuery=t.value}),p.toString(),d,c,null!==(o=null===(r=customElements.get("foxy-pagination"))||void 0===r?void 0:r.defaultNS)&&void 0!==o?o:"",u,n,d,c,this.__codesTableColumns,this.renderTemplateOrSlot("codes:after"))}__renderUsage(){var e,t,i;const r=!this.in("idle")||this.disabledSelector.matches("usage",!0),o=this.readonlySelector.matches("usage",!0),a=null!==(e=this.form.number_of_uses_allowed)&&void 0!==e?e:0,n=null!==(t=this.form.number_of_uses_allowed_per_customer)&&void 0!==t?t:0,l=null!==(i=this.form.number_of_uses_allowed_per_code)&&void 0!==i?i:0;return s(F||(F=ae` <div data-testid="usage"> ${0} <div class="space-y-s"> <div class="grid gap-m grid-cols-3"> <vaadin-integer-field placeholder="${0}" data-testid="usage:per-coupon" label="${0}" class="w-full" min="0" prevent-invalid-input has-controls .value="${0}" ?disabled="${0}" ?readonly="${0}" @change="${0}"> </vaadin-integer-field> <vaadin-integer-field placeholder="${0}" data-testid="usage:per-coupon-code" label="${0}" class="w-full" min="0" prevent-invalid-input has-controls .value="${0}" ?disabled="${0}" ?readonly="${0}" @change="${0}"> </vaadin-integer-field> <vaadin-integer-field placeholder="${0}" data-testid="usage:per-customer" label="${0}" class="w-full" min="0" prevent-invalid-input has-controls .value="${0}" ?disabled="${0}" ?readonly="${0}" @change="${0}"> </vaadin-integer-field> </div> <div class="${0}"> <foxy-i18n options="${0}" lang="${0}" key="uses_per_coupon_summary${0}" ns="${0}"> </foxy-i18n> <foxy-i18n options="${0}" lang="${0}" key="uses_per_coupon_code_summary${0}" ns="${0}"> </foxy-i18n> <foxy-i18n options="${0}" lang="${0}" key="uses_per_customer_summary${0}" ns="${0}"> </foxy-i18n> </div> </div> ${0} </div> `),this.renderTemplateOrSlot("usage:before"),this.t("unlimited"),this.t("uses_per_coupon"),a||"",r,o,(e=>{const t=e.currentTarget;this.edit({number_of_uses_allowed:parseInt(t.value)})}),this.t("unlimited"),this.t("uses_per_coupon_code"),l||"",r,o,(e=>{const t=e.currentTarget;this.edit({number_of_uses_allowed_per_code:parseInt(t.value)})}),this.t("unlimited"),this.t("uses_per_customer"),n||"",r,o,(e=>{const t=e.currentTarget;this.edit({number_of_uses_allowed_per_customer:parseInt(t.value)})}),m({"transition-colors text-xs leading-s":!0,"text-secondary":!r,"text-disabled":r}),JSON.stringify({count:a}),this.lang,a?"":"_0",this.ns,JSON.stringify({count:l}),this.lang,l?"":"_0",this.ns,JSON.stringify({count:n}),this.lang,n?"":"_0",this.ns,this.renderTemplateOrSlot("usage:after"))}__renderProductRestrictions(){var e;const t="product-restrictions",i=!this.in("idle")||this.disabledSelector.matches(t,!0),r=this.readonlySelector.matches(t,!0),o=null!==(e=this.form.product_code_restrictions)&&void 0!==e?e:"",a=[{header:"allow",items:[]},{header:"block",items:[]}];return o&&o.split(",").forEach((e=>{const t=e.trim();if(!t)return;const s=t.startsWith("-"),i=s?1:0,r=s?t.substring(1):t;a[i].items.push({label:r,value:t})})),s(H||(H=ae` <div data-testid="product-restrictions"> ${0} <div class="space-y-s"> <x-group frame> <foxy-i18n class="${0}" slot="header" lang="${0}" key="product_restrictions" ns="${0}"> </foxy-i18n> <div class="grid sm-grid-cols-2 bg-contrast-10" style="gap:1px"> ${0} </div> </x-group> <foxy-i18n class="${0}" lang="${0}" key="product_restrictions_explainer" ns="${0}"> </foxy-i18n> </div> ${0} </div> `),this.renderTemplateOrSlot("product-restrictions:before"),i?"text-disabled":"text-secondary",this.lang,this.ns,a.map(((e,t)=>s(K||(K=ae` <x-group class="bg-base pt-m"> <foxy-i18n class="${0}" slot="header" lang="${0}" key="${0}" ns="${0}"> </foxy-i18n> <x-editable-list data-testid="product-restrictions:${0}" lang="${0}" ns="${0}" ?disabled="${0}" ?readonly="${0}" .items="${0}" @change="${0}"> </x-editable-list> </x-group> `),i?"text-disabled":"text-tertiary",this.lang,e.header,this.ns,e.header,this.lang,this.ns,i,r,e.items,(e=>{const s=[0===t?e.currentTarget.items:a[0].items,1===t?e.currentTarget.items:a[1].items].map((e=>e.map((e=>e.value.replace(/^[\s-]*/,"").trimEnd())))).map((e=>e.filter((e=>!!e)))).map((e=>Array.from(new Set(e)))),i=s[0].concat(s[1].map((e=>`-${e}`))).join(",");this.edit({product_code_restrictions:i})})))),m({"block text-xs leading-s transition-colors":!0,"text-secondary":!i,"text-disabled":i}),this.lang,this.ns,this.renderTemplateOrSlot("product-restrictions:after"))}__renderCategoryRestrictions(){var e,t,i;const r="category-restrictions",o=!this.in("idle")||this.disabledSelector.matches(r,!0),a=this.readonlySelector.matches(r,!0);return s(X||(X=ae` <div data-testid="category-restrictions"> ${0} <div class="space-y-xs"> <foxy-pagination first="${0}" lang="${0}" ns="${0} ${0}" ?disabled="${0}"> <foxy-i18n class="block text-s font-medium text-secondary leading-none mb-s" lang="${0}" key="category_restrictions" ns="${0}"> </foxy-i18n> <x-category-restrictions-page coupon-item-categories="${0}" data-testid="category-restrictions:page" coupon="${0}" class="border border-contrast-10 rounded mb-s" group="${0}" lang="${0}" ns="${0}" ?disabled="${0}" ?readonly="${0}"> </x-category-restrictions-page> </foxy-pagination> <foxy-i18n class="block text-xs leading-s text-tertiary" lang="${0}" key="category_restrictions_helper_text" ns="${0}"> </foxy-i18n> </div> ${0} </div> `),this.renderTemplateOrSlot("category-restrictions:before"),this.__itemCategories,this.lang,this.ns,null!==(t=null===(e=customElements.get("foxy-pagination"))||void 0===e?void 0:e.defaultNS)&&void 0!==t?t:"",o,this.lang,this.ns,u(null===(i=this.data)||void 0===i?void 0:i._links["fx:coupon_item_categories"].href),this.href,this.group,this.lang,this.ns,o,a,this.lang,this.ns,this.renderTemplateOrSlot("category-restrictions:after"))}__renderCustomerAttributeRestrictions(){var e;const t="customer-attribute-restrictions",i=this.disabledSelector.matches(t,!0),r=this.readonlySelector.matches(t,!0);return s(Y||(Y=ae` <div data-testid="customer-attribute-restrictions"> ${0} <div class="${0}"> <foxy-i18n class="text-s font-medium" infer="${0}" key="label"></foxy-i18n> <foxy-query-builder infer="${0}" .value="${0}" @change="${0}"> </foxy-query-builder> <foxy-i18n class="text-xs" infer="${0}" key="helper_text"></foxy-i18n> </div> ${0} </div> `),this.renderTemplateOrSlot(`${t}:before`),m({"grid gap-xs leading-xs transition-colors":!0,"text-secondary hover-text-body":!i&&!r,"text-disabled":i,"text-body":r}),t,t,null!==(e=this.form.customer_attribute_restrictions)&&void 0!==e?e:null,(e=>{var t;const s=e.currentTarget;this.edit({customer_attribute_restrictions:null!==(t=s.value)&&void 0!==t?t:""}),this.edit({customer_auto_apply:!!this.form.customer_subscription_restrictions||!!this.form.customer_attribute_restrictions})}),t,this.renderTemplateOrSlot(`${t}:after`))}__renderOptions(){const e=!this.in("idle")||this.disabledSelector.matches("options",!0),t=this.readonlySelector.matches("options",!0);return s(Z||(Z=ae` <div data-testid="options"> ${0} <x-group frame> <foxy-i18n class="transition-colors ${0}" slot="header" lang="${0}" key="option_plural" ns="${0}"> </foxy-i18n> ${0} <x-checkbox data-testclass="inputs" data-testid="options:dates" ?disabled="${0}" ?readonly="${0}" ?checked="${0}" class="m-m" @change="${0}"> <div class="flex flex-col"> <foxy-i18n lang="${0}" key="set_time_constraints" ns="${0}"></foxy-i18n> <foxy-i18n class="text-xs leading-s ${0}" lang="${0}" key="set_time_constraints_explainer" ns="${0}"> </foxy-i18n> </div> ${0} </x-checkbox> </x-group> ${0} </div> `),this.renderTemplateOrSlot("options:before"),e?"text-disabled":"text-secondary",this.lang,this.ns,[{param:"multiple_codes_allowed"},{param:"combinable"},{param:"exclude_category_discounts",label:"combine_with_category_discounts",flip:!0},{param:"exclude_line_item_discounts",label:"combine_with_line_discounts",flip:!0},{param:"is_taxable",label:"apply_taxes_before_coupon"}].map((i=>{var r;const o=this.form[i.param],a=null!==(r=i.label)&&void 0!==r?r:i.param,n=e?"text-disabled":"text-secondary";return s(ee||(ee=ae` <x-checkbox data-testclass="inputs" data-testid="options:${0}" ?disabled="${0}" ?readonly="${0}" ?checked="${0}" class="m-m" @change="${0}"> <div class="flex flex-col"> <foxy-i18n lang="${0}" key="${0}" ns="${0}"></foxy-i18n> <foxy-i18n class="transition-colors text-xs leading-s ${0}" lang="${0}" key="${0}_explainer" ns="${0}"> </foxy-i18n> </div> </x-checkbox> <div style="margin-left:calc(1.125rem + (var(--lumo-space-m) * 2))"> <div class="border-b border-contrast-10"></div> </div> `),i.param.replace(/_/g,"-"),e,t,i.flip?!o:o,(e=>{this.edit({[i.param]:i.flip?!e.detail:e.detail})}),this.lang,a,this.ns,n,this.lang,a,this.ns)})),e,t,this.form.start_date||this.form.end_date,(e=>{if(e instanceof r){let t=null,s=null;if(e.detail){const e=Date.now(),i=new Date(e).setMonth((new Date).getMonth()+1);t=g(new Date(e)),s=g(new Date(i))}this.edit({start_date:t,end_date:s})}}),this.lang,this.ns,e?"text-disabled":"text-secondary",this.lang,this.ns,this.form.start_date||this.form.end_date?s(te||(te=ae` <div class="grid grid-cols-2 gap-m mt-m" slot="content" style="--lumo-border-radius:var(--lumo-border-radius-s)"> ${0} </div> `),["start_date","end_date"].map((i=>{const r=this.form[i],o=r?r.length>10?g(new Date(r)):r:"";return s(se||(se=ae` <vaadin-date-picker data-testclass="inputs" data-testid="options:${0}" placeholder="${0}" label="${0}" clear-button-visible ?disabled="${0}" ?readonly="${0}" .value="${0}" @change="${0}"> </vaadin-date-picker> `),i.replace("_","-"),this.t("select"),this.t(i),e,t,y(o),(e=>{const t=e.currentTarget;this.edit({[i]:t.value})}))}))):"",this.renderTemplateOrSlot("options:after"))}__renderTimestamps(){return s(ie||(ie=ae` <div> ${0} <x-property-table data-testid="timestamps" .items="${0}"> </x-property-table> ${0} </div> `),this.renderTemplateOrSlot("timestamps:before"),["date_modified","date_created"].map((e=>{var t;return{name:this.t(e),value:(null===(t=this.data)||void 0===t?void 0:t[e])?this.t("date",{value:new Date(this.data[e])}):""}})),this.renderTemplateOrSlot("timestamps:after"))}__renderCreate(){const e=this.in({idle:{template:{clean:"invalid"}}}),t=this.in({idle:{template:{dirty:"invalid"}}}),i=this.in({idle:{snapshot:{clean:"invalid"}}}),r=this.in({idle:{snapshot:{dirty:"invalid"}}}),o=e||t||(i||r),a=this.in("idle");return s(re||(re=ae` <div> ${0} <vaadin-button data-testid="create" class="w-full" theme="primary success" ?disabled="${0}" @click="${0}"> <foxy-i18n ns="${0}" key="create" lang="${0}"></foxy-i18n> </vaadin-button> ${0} </div> `),this.renderTemplateOrSlot("create:before"),!a||o||this.disabledSelector.matches("create",!0),this.submit,this.ns,this.lang,this.renderTemplateOrSlot("create:after"))}__renderDelete(){return s(oe||(oe=ae` <div> <foxy-internal-confirm-dialog data-testid="confirm" message="delete_prompt" confirm="delete" cancel="cancel" header="delete" theme="primary error" lang="${0}" ns="${0}" id="confirm" @hide="${0}"> </foxy-internal-confirm-dialog> ${0} <vaadin-button data-testid="delete" theme="error" class="w-full" ?disabled="${0}" @click="${0}"> <foxy-i18n ns="${0}" key="delete" lang="${0}"></foxy-i18n> </vaadin-button> ${0} </div> `),this.lang,this.ns,(e=>!e.detail.cancelled&&this.delete()),this.renderTemplateOrSlot("delete:before"),!this.in("idle")||this.disabledSelector.matches("delete",!0),(e=>{this.renderRoot.querySelector("#confirm").show(e.currentTarget)}),this.ns,this.lang,this.renderTemplateOrSlot("delete:after"))}}le.__codesQueryOptions=[{label:"code",path:"code",type:e.String},{label:"used_codes",path:"number_of_uses_to_date",type:e.Number},{label:"date_created",path:"date_created",type:e.Date},{label:"date_modified",path:"date_modified",type:e.Date}],customElements.define("foxy-coupon-form",le);export{le as CouponForm};
|
|
1
|
+
import"./shared-aeec3cab.js";import"./shared-b95ef318.js";import"./shared-f3f5e87e.js";import"./shared-9048c076.js";import"./shared-cb6f2388.js";import"./shared-ca58ef47.js";import"./shared-e28f16db.js";import"./shared-8349938a.js";import"./shared-0dc1d012.js";import"./shared-0479553e.js";import"./foxy-generate-codes-form.js";import"./foxy-coupon-codes-form.js";import"./foxy-copy-to-clipboard.js";import"./foxy-discount-builder.js";import"./foxy-coupon-code-form.js";import{T as e}from"./shared-2756a4f0.js";import"./foxy-pagination.js";import"./foxy-form-dialog.js";import"./foxy-spinner.js";import"./foxy-table.js";import"./shared-86768244.js";import{_ as t}from"./shared-98755831.js";import{h as s}from"./shared-7f33a83a.js";import{C as i,a as r}from"./shared-ad396f3c.js";import{C as o}from"./shared-de790de9.js";import{N as a}from"./shared-eb900735.js";import{S as n,T as l,a as d,R as c}from"./shared-16b542bc.js";import{i as u}from"./shared-d3bf9ac0.js";import{c as m}from"./shared-4e709717.js";import{E as p}from"./shared-7c5754a4.js";import{G as h}from"./shared-08ff9a8d.js";import{P as f}from"./shared-7bf46d6d.js";import{l as y}from"./shared-f3b35364.js";import{s as g}from"./shared-79d0699c.js";import"./shared-4c9f96ec.js";import"./shared-7a290f36.js";import"./shared-c40d85dc.js";import"./shared-0543c6e0.js";import"./shared-4db2c7b1.js";import"./shared-6b53ef85.js";import"./shared-cd096e97.js";import"./shared-ee13d1a6.js";import"./shared-6f465111.js";import"./shared-e5c19ea3.js";import"./shared-068480a3.js";import"./shared-a8cf402a.js";import"./shared-11c2efc8.js";import"./shared-a89cb472.js";import"./shared-0c02b4ee.js";import"./shared-5dd31b4e.js";import"./shared-d519a301.js";import"./shared-9e60ef60.js";import"./shared-509a2f52.js";import"./shared-64657919.js";import"./shared-d6276c83.js";import"./shared-e6f3e9f0.js";import"./shared-6eb7dc77.js";import"./foxy-nucleon-element.js";let x,$=e=>e;const _=o(n(l(a)));class b extends _{constructor(){super(...arguments),this.itemCategory="",this.coupon=""}static get scopedElements(){return{"x-checkbox":i}}static get properties(){return t(t({},super.properties),{},{itemCategory:{type:String,attribute:"item-category"},coupon:{type:String}})}render(){return s(x||(x=$` <div class="h-full flex items-center"> <x-checkbox data-testid="checkbox" ?disabled="${0}" ?readonly="${0}" ?checked="${0}" @change="${0}"> <slot></slot> </x-checkbox> </div> `),!this.in("idle")||this.disabled,this.readonly,!!this.data,(e=>{e.detail?(this.edit({item_category_uri:this.itemCategory,coupon_uri:this.coupon}),this.submit()):this.delete()}))}}let v,S=e=>e;const k=o(n(l(a)));class j extends k{constructor(){super(...arguments),this.itemCategory="",this.coupon=""}static get scopedElements(){return{"foxy-spinner":customElements.get("foxy-spinner"),"x-category-restrictions-page-item-content":b}}static get properties(){return t(t({},super.properties),{},{itemCategory:{type:String,attribute:"item-category"},coupon:{type:String}})}render(){var e;const t=null===(e=this.data)||void 0===e?void 0:e._embedded["fx:coupon_item_categories"][0],i=t?void 0:this.href,r=t?t._links.self.href:void 0;return s(v||(v=S` <x-category-restrictions-page-item-content item-category="${0}" data-testid="content" coupon="${0}" parent="${0}" class="h-full" group="${0}" href="${0}" ?disabled="${0}" ?readonly="${0}"> <slot></slot> </x-category-restrictions-page-item-content> `),this.itemCategory,this.coupon,u(i),this.group,u(r),!this.in("idle")||this.disabled,this.readonly)}}let w,T,E,O=e=>e;const R=o(n(l(d(a))));class C extends R{constructor(){super(...arguments),this.couponItemCategories="",this.coupon=""}static get scopedElements(){return{"foxy-spinner":customElements.get("foxy-spinner"),"x-category-restrictions-page-item":j}}static get properties(){return t(t({},super.properties),{},{couponItemCategories:{type:String,attribute:"coupon-item-categories"},coupon:{type:String}})}render(){var e,t,i,r,o;const a=null!==(t=null===(e=this.data)||void 0===e?void 0:e._embedded["fx:item_categories"])&&void 0!==t?t:[];let n=20;try{const e=parseInt(null!==(i=new URL(this.href).searchParams.get("limit"))&&void 0!==i?i:"");isNaN(e)||(n=e)}catch(e){}return s(w||(w=O` <div class="relative"> <div class="relative divide-y divide-contrast-10 ml-m"> ${0} </div> <div data-testid="spinner" class="${0}"> <foxy-spinner layout="vertical" state="${0}" class="m-auto p-m bg-base rounded-t-l rounded-b-l shadow-xs" lang="${0}" ns="${0} ${0}"> </foxy-spinner> </div> </div> `),new Array(n).fill(0).map(((e,t)=>{const i=a[t];let r;if(i)try{const e=new URL(this.couponItemCategories),t=new URL(i._links.self.href).pathname.split("/").pop();e.searchParams.set("item_category_id",t),e.searchParams.set("limit","1"),r=e.toString()}catch(e){}return r?s(E||(E=O` <x-category-restrictions-page-item data-testclass="item" item-category="${0}" coupon="${0}" class="h-l" group="${0}" href="${0}" ?disabled="${0}" ?readonly="${0}"> ${0} </x-category-restrictions-page-item> `),i._links.self.href,this.coupon,this.group,r,!this.in("idle")||this.disabled,this.readonly,null==i?void 0:i.name):s(T||(T=O`<div class="h-l"></div>`))})),m({"pointer-events-none absolute inset-0 flex transition-opacity":!0,"opacity-0":!!this.data}),this.in("fail")?"error":this.in({idle:"template"})?"empty":"busy",this.lang,this.ns,null!==(o=null===(r=customElements.get("foxy-spinner"))||void 0===r?void 0:r.defaultNS)&&void 0!==o?o:"")}}let q,N,P,D,U,V,z,I,J,Q,L,G,A,M,W,B,F,H,K,X,Y,Z,ee,te,se,ie,re,oe,ae=e=>e;const ne=n(l(o(c(d(a,"coupon-form")))));class le extends ne{constructor(){super(...arguments),this.__codesTableColumns=[{header:e=>s(q||(q=ae`<foxy-i18n lang="${0}" key="code" ns="${0}"></foxy-i18n>`),e.lang,e.ns),cell:e=>{const t=!this.in("idle")||this.disabledSelector.matches("codes",!0);return s(N||(N=ae` <div class="flex items-center gap-xs"> <vaadin-button theme="tertiary-inline contrast" class="p-0" ?disabled="${0}" @click="${0}"> <span class="font-tnum">${0}</span> </vaadin-button> <foxy-copy-to-clipboard ?disabled="${0}" text="${0}" lang="${0}" ns="${0} copy-to-clipboard"> </foxy-copy-to-clipboard> </div> `),t,(t=>{const s=this.renderRoot.querySelector("#code-dialog"),i=t.currentTarget;s.href=e.data._links.self.href,s.show(i)}),e.data.code,t,e.data.code,e.lang,e.ns)}},{header:e=>s(P||(P=ae`<foxy-i18n lang="${0}" key="date_created" ns="${0}"></foxy-i18n>`),e.lang,e.ns),cell:e=>s(D||(D=ae` <foxy-i18n options="${0}" class="text-tertiary" lang="${0}" key="date" ns="${0}"> </foxy-i18n> `),JSON.stringify({value:e.data.date_created}),e.lang,e.ns)},{hideBelow:"sm",header:e=>s(U||(U=ae`<foxy-i18n lang="${0}" key="date_modified" ns="${0}"></foxy-i18n>`),e.lang,e.ns),cell:e=>s(V||(V=ae` <foxy-i18n options="${0}" class="text-tertiary" lang="${0}" key="date" ns="${0}"> </foxy-i18n> `),JSON.stringify({value:e.data.date_modified}),e.lang,e.ns)},{header:e=>s(z||(z=ae`<foxy-i18n lang="${0}" key="used_codes" ns="${0}"></foxy-i18n>`),e.lang,e.ns),cell:e=>s(I||(I=ae`${0}`),e.data.number_of_uses_to_date)}],this.__customerSubscriptionRestrictionsGetValue=()=>{var e;const t=null===(e=this.form.customer_subscription_restrictions)||void 0===e?void 0:e.split(",").map((e=>e.trim())).filter(((e,t,s)=>!!e&&s.indexOf(e)===t)).map((e=>({value:e})));return null!=t?t:[]},this.__customerSubscriptionRestrictionsSetValue=e=>{this.edit({customer_subscription_restrictions:e.map((({value:e})=>e.trim())).filter(((e,t,s)=>!!e&&s.indexOf(e)===t)).join()}),this.edit({customer_auto_apply:!!this.form.customer_subscription_restrictions||!!this.form.customer_attribute_restrictions})},this.__codesTableQuery=null,this.__itemCategories=""}static get scopedElements(){return{"vaadin-integer-field":customElements.get("vaadin-integer-field"),"vaadin-date-picker":customElements.get("vaadin-date-picker"),"vaadin-text-field":customElements.get("vaadin-text-field"),"vaadin-button":customElements.get("vaadin-button"),"iron-dropdown":customElements.get("iron-dropdown"),"iron-icon":customElements.get("iron-icon"),"foxy-internal-editable-list-control":customElements.get("foxy-internal-editable-list-control"),"foxy-internal-confirm-dialog":customElements.get("foxy-internal-confirm-dialog"),"foxy-copy-to-clipboard":customElements.get("foxy-copy-to-clipboard"),"foxy-internal-sandbox":customElements.get("foxy-internal-sandbox"),"foxy-discount-builder":customElements.get("foxy-discount-builder"),"foxy-query-builder":customElements.get("foxy-query-builder"),"foxy-form-dialog":customElements.get("foxy-form-dialog"),"foxy-pagination":customElements.get("foxy-pagination"),"foxy-spinner":customElements.get("foxy-spinner"),"foxy-table":customElements.get("foxy-table"),"foxy-i18n":customElements.get("foxy-i18n"),"x-category-restrictions-page":C,"x-property-table":f,"x-editable-list":p,"x-checkbox":i,"x-group":h}}static get properties(){return t(t({},super.properties),{},{__codesTableQuery:{attribute:!1},__itemCategories:{attribute:!1}})}static get v8n(){return[({name:e})=>!!e||"name_required",({name:e})=>!e||e.length<=50||"name_too_long"]}render(){var e,t;const i=this.hiddenSelector;return s(J||(J=ae` <div class="relative space-y-l"> ${0} ${0} ${0} ${0} ${0} ${0} <foxy-internal-editable-list-control infer="customer-subscription-restrictions" .getValue="${0}" .setValue="${0}"> </foxy-internal-editable-list-control> ${0} ${0} ${0} ${0} ${0} <div data-testid="spinner" class="${0}"> <foxy-spinner layout="vertical" class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l" state="${0}" lang="${0}" ns="${0} ${0}"> </foxy-spinner> </div> </div> `),i.matches("name",!0)?"":this.__renderName(),i.matches("rules",!0)?"":this.__renderRules(),i.matches("codes",!0)||!this.data?"":this.__renderCodes(),i.matches("usage",!0)?"":this.__renderUsage(),i.matches("product-restrictions",!0)?"":this.__renderProductRestrictions(),i.matches("category-restrictions",!0)||!this.data?"":this.__renderCategoryRestrictions(),this.__customerSubscriptionRestrictionsGetValue,this.__customerSubscriptionRestrictionsSetValue,i.matches("customer-attribute-restrictions",!0)?"":this.__renderCustomerAttributeRestrictions(),i.matches("options",!0)?"":this.__renderOptions(),i.matches("timestamps",!0)?"":this.__renderTimestamps(),i.matches("create",!0)||this.data?"":this.__renderCreate(),i.matches("delete",!0)||!this.data?"":this.__renderDelete(),m({"transition duration-500 ease-in-out absolute inset-0 flex":!0,"opacity-0 pointer-events-none":this.in("idle")}),this.in("fail")?"error":this.in("busy")?"busy":"empty",this.lang,this.ns,null!==(t=null===(e=customElements.get("foxy-spinner"))||void 0===e?void 0:e.defaultNS)&&void 0!==t?t:"")}async _sendGet(){const e=await super._sendGet(),t=await super._fetch(e._links["fx:store"].href),s=new URL(t._links["fx:item_categories"].href);return s.searchParams.set("limit","5"),this.__itemCategories=s.toString(),e}__getErrorMessage(e){const t=this.errors.find((t=>t.startsWith(e)));return t?this.t(t.replace(e,"v8n")).toString():""}__getValidator(e){return()=>!this.errors.some((t=>t.startsWith(e)))}__renderName(){return s(Q||(Q=ae` <div> ${0} <vaadin-text-field error-message="${0}" helper-text="${0}" data-testid="name" class="w-full" label="${0}" .checkValidity="${0}" .value="${0}" ?disabled="${0}" ?readonly="${0}" required @keydown="${0}" @input="${0}"> </vaadin-text-field> ${0} </div> `),this.renderTemplateOrSlot("name:before"),this.__getErrorMessage("name"),this.t("coupon_name_helper_text"),this.t("name"),this.__getValidator("name"),this.form.name,!this.in("idle")||this.disabledSelector.matches("name",!0),this.readonlySelector.matches("name",!0),(e=>"Enter"===e.key&&this.submit()),(e=>{const t=e.currentTarget.value;this.edit({name:t})}),this.renderTemplateOrSlot("name:after"))}__renderRulesPreset(){const e=!this.in("idle")||this.disabledSelector.matches("rules",!0),i=this.readonlySelector.matches("rules",!0),r=this.form.coupon_discount_details,o=this.form.coupon_discount_type,a=[{type:"quantity_amount",details:"allunits|2-2"},{type:"quantity_percentage",details:"allunits|5-10|10-20"},{type:"quantity_amount",details:"incremental|3-5"},{type:"quantity_percentage",details:"incremental|11-10|51-15|101-20"},{type:"quantity_percentage",details:"repeat|2-100"},{type:"quantity_percentage",details:"repeat|4-50"},{type:"quantity_amount",details:"single|5-10"},{type:"price_percentage",details:"single|99.99-10"}],n=a.find((e=>e.details===r&&e.type===o));return s(L||(L=ae` <label data-testid="rules:preset" class="${0}"> <foxy-i18n class="sr-only" lang="${0}" key="preset" ns="${0}"></foxy-i18n> <span class="relative font-medium flex items-center"> <span class="truncate"> ${0} </span> <iron-icon class="icon-inline text-xl ml-xs -mr-xs" icon="icons:expand-more"></iron-icon> <select data-testclass="interactive editable" data-testid="rules:preset:select" class="opacity-0 absolute inset-0 focus-outline-none" ?disabled="${0}" @change="${0}"> ${0} <option value="custom" ?selected="${0}"> ${0} </option> </select> </span> </label> `),m({"whitespace-nowrap block ring-primary-50 rounded px-xs -mx-xs transition-colors":!0,"text-body hover-text-primary focus-within-ring-2":!e&&!i,"text-disabled":e,"text-secondary":i}),this.lang,this.ns,n?this.t("discount_summary",{params:t(t({},n),{},{ns:this.ns})}):this.t("custom_discount"),e||i,(e=>{var t,s;const i=e.currentTarget,r=a[i.selectedIndex];this.edit({coupon_discount_details:null!==(t=null==r?void 0:r.details)&&void 0!==t?t:"",coupon_discount_type:null!==(s=null==r?void 0:r.type)&&void 0!==s?s:"quantity_amount"})}),a.map((e=>s(G||(G=ae` <option value="${0}" ?selected="${0}"> ${0} </option> `),e.details,e===n,this.t("discount_summary",{params:t(t({},e),{},{ns:this.ns})})))),!n,this.t("custom_discount"))}__renderRulesUrlParameter(){var e,t,i;const r=null!==(e=this.form.name)&&void 0!==e?e:"",o=null!==(t=this.form.coupon_discount_type)&&void 0!==t?t:"quantity_amount",a=null!==(i=this.form.coupon_discount_details)&&void 0!==i?i:"",n=`discount_${o}=${encodeURIComponent(`${r}{${a}}`)}`,l=!this.in("idle")||this.disabledSelector.matches("rules",!0);return s(A||(A=ae` <div data-testid="rules:url" class="text-xs flex space-x-xs"> <span class="${0}"> <foxy-i18n lang="${0}" key="url_parameter" ns="${0}"></foxy-i18n>: </span> <code class="${0}"> ${0} </code> <foxy-copy-to-clipboard data-testid="rules:url:copy" text="${0}" lang="${0}" ns="${0} copy-to-clipboard" ?disabled="${0}"> </foxy-copy-to-clipboard> </div> `),m({"flex-shrink-0 transition-colors":!0,"text-tertiary":!l,"text-disabled":l}),this.lang,this.ns,m({"bg-contrast-5 transition-colors font-lumo truncate rounded-s px-xs":!0,"text-secondary":!l,"text-disabled":l}),n,n,this.lang,this.ns,l)}__renderRulesDescription(){var e,t;const i=null!==(e=this.form.coupon_discount_type)&&void 0!==e?e:"quantity_amount",r=null!==(t=this.form.coupon_discount_details)&&void 0!==t?t:"",o=!this.in("idle")||this.disabledSelector.matches("rules",!0);return s(M||(M=ae` <div data-testid="rules:description" class="text-xs leading-m"> <span class="transition-colors ${0}"> <foxy-i18n lang="${0}" key="description" ns="${0}"></foxy-i18n>: </span> <foxy-i18n options="${0}" class="transition-colors ${0}" lang="${0}" key="discount_summary" ns="${0}"> </foxy-i18n> </div> `),o?"text-disabled":"text-tertiary",this.lang,this.ns,JSON.stringify({params:{details:r,type:i,ns:this.ns}}),o?"text-disabled":"text-secondary",this.lang,this.ns)}__renderRules(){var e,t;const i=!this.in("idle")||this.disabledSelector.matches("rules",!0),r=this.readonlySelector.matches("rules",!0),o=null!==(e=this.form.coupon_discount_details)&&void 0!==e?e:"",a=null!==(t=this.form.coupon_discount_type)&&void 0!==t?t:"quantity_amount";return s(W||(W=ae` <div data-testid="rules"> ${0} <div> <div class="flex items-center justify-between space-x-m text-s mb-xs"> <foxy-i18n class="${0}" lang="${0}" key="rule_plural" ns="${0}"> </foxy-i18n> <div class="min-w-0">${0}</div> </div> <foxy-discount-builder data-testclass="interactive" lang="${0}" ns="${0}" ?readonly="${0}" ?disabled="${0}" .parsedValue="${0}" @change="${0}"> </foxy-discount-builder> <div class="space-y-xs mt-m"> ${0} ${0} </div> </div> ${0} </div> `),this.renderTemplateOrSlot("rules:before"),m({"transition-colors font-medium flex-1":!0,"text-secondary":!i,"text-disabled":i}),this.lang,this.ns,this.__renderRulesPreset(),this.lang,this.ns,r,i,{details:o,type:a,name:"Rules"},(e=>{const t=e.currentTarget.parsedValue;this.edit({coupon_discount_details:t.details,coupon_discount_type:t.type})}),this.__renderRulesUrlParameter(),this.__renderRulesDescription(),this.renderTemplateOrSlot("rules:after"))}__renderCodes(){var e,t,i,r,o;const{disabledSelector:a,group:n,data:l,lang:d,ns:c}=this,u=!this.in("idle")||a.matches("codes",!0),m=this.__codesTableQuery,p=new URL(l._links["fx:coupon_codes"].href);new URLSearchParams(null!=m?m:"").forEach(((e,t)=>p.searchParams.set(t,e))),p.searchParams.set("limit","5");const h=null===m?"filter":"clear_filters",f="icons:"+(null===m?"filter-list":"clear");return s(B||(B=ae` <div data-testid="codes"> <foxy-form-dialog disabledcontrols="${0}" readonlycontrols="${0}" hiddencontrols="save-button current-balance ${0}" related="${0}" header="generate" parent="${0}" group="${0}" lang="${0}" form="foxy-generate-codes-form" ns="${0}" id="generate-codes-dialog" alert .related="${0}"> </foxy-form-dialog> <foxy-form-dialog disabledcontrols="${0}" readonlycontrols="${0}" hiddencontrols="${0}" header="code" parent="${0}" group="${0}" lang="${0}" form="foxy-coupon-code-form" ns="${0}" id="code-dialog"> </foxy-form-dialog> <foxy-form-dialog disabledcontrols="${0}" readonlycontrols="${0}" hiddencontrols="save-button ${0}" header="import" parent="${0}" group="${0}" lang="${0}" form="foxy-coupon-codes-form" ns="${0}" id="import-dialog"> </foxy-form-dialog> ${0} <div class="flex items-center justify-between mb-xs space-x-s"> <foxy-i18n class="text-s font-medium text-secondary leading-none flex-1" lang="${0}" key="code_plural" ns="${0}"> </foxy-i18n> <vaadin-button data-testid="codes:generate-button" theme="success tertiary small" ?disabled="${0}" @click="${0}"> <foxy-i18n class="text-s" lang="${0}" key="generate" ns="${0}"></foxy-i18n> <iron-icon class="icon-inline text-s" icon="icons:add"></iron-icon> </vaadin-button> <vaadin-button data-testid="codes:import-button" theme="contrast tertiary small" ?disabled="${0}" @click="${0}"> <foxy-i18n class="text-s" lang="${0}" key="import" ns="${0}"></foxy-i18n> <iron-icon class="icon-inline text-s" icon="icons:open-in-browser"></iron-icon> </vaadin-button> <vaadin-button data-testid="codes:filter-button" theme="contrast ${0} small" ?disabled="${0}" @click="${0}"> <foxy-i18n class="text-s" lang="${0}" key="${0}" ns="${0}"></foxy-i18n> <iron-icon class="icon-inline text-s" icon="${0}"></iron-icon> </vaadin-button> </div> <foxy-query-builder class="my-s" lang="${0}" ns="${0} ${0}" ?disabled="${0}" ?hidden="${0}" .options="${0}" .value="${0}" @change="${0}"> </foxy-query-builder> <foxy-pagination first="${0}" lang="${0}" ns="${0} ${0}" ?disabled="${0}"> <foxy-table class="px-m mb-s border border-contrast-10 rounded" group="${0}" lang="${0}" ns="${0}" .columns="${0}"> </foxy-table> </foxy-pagination> ${0} </div> `),a.zoom("codes:generate:form").toString(),this.readonlySelector.zoom("codes:generate:form").toString(),this.hiddenSelector.zoom("codes:generate:form").toString(),JSON.stringify([p.toString()]),null!==(e=null==l?void 0:l._links["fx:generate_codes"].href)&&void 0!==e?e:"",n,d,c,[p.toString()],a.zoom("codes:form").toString(),this.readonlySelector.zoom("codes:form").toString(),this.hiddenSelector.zoom("codes:form").toString(),p.toString(),n,d,c,a.zoom("codes:import:form").toString(),this.readonlySelector.zoom("codes:import:form").toString(),this.hiddenSelector.zoom("codes:import:form").toString(),l._links["fx:coupon_codes"].href,n,d,c,this.renderTemplateOrSlot("codes:before"),d,c,u,(e=>{const t=this.renderRoot.querySelector("#generate-codes-dialog"),s=e.currentTarget;null==t||t.show(s)}),d,c,u,(e=>{const t=this.renderRoot.querySelector("#import-dialog"),s=e.currentTarget;null==t||t.show(s)}),d,c,null===m?"tertiary":"",u,(()=>this.__codesTableQuery=null===m?"":null),d,h,c,f,d,c,null!==(i=null===(t=customElements.get("foxy-query-builder"))||void 0===t?void 0:t.defaultNS)&&void 0!==i?i:"",u,null===m,le.__codesQueryOptions,m,(e=>{const t=e.currentTarget;this.__codesTableQuery=t.value}),p.toString(),d,c,null!==(o=null===(r=customElements.get("foxy-pagination"))||void 0===r?void 0:r.defaultNS)&&void 0!==o?o:"",u,n,d,c,this.__codesTableColumns,this.renderTemplateOrSlot("codes:after"))}__renderUsage(){var e,t,i;const r=!this.in("idle")||this.disabledSelector.matches("usage",!0),o=this.readonlySelector.matches("usage",!0),a=null!==(e=this.form.number_of_uses_allowed)&&void 0!==e?e:0,n=null!==(t=this.form.number_of_uses_allowed_per_customer)&&void 0!==t?t:0,l=null!==(i=this.form.number_of_uses_allowed_per_code)&&void 0!==i?i:0;return s(F||(F=ae` <div data-testid="usage"> ${0} <div class="space-y-s"> <div class="grid gap-m grid-cols-3"> <vaadin-integer-field placeholder="${0}" data-testid="usage:per-coupon" label="${0}" class="w-full" min="0" prevent-invalid-input has-controls .value="${0}" ?disabled="${0}" ?readonly="${0}" @change="${0}"> </vaadin-integer-field> <vaadin-integer-field placeholder="${0}" data-testid="usage:per-coupon-code" label="${0}" class="w-full" min="0" prevent-invalid-input has-controls .value="${0}" ?disabled="${0}" ?readonly="${0}" @change="${0}"> </vaadin-integer-field> <vaadin-integer-field placeholder="${0}" data-testid="usage:per-customer" label="${0}" class="w-full" min="0" prevent-invalid-input has-controls .value="${0}" ?disabled="${0}" ?readonly="${0}" @change="${0}"> </vaadin-integer-field> </div> <div class="${0}"> <foxy-i18n options="${0}" lang="${0}" key="uses_per_coupon_summary${0}" ns="${0}"> </foxy-i18n> <foxy-i18n options="${0}" lang="${0}" key="uses_per_coupon_code_summary${0}" ns="${0}"> </foxy-i18n> <foxy-i18n options="${0}" lang="${0}" key="uses_per_customer_summary${0}" ns="${0}"> </foxy-i18n> </div> </div> ${0} </div> `),this.renderTemplateOrSlot("usage:before"),this.t("unlimited"),this.t("uses_per_coupon"),a||"",r,o,(e=>{const t=e.currentTarget;this.edit({number_of_uses_allowed:parseInt(t.value)})}),this.t("unlimited"),this.t("uses_per_coupon_code"),l||"",r,o,(e=>{const t=e.currentTarget;this.edit({number_of_uses_allowed_per_code:parseInt(t.value)})}),this.t("unlimited"),this.t("uses_per_customer"),n||"",r,o,(e=>{const t=e.currentTarget;this.edit({number_of_uses_allowed_per_customer:parseInt(t.value)})}),m({"transition-colors text-xs leading-s":!0,"text-secondary":!r,"text-disabled":r}),JSON.stringify({count:a}),this.lang,a?"":"_0",this.ns,JSON.stringify({count:l}),this.lang,l?"":"_0",this.ns,JSON.stringify({count:n}),this.lang,n?"":"_0",this.ns,this.renderTemplateOrSlot("usage:after"))}__renderProductRestrictions(){var e;const t="product-restrictions",i=!this.in("idle")||this.disabledSelector.matches(t,!0),r=this.readonlySelector.matches(t,!0),o=null!==(e=this.form.product_code_restrictions)&&void 0!==e?e:"",a=[{header:"allow",items:[]},{header:"block",items:[]}];return o&&o.split(",").forEach((e=>{const t=e.trim();if(!t)return;const s=t.startsWith("-"),i=s?1:0,r=s?t.substring(1):t;a[i].items.push({label:r,value:t})})),s(H||(H=ae` <div data-testid="product-restrictions"> ${0} <div class="space-y-s"> <x-group frame> <foxy-i18n class="${0}" slot="header" lang="${0}" key="product_restrictions" ns="${0}"> </foxy-i18n> <div class="grid sm-grid-cols-2 bg-contrast-10" style="gap:1px"> ${0} </div> </x-group> <foxy-i18n class="${0}" lang="${0}" key="product_restrictions_explainer" ns="${0}"> </foxy-i18n> </div> ${0} </div> `),this.renderTemplateOrSlot("product-restrictions:before"),i?"text-disabled":"text-secondary",this.lang,this.ns,a.map(((e,t)=>s(K||(K=ae` <x-group class="bg-base pt-m"> <foxy-i18n class="${0}" slot="header" lang="${0}" key="${0}" ns="${0}"> </foxy-i18n> <x-editable-list data-testid="product-restrictions:${0}" lang="${0}" ns="${0}" ?disabled="${0}" ?readonly="${0}" .items="${0}" @change="${0}"> </x-editable-list> </x-group> `),i?"text-disabled":"text-tertiary",this.lang,e.header,this.ns,e.header,this.lang,this.ns,i,r,e.items,(e=>{const s=[0===t?e.currentTarget.items:a[0].items,1===t?e.currentTarget.items:a[1].items].map((e=>e.map((e=>e.value.replace(/^[\s-]*/,"").trimEnd())))).map((e=>e.filter((e=>!!e)))).map((e=>Array.from(new Set(e)))),i=s[0].concat(s[1].map((e=>`-${e}`))).join(",");this.edit({product_code_restrictions:i})})))),m({"block text-xs leading-s transition-colors":!0,"text-secondary":!i,"text-disabled":i}),this.lang,this.ns,this.renderTemplateOrSlot("product-restrictions:after"))}__renderCategoryRestrictions(){var e,t,i;const r="category-restrictions",o=!this.in("idle")||this.disabledSelector.matches(r,!0),a=this.readonlySelector.matches(r,!0);return s(X||(X=ae` <div data-testid="category-restrictions"> ${0} <div class="space-y-xs"> <foxy-pagination first="${0}" lang="${0}" ns="${0} ${0}" ?disabled="${0}"> <foxy-i18n class="block text-s font-medium text-secondary leading-none mb-s" lang="${0}" key="category_restrictions" ns="${0}"> </foxy-i18n> <x-category-restrictions-page coupon-item-categories="${0}" data-testid="category-restrictions:page" coupon="${0}" class="border border-contrast-10 rounded mb-s" group="${0}" lang="${0}" ns="${0}" ?disabled="${0}" ?readonly="${0}"> </x-category-restrictions-page> </foxy-pagination> <foxy-i18n class="block text-xs leading-s text-tertiary" lang="${0}" key="category_restrictions_helper_text" ns="${0}"> </foxy-i18n> </div> ${0} </div> `),this.renderTemplateOrSlot("category-restrictions:before"),this.__itemCategories,this.lang,this.ns,null!==(t=null===(e=customElements.get("foxy-pagination"))||void 0===e?void 0:e.defaultNS)&&void 0!==t?t:"",o,this.lang,this.ns,u(null===(i=this.data)||void 0===i?void 0:i._links["fx:coupon_item_categories"].href),this.href,this.group,this.lang,this.ns,o,a,this.lang,this.ns,this.renderTemplateOrSlot("category-restrictions:after"))}__renderCustomerAttributeRestrictions(){var e;const t="customer-attribute-restrictions",i=this.disabledSelector.matches(t,!0),r=this.readonlySelector.matches(t,!0);return s(Y||(Y=ae` <div data-testid="customer-attribute-restrictions"> ${0} <div class="${0}"> <foxy-i18n class="text-s font-medium" infer="${0}" key="label"></foxy-i18n> <foxy-query-builder infer="${0}" .value="${0}" @change="${0}"> </foxy-query-builder> <foxy-i18n class="text-xs" infer="${0}" key="helper_text"></foxy-i18n> </div> ${0} </div> `),this.renderTemplateOrSlot(`${t}:before`),m({"grid gap-xs leading-xs transition-colors":!0,"text-secondary hover-text-body":!i&&!r,"text-disabled":i,"text-body":r}),t,t,null!==(e=this.form.customer_attribute_restrictions)&&void 0!==e?e:null,(e=>{var t;const s=e.currentTarget;this.edit({customer_attribute_restrictions:null!==(t=s.value)&&void 0!==t?t:""}),this.edit({customer_auto_apply:!!this.form.customer_subscription_restrictions||!!this.form.customer_attribute_restrictions})}),t,this.renderTemplateOrSlot(`${t}:after`))}__renderOptions(){const e=!this.in("idle")||this.disabledSelector.matches("options",!0),t=this.readonlySelector.matches("options",!0);return s(Z||(Z=ae` <div data-testid="options"> ${0} <x-group frame> <foxy-i18n class="transition-colors ${0}" slot="header" lang="${0}" key="option_plural" ns="${0}"> </foxy-i18n> ${0} <x-checkbox data-testclass="inputs" data-testid="options:dates" ?disabled="${0}" ?readonly="${0}" ?checked="${0}" class="m-m" @change="${0}"> <div class="flex flex-col"> <foxy-i18n lang="${0}" key="set_time_constraints" ns="${0}"></foxy-i18n> <foxy-i18n class="text-xs leading-s ${0}" lang="${0}" key="set_time_constraints_explainer" ns="${0}"> </foxy-i18n> </div> ${0} </x-checkbox> </x-group> ${0} </div> `),this.renderTemplateOrSlot("options:before"),e?"text-disabled":"text-secondary",this.lang,this.ns,[{param:"multiple_codes_allowed"},{param:"combinable"},{param:"exclude_category_discounts",label:"combine_with_category_discounts",flip:!0},{param:"exclude_line_item_discounts",label:"combine_with_line_discounts",flip:!0},{param:"is_taxable",label:"apply_taxes_before_coupon"}].map((i=>{var r;const o=this.form[i.param],a=null!==(r=i.label)&&void 0!==r?r:i.param,n=e?"text-disabled":"text-secondary";return s(ee||(ee=ae` <x-checkbox data-testclass="inputs" data-testid="options:${0}" ?disabled="${0}" ?readonly="${0}" ?checked="${0}" class="m-m" @change="${0}"> <div class="flex flex-col"> <foxy-i18n lang="${0}" key="${0}" ns="${0}"></foxy-i18n> <foxy-i18n class="transition-colors text-xs leading-s ${0}" lang="${0}" key="${0}_explainer" ns="${0}"> </foxy-i18n> </div> </x-checkbox> <div style="margin-left:calc(1.125rem + (var(--lumo-space-m) * 2))"> <div class="border-b border-contrast-10"></div> </div> `),i.param.replace(/_/g,"-"),e,t,i.flip?!o:o,(e=>{this.edit({[i.param]:i.flip?!e.detail:e.detail})}),this.lang,a,this.ns,n,this.lang,a,this.ns)})),e,t,this.form.start_date||this.form.end_date,(e=>{if(e instanceof r){let t=null,s=null;if(e.detail){const e=Date.now(),i=new Date(e).setMonth((new Date).getMonth()+1);t=g(new Date(e)),s=g(new Date(i))}this.edit({start_date:t,end_date:s})}}),this.lang,this.ns,e?"text-disabled":"text-secondary",this.lang,this.ns,this.form.start_date||this.form.end_date?s(te||(te=ae` <div class="grid grid-cols-2 gap-m mt-m" slot="content" style="--lumo-border-radius:var(--lumo-border-radius-s)"> ${0} </div> `),["start_date","end_date"].map((i=>{const r=this.form[i],o=r?r.length>10?g(new Date(r)):r:"";return s(se||(se=ae` <vaadin-date-picker data-testclass="inputs" data-testid="options:${0}" placeholder="${0}" label="${0}" clear-button-visible ?disabled="${0}" ?readonly="${0}" .value="${0}" @change="${0}"> </vaadin-date-picker> `),i.replace("_","-"),this.t("select"),this.t(i),e,t,y(o),(e=>{const t=e.currentTarget;this.edit({[i]:t.value})}))}))):"",this.renderTemplateOrSlot("options:after"))}__renderTimestamps(){return s(ie||(ie=ae` <div> ${0} <x-property-table data-testid="timestamps" .items="${0}"> </x-property-table> ${0} </div> `),this.renderTemplateOrSlot("timestamps:before"),["date_modified","date_created"].map((e=>{var t;return{name:this.t(e),value:(null===(t=this.data)||void 0===t?void 0:t[e])?this.t("date",{value:new Date(this.data[e])}):""}})),this.renderTemplateOrSlot("timestamps:after"))}__renderCreate(){const e=this.in({idle:{template:{clean:"invalid"}}}),t=this.in({idle:{template:{dirty:"invalid"}}}),i=this.in({idle:{snapshot:{clean:"invalid"}}}),r=this.in({idle:{snapshot:{dirty:"invalid"}}}),o=e||t||(i||r),a=this.in("idle");return s(re||(re=ae` <div> ${0} <vaadin-button data-testid="create" class="w-full" theme="primary success" ?disabled="${0}" @click="${0}"> <foxy-i18n ns="${0}" key="create" lang="${0}"></foxy-i18n> </vaadin-button> ${0} </div> `),this.renderTemplateOrSlot("create:before"),!a||o||this.disabledSelector.matches("create",!0),this.submit,this.ns,this.lang,this.renderTemplateOrSlot("create:after"))}__renderDelete(){return s(oe||(oe=ae` <div> <foxy-internal-confirm-dialog data-testid="confirm" message="delete_prompt" confirm="delete" cancel="cancel" header="delete" theme="primary error" lang="${0}" ns="${0}" id="confirm" @hide="${0}"> </foxy-internal-confirm-dialog> ${0} <vaadin-button data-testid="delete" theme="error" class="w-full" ?disabled="${0}" @click="${0}"> <foxy-i18n ns="${0}" key="delete" lang="${0}"></foxy-i18n> </vaadin-button> ${0} </div> `),this.lang,this.ns,(e=>!e.detail.cancelled&&this.delete()),this.renderTemplateOrSlot("delete:before"),!this.in("idle")||this.disabledSelector.matches("delete",!0),(e=>{this.renderRoot.querySelector("#confirm").show(e.currentTarget)}),this.ns,this.lang,this.renderTemplateOrSlot("delete:after"))}}le.__codesQueryOptions=[{label:"code",path:"code",type:e.String},{label:"used_codes",path:"number_of_uses_to_date",type:e.Number},{label:"date_created",path:"date_created",type:e.Date},{label:"date_modified",path:"date_modified",type:e.Date}],customElements.define("foxy-coupon-form",le);export{le as CouponForm};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./foxy-customer.js";import"./shared-cb6f2388.js";import"./shared-ca58ef47.js";import"./shared-e28f16db.js";import"./shared-0479553e.js";import"./foxy-access-recovery-form.js";import"./foxy-payment-method-card.js";import{TransactionsTable as e}from"./foxy-transactions-table.js";import"./foxy-subscription-card.js";import"./foxy-subscription-form.js";import"./foxy-collection-pages.js";import"./foxy-collection-page.js";import"./foxy-sign-in-form.js";import"./foxy-form-dialog.js";import"./foxy-spinner.js";import{_ as t,B as s,am as r}from"./shared-98755831.js";import{h as o,L as i,c as n}from"./shared-7f33a83a.js";import{A as a}from"./shared-daf52401.js";import"./shared-b5517c1b.js";import{C as l}from"./shared-bd819b5b.js";import{a as d,T as c,R as m}from"./shared-16b542bc.js";import{A as h}from"./shared-509a2f52.js";import{I as u}from"./shared-a8cf402a.js";import{c as p}from"./shared-4e709717.js";import{C as f}from"./shared-de790de9.js";import{N as g}from"./shared-eb900735.js";import{i as $}from"./shared-d3bf9ac0.js";import"./shared-7a290f36.js";import"./foxy-attribute-card.js";import"./shared-86768244.js";import"./shared-64657919.js";import"./shared-d6276c83.js";import"./shared-a89cb472.js";import"./foxy-attribute-form.js";import"./shared-e5c19ea3.js";import"./shared-c40d85dc.js";import"./shared-b95ef318.js";import"./shared-4c9f96ec.js";import"./shared-0dc1d012.js";import"./shared-9e60ef60.js";import"./shared-6f465111.js";import"./shared-ee13d1a6.js";import"./shared-aeec3cab.js";import"./shared-f3f5e87e.js";import"./shared-068480a3.js";import"./shared-0543c6e0.js";import"./shared-4db2c7b1.js";import"./shared-11c2efc8.js";import"./shared-6b53ef85.js";import"./shared-cd096e97.js";import"./shared-08ff9a8d.js";import"./shared-7bf46d6d.js";import"./foxy-customer-form.js";import"./foxy-nucleon-element.js";import"./shared-b738ee96.js";import"./foxy-address-card.js";import"./shared-bd81cc08.js";import"./foxy-address-form.js";import"./foxy-table.js";import"./shared-6eb7dc77.js";import"./shared-eb4b4597.js";import"./shared-bb009254.js";import"./shared-99065f2a.js";import"./shared-6fb923d5.js";import"./shared-5dd31b4e.js";import"./shared-03b39ec4.js";import"./foxy-swipe-actions.js";import"./foxy-pagination.js";import"./shared-0c02b4ee.js";import"./shared-61a510d8.js";import"./foxy-cancellation-form.js";import"./shared-380db651.js";import"./shared-
|
|
1
|
+
import"./foxy-customer.js";import"./shared-cb6f2388.js";import"./shared-ca58ef47.js";import"./shared-e28f16db.js";import"./shared-0479553e.js";import"./foxy-access-recovery-form.js";import"./foxy-payment-method-card.js";import{TransactionsTable as e}from"./foxy-transactions-table.js";import"./foxy-subscription-card.js";import"./foxy-subscription-form.js";import"./foxy-collection-pages.js";import"./foxy-collection-page.js";import"./foxy-sign-in-form.js";import"./foxy-form-dialog.js";import"./foxy-spinner.js";import{_ as t,B as s,am as r}from"./shared-98755831.js";import{h as o,L as i,c as n}from"./shared-7f33a83a.js";import{A as a}from"./shared-daf52401.js";import"./shared-b5517c1b.js";import{C as l}from"./shared-bd819b5b.js";import{a as d,T as c,R as m}from"./shared-16b542bc.js";import{A as h}from"./shared-509a2f52.js";import{I as u}from"./shared-a8cf402a.js";import{c as p}from"./shared-4e709717.js";import{C as f}from"./shared-de790de9.js";import{N as g}from"./shared-eb900735.js";import{i as $}from"./shared-d3bf9ac0.js";import"./shared-7a290f36.js";import"./foxy-attribute-card.js";import"./shared-86768244.js";import"./shared-64657919.js";import"./shared-d6276c83.js";import"./shared-a89cb472.js";import"./foxy-attribute-form.js";import"./shared-e5c19ea3.js";import"./shared-c40d85dc.js";import"./shared-b95ef318.js";import"./shared-4c9f96ec.js";import"./shared-0dc1d012.js";import"./shared-9e60ef60.js";import"./shared-6f465111.js";import"./shared-ee13d1a6.js";import"./shared-aeec3cab.js";import"./shared-f3f5e87e.js";import"./shared-068480a3.js";import"./shared-0543c6e0.js";import"./shared-4db2c7b1.js";import"./shared-11c2efc8.js";import"./shared-6b53ef85.js";import"./shared-cd096e97.js";import"./shared-08ff9a8d.js";import"./shared-7bf46d6d.js";import"./foxy-customer-form.js";import"./foxy-nucleon-element.js";import"./shared-b738ee96.js";import"./foxy-address-card.js";import"./shared-bd81cc08.js";import"./foxy-address-form.js";import"./foxy-table.js";import"./shared-6eb7dc77.js";import"./shared-eb4b4597.js";import"./shared-bb009254.js";import"./shared-99065f2a.js";import"./shared-6fb923d5.js";import"./shared-5dd31b4e.js";import"./shared-03b39ec4.js";import"./foxy-swipe-actions.js";import"./foxy-pagination.js";import"./shared-0c02b4ee.js";import"./shared-61a510d8.js";import"./foxy-cancellation-form.js";import"./shared-380db651.js";import"./shared-79d0699c.js";import"./foxy-transaction-card.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./shared-49d978e1.js";import"./shared-3a252ccd.js";import"./shared-d519a301.js";import"./shared-4abfda9b.js";import"./shared-6bfa699d.js";import"./shared-d493355a.js";let y,b,v=e=>e;class S extends(d(c(l),"customer-portal")){constructor(){super(...arguments),this.transactionsTableColumns=[e.priceColumn,e.summaryColumn,e.statusColumn,e.idColumn,e.dateColumn,e.receiptColumn],this.group=""}static get properties(){return t(t({},super.properties),{},{transactionsTableColumns:{attribute:!1},group:{type:String}})}render(){return this.api.storage.getItem(a.SESSION)?o(y||(y=v` <foxy-internal-customer-portal-logged-in-view disabledcontrols="${0}" readonlycontrols="${0}" hiddencontrols="${0}" customer="${0}" group="${0}" class="h-full" lang="${0}" href="${0}" ns="${0}" .transactionsTableColumns="${0}" .templates="${0}"> </foxy-internal-customer-portal-logged-in-view> `),this.disabledSelector.toString(),this.readonlySelector.toString(),this.hiddenSelector.toString(),this.base,this.group,this.lang,new URL("./customer_portal_settings",this.base).toString(),this.ns,this.transactionsTableColumns,this.templates):o(b||(b=v` <foxy-internal-customer-portal-logged-out-view disabledcontrols="${0}" readonlycontrols="${0}" hiddencontrols="${0}" group="${0}" class="h-full" lang="${0}" ns="${0}" .templates="${0}"> </foxy-internal-customer-portal-logged-out-view> `),this.disabledSelector.toString(),this.readonlySelector.toString(),this.hiddenSelector.toString(),this.group,this.lang,this.ns,this.templates)}}let x,_,j=e=>e;const T=m(c(d(u(i))));let w,O,k,E,R=e=>e;class z extends(c(i)){constructor(){super(...arguments),this.disabled=!1,this.href="",this.icon=""}static get properties(){return t(t({},super.properties),{},{disabled:{type:Boolean},href:{type:String},icon:{type:String}})}render(){const e=p({"flex-auto font-medium tracking-wide text-s rounded-s transition-colors":!0,"hover-text-primary hover-cursor-pointer":!this.disabled,"focus-outline-none focus-ring-2 ring-primary-50 ring-offset-2":!this.disabled,"text-disabled cursor-default":this.disabled}),t=o(w||(w=R` ${0} <slot></slot> `),this.icon?o(O||(O=R`<iron-icon icon="${0}" class="icon-inline"></iron-icon>`),this.icon):"");return this.disabled?o(k||(k=R`<button class="${0}" disabled="disabled">${0}</button>`),e,t):o(E||(E=R` <a class="${0}" href="${0}" rel="nofollow noopener">${0}</a> `),e,this.href,t)}}let N,A,F,C,I,H,U,q,L,P,D=e=>e;const V=c(f(d(g)));let B,J,W,G,K,M,Q,X,Y,Z,ee=e=>e;const te=c(f(d(u(i))));const se=["html"],re=["html"];let oe,ie,ne,ae,le,de,ce,me,he,ue,pe,fe,ge=e=>e;const $e=d(f(c(u(i))));let ye,be,ve,Se=e=>e;const xe=f(c(d(u(i),"customer-portal")));customElements.define("foxy-internal-customer-portal-logged-in-view",class extends V{constructor(){var e;super(...arguments),e=this,this.templates={},this.customer="",this.loggingOutState="idle",this.transactionsTableColumns=[],this.loggingOutStateResetTimeout=null,this.__renderHeaderActionsSignOut=()=>{var t,s,r,i,n;const a="customer:header:actions:sign-out",l=this.loggingOutState,d=this.disabledSelector.matches(a)||!(null===(t=this.__customerElement)||void 0===t?void 0:t.in({idle:"snapshot"}))||"idle"!==l,c={"border-radius":"100%",padding:"var(--lumo-space-xs)",display:"flex",margin:"0",cursor:d?"default":"pointer"};return o(N||(N=D` <div style="display:flex;margin-left:var(--lumo-space-m)"> ${0} <vaadin-button data-testid="sign-out" aria-label="${0}" style="${0}" theme="icon" ?disabled="${0}" @click="${0}"> ${0} </vaadin-button> ${0} </div> `),this.renderTemplateOrSlot(`${a}:before`),this.t("sign_out").toString(),Object.entries(c).reduce(((e,[t,s])=>`${e}${t}:${s};`),""),d,(async function(){try{e.loggingOutState="busy",await new h(e).fetch("foxy://customer-api/session",{method:"DELETE"}),e.loggingOutState="idle"}catch(t){e.loggingOutState="fail",e.loggingOutStateResetTimeout=setTimeout((()=>{e.loggingOutState="idle",e.loggingOutStateResetTimeout=null}),1e3)}}),"idle"===l?o(A||(A=D`<iron-icon icon="icons:exit-to-app"></iron-icon>`)):o(F||(F=D` <foxy-spinner layout="no-label" state="${0}" style="margin:auto" lang="${0}" ns="${0}"> </foxy-spinner> `),"fail"===l?"error":"busy",this.lang,[this.ns,null!==(r=null===(s=customElements.get("foxy-customer"))||void 0===s?void 0:s.defaultNS)&&void 0!==r?r:"",null!==(n=null===(i=customElements.get("foxy-spinner"))||void 0===i?void 0:i.defaultNS)&&void 0!==n?n:""].join(" ")),this.renderTemplateOrSlot(`${a}:after`))},this.__renderSubscriptions=(e,t)=>{const s="customer:subscriptions";return e(C||(C=D`
|
|
2
2
|
${0}
|
|
3
3
|
|
|
4
4
|
<foxy-internal-customer-portal-subscriptions
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./shared-e28f16db.js";import"./shared-ca58ef47.js";import{h as t}from"./shared-7a290f36.js";import"./shared-cb6f2388.js";import"./shared-0479553e.js";import"./foxy-payment-method-card.js";import"./foxy-subscription-form.js";import"./foxy-form-dialog.js";import"./foxy-transactions-table.js";import"./foxy-collection-pages.js";import"./foxy-collection-page.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-customer-form.js";import"./foxy-address-card.js";import"./foxy-address-form.js";import"./foxy-spinner.js";import"./foxy-table.js";import"./shared-86768244.js";import{am as e}from"./shared-98755831.js";import{L as s,h as r,c as a}from"./shared-7f33a83a.js";import{C as o}from"./shared-de790de9.js";import"./shared-c40d85dc.js";import"./shared-6f465111.js";import{w as i,S as h,T as d,a as n}from"./shared-16b542bc.js";import{c as l}from"./shared-4e709717.js";import"./shared-ee13d1a6.js";import"./shared-9e60ef60.js";import{S as m}from"./shared-6b53ef85.js";import"./shared-aeec3cab.js";import"./shared-b95ef318.js";import"./shared-f3f5e87e.js";import"./shared-068480a3.js";import"./shared-0543c6e0.js";import{G as c}from"./shared-08ff9a8d.js";import"./shared-4c9f96ec.js";import{N as v}from"./shared-eb900735.js";import{S as p}from"./shared-eb4b4597.js";import{i as f}from"./shared-d3bf9ac0.js";import"./shared-0dc1d012.js";import"./shared-99065f2a.js";import"./foxy-nucleon-element.js";import"./shared-509a2f52.js";import"./shared-64657919.js";import"./shared-d6276c83.js";import"./shared-a8cf402a.js";import"./shared-a89cb472.js";import"./shared-6fb923d5.js";import"./shared-5dd31b4e.js";import"./shared-03b39ec4.js";import"./foxy-swipe-actions.js";import"./foxy-pagination.js";import"./shared-0c02b4ee.js";import"./shared-61a510d8.js";import"./foxy-cancellation-form.js";import"./shared-380db651.js";import"./shared-
|
|
1
|
+
import"./shared-e28f16db.js";import"./shared-ca58ef47.js";import{h as t}from"./shared-7a290f36.js";import"./shared-cb6f2388.js";import"./shared-0479553e.js";import"./foxy-payment-method-card.js";import"./foxy-subscription-form.js";import"./foxy-form-dialog.js";import"./foxy-transactions-table.js";import"./foxy-collection-pages.js";import"./foxy-collection-page.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-customer-form.js";import"./foxy-address-card.js";import"./foxy-address-form.js";import"./foxy-spinner.js";import"./foxy-table.js";import"./shared-86768244.js";import{am as e}from"./shared-98755831.js";import{L as s,h as r,c as a}from"./shared-7f33a83a.js";import{C as o}from"./shared-de790de9.js";import"./shared-c40d85dc.js";import"./shared-6f465111.js";import{w as i,S as h,T as d,a as n}from"./shared-16b542bc.js";import{c as l}from"./shared-4e709717.js";import"./shared-ee13d1a6.js";import"./shared-9e60ef60.js";import{S as m}from"./shared-6b53ef85.js";import"./shared-aeec3cab.js";import"./shared-b95ef318.js";import"./shared-f3f5e87e.js";import"./shared-068480a3.js";import"./shared-0543c6e0.js";import{G as c}from"./shared-08ff9a8d.js";import"./shared-4c9f96ec.js";import{N as v}from"./shared-eb900735.js";import{S as p}from"./shared-eb4b4597.js";import{i as f}from"./shared-d3bf9ac0.js";import"./shared-0dc1d012.js";import"./shared-99065f2a.js";import"./foxy-nucleon-element.js";import"./shared-509a2f52.js";import"./shared-64657919.js";import"./shared-d6276c83.js";import"./shared-a8cf402a.js";import"./shared-a89cb472.js";import"./shared-6fb923d5.js";import"./shared-5dd31b4e.js";import"./shared-03b39ec4.js";import"./foxy-swipe-actions.js";import"./foxy-pagination.js";import"./shared-0c02b4ee.js";import"./shared-61a510d8.js";import"./foxy-cancellation-form.js";import"./shared-380db651.js";import"./shared-79d0699c.js";import"./shared-e5c19ea3.js";import"./shared-11c2efc8.js";import"./shared-cd096e97.js";import"./shared-4db2c7b1.js";import"./foxy-transaction-card.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./shared-49d978e1.js";import"./shared-3a252ccd.js";import"./shared-bb009254.js";import"./shared-daf52401.js";import"./shared-b5517c1b.js";import"./shared-d519a301.js";import"./shared-7bf46d6d.js";import"./shared-6eb7dc77.js";import"./shared-b738ee96.js";import"./shared-bd81cc08.js";let g,z,u,b=t=>t;class $ extends s{constructor(){super(...arguments),this.value=0,this.size=0}static get properties(){return{value:{type:Number},size:{type:Number}}}static get styles(){return i.styles}render(){const t=[],e=[];for(let s=0;s<this.size;++s)t.push(r(g||(g=b` <button id="tab-${0}" role="tab" class="${0}" aria-controls="panel-${0}" aria-selected="${0}" @click="${0}" @keydown="${0}"> <slot name="tab-${0}"></slot> </button> `),s,l({"text-l font-medium px-s rounded focus-outline-none focus-shadow-outline":!0,"text-tertiary hover-text-body focus-text-body":this.value!==s}),s,this.value===s,(()=>this.value=s),this.__handleKeyDown,s)),e.push(r(z||(z=b` <slot id="panel-${0}" role="tabpanel" name="panel-${0}" class="${0}" aria-hidden="${0}" aria-labelledby="tab-${0}"> </slot> `),s,s,l({hidden:this.value!==s}),this.value!==s,s));return r(u||(u=b` <div role="tablist" aria-orientation="horizontal" class="-mx-s mb-s">${0}</div> ${0} `),t,e)}__handleKeyDown(t){if(t.key.startsWith("Arrow")){t.preventDefault();const e=t.target;let s=null;"ArrowRight"===t.key||"ArrowDown"===t.key?s=e.nextElementSibling:"ArrowLeft"!==t.key&&"ArrowUp"!==t.key||(s=e.previousElementSibling),null==s||s.click(),null==s||s.focus()}}}
|
|
2
2
|
/**
|
|
3
3
|
@license
|
|
4
4
|
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-b95ef318.js";import"./shared-cb6f2388.js";import"./shared-3a82d3f5.js";import"./shared-0dc1d012.js";import"./shared-e6066f46.js";import"./shared-1e5292a1.js";import"./shared-0479553e.js";import"./foxy-spinner.js";import"./shared-86768244.js";import{_ as e}from"./shared-98755831.js";import"./shared-e28f16db.js";import"./shared-c40d85dc.js";import"./shared-6f465111.js";import{h as t}from"./shared-7f33a83a.js";import{S as s,T as a,a as i}from"./shared-16b542bc.js";import{c as r}from"./shared-4e709717.js";import{C as n,a as o}from"./shared-ee13d1a6.js";import"./shared-9e60ef60.js";import"./shared-6b53ef85.js";import"./shared-aeec3cab.js";import"./shared-f3f5e87e.js";import"./shared-068480a3.js";import"./shared-0543c6e0.js";import{G as l}from"./shared-08ff9a8d.js";import"./shared-4c9f96ec.js";import{P as d}from"./shared-7bf46d6d.js";import{C as c}from"./shared-de790de9.js";import{N as h}from"./shared-eb900735.js";import{i as m}from"./shared-d3bf9ac0.js";import"./shared-7a290f36.js";import"./shared-0c02b4ee.js";import"./shared-5dd31b4e.js";import"./shared-a8cf402a.js";import"./shared-d519a301.js";import"./shared-ca58ef47.js";import"./shared-64657919.js";import"./shared-e5c19ea3.js";import"./shared-11c2efc8.js";import"./shared-a89cb472.js";import"./shared-509a2f52.js";import"./shared-cd096e97.js";import"./shared-4db2c7b1.js";import"./shared-d6276c83.js";let p,f,u,_,y,b,x,$,v=e=>e;const g=s(a(c(i(h,"email-template-form"))));class j extends g{constructor(){super(...arguments),this.templates={},this.__templateLanguageOptions=[{label:"Nunjucks",value:"nunjucks"},{label:"Handlebars",value:"handlebars"},{label:"Pug",value:"pug"},{label:"Twig",value:"twig"},{label:"EJS",value:"ejs"}],this.__textContentChoice="default",this.__htmlContentChoice="default",this.__cacheState="idle"}static get properties(){return e(e({},super.properties),{},{__cacheState:{attribute:!1},__contentChoice:{attribute:!1}})}static get scopedElements(){return{"foxy-internal-select-control":customElements.get("foxy-internal-select-control"),"foxy-internal-confirm-dialog":customElements.get("foxy-internal-confirm-dialog"),"foxy-internal-source-control":customElements.get("foxy-internal-source-control"),"foxy-internal-text-control":customElements.get("foxy-internal-text-control"),"foxy-internal-sandbox":customElements.get("foxy-internal-sandbox"),"foxy-spinner":customElements.get("foxy-spinner"),"foxy-i18n":customElements.get("foxy-i18n"),"vaadin-text-field":customElements.get("vaadin-text-field"),"vaadin-button":customElements.get("vaadin-button"),"x-property-table":d,"x-choice":n,"x-group":l}}render(){var e,s,a;const{hiddenSelector:i,href:n,lang:o,ns:l}=this,d=n?"delete":"create",c=this.in("busy"),h=this.in("fail");return t(p||(p=v` <div class="space-y-m"> ${0} <foxy-internal-text-control infer="subject"></foxy-internal-text-control> ${0} ${0} ${0} ${0} <div data-testid="spinner" class="${0}"> <foxy-spinner layout="vertical" class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l" state="${0}" lang="${0}" ns="${0} ${0}"> </foxy-spinner> </div> </div> `),i.matches("description",!0)?"":this.__renderDescription(),"Email Receipt Template"===(null===(e=this.data)||void 0===e?void 0:e.description)?"":t(f||(f=v` <foxy-internal-select-control infer="template-language" .options="${0}"> </foxy-internal-select-control> `),this.__templateLanguageOptions),i.matches("content",!0)?"":this.__renderContent(),i.matches("timestamps",!0)||!n?"":this.__renderTimestamps(),i.matches(d)?"":this.__renderAction(d),r({"transition duration-500 ease-in-out absolute inset-0 flex":!0,"opacity-0 pointer-events-none":!c&&!h}),h?"error":c?"busy":"empty",o,l,null!==(a=null===(s=customElements.get("foxy-spinner"))||void 0===s?void 0:s.defaultNS)&&void 0!==a?a:"")}async _sendPost(e){const t=await super._sendPost(e);if(!t.content_html_url&&!t.content_text_url)return t;this.__cacheState="busy";const s=t._links["fx:cache"].href,a=await new j.API(this).fetch(s,{method:"POST"});return this.__cacheState=a.ok?"idle":"fail",await this._fetch(t._links.self.href)}async _sendPatch(e){const t=await super._sendPatch(e);if(!t.content_html_url&&!t.content_text_url)return t;this.__cacheState="busy";const s=t._links["fx:cache"].href,a=await new j.API(this).fetch(s,{method:"POST"});return this.__cacheState=a.ok?"idle":"fail",await this._fetch(t._links.self.href)}__renderDescription(){var e,s;const a="description";return t(u||(u=v` <div> ${0} <vaadin-text-field data-testid="${0}" class="w-full mb-s" label="${0}" ?disabled="${0}" ?readonly="${0}" .value="${0}" @keydown="${0}" @input="${0}"> </vaadin-text-field> ${0} </div> `),this.renderTemplateOrSlot(`${a}:before`),a,this.t(a),!this.in("idle")||this.disabledSelector.matches(a),this.readonlySelector.matches(a),null!==(s=null===(e=this.form)||void 0===e?void 0:e.description)&&void 0!==s?s:"",(e=>"Enter"===e.key&&this.submit()),(e=>{this.edit({description:e.currentTarget.value})}),this.renderTemplateOrSlot(`${a}:after`))}__renderContent(){return t(_||(_=v` <div data-testid="content"> <div class="space-y-l">${0}</div> </div> `),["text","html"].map((e=>this.__renderContentVariant(e))))}__renderContentVariant(e){var s,a;const i="text"===e?"content_text_url":"content_html_url",n="text"===e?"content_text":"content_html",l="text"===e?"text_template":"html_template",d=this.form[i],c=this.form[n],h="text"===e?"__textContentChoice":"__htmlContentChoice",p=d?"url":c?"clipboard":this[h],f=!this.in("idle")||this.disabledSelector.matches("content",!0),u=this.readonlySelector.matches("content",!0),_=u||!(null===(s=this.data)||void 0===s?void 0:s[i])||d!==this.data[i];return t(y||(y=v` <x-group frame> <foxy-i18n class="${0}" lang="${0}" slot="header" key="${0}" ns="${0}"> </foxy-i18n> <x-choice data-testid="${0}-type" .value="${0}" .items="${0}" ?readonly="${0}" ?disabled="${0}" @change="${0}"> ${0} <div style="--lumo-border-radius:var(--lumo-border-radius-s)" class="mb-m" slot="url" ?hidden="${0}"> <div class="flex items-end mt-0"> <vaadin-text-field data-testid="${0}-url" placeholder="https://example.com/my-template" label="${0}" class="flex-1 min-w-0" value="${0}" ?readonly="${0}" ?disabled="${0}" @keydown="${0}" @input="${0}"> </vaadin-text-field> <vaadin-button data-testid="${0}-cache" class="relative flex-shrink-0 ml-s" ?disabled="${0}" ?hidden="${0}" @click="${0}"> <foxy-i18n class="${0}" lang="${0}" key="cache" ns="${0}"> </foxy-i18n> <div class="${0}"> <foxy-spinner layout="no-label" class="m-auto" state="${0}" lang="${0}" ns="${0}"> </foxy-spinner> </div> </vaadin-button> </div> <foxy-internal-source-control placeholder="${0}" property="${0}" label="${0}" infer="content" class="mt-m${0}" style="--lumo-border-radius:var(--lumo-border-radius-s)"> </foxy-internal-source-control> </div> <foxy-internal-source-control placeholder="${0}" property="${0}" label="${0}" infer="content" class="mb-m${0}" style="--lumo-border-radius:var(--lumo-border-radius-s)" slot="clipboard"> </foxy-internal-source-control> </x-choice> </x-group> `),r({"transition-colors":!0,"text-disabled":f}),this.lang,l,this.ns,n.replace("_","-"),p,["default","url","clipboard"],u,f,(e=>{e instanceof o&&(this.edit({[n]:"",[i]:""}),this[h]=e.detail)}),["default","url","clipboard"].map((e=>t(b||(b=v` <div slot="${0}-label" class="py-s leading-s"> <foxy-i18n class="block" lang="${0}" key="template_${0}" ns="${0}"> </foxy-i18n> </div> `),e,this.lang,e,this.ns))),"url"!==p,n.replace("_","-"),this.t("url"),m(this.form[i]),u,f,(e=>"Enter"===e.key&&this.submit()),(e=>{const t=e.currentTarget.value;this.edit({[n]:"",[i]:t})}),n.replace("_","-"),f||"busy"===this.__cacheState,_,this.__cache,r({"relative transition-opacity":!0,"opacity-0":"idle"!==this.__cacheState}),this.lang,this.ns,r({"absolute inset-0 flex transition-opacity":!0,"opacity-0":"idle"===this.__cacheState}),"fail"===this.__cacheState?"error":"busy",this.lang,this.ns,this.t("url_source_placeholder"),n,this.t("url_source_label"),(null===(a=this.data)||void 0===a?void 0:a[n])?"":" hidden",this.t("clipboard_source_placeholder"),n,this.t("clipboard_source_label"),"clipboard"===p?"":" hidden")}__renderTimestamps(){const e="timestamps";return t(x||(x=v` <div> ${0} <x-property-table data-testid="timestamps" .items="${0}"> </x-property-table> ${0} </div> `),this.renderTemplateOrSlot(`${e}:before`),["date_modified","date_created"].map((e=>{var t;return{name:this.t(e),value:(null===(t=this.data)||void 0===t?void 0:t[e])?this.t("date",{value:new Date(this.data[e])}):""}})),this.renderTemplateOrSlot(`${e}:after`))}__renderAction(e){const{disabledSelector:s,href:a,lang:i,ns:r}=this,n=this.in({idle:{template:{dirty:"valid"}}}),o=this.in({idle:{snapshot:{dirty:"valid"}}}),l=!this.in("idle")||s.matches(e,!0),d=n||o;return t($||($=v` <div> ${0} <foxy-internal-confirm-dialog message="delete_prompt" confirm="delete" cancel="cancel" header="delete" theme="primary error" lang="${0}" ns="${0}" id="confirm" data-testid="confirm" @hide="${0}"> </foxy-internal-confirm-dialog> <vaadin-button class="w-full" theme="${0}" data-testid="${0}" ?disabled="${0}" @click="${0}"> <foxy-i18n ns="${0}" key="${0}" lang="${0}"></foxy-i18n> </vaadin-button> ${0} </div> `),this.renderTemplateOrSlot(`${e}:before`),i,r,(e=>{e.detail.cancelled||this.delete()}),this.in("idle")?a?"error":"primary success":"",e,this.in({idle:"template"})&&!d||l,(t=>{if("delete"===e){this.renderRoot.querySelector("#confirm").show(t.currentTarget)}else this.submit()}),r,e,i,this.renderTemplateOrSlot(`${e}:after`))}async __cache(){var e,t;this.__cacheState="busy";try{const s=null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:cache"].href)&&void 0!==t?t:"",a=await new j.API(this).fetch(s,{method:"POST"});this.__cacheState=a.ok?"idle":"fail",this.refresh()}catch(e){this.__cacheState="fail"}}}customElements.define("foxy-email-template-form",j);export{j as EmailTemplateForm};
|
|
1
|
+
import"./shared-b95ef318.js";import"./shared-cb6f2388.js";import"./shared-3a82d3f5.js";import"./shared-0dc1d012.js";import"./shared-e6066f46.js";import"./shared-1e5292a1.js";import"./shared-0479553e.js";import"./foxy-spinner.js";import"./shared-86768244.js";import{_ as e}from"./shared-98755831.js";import"./shared-e28f16db.js";import"./shared-c40d85dc.js";import"./shared-6f465111.js";import{h as t}from"./shared-7f33a83a.js";import{S as s,T as a,a as i}from"./shared-16b542bc.js";import{c as r}from"./shared-4e709717.js";import{C as n,a as o}from"./shared-ee13d1a6.js";import"./shared-9e60ef60.js";import"./shared-6b53ef85.js";import"./shared-aeec3cab.js";import"./shared-f3f5e87e.js";import"./shared-068480a3.js";import"./shared-0543c6e0.js";import{G as l}from"./shared-08ff9a8d.js";import"./shared-4c9f96ec.js";import{P as d}from"./shared-7bf46d6d.js";import{C as c}from"./shared-de790de9.js";import{N as h}from"./shared-eb900735.js";import{i as m}from"./shared-d3bf9ac0.js";import"./shared-7a290f36.js";import"./shared-0c02b4ee.js";import"./shared-5dd31b4e.js";import"./shared-a8cf402a.js";import"./shared-d519a301.js";import"./shared-ca58ef47.js";import"./shared-64657919.js";import"./shared-e5c19ea3.js";import"./shared-11c2efc8.js";import"./shared-a89cb472.js";import"./shared-509a2f52.js";import"./shared-cd096e97.js";import"./shared-4db2c7b1.js";import"./shared-d6276c83.js";let p,f,u,_,y,b,x,$,v=e=>e;const g=s(a(c(i(h,"email-template-form"))));class j extends g{constructor(){super(...arguments),this.templates={},this.__templateLanguageOptions=[{label:"Nunjucks",value:"nunjucks"},{label:"Handlebars",value:"handlebars"},{label:"Pug",value:"pug"},{label:"Twig",value:"twig"},{label:"EJS",value:"ejs"}],this.__textContentChoice="default",this.__htmlContentChoice="default",this.__cacheState="idle"}static get properties(){return e(e({},super.properties),{},{__cacheState:{attribute:!1},__contentChoice:{attribute:!1}})}static get scopedElements(){return{"foxy-internal-select-control":customElements.get("foxy-internal-select-control"),"foxy-internal-confirm-dialog":customElements.get("foxy-internal-confirm-dialog"),"foxy-internal-source-control":customElements.get("foxy-internal-source-control"),"foxy-internal-text-control":customElements.get("foxy-internal-text-control"),"foxy-internal-sandbox":customElements.get("foxy-internal-sandbox"),"foxy-spinner":customElements.get("foxy-spinner"),"foxy-i18n":customElements.get("foxy-i18n"),"vaadin-text-field":customElements.get("vaadin-text-field"),"vaadin-button":customElements.get("vaadin-button"),"x-property-table":d,"x-choice":n,"x-group":l}}render(){var e,s,a;const{hiddenSelector:i,href:n,lang:o,ns:l}=this,d=n?"delete":"create",c=this.in("busy"),h=this.in("fail");return t(p||(p=v` <div class="space-y-m"> ${0} <foxy-internal-text-control infer="subject"></foxy-internal-text-control> ${0} ${0} ${0} ${0} <div data-testid="spinner" class="${0}"> <foxy-spinner layout="vertical" class="m-auto p-m bg-base shadow-xs rounded-t-l rounded-b-l" state="${0}" lang="${0}" ns="${0} ${0}"> </foxy-spinner> </div> </div> `),i.matches("description",!0)?"":this.__renderDescription(),"Email Receipt Template"===(null===(e=this.data)||void 0===e?void 0:e.description)?"":t(f||(f=v` <foxy-internal-select-control infer="template-language" .options="${0}"> </foxy-internal-select-control> `),this.__templateLanguageOptions),i.matches("content",!0)?"":this.__renderContent(),i.matches("timestamps",!0)||!n?"":this.__renderTimestamps(),i.matches(d)?"":this.__renderAction(d),r({"transition duration-500 ease-in-out absolute inset-0 flex":!0,"opacity-0 pointer-events-none":!c&&!h}),h?"error":c?"busy":"empty",o,l,null!==(a=null===(s=customElements.get("foxy-spinner"))||void 0===s?void 0:s.defaultNS)&&void 0!==a?a:"")}async _sendPost(e){const t=await super._sendPost(e);if(!t.content_html_url&&!t.content_text_url)return t;this.__cacheState="busy";const s=t._links["fx:cache"].href,a=await new j.API(this).fetch(s,{method:"POST"});return this.__cacheState=a.ok?"idle":"fail",await this._fetch(t._links.self.href)}async _sendPatch(e){const t=await super._sendPatch(e);if(!t.content_html_url&&!t.content_text_url)return t;this.__cacheState="busy";const s=t._links["fx:cache"].href,a=await new j.API(this).fetch(s,{method:"POST"});return this.__cacheState=a.ok?"idle":"fail",await this._fetch(t._links.self.href)}__renderDescription(){var e,s;const a="description";return t(u||(u=v` <div> ${0} <vaadin-text-field data-testid="${0}" class="w-full mb-s" label="${0}" ?disabled="${0}" ?readonly="${0}" .value="${0}" @keydown="${0}" @input="${0}"> </vaadin-text-field> ${0} </div> `),this.renderTemplateOrSlot(`${a}:before`),a,this.t(a),!this.in("idle")||this.disabledSelector.matches(a),this.readonlySelector.matches(a),null!==(s=null===(e=this.form)||void 0===e?void 0:e.description)&&void 0!==s?s:"",(e=>"Enter"===e.key&&this.submit()),(e=>{this.edit({description:e.currentTarget.value})}),this.renderTemplateOrSlot(`${a}:after`))}__renderContent(){return t(_||(_=v` <div data-testid="content"> <div class="space-y-l">${0}</div> </div> `),["text","html"].map((e=>this.__renderContentVariant(e))))}__renderContentVariant(e){var s,a;const i="text"===e?"content_text_url":"content_html_url",n="text"===e?"content_text":"content_html",l="text"===e?"text_template":"html_template",d=this.form[i],c=this.form[n],h="text"===e?"__textContentChoice":"__htmlContentChoice",p=d?"url":c?"clipboard":this[h],f=!this.in("idle")||this.disabledSelector.matches("content",!0),u=this.readonlySelector.matches("content",!0),_=u||!(null===(s=this.data)||void 0===s?void 0:s[i])||d!==this.data[i];return t(y||(y=v` <x-group frame> <foxy-i18n class="${0}" lang="${0}" slot="header" key="${0}" ns="${0}"> </foxy-i18n> <x-choice data-testid="${0}-type" .value="${0}" .items="${0}" ?readonly="${0}" ?disabled="${0}" @change="${0}"> ${0} <div style="--lumo-border-radius:var(--lumo-border-radius-s)" class="mb-m" slot="url" ?hidden="${0}"> <div class="flex items-end mt-0"> <vaadin-text-field data-testid="${0}-url" placeholder="https://example.com/my-template" label="${0}" class="flex-1 min-w-0" value="${0}" ?readonly="${0}" ?disabled="${0}" @keydown="${0}" @input="${0}"> </vaadin-text-field> <vaadin-button data-testid="${0}-cache" class="relative flex-shrink-0 ml-s" ?disabled="${0}" ?hidden="${0}" @click="${0}"> <foxy-i18n class="${0}" lang="${0}" key="cache" ns="${0}"> </foxy-i18n> <div class="${0}"> <foxy-spinner layout="no-label" class="m-auto" state="${0}" lang="${0}" ns="${0}"> </foxy-spinner> </div> </vaadin-button> </div> <foxy-internal-source-control placeholder="${0}" helper-text="" property="${0}" label="${0}" infer="content" class="mt-m${0}" style="--lumo-border-radius:var(--lumo-border-radius-s)"> </foxy-internal-source-control> </div> <foxy-internal-source-control placeholder="${0}" helper-text="" property="${0}" label="${0}" infer="content" class="mb-m${0}" style="--lumo-border-radius:var(--lumo-border-radius-s)" slot="clipboard"> </foxy-internal-source-control> </x-choice> </x-group> `),r({"transition-colors":!0,"text-disabled":f}),this.lang,l,this.ns,n.replace("_","-"),p,["default","url","clipboard"],u,f,(e=>{e instanceof o&&(this.edit({[n]:"",[i]:""}),this[h]=e.detail)}),["default","url","clipboard"].map((e=>t(b||(b=v` <div slot="${0}-label" class="py-s leading-s"> <foxy-i18n class="block" lang="${0}" key="template_${0}" ns="${0}"> </foxy-i18n> </div> `),e,this.lang,e,this.ns))),"url"!==p,n.replace("_","-"),this.t("url"),m(this.form[i]),u,f,(e=>"Enter"===e.key&&this.submit()),(e=>{const t=e.currentTarget.value;this.edit({[n]:"",[i]:t})}),n.replace("_","-"),f||"busy"===this.__cacheState,_,this.__cache,r({"relative transition-opacity":!0,"opacity-0":"idle"!==this.__cacheState}),this.lang,this.ns,r({"absolute inset-0 flex transition-opacity":!0,"opacity-0":"idle"===this.__cacheState}),"fail"===this.__cacheState?"error":"busy",this.lang,this.ns,this.t("url_source_placeholder"),n,this.t("url_source_label"),(null===(a=this.data)||void 0===a?void 0:a[n])?"":" hidden",this.t("clipboard_source_placeholder"),n,this.t("clipboard_source_label"),"clipboard"===p?"":" hidden")}__renderTimestamps(){const e="timestamps";return t(x||(x=v` <div> ${0} <x-property-table data-testid="timestamps" .items="${0}"> </x-property-table> ${0} </div> `),this.renderTemplateOrSlot(`${e}:before`),["date_modified","date_created"].map((e=>{var t;return{name:this.t(e),value:(null===(t=this.data)||void 0===t?void 0:t[e])?this.t("date",{value:new Date(this.data[e])}):""}})),this.renderTemplateOrSlot(`${e}:after`))}__renderAction(e){const{disabledSelector:s,href:a,lang:i,ns:r}=this,n=this.in({idle:{template:{dirty:"valid"}}}),o=this.in({idle:{snapshot:{dirty:"valid"}}}),l=!this.in("idle")||s.matches(e,!0),d=n||o;return t($||($=v` <div> ${0} <foxy-internal-confirm-dialog message="delete_prompt" confirm="delete" cancel="cancel" header="delete" theme="primary error" lang="${0}" ns="${0}" id="confirm" data-testid="confirm" @hide="${0}"> </foxy-internal-confirm-dialog> <vaadin-button class="w-full" theme="${0}" data-testid="${0}" ?disabled="${0}" @click="${0}"> <foxy-i18n ns="${0}" key="${0}" lang="${0}"></foxy-i18n> </vaadin-button> ${0} </div> `),this.renderTemplateOrSlot(`${e}:before`),i,r,(e=>{e.detail.cancelled||this.delete()}),this.in("idle")?a?"error":"primary success":"",e,this.in({idle:"template"})&&!d||l,(t=>{if("delete"===e){this.renderRoot.querySelector("#confirm").show(t.currentTarget)}else this.submit()}),r,e,i,this.renderTemplateOrSlot(`${e}:after`))}async __cache(){var e,t;this.__cacheState="busy";try{const s=null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:cache"].href)&&void 0!==t?t:"",a=await new j.API(this).fetch(s,{method:"POST"});this.__cacheState=a.ok?"idle":"fail",this.refresh()}catch(e){this.__cacheState="fail"}}}customElements.define("foxy-email-template-form",j);export{j as EmailTemplateForm};
|