D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafdxji
/
shihty.com
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
surecart
/
Filename :
p-d2bfe7f4.entry.js
back
Copy
import{r as e,c as t,h as i,a as s,F as o}from"./p-e97fde0a.js";import{g as r,c as n}from"./p-e3f4d732.js";import{r as l,F as a}from"./p-8b323bfb.js";import{i as c}from"./p-b0d8cd6e.js";import{s as h}from"./p-830ab1a3.js";import{z as d}from"./p-e677365e.js";import"./p-401e165e.js";const u=":host{display:block}.sc-address{display:block;position:relative}.sc-address [hidden]{display:none}.sc-address--loading{min-height:230px}.sc-address sc-skeleton{display:block;margin-bottom:1em}.sc-address__control{display:block}.sc-address__control>*{margin-bottom:var(--sc-address-column-spacing, -1px)}.sc-address__columns{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap;justify-content:space-between}.sc-address__columns>*{flex:1;width:50%;margin-right:var(--sc-address-column-spacing, -1px)}.sc-address__columns>*:last-child{margin-right:0}";const p=u;const b=[{name:"country",priority:30,label:wp.i18n.__("Country","surecart")},{name:"name",priority:40,label:wp.i18n.__("Name or Company Name","surecart")},{name:"line_1",priority:50,label:wp.i18n.__("Address","surecart")},{name:"line_2",priority:60,label:wp.i18n.__("Line 2","surecart")},{name:"city",priority:70,label:wp.i18n.__("City","surecart")},{name:"state",priority:80,label:wp.i18n.__("State / County","surecart")},{name:"postal_code",priority:90,label:wp.i18n.__("Postal Code","surecart")}];const v=class{constructor(i){e(this,i);this.scChangeAddress=t(this,"scChangeAddress",7);this.scInputAddress=t(this,"scInputAddress",7);this.address={country:null,city:null,line_1:null,line_2:null,postal_code:null,state:null};this.names={name:"shipping_name",country:"shipping_country",city:"shipping_city",line_1:"shipping_line_1",line_2:"shipping_line_2",postal_code:"shipping_postal_code",state:"shipping_state"};this.loading=false;this.disabled=undefined;this.label=undefined;this.showName=undefined;this.showLine2=undefined;this.required=false;this.requireName=false;this.showCity=true;this.showPostal=true;this.countryDetails=null;this.countryChoices=undefined}async handleAddressChange(){var e,t;if(!((e=this.address)===null||e===void 0?void 0:e.country))return;if(!this.countryDetails||((t=this.countryDetails)===null||t===void 0?void 0:t.code)!==this.address.country){this.countryDetails=await r(this.address.country)}this.scChangeAddress.emit(this.address);this.scInputAddress.emit(this.address)}handleNameChange(){if(this.requireName){this.showName=true}}decodeHtmlEntities(e){var t;return((t=(new DOMParser).parseFromString(e,"text/html"))===null||t===void 0?void 0:t.body.textContent)||e}updateAddress(e){this.address={...this.address,...e}}handleAddressInput(e){this.scInputAddress.emit({...this.address,...e})}clearAddress(){var e;this.address={name:(e=this.address)===null||e===void 0?void 0:e.name,country:null,city:null,line_1:null,line_2:null,postal_code:null,state:null}}componentWillLoad(){this.initCountryChoices();this.handleAddressChange();this.handleNameChange()}async initCountryChoices(){var e,t;this.countryChoices=await n();const i=((t=(e=this.countryChoices)===null||e===void 0?void 0:e.find((e=>{var t;return e.value===((t=this.address)===null||t===void 0?void 0:t.country)})))===null||t===void 0?void 0:t.value)||null;this.updateAddress({country:i})}async reportValidity(){return l(this.el)}sortedFields(){var e,t,i,s;if(!this.countryDetails||!((e=this===null||this===void 0?void 0:this.address)===null||e===void 0?void 0:e.country)){return b}return((s=(i=(t=this===null||this===void 0?void 0:this.countryDetails)===null||t===void 0?void 0:t.address_formats)===null||i===void 0?void 0:i.edit)===null||s===void 0?void 0:s.match(/{{([^}]+)}}/g).map((e=>e.slice(2,-2))).map((e=>{var t,i,s;return{name:e,label:((i=(t=this===null||this===void 0?void 0:this.countryDetails)===null||t===void 0?void 0:t.address_labels)===null||i===void 0?void 0:i[e])||((s=b===null||b===void 0?void 0:b.find((t=>(t===null||t===void 0?void 0:t.name)===e)))===null||s===void 0?void 0:s.label)}})))||[]}regions(){var e,t,i,s,o;let r=((t=(e=this===null||this===void 0?void 0:this.countryDetails)===null||e===void 0?void 0:e.states)===null||t===void 0?void 0:t.map((e=>({value:e===null||e===void 0?void 0:e.code,label:e===null||e===void 0?void 0:e.name}))))||[];if((s=(i=window===null||window===void 0?void 0:window.wp)===null||i===void 0?void 0:i.hooks)===null||s===void 0?void 0:s.applyFilters){r=window.wp.hooks.applyFilters("surecart_address_regions",r,(o=this===null||this===void 0?void 0:this.address)===null||o===void 0?void 0:o.country)}return r}getRoundedProps(e,t){const i=e===0;const s=e===t-1;return{squaredTop:s,squaredBottom:i,squared:!s&&!i}}render(){var e,t;const s=(t=(e=this.sortedFields())!==null&&e!==void 0?e:[])===null||t===void 0?void 0:t.filter((e=>{var t,i,s,o;switch(e.name){case"name":return this.showName;case"line_2":return this.showLine2||!!((i=(t=this===null||this===void 0?void 0:this.address)===null||t===void 0?void 0:t.line_2)===null||i===void 0?void 0:i.length);case"city":return this.showCity;case"state":return!!((s=this===null||this===void 0?void 0:this.regions())===null||s===void 0?void 0:s.length)&&!!((o=this===null||this===void 0?void 0:this.address)===null||o===void 0?void 0:o.country);case"postal_code":return this.showPostal;default:return true}}));return i("div",{class:"sc-address",part:"base"},i("sc-form-control",{label:this.label,exportparts:"label, help-text, form-control",class:"sc-address__control",required:this.required},s.map(((e,t)=>{var o,r,n,l,a,c,h,d,u,p,b,v,m,_,f;const x=this.getRoundedProps(t,s.length);switch(e.name){case"country":return i("sc-select",{exportparts:"base:select__base, input, form-control, label, help-text, trigger, panel, caret, search__base, search__input, search__form-control, menu__base, spinner__base, empty",part:"name__input",value:(o=this.address)===null||o===void 0?void 0:o.country,onScChange:e=>{var t;if(e.target.value===((t=this.address)===null||t===void 0?void 0:t.country))return;this.clearAddress();this.updateAddress({country:e.target.value})},choices:this.countryChoices,autocomplete:"country-name",placeholder:e.label,name:(r=this.names)===null||r===void 0?void 0:r.country,search:true,unselect:false,disabled:this.disabled,required:this.required,"aria-label":e.label,...x});case"name":return i("sc-input",{exportparts:"base:input__base, input, form-control, label, help-text",value:(n=this===null||this===void 0?void 0:this.address)===null||n===void 0?void 0:n.name,onScChange:e=>this.updateAddress({name:e.target.value||null}),onScInput:e=>this.handleAddressInput({name:e.target.value||null}),autocomplete:"street-address",placeholder:e.label,name:(l=this.names)===null||l===void 0?void 0:l.name,disabled:this.disabled,required:this.requireName,"aria-label":e.label,...x});case"line_1":return i("sc-input",{exportparts:"base:input__base, input, form-control, label, help-text",value:(a=this===null||this===void 0?void 0:this.address)===null||a===void 0?void 0:a.line_1,onScChange:e=>this.updateAddress({line_1:e.target.value||null}),onScInput:e=>this.handleAddressInput({line_1:e.target.value||null}),autocomplete:"street-address",placeholder:e.label,name:(c=this.names)===null||c===void 0?void 0:c.line_1,disabled:this.disabled,required:this.required,"aria-label":e.label,...x});case"line_2":return i("sc-input",{exportparts:"base:input__base, input, form-control, label, help-text",value:(h=this===null||this===void 0?void 0:this.address)===null||h===void 0?void 0:h.line_2,onScChange:e=>this.updateAddress({line_2:e.target.value||null}),onScInput:e=>this.handleAddressInput({line_2:e.target.value||null}),autocomplete:"street-address",placeholder:e.label,name:(d=this.names)===null||d===void 0?void 0:d.line_2,disabled:this.disabled,"aria-label":e.label,...x});case"city":return i("sc-input",{exportparts:"base:input__base, input, form-control, label, help-text",placeholder:e.label,name:(u=this.names)===null||u===void 0?void 0:u.city,value:(p=this===null||this===void 0?void 0:this.address)===null||p===void 0?void 0:p.city,onScChange:e=>this.updateAddress({city:e.target.value||null}),onScInput:e=>this.handleAddressInput({city:e.target.value||null}),required:this.required,disabled:this.disabled,"aria-label":e.label,...x});case"state":return i("sc-select",{exportparts:"base:select__base, input, form-control, label, help-text, trigger, panel, caret, search__base, search__input, search__form-control, menu__base, spinner__base, empty",placeholder:e.label,name:(b=this.names)===null||b===void 0?void 0:b.state,autocomplete:"address-level1",value:(v=this===null||this===void 0?void 0:this.address)===null||v===void 0?void 0:v.state,onScChange:e=>{var t;return this.updateAddress({state:e.target.value||((t=e.detail)===null||t===void 0?void 0:t.value)||null})},choices:this.regions(),required:this.required,disabled:this.disabled,search:true,"aria-label":e.label,...x});case"postal_code":return i("sc-input",{exportparts:"base:input__base, input, form-control, label, help-text",placeholder:e.label,name:(m=this.names)===null||m===void 0?void 0:m.postal_code,onScChange:e=>this.updateAddress({postal_code:e.target.value||null}),onScInput:e=>this.handleAddressInput({postal_code:e.target.value||null}),autocomplete:"postal-code",required:this.required,value:(_=this===null||this===void 0?void 0:this.address)===null||_===void 0?void 0:_.postal_code,disabled:this.disabled,maxlength:((f=this.address)===null||f===void 0?void 0:f.country)==="US"?5:null,"aria-label":e.label,...x});default:return null}}))),this.loading&&i("sc-block-ui",{exportparts:"base:block-ui, content:block-ui__content"}))}get el(){return s(this)}static get watchers(){return{address:["handleAddressChange"],requireName:["handleNameChange"]}}};v.style=p;const m=':host{display:block}.checkbox{display:flex;font-family:var(--sc-input-font-family);font-size:var(--sc-input-font-size-medium);font-weight:var(--sc-input-font-weight);color:var(--sc-input-color);vertical-align:middle;cursor:pointer}.checkbox__control{flex:0 0 auto;position:relative;display:inline-flex;align-items:center;justify-content:center;width:var(--sc-checkbox-size);height:var(--sc-checkbox-size);border:solid var(--sc-input-border-width) var(--sc-input-border-color);border-radius:2px;background-color:var(--sc-input-background-color);color:var(--sc-color-white);transition:var(--sc-input-transition, var(--sc-transition-medium)) border-color, var(--sc-input-transition, var(--sc-transition-medium)) opacity, var(--sc-input-transition, var(--sc-transition-medium)) background-color, var(--sc-input-transition, var(--sc-transition-medium)) color, var(--sc-input-transition, var(--sc-transition-medium)) box-shadow}.checkbox__control input[type=checkbox]{position:absolute;opacity:0;padding:0;margin:0;pointer-events:none}.checkbox__control .checkbox__icon{display:inline-flex;width:var(--sc-checkbox-size);height:var(--sc-checkbox-size)}.checkbox__control .checkbox__icon svg{width:100%;height:100%}.checkbox:not(.checkbox--checked):not(.checkbox--disabled) .checkbox__control:hover{border-color:var(--sc-input-border-color-hover);background-color:var(--sc-input-background-color-hover)}.checkbox.checkbox--focused:not(.checkbox--checked):not(.checkbox--disabled) .checkbox__control{border-color:var(--sc-input-border-color-focus);background-color:var(--sc-input-background-color-focus);box-shadow:0 0 0 var(--sc-focus-ring-width) var(--sc-focus-ring-color-primary)}.checkbox--checked .checkbox__control,.checkbox--indeterminate .checkbox__control{border-color:var(--sc-color-primary-500);background-color:var(--sc-color-primary-500)}.checkbox.checkbox--checked:not(.checkbox--disabled) .checkbox__control:hover,.checkbox.checkbox--indeterminate:not(.checkbox--disabled) .checkbox__control:hover{opacity:0.8}.checkbox.checkbox--checked:not(.checkbox--disabled).checkbox--focused .checkbox__control,.checkbox.checkbox--indeterminate:not(.checkbox--disabled).checkbox--focused .checkbox__control{border-color:var(--sc-color-white);background-color:var(--sc-color-primary-500);box-shadow:0 0 0 var(--sc-focus-ring-width) var(--sc-focus-ring-color-primary)}.checkbox--disabled{opacity:0.5;cursor:not-allowed}.checkbox__label{line-height:var(--sc-checkbox-size);margin-top:var(--sc-input-border-width);margin-left:0.5em;flex:1}.checkbox--is-required .checkbox__label:after{content:" *";color:var(--sc-color-danger-500)}::slotted(*){display:inline-block}.checkbox--is-rtl .checkbox__label{margin-left:0;margin-right:0.5em}';const _=m;let f=0;const x=class{constructor(i){e(this,i);this.scBlur=t(this,"scBlur",7);this.scChange=t(this,"scChange",7);this.scFocus=t(this,"scFocus",7);this.inputId=`checkbox-${++f}`;this.labelId=`checkbox-label-${f}`;this.hasFocus=false;this.name=undefined;this.value=undefined;this.disabled=false;this.edit=false;this.required=false;this.checked=false;this.indeterminate=false;this.invalid=false}firstUpdated(){this.input.indeterminate=this.indeterminate}async triggerClick(){return this.input.click()}async triggerFocus(e){return this.input.focus(e)}async triggerBlur(){return this.input.blur()}async reportValidity(){this.invalid=!this.input.checkValidity();return this.input.reportValidity()}setCustomValidity(e){this.input.setCustomValidity(e);this.invalid=!this.input.checkValidity()}handleClick(){this.checked=!this.checked;this.indeterminate=false}handleBlur(){this.hasFocus=false;this.scBlur.emit()}handleFocus(){this.hasFocus=true;this.scFocus.emit()}handleLabelMouseDown(){this.input.focus()}handleStateChange(){this.input.checked=this.checked;this.input.indeterminate=this.indeterminate;this.scChange.emit()}componentDidLoad(){this.formController=new a(this.el,{value:e=>e.checked?e.value:undefined}).addFormData()}disconnectedCallback(){var e;(e=this.formController)===null||e===void 0?void 0:e.removeFormData()}render(){const e=this.edit?"div":"label";return i(e,{key:"3ac07eb97439442d837d0a8cda4136edc3616f2a",part:"base",class:{checkbox:true,"checkbox--is-required":this.required,"checkbox--checked":this.checked,"checkbox--disabled":this.disabled,"checkbox--focused":this.hasFocus,"checkbox--indeterminate":this.indeterminate,"checkbox--is-rtl":c()},htmlFor:this.inputId,onMouseDown:()=>this.handleLabelMouseDown()},i("span",{key:"ecd9c8541f7ee252d1a2e3224b109632680d3a15",part:"control",class:"checkbox__control"},this.checked?i("span",{part:"checked-icon",class:"checkbox__icon"},i("svg",{viewBox:"0 0 16 16"},i("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd","stroke-linecap":"round"},i("g",{stroke:"currentColor","stroke-width":"2"},i("g",{transform:"translate(3.428571, 3.428571)"},i("path",{d:"M0,5.71428571 L3.42857143,9.14285714"}),i("path",{d:"M9.14285714,0 L3.42857143,9.14285714"})))))):"",!this.checked&&this.indeterminate?i("span",{part:"indeterminate-icon",class:"checkbox__icon"},i("svg",{viewBox:"0 0 16 16"},i("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd","stroke-linecap":"round"},i("g",{stroke:"currentColor","stroke-width":"2"},i("g",{transform:"translate(2.285714, 6.857143)"},i("path",{d:"M10.2857143,1.14285714 L1.14285714,1.14285714"})))))):"",i("input",{key:"8bf943beb6241b829eea924acb3d9e6edef0f7c4",id:this.inputId,ref:e=>this.input=e,type:"checkbox",name:this.name,value:this.value,checked:this.checked,disabled:this.disabled,required:this.required,role:"checkbox","aria-checked":this.checked?"true":"false","aria-labelledby":this.labelId,onClick:()=>this.handleClick(),onBlur:()=>this.handleBlur(),onFocus:()=>this.handleFocus()})),i("span",{key:"c6dc0936a6c90ca0d416cf701ee8277a3045a1a2",part:"label",id:this.labelId,class:"checkbox__label"},i("slot",{key:"78426ec19722b27768b493aba35ec99a82679d27"})))}get el(){return s(this)}static get watchers(){return{checked:["handleStateChange"],indeterminate:["handleStateChange"]}}};x.style=_;const k=":host{display:block;z-index:3;position:relative}";const g=k;const y=class{constructor(i){e(this,i);this.scChange=t(this,"scChange",7);this.scInput=t(this,"scInput",7);this.scInputType=t(this,"scInputType",7);this.scSetState=t(this,"scSetState",7);this.country=undefined;this.show=false;this.type="other";this.number=null;this.status="unknown";this.loading=undefined;this.help=undefined;this.otherLabel=wp.i18n.__("Tax ID","surecart");this.caGstLabel=wp.i18n.__("GST Number","surecart");this.auAbnLabel=wp.i18n.__("ABN Number","surecart");this.gbVatLabel=wp.i18n.__("UK VAT","surecart");this.euVatLabel=wp.i18n.__("EU VAT","surecart");this.taxIdTypes=[];this.required=false}async reportValidity(){return this.input.reportValidity()}onLabelChange(){d.ca_gst.label=this.caGstLabel||d.ca_gst.label;d.au_abn.label=this.auAbnLabel||d.au_abn.label;d.gb_vat.label=this.gbVatLabel||d.gb_vat.label;d.eu_vat.label=this.euVatLabel||d.eu_vat.label;d.other.label=this.otherLabel||d.other.label}componentWillLoad(){this.onLabelChange()}renderStatus(){if(this.status==="valid"){return i("sc-icon",{name:"check",slot:"prefix",style:{color:"var(--sc-color-success-500)"}})}if(this.status==="invalid"){return i("sc-icon",{name:"x",slot:"prefix",style:{color:"var(--sc-color-danger-500)"}})}}filteredZones(){if(!!this.taxIdTypes.length){return Object.keys(d).filter((e=>this.taxIdTypes.includes(e))).reduce(((e,t)=>{e[t]=d[t];return e}),{})}return d}onTaxIdTypesChange(){if(!!this.taxIdTypes.length){this.type=!this.taxIdTypes.includes("other")?this.taxIdTypes[0]:"other"}}getZoneLabel(){var e,t;const i=this.filteredZones()||{};return((e=i===null||i===void 0?void 0:i[(this===null||this===void 0?void 0:this.type)||"other"])===null||e===void 0?void 0:e.label)||((t=i===null||i===void 0?void 0:i[Object.keys(i)[0]])===null||t===void 0?void 0:t.label)}render(){var e,t,s,r,n;return i(o,{key:"43a7cad8450579f6d5060c612c82f4c72893cbbf"},i("sc-input",{key:"00ad99ba8390326c977bd3ea55c8cd0c396d827f",name:"tax_identifier.number_type",required:this.required,value:this.type,style:{display:"none"}}),i("sc-input",{key:"cc9bb4148eae72267fc0f649980ddbef95f43a98",ref:e=>this.input=e,label:this.getZoneLabel(),"aria-label":wp.i18n.__("Tax ID","surecart"),placeholder:wp.i18n.__("Enter Tax ID","surecart"),name:"tax_identifier.number",value:this.number,onScInput:e=>{e.stopImmediatePropagation();this.scInput.emit({number:e.target.value,number_type:this.type||"other"})},onScChange:e=>{e.stopImmediatePropagation();this.scChange.emit({number:e.target.value,number_type:this.type||"other"})},help:this.help,required:this.required},this.loading&&this.type==="eu_vat"?i("sc-spinner",{slot:"prefix",style:{"--spinner-size":"10px"}}):this.renderStatus(),((e=Object.keys(this.filteredZones()||{}))===null||e===void 0?void 0:e.length)===1?i("span",{slot:"suffix"},(s=(t=Object.values(this.filteredZones()||{}))===null||t===void 0?void 0:t[0])===null||s===void 0?void 0:s["label_small"]):i("sc-dropdown",{slot:"suffix",position:"bottom-right",role:"select","aria-multiselectable":"false","aria-label":wp.i18n.__("Select number type","surecart")},i("sc-button",{type:"text",slot:"trigger",caret:true,loading:false,style:{color:"var(--sc-input-label-color)"},tabindex:"0"},(n=(r=this.filteredZones())===null||r===void 0?void 0:r[(this===null||this===void 0?void 0:this.type)||"other"])===null||n===void 0?void 0:n.label_small),i("sc-menu",null,Object.keys(this.filteredZones()||{}).map((e=>i("sc-menu-item",{role:"option",onClick:()=>{this.scInput.emit({number:this.number,number_type:e});this.scChange.emit({number:this.number,number_type:e});this.type=e},onKeyDown:t=>{var i;if(t.key==="Enter"){this.scInput.emit({number:this.number,number_type:e});this.scChange.emit({number:this.number,number_type:e});this.type=e;(i=this.input)===null||i===void 0?void 0:i.triggerFocus();h(wp.i18n.sprintf(wp.i18n.__("%s selected","surecart"),d[e].label_small,"assertive"))}},checked:this.type===e,"aria-selected":this.type===e?"true":"false","aria-label":d[e].label_small},d[e].label_small)))))))}static get watchers(){return{otherLabel:["onLabelChange"],caGstLabel:["onLabelChange"],auAbnLabel:["onLabelChange"],gbVatLabel:["onLabelChange"],euVatLabel:["onLabelChange"],taxIdTypes:["onTaxIdTypesChange"]}}};y.style=g;export{v as sc_address,x as sc_checkbox,y as sc_tax_id_input}; //# sourceMappingURL=p-d2bfe7f4.entry.js.map