// source --> https://mfrash.com/wp-content/plugins/woocommerce/assets/client/blocks/wc-blocks-registry.js?ver=6436a923b42f4d1b1f6d 
(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{__experimentalDeRegisterExpressPaymentMethod:()=>P,__experimentalDeRegisterPaymentMethod:()=>k,__experimentalRegisterProductCollection:()=>z,getExpressPaymentMethods:()=>S,getPaymentMethods:()=>I,getRegisteredBlockComponents:()=>A,getRegisteredInnerBlocks:()=>T,registerBlockComponent:()=>x,registerExpressPaymentMethod:()=>g,registerInnerBlock:()=>R,registerPaymentMethod:()=>h,registerPaymentMethodExtensionCallbacks:()=>v});const o=window.wp.deprecated;var r=e.n(o);const n=window.wp.data,a={},i=a,s=(e,t,o)=>{const r=((e,t)=>o=>(o?.paymentRequirements||[]).every((e=>t.includes(e)))&&e(o))(e,t);return Object.values(i).some((e=>o in e))?((e,t,o)=>r=>{let n=e(r);if(n){const e={};Object.entries(t).forEach((([t,r])=>{o in r&&"function"==typeof r[o]&&(e[t]=r[o])})),n=Object.keys(e).every((t=>{try{return e[t](r)}catch(e){return console.error(`Error when executing callback for ${o} in ${t}`,e),!0}}))}return n})(r,i,o):r},c=window.wp.element,l=(e,t)=>{if(null!==e&&!(0,c.isValidElement)(e))throw new TypeError(`The ${t} property for the payment method must be a React element or null.`)},u=(e,t=[])=>{const o=t.reduce(((t,o)=>(e.hasOwnProperty(o)||t.push(o),t)),[]);if(o.length>0)throw new TypeError("The payment method configuration object is missing the following properties:"+o.join(", "))},p=window.ReactJSXRuntime,d=()=>null;class m{constructor(e){m.assertValidConfig(e),this.name=e.name,this.label=e.label,this.placeOrderButtonLabel=e.placeOrderButtonLabel,this.placeOrderButton=e.placeOrderButton,this.ariaLabel=e.ariaLabel,this.content=e.content,this.savedTokenComponent=e.savedTokenComponent,this.icons=e.icons||null,this.edit=e.edit,this.paymentMethodId=e.paymentMethodId||this.name,this.supports={showSavedCards:e?.supports?.showSavedCards||e?.supports?.savePaymentInfo||!1,showSaveOption:e?.supports?.showSaveOption||!1,features:e?.supports?.features||["products"]},this.canMakePaymentFromConfig=e.canMakePayment}get canMakePayment(){return s(this.canMakePaymentFromConfig,this.supports.features,this.name)}static assertValidConfig=e=>{if(e.savedTokenComponent=e.savedTokenComponent||(0,p.jsx)(d,{}),u(e,["name","label","ariaLabel","content","edit","canMakePayment"]),"string"!=typeof e.name)throw new Error("The name property for the payment method must be a string");if(void 0!==e.icons&&!Array.isArray(e.icons)&&null!==e.icons)throw new Error("The icons property for the payment method must be an array or null.");if("string"!=typeof e.paymentMethodId&&void 0!==e.paymentMethodId)throw new Error("The paymentMethodId property for the payment method must be a string or undefined (in which case it will be the value of the name property).");if("string"!=typeof e.placeOrderButtonLabel&&void 0!==e.placeOrderButtonLabel)throw new TypeError("The placeOrderButtonLabel property for the payment method must be a string");if(e.placeOrderButton&&"function"!=typeof e.placeOrderButton)throw new TypeError("The placeOrderButton property for the payment method must be a React component (function)");if(e.placeOrderButton&&e.placeOrderButtonLabel&&console.warn(`Payment method "${e.name}" provided both placeOrderButton and placeOrderButtonLabel. Using placeOrderButton.`),(e=>{if(null!==e&&!(0,c.isValidElement)(e)&&"string"!=typeof e)throw new TypeError("The label property for the payment method must be a React element, a string, or null.")})(e.label),l(e.content,"content"),l(e.edit,"edit"),l(e.savedTokenComponent,"savedTokenComponent"),"string"!=typeof e.ariaLabel)throw new TypeError("The ariaLabel property for the payment method must be a string");if("function"!=typeof e.canMakePayment)throw new TypeError("The canMakePayment property for the payment method must be a function.");if(void 0!==e.supports?.showSavedCards&&"boolean"!=typeof e.supports?.showSavedCards)throw new TypeError("If the payment method includes the `supports.showSavedCards` property, it must be a boolean");if(void 0!==e.supports?.savePaymentInfo&&r()("Passing savePaymentInfo when registering a payment method.",{alternative:"Pass showSavedCards and showSaveOption",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3686"}),void 0!==e.supports?.features&&!Array.isArray(e.supports?.features))throw new Error("The features property for the payment method must be an array or undefined.");if(void 0!==e.supports?.showSaveOption&&"boolean"!=typeof e.supports?.showSaveOption)throw new TypeError("If the payment method includes the `supports.showSaveOption` property, it must be a boolean")}}class y{constructor(e){const t="string"==typeof e.name?e.name.replace(/[_-]/g," "):e.name,o="string"==typeof e?.description&&e.description.length>130?e.description.slice(0,130)+"...":e.description;y.assertValidConfig(e),this.name=e.name,this.title=e.title||t,this.description=o||"",this.gatewayId=e.gatewayId||"",this.content=e.content,this.edit=e.edit,this.paymentMethodId=e.paymentMethodId||this.name,this.supports={features:e?.supports?.features||["products"],style:e?.supports?.style||[]},this.canMakePaymentFromConfig=e.canMakePayment}get canMakePayment(){return s(this.canMakePaymentFromConfig,this.supports.features,this.name)}static assertValidConfig=e=>{if(u(e,["name","content","edit"]),"string"!=typeof e.name)throw new TypeError("The name property for the express payment method must be a string");if("string"!=typeof e.paymentMethodId&&void 0!==e.paymentMethodId)throw new Error("The paymentMethodId property for the payment method must be a string or undefined (in which case it will be the value of the name property).");if(void 0!==e.supports?.features&&!Array.isArray(e.supports?.features))throw new Error("The features property for the payment method must be an array or undefined.");if(l(e.content,"content"),l(e.edit,"edit"),"function"!=typeof e.canMakePayment)throw new TypeError("The canMakePayment property for the express payment method must be a function.")}}const b="wc/store/payment",w={},f={},h=e=>{let t;"function"==typeof e?(t=e(m),r()("Passing a callback to registerPaymentMethod()",{alternative:"a config options object",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3404"})):t=new m(e),t instanceof m&&(w[t.name]=t)},g=e=>{let t;"function"==typeof e?(t=e(y),r()("Passing a callback to registerExpressPaymentMethod()",{alternative:"a config options object",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3404"})):t=new y(e),t instanceof y&&(f[t.name]=t)},v=(e,t)=>{a[e]?console.error(`The namespace provided to registerPaymentMethodExtensionCallbacks must be unique. Callbacks have already been registered for the ${e} namespace.`):(a[e]={},Object.entries(t).forEach((([t,o])=>{"function"==typeof o?a[e][t]=o:console.error(`All callbacks provided to registerPaymentMethodExtensionCallbacks must be functions. The callback for the ${t} payment method in the ${e} namespace was not a function.`)})))},k=e=>{delete w[e];const{__internalRemoveAvailablePaymentMethod:t}=(0,n.dispatch)(b);t(e)},P=e=>{delete f[e];const{__internalRemoveAvailableExpressPaymentMethod:t}=(0,n.dispatch)(b);t(e)},I=()=>w,S=()=>f,E={};function A(e){return{..."object"==typeof E[e]&&Object.keys(E[e]).length>0?E[e]:{},...E.any}}function T(e){return r()("getRegisteredInnerBlocks",{version:"2.8.0",alternative:"getRegisteredBlockComponents",plugin:"WooCommerce Blocks"}),A(e)}const O=(e,t,o)=>{const r=typeof e[t];if(r!==o)throw new Error(`Incorrect value for the ${t} argument when registering a block component. It was a ${r}, but must be a ${o}.`)},C=(e,t)=>{if(e[t]){if("function"==typeof e[t])return;if(e[t].$$typeof&&e[t].$$typeof===Symbol.for("react.lazy"))return}throw new Error(`Incorrect value for the ${t} argument when registering a block component. Component must be a valid React Element or Lazy callback.`)};function x(e){e.context||(e.context="any"),O(e,"context","string"),O(e,"blockName","string"),C(e,"component");const{context:t,blockName:o,component:r}=e;E[t]||(E[t]={}),E[t][o]=r}function R(e){r()("registerInnerBlock",{version:"2.8.0",alternative:"registerBlockComponent",plugin:"WooCommerce Blocks",hint:'"main" has been replaced with "context" and is now optional.'}),O(e,"main","string"),x({...e,context:e.main})}const B=window.wp.hooks;let q=function(e){return e.GRID="flex",e.STACK="list",e.CAROUSEL="carousel",e}({}),M=function(e){return e.FILL="fill",e.FIXED="fixed",e}({}),j=function(e){return e.ATTRIBUTES="attributes",e.CREATED="created",e.FEATURED="featured",e.HAND_PICKED="hand-picked",e.INHERIT="inherit",e.KEYWORD="keyword",e.ON_SALE="on-sale",e.ORDER="order",e.DEFAULT_ORDER="default-order",e.STOCK_STATUS="stock-status",e.TAXONOMY="taxonomy",e.PRICE_RANGE="price-range",e.FILTERABLE="filterable",e.PRODUCTS_PER_PAGE="products-per-page",e.MAX_PAGES_TO_SHOW="max-pages-to-show",e.OFFSET="offset",e.RELATED_BY="related-by",e}({});const L=window.wc.wcSettings,_=JSON.parse('{"UU":"woocommerce/product-collection"}');let F=function(e){return e.SINGLE="single",e.THUMBNAIL="thumbnail",e}({});const $=_.UU,D=`${$}/product-title`,H=(0,L.getSetting)("stockStatusOptions",[]),N={perPage:9,pages:0,offset:0,postType:"product",order:"asc",orderBy:"title",search:"",exclude:[],inherit:!1,taxQuery:{},isProductCollectionBlock:!0,featured:!1,woocommerceOnSale:!1,woocommerceStockStatus:(0,L.getSetting)("hideOutOfStockItems",!1)?Object.keys(function(e,t){const{[t]:o,...r}=e;return r}(H,"outofstock")):Object.keys(H),woocommerceAttributes:[],woocommerceHandPickedProducts:[],timeFrame:void 0,priceRange:void 0,filterable:!1,relatedBy:{categories:!0,tags:!0}},U={query:N,tagName:"div",displayLayout:{type:q.GRID,columns:3,shrinkColumns:!0},dimensions:{widthType:M.FILL},queryContextIncludes:["collection"],forcePageReload:!1},V=[["woocommerce/product-template",{},[["woocommerce/product-image",{imageSizing:F.THUMBNAIL,showSaleBadge:!1},[["woocommerce/product-sale-badge",{align:"right"}]]],["core/post-title",{textAlign:"center",level:2,fontSize:"medium",style:{spacing:{margin:{bottom:"0.75rem",top:"0"}},typography:{lineHeight:"1.4"}},isLink:!0,__woocommerceNamespace:D}],["woocommerce/product-price",{textAlign:"center",fontSize:"small"}],["woocommerce/product-button",{textAlign:"center",fontSize:"small"}]]],["core/query-pagination",{layout:{type:"flex",justifyContent:"center"}}],["woocommerce/product-collection-no-results"]],z=e=>{if(!(e=>"object"!=typeof e||null===e?(console.error("Invalid arguments: You must pass an object to __experimentalRegisterProductCollection."),!1):"string"!=typeof e.name||0===e.name.length?(console.error("Invalid name: name must be a non-empty string."),!1):(e.name.match(/^[a-zA-Z0-9-]+\/product-collection\/[a-zA-Z0-9-]+$/)||console.warn('To prevent conflicts with other collections, please use a unique name following the pattern: "<plugin-name>/product-collection/<collection-name>". Ensure "<plugin-name>" is your plugin name and "<collection-name>" is your collection name. Both should consist only of alphanumeric characters and hyphens (e.g., "my-plugin/product-collection/my-collection").'),"string"!=typeof e.title||0===e.title.length?(console.error("Invalid title: title must be a non-empty string."),!1):(void 0!==e.description&&"string"!=typeof e.description&&console.warn("Invalid description: description must be a string."),void 0!==e.category&&"string"!=typeof e.category&&console.warn("Invalid category: category must be a string."),void 0===e.keywords||Array.isArray(e.keywords)||console.warn("Invalid keywords: keywords must be an array of strings."),void 0!==e.icon&&"string"!=typeof e.icon&&"object"!=typeof e.icon&&console.warn("Invalid icon: icon must be a string or an object."),void 0!==e.example&&"object"!=typeof e.example&&console.warn("Invalid example: example must be an object."),void 0===e.scope||Array.isArray(e.scope)||console.warn("Invalid scope: scope must be an array of type WPBlockVariationScope."),void 0!==e.attributes&&"object"!=typeof e.attributes&&console.warn("Invalid attributes: attributes must be an object."),void 0!==e.attributes?.query&&"object"!=typeof e.attributes.query&&console.warn("Invalid query: query must be an object."),void 0!==e.attributes?.query?.offset&&"number"!=typeof e.attributes.query.offset&&console.warn("Invalid offset: offset must be a number."),void 0!==e.attributes?.query?.order&&"string"!=typeof e.attributes.query.order&&console.warn("Invalid order: order must be a string."),void 0!==e.attributes?.query?.orderBy&&"string"!=typeof e.attributes.query.orderBy&&console.warn("Invalid orderBy: orderBy must be a string."),void 0!==e.attributes?.query?.pages&&"number"!=typeof e.attributes.query.pages&&console.warn("Invalid pages: pages must be a number."),void 0!==e.attributes?.query?.perPage&&"number"!=typeof e.attributes.query.perPage&&console.warn("Invalid perPage: perPage must be a number."),void 0!==e.attributes?.query?.search&&"string"!=typeof e.attributes.query.search&&console.warn("Invalid search: search must be a string."),void 0!==e.attributes?.query?.taxQuery&&"object"!=typeof e.attributes.query.taxQuery&&console.warn("Invalid taxQuery: taxQuery must be an object."),void 0!==e.attributes?.query?.featured&&"boolean"!=typeof e.attributes.query.featured&&console.warn("Invalid featured: featured must be a boolean."),void 0!==e.attributes?.query?.timeFrame&&"object"!=typeof e.attributes.query.timeFrame&&console.warn("Invalid timeFrame: timeFrame must be an object."),void 0!==e.attributes?.query?.woocommerceOnSale&&"boolean"!=typeof e.attributes.query.woocommerceOnSale&&console.warn("Invalid woocommerceOnSale: woocommerceOnSale must be a boolean."),void 0===e.attributes?.query?.woocommerceStockStatus||Array.isArray(e.attributes.query.woocommerceStockStatus)||console.warn("Invalid woocommerceStockStatus: woocommerceStockStatus must be an array."),void 0===e.attributes?.query?.woocommerceAttributes||Array.isArray(e.attributes.query.woocommerceAttributes)||console.warn("Invalid woocommerceAttributes: woocommerceAttributes must be an array."),void 0===e.attributes?.query?.woocommerceHandPickedProducts||Array.isArray(e.attributes.query.woocommerceHandPickedProducts)||console.warn("Invalid woocommerceHandPickedProducts: woocommerceHandPickedProducts must be an array."),void 0!==e.attributes?.query?.priceRange&&"object"!=typeof e.attributes.query.priceRange&&console.warn("Invalid priceRange: priceRange must be an object."),void 0!==e.attributes?.displayLayout&&"object"!=typeof e.attributes.displayLayout&&console.warn("Invalid displayLayout: displayLayout must be an object."),void 0!==e.attributes?.dimensions&&"object"!=typeof e.attributes.dimensions&&console.warn("Invalid dimensions: dimensions must be an object."),void 0===e.attributes?.hideControls||Array.isArray(e.attributes.hideControls)||console.warn("Invalid hideControls: hideControls must be an array of strings."),void 0===e.attributes?.queryContextIncludes||Array.isArray(e.attributes.queryContextIncludes)||console.warn("Invalid queryContextIncludes: queryContextIncludes must be an array of strings."),void 0!==e.preview&&("object"==typeof e.preview&&null!==e.preview||console.warn("Invalid preview: preview must be an object."),void 0!==e.preview.setPreviewState&&"function"!=typeof e.preview.setPreviewState&&console.warn("Invalid preview: setPreviewState must be a function."),void 0!==e.preview.initialPreviewState&&("object"!=typeof e.preview.initialPreviewState&&console.warn("Invalid preview: initialPreviewState must be an object."),"boolean"!=typeof e.preview.initialPreviewState.isPreview&&console.warn("Invalid preview: preview.isPreview must be a boolean."),"string"!=typeof e.preview.initialPreviewState.previewMessage&&console.warn("Invalid preview: preview.previewMessage must be a string."))),!(void 0!==e.usesReference&&!Array.isArray(e.usesReference)&&(console.error("Invalid usesReference: usesReference must be an array of strings."),1)))))(e))return void console.error("Collection could not be registered due to invalid configuration.");const{preview:{setPreviewState:t,initialPreviewState:o}={},usesReference:r}=e,n=e.attributes?.query||{},a=[...new Set([j.INHERIT,...e.attributes?.hideControls||[]])],i={name:e.name,title:e.title,description:e.description,category:e.category,keywords:e.keywords,icon:e.icon,example:e.example,scope:e.scope,attributes:{...e.attributes,query:{...N,...void 0!==n.offset&&{offset:n.offset},...void 0!==n.order&&{order:n.order},...void 0!==n.orderBy&&{orderBy:n.orderBy},...void 0!==n.pages&&{pages:n.pages},...void 0!==n.perPage&&{perPage:n.perPage},...void 0!==n.search&&{search:n.search},...void 0!==n.taxQuery&&{taxQuery:n.taxQuery},...void 0!==n.featured&&{featured:n.featured},...void 0!==n.timeFrame&&{timeFrame:n.timeFrame},...void 0!==n.woocommerceOnSale&&{woocommerceOnSale:n.woocommerceOnSale},...void 0!==n.woocommerceStockStatus&&{woocommerceStockStatus:n.woocommerceStockStatus},...void 0!==n.woocommerceAttributes&&{woocommerceAttributes:n.woocommerceAttributes},...void 0!==n.woocommerceHandPickedProducts&&{woocommerceHandPickedProducts:n.woocommerceHandPickedProducts},...void 0!==n.priceRange&&{priceRange:n.priceRange}},hideControls:a,collection:e.name,inherit:!1},innerBlocks:e.innerBlocks||V,isActive:(e,t)=>e.collection===t.collection,isDefault:!1};if(t||o||Array.isArray(r)&&r.length>0){const e=e=>n=>n.attributes.collection!==i.name?(0,p.jsx)(e,{...n}):(0,p.jsx)(e,{...n,...o||t?{preview:{setPreviewState:t,initialPreviewState:o}}:{},usesReference:r});(0,B.addFilter)("editor.BlockEdit",i.name,e)}wp?.blocks?.registerBlockVariation&&wp.blocks.registerBlockVariation($,{...i,attributes:{...U,...i.attributes,query:{...N,...i.attributes?.query},displayLayout:{...U.displayLayout,...i.attributes?.displayLayout}}})};(this.wc=this.wc||{}).wcBlocksRegistry=t})();
// source --> https://mfrash.com/wp-includes/js/dist/html-entities.min.js?ver=e8b78b18a162491d5e5f 
/*! This file is auto-generated */
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};let n;function o(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===n&&(n=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),n.innerHTML=e;const t=n.textContent??"";return n.innerHTML="",t}e.r(t),e.d(t,{decodeEntities:()=>o}),(window.wp=window.wp||{}).htmlEntities=t})();
// source --> https://mfrash.com/wp-content/plugins/tabby-checkout/assets/blocks/tabby-installments/index.js?ver=5.10.3 
/**
 * External dependencies
 */
const registerPaymentMethod = window.wc.wcBlocksRegistry.registerPaymentMethod;
const getPaymentMethodData = window.wc.wcSettings.getPaymentMethodData;

const settings = getPaymentMethodData( 'tabby_installments', {} );
const defaultLabel = 'Pay in 4. No interest, no fees.';
const title = settings?.title || '';


/**
 * Icon component
 */

const TabbyIcon = () => {
    return React.createElement('img', {
        src: settings?.icon_src,
        style: {marginRight:'10px'},
        alt: title
    }, null);
}

const Label = () => {
    return [window.wp.element.createElement(TabbyIcon), React.createElement('span', null, title)];
}

const InitTabbyCard = (className, classParams) => {
    if (eval('typeof ' + className) == 'function') {
        eval('new ' + className + '(' + classParams + ');');
        return true;
    }
    return false;
};

const TabbyPromotionCard = () => {
    React.useEffect(() => {
        // init Tabby Promo Card
        if (!InitTabbyCard(settings?.config?.jsClass, settings?.config?.jsConf)) {
            let timerId = setInterval(function () {
                if (InitTabbyCard(settings?.config?.jsClass, settings?.config?.jsConf)) {
                    clearInterval(timerId);
                }
            }, 300);
        }
    });
    return React.createElement('div', {id: settings?.config?.id}, '');    
}

const TabbyInstallmentsMethodName = 'tabby_installments';
/**
 * Content component
 */
const Content = () => {
    switch (settings?.config?.class) {
        case 'empty':
            return null;
        case 'tabbyDesc':
            return React.createElement('span', null, settings?.config?.html || '');
        default: 
            return window.wp.element.createElement(TabbyPromotionCard);
    }
};

/**
 * Tabby installments payment method config object.
 */

const tabbyInstallmentsPaymentMethod = {
    name: TabbyInstallmentsMethodName,
    label: Object( window.wp.element.createElement ) (Label, null),
    content: Object( window.wp.element.createElement ) (Content, null),
    edit: Object( window.wp.element.createElement ) (Content, null),
    canMakePayment: (props) => {
        return true;
    },
    ariaLabel: title,
    placeOrderButtonLabel: window.wp.i18n.__(
        'Proceed to Tabby',
        'tabby-checkout'
    ),
    supports: {
        features: settings?.supports ?? []
    }
};

registerPaymentMethod( tabbyInstallmentsPaymentMethod );
// source --> https://mfrash.com/wp-content/uploads/wpcode/assets/66e8217a2c8c491a60eeed9f5a167db3.js?ver=1776102692 
jQuery(document).ready(function($){
    // $("#billing_city option:first").remove();
    // $(document).on('change', '#billing_state', function(){
    //     var thisVal = $(this).val();
    //     var thisText = $( "#billing_state option:selected" ).text();
        
    //     console.log(thisVal, thisText);
    //     // Search on 
    //     /*
    //     billing_state
    //     billing_city
    //     */
    //     $('#billing_city').val(thisText);
    //     $("#billing_city option:first").remove();
    // });
    
    $(document).on('change', "#shipping_state",function(){
        $("#shipping_city").val($(this).val());
    });
    $(document).on('change', "#billing_state",function(){
        $("#billing_city").val($(this).val());
    });
    
});
// source --> https://mfrash.com/wp-content/uploads/wpcode/assets/213a33e8cc9cae6743c2c50386bb2826.js?ver=1776102692 
document.addEventListener("DOMContentLoaded", function () {
  const products = document.querySelectorAll('.mfrash-slider-wrapper');

  products.forEach(function (wrapper) {
    const productId = wrapper.dataset.productId;
    const viewsKey = 'mfrash_views_' + productId;
    const cartKey = 'mfrash_cart_' + productId;

    // عدد المشاهدات
    let views = parseInt(localStorage.getItem(viewsKey) || '0') + 1;
    localStorage.setItem(viewsKey, views);
    const viewsEl = wrapper.querySelector('.mfrash-views-count');
    if (viewsEl) viewsEl.textContent = views;

    // عدد إضافات السلة (عند الضغط على الزر)
    let cartCount = parseInt(localStorage.getItem(cartKey) || '0');
    const cartEls = wrapper.querySelectorAll('.mfrash-cart-count');
    cartEls.forEach(el => el.textContent = cartCount);

    // استهداف زر "اختر التصميم" أو أي زر بداخل المنتج
    const productBox = wrapper.closest('.product');
    if (productBox) {
      const designBtn = productBox.querySelector('a.button, a.choose-button, .choose-style');
      if (designBtn) {
        designBtn.addEventListener('click', function () {
          cartCount++;
          localStorage.setItem(cartKey, cartCount);
          cartEls.forEach(el => el.textContent = cartCount);
        });
      }
    }
  });
});
// source --> https://mfrash.com/wp-content/plugins/woo-variation-swatches-pro/assets/js/add-to-cart-variation.min.js?ver=2.2.3 
!function(t,a,i,o){var e=function(t){var i=this;i.$form=t,i.$wrapper=t.find(">div"),i.threshold_max=parseInt(i.$wrapper.data("threshold_max"),10),i.total_children=parseInt(i.$wrapper.data("total"),10),i.$attributeFields=t.find(".variations select"),i.$singleVariation=t.find(".single_variation"),i.$singleVariationWrap=t.find(".single_variation_wrap"),i.$resetVariations=t.find(".reset_variations"),i.$product=t.closest(".product"),i.variationData=t.data("product_variations"),i.useAjax=!1===i.variationData,i.xhr=!1,i.previewXhr=!1,i.loading=!0,i.product_id=parseInt(t.data("product_id"),10),woo_variation_swatches_pro_options.enable_linkable_url&&(i.currentURL=new URL(a.location.href)),i.$firstUL=t.find(".variations ul:first");var o=!1;if(i.single_variation_preview_selected=!1,woo_variation_swatches_pro_options.enable_single_variation_preview){var e=i.$firstUL.data("preview_attribute_name")?i.$firstUL.data("preview_attribute_name"):i.$attributeFields.first().data("attribute_name");o=".variations select[data-attribute_name='".concat(e,"']"),i.single_variation_preview_selected=".variations select[data-attribute_name='".concat(e,"']")}i.$singleVariationWrap.show(),i.$form.off(".wc-variation-form"),i.getChosenAttributes=i.getChosenAttributes.bind(i),i.findMatchingVariations=i.findMatchingVariations.bind(i),i.isMatch=i.isMatch.bind(i),i.toggleResetLink=i.toggleResetLink.bind(i),i.generateShareableURL=i.generateShareableURL.bind(i),i.showNoMatchingVariationsMsg=i.showNoMatchingVariationsMsg.bind(i),t.on("keydown.wc-variation-form",".reset_variations",{variationForm:i},i.onResetKeyDown),t.on("click.wc-variation-form",".reset_variations",{variationForm:i},i.onReset),t.on("reload_product_variations",{variationForm:i},i.onReload),t.on("hide_variation",{variationForm:i},i.onHide),t.on("show_variation",{variationForm:i},i.onShow),t.on("click",".single_add_to_cart_button",{variationForm:i},i.onAddToCart),t.on("reset_data.wc-variation-form",{variationForm:i},i.onResetDisplayedVariation),t.on("reset_image.wc-variation-form",{variationForm:i},i.onResetImage),t.on("change.wc-variation-form",".variations select",{variationForm:i},i.onChange),t.on("found_variation.wc-variation-form",{variationForm:i},i.onFoundVariation),t.on("check_variations.wc-variation-form",{variationForm:i},i.onFindVariation),t.on("update_variation_values.wc-variation-form",{variationForm:i},i.onUpdateAttributes),woo_variation_swatches_pro_options.enable_single_variation_preview&&(t.on("woo_variation_swatches_add-to-cart-variation_start.wc-variation-form",{variationForm:i},i.initPreviewChange),t.on("change.wc-variation-form",o,{variationForm:i},i.onPreviewChange),t.on("click.wc-variation-form",".reset_variations",{variationForm:i},i.onResetPreview),t.on("keydown.wc-variation-form",".reset_variations",{variationForm:i},i.onResetPreview)),t.on("woo_variation_swatches_add-to-cart-variation_init.wc-variation-form",{variationForm:i},i.initFetch),t.trigger("woo_variation_swatches_add-to-cart-variation_init",i)};e.prototype.start=function(t){var a=t.data.variationForm;setTimeout(function(){a.$form.trigger("check_variations"),a.$form.trigger("wc_variation_form",self),a.$form.trigger("woo_variation_swatches_add-to-cart-variation_start",self),a.$form.find(".single_add_to_cart_button").removeAttr("disabled"),a.loading=!1},100)},e.prototype.init=function(a){var i=a.data.variationForm,o=parseInt(wc_add_to_cart_variation_params.woo_variation_swatches_ajax_variation_threshold_max,10),e=parseInt(wc_add_to_cart_variation_params.woo_variation_swatches_total_children,10),r=i.product_id;i.useAjax&&o>=e?(i.xhr&&i.xhr.abort(),woo_variation_swatches_pro_options.enable_single_preloader&&i.$form.block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}}),i.xhr=t.ajax({global:!1,cache:!0,url:wc_add_to_cart_variation_params.wc_ajax_url.toString().replace("%%endpoint%%","woo_get_all_variations"),method:"POST",data:{product_id:r,is_archive:!1,_wpnonce:woo_variation_swatches_pro_params._wpnonce}}),i.xhr.fail(function(t,a){console.error("single product variations ajax failed: ".concat(r,"."),a)}),i.xhr.done(function(t){t?(i.$form.data("product_variations",t),i.variationData=i.$form.data("product_variations"),i.useAjax=!1,i.start(a)):console.error("single product variations not available on: ".concat(r,"."))}),i.xhr.always(function(){woo_variation_swatches_pro_options.enable_single_preloader&&i.$form.unblock()})):i.start(a)},e.prototype.initFetch=function(t){var a=t.data.variationForm,i=parseInt(wc_add_to_cart_variation_params.woo_variation_swatches_ajax_variation_threshold_max,10),o=parseInt(wc_add_to_cart_variation_params.woo_variation_swatches_total_children,10),e=a.product_id;i=isNaN(i)?a.threshold_max:i,o=isNaN(o)?a.total_children:o,a.useAjax&&i>=o?(woo_variation_swatches_pro_options.enable_single_preloader&&a.$form.block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}}),wp.apiFetch({path:"woo-variation-swatches/v1/single-product/".concat(e)}).then(function(i){a.$form.data("product_variations",i),a.variationData=a.$form.data("product_variations"),a.useAjax=!1,a.start(t)}).catch(function(t){console.error("single product variations fetching failed: ".concat(e,"."),t)}).finally(function(){woo_variation_swatches_pro_options.enable_single_preloader&&a.$form.unblock()})):a.start(t)},e.prototype.onReset=function(t){t.preventDefault(),t.data.variationForm.$attributeFields.val("").trigger("change"),t.data.variationForm.$form.trigger("reset_data")},e.prototype.onResetPreview=function(t){var a=t.data.variationForm;a.$form.on("reset_image.wc-variation-form",{variationForm:a},a.onResetImage).trigger("reset_image")},e.prototype.showPreviewFetch=function(a,i,o){var e=a.getChosenAttributes(),r={};if(o&&e.count&&e.count>e.chosenCount){r.product_id=a.product_id,r[i]=o;var n=t(".woocommerce-product-gallery");n.length>0&&n.block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}}),wp.apiFetch({path:wp.url.addQueryArgs("/woo-variation-swatches/v1/single-product-preview",r)}).then(function(t){var i=a.getChosenAttributes();i.count&&i.count>i.chosenCount&&(a.$form.off("reset_image.wc-variation-form"),a.$form.wc_variations_image_update(t),a.$form.trigger("show_variation",[t,!1])),n.length>0&&n.unblock()}).catch(function(t){console.error("single product variation preview fetching failed: ".concat(a.product_id,"."),t)}).finally(function(){n.length>0&&n.unblock()})}!o&&woo_variation_swatches_pro_options.clear_on_reselect&&a.$form.on("reset_image.wc-variation-form",{variationForm:a},a.onResetImage).trigger("reset_image")},e.prototype.initPreviewChange=function(a){var i=a.data.variationForm,o=t(i.single_variation_preview_selected).data("attribute_name")||t(i.single_variation_preview_selected).attr("name"),e=t(i.single_variation_preview_selected).val()||"";i.showPreviewFetch(i,o,e)},e.prototype.onPreviewChange=function(a){a.preventDefault();var i=a.data.variationForm,o=t(this).data("attribute_name")||t(this).attr("name"),e=t(this).val()||"";i.showPreviewFetch(i,o,e)},e.prototype.__showPreview=function(a,i,o){var e=this,r=a.getChosenAttributes(),n={};o&&r.count&&r.count>r.chosenCount&&(n.product_id=a.product_id,n[i]=o,t(".woocommerce-product-gallery").length>0&&t(".woocommerce-product-gallery").block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}}),a.previewXhr=t.ajax({global:!1,url:woo_variation_swatches_pro_params.wc_ajax_url.toString().replace("%%endpoint%%","woo_get_preview_variation"),method:"POST",data:n}),a.previewXhr.fail(function(t,a){console.error("product preview not available on ".concat(e.product_id,"."),i,a)}),a.previewXhr.done(function(i){a.$form.off("reset_image.wc-variation-form"),a.$form.wc_variations_image_update(i),a.$form.trigger("show_variation",[i,!1]),t(".woocommerce-product-gallery").length>0&&t(".woocommerce-product-gallery").unblock()})),!o&&woo_variation_swatches_pro_options.clear_on_reselect&&a.$form.on("reset_image.wc-variation-form",{variationForm:a},a.onResetImage).trigger("reset_image")},e.prototype.__onPreviewChange=function(a){var i=this;a.preventDefault();var o=a.data.variationForm,e=t(this).data("attribute_name")||t(this).attr("name"),r=t(this).val()||"",n=o.getChosenAttributes(),s={};r&&n.count&&n.count>n.chosenCount&&(s.product_id=o.product_id,s[e]=r,t(".woocommerce-product-gallery").length>0&&t(".woocommerce-product-gallery").block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}}),o.previewXhr=t.ajax({global:!1,url:woo_variation_swatches_pro_params.wc_ajax_url.toString().replace("%%endpoint%%","woo_get_preview_variation"),method:"POST",data:s}),o.previewXhr.fail(function(t,a){console.error("product preview not available on ".concat(i.product_id,"."),e,a)}),o.previewXhr.done(function(a){o.$form.off("reset_image.wc-variation-form"),o.$form.wc_variations_image_update(a),o.$form.trigger("show_variation",[a,!1]),t(".woocommerce-product-gallery").length>0&&t(".woocommerce-product-gallery").unblock()})),!r&&woo_variation_swatches_pro_options.clear_on_reselect&&o.$form.on("reset_image.wc-variation-form",{variationForm:o},o.onResetImage).trigger("reset_image")},e.prototype.onReload=function(t){var a=t.data.variationForm;a.variationData=a.$form.data("product_variations"),a.useAjax=!1===a.variationData,a.$form.trigger("check_variations")},e.prototype.onHide=function(t){t.preventDefault(),t.data.variationForm.$form.find(".single_add_to_cart_button").removeClass("wc-variation-is-unavailable").addClass("disabled wc-variation-selection-needed"),t.data.variationForm.$form.find(".woocommerce-variation-add-to-cart").removeClass("woocommerce-variation-add-to-cart-enabled").addClass("woocommerce-variation-add-to-cart-disabled")},e.prototype.generateShareableURL=function(t){if(woo_variation_swatches_pro_options.enable_linkable_url){var i=this.currentURL;if(t.chosenCount>0){var o=new URL(a.location.href);for(var e in t.data){var r=t.data[e];r&&o.searchParams.set(e,r)}i.href!==o.href&&a.history.replaceState({},"",o.href)}else a.history.replaceState({},"",this.$form.attr("action"))}},e.prototype.onShow=function(a,i,o){a.preventDefault(),o?(a.data.variationForm.$form.find(".single_add_to_cart_button").removeClass("disabled wc-variation-selection-needed wc-variation-is-unavailable"),a.data.variationForm.$form.find(".woocommerce-variation-add-to-cart").removeClass("woocommerce-variation-add-to-cart-disabled").addClass("woocommerce-variation-add-to-cart-enabled")):(a.data.variationForm.$form.find(".single_add_to_cart_button").removeClass("wc-variation-selection-needed").addClass("disabled wc-variation-is-unavailable"),a.data.variationForm.$form.find(".woocommerce-variation-add-to-cart").removeClass("woocommerce-variation-add-to-cart-enabled").addClass("woocommerce-variation-add-to-cart-disabled")),wp.mediaelement&&a.data.variationForm.$form.find(".wp-audio-shortcode, .wp-video-shortcode").not(".mejs-container").filter(function(){return!t(this).parent().hasClass("mejs-mediaelement")}).mediaelementplayer(wp.mediaelement.settings)},e.prototype.onAddToCart=function(i){t(this).is(".disabled")&&(i.preventDefault(),t(this).is(".wc-variation-is-unavailable")?a.alert(wc_add_to_cart_variation_params.i18n_unavailable_text):t(this).is(".wc-variation-selection-needed")&&a.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text))},e.prototype.onResetDisplayedVariation=function(t){var a=t.data.variationForm;a.$product.find(".product_meta").find(".sku").wc_reset_content(),a.$product.find(".product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value").wc_reset_content(),a.$product.find(".product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value").wc_reset_content(),a.$form.trigger("reset_image"),a.$singleVariation.slideUp(200).trigger("hide_variation")},e.prototype.onResetImage=function(t){t.data.variationForm.$form.wc_variations_image_update(!1)},e.prototype.onFindVariation=function(a,i){var o=a.data.variationForm,e=void 0!==i?i:o.getChosenAttributes(),r=e.data;if(o.generateShareableURL(e),e.count&&e.count===e.chosenCount)if(o.useAjax)o.xhr&&o.xhr.abort(),o.$form.block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}}),r.product_id=parseInt(o.$form.data("product_id"),10),r.custom_data=o.$form.data("custom_data"),o.xhr=t.ajax({global:!1,url:wc_add_to_cart_variation_params.wc_ajax_url.toString().replace("%%endpoint%%","get_variation"),method:"POST",data:r,success:function(t){t?o.$form.trigger("found_variation",[t]):(o.$form.trigger("reset_data"),e.chosenCount=0,o.loading||o.showNoMatchingVariationsMsg())},complete:function(){o.$form.unblock()}});else{o.$form.trigger("update_variation_values");var n=o.findMatchingVariations(o.variationData,r).shift();n?o.$form.trigger("found_variation",[n]):(o.$form.trigger("reset_data"),e.chosenCount=0,o.loading||o.showNoMatchingVariationsMsg())}else o.$form.trigger("update_variation_values"),o.$form.trigger("reset_data");o.toggleResetLink(e.chosenCount>0)},e.prototype.onFoundVariation=function(a,i){var o=a.data.variationForm,e=o.$product.find(".product_meta").find(".sku"),n=o.$product.find(".product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value"),s=o.$product.find(".product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value"),c=o.$singleVariationWrap.find(".quantity"),_=!0,d=!1,l="";if(i.sku?e.wc_set_content(i.sku):e.wc_reset_content(),i.weight?n.wc_set_content(i.weight_html):n.wc_reset_content(),i.dimensions?s.wc_set_content(t.parseHTML(i.dimensions_html)[0].data):s.wc_reset_content(),o.$form.wc_variations_image_update(i),i.variation_is_visible?(d=r("variation-template"),i.variation_id):d=r("unavailable-variation-template"),l=(l=(l=d({variation:i})).replace("/*<![CDATA[*/","")).replace("/*]]>*/",""),o.$form.find('input[name="variation_id"], input.variation_id').val(i.variation_id).trigger("change"),"yes"===i.is_sold_individually)c.find("input.qty").val("1").attr("min","1").attr("max","").trigger("change"),c.hide();else{var v=c.find("input.qty"),m=parseFloat(v.val());m=isNaN(m)||(m=m>parseFloat(i.max_qty)?i.max_qty:m)<parseFloat(i.min_qty)?i.min_qty:m,v.attr("min",i.min_qty).attr("max",i.max_qty).val(m).trigger("change"),c.show()}i.is_purchasable&&i.is_in_stock&&i.variation_is_visible||(_=!1),setTimeout(function(){o.$singleVariation.html(l),o.$singleVariation.text().trim()?o.$singleVariation.slideDown(200).trigger("show_variation",[i,_]):o.$singleVariation.show().trigger("show_variation",[i,_])},300)},e.prototype.onChange=function(t){var a=t.data.variationForm;a.$form.find('input[name="variation_id"], input.variation_id').val("").trigger("change"),a.$form.find(".wc-no-matching-variations").remove(),a.useAjax||a.$form.trigger("woocommerce_variation_select_change"),a.$form.trigger("check_variations"),a.$form.trigger("woocommerce_variation_has_changed")},e.prototype.addSlashes=function(t){return t=(t=t.replace(/'/g,"\\'")).replace(/"/g,'\\"')},e.prototype.onUpdateAttributes=function(a){var i=a.data.variationForm,o=i.getChosenAttributes(),e=o.data;i.useAjax||(i.$attributeFields.each(function(a,r){var n,s=t(r),c=s.data("attribute_name")||s.attr("name"),_=t(r).data("show_option_none"),d=":gt(0)",l=t("<select/>"),v=s.val()||"",m=!0;if(!s.data("attribute_html")){var g=s.clone();g.find("option").removeAttr("attached").prop("disabled",!1).prop("selected",!1),s.data("attribute_options",g.find("option"+d).get()),s.data("attribute_html",g.html())}l.html(s.data("attribute_html"));var u=t.extend(!0,{},e);u[c]="";var p=i.findMatchingVariations(i.variationData,u),f={};for(var h in p)if(void 0!==p[h]){var w=p[h].attributes;for(var b in w)if(b===c){var F=w[b];p[h].is_in_stock&&(f[F]=!0)}}for(var y in p)if(void 0!==p[y]){var $=p[y].attributes;for(var x in $)if($.hasOwnProperty(x)){var C=$[x],k="";if(x===c)if(p[y].variation_is_active&&(k="enabled"),p[y].is_in_stock,C){C=t("<div/>").html(C).text();var R=l.find("option");if(R.length)for(var S=0,V=R.length;S<V;S++){var A=t(R[S]);if(C===A.val()){A.addClass("attached "+k),f.hasOwnProperty(C)||A.addClass("out-of-stock"),o.count>1&&o.chosenCount,o.count>1&&(o.chosenCount,o.count),o.count;break}}}else l.find("option:gt(0)").addClass("attached "+k)}}n=l.find("option.attached").length,v&&(m=!1,0!==n&&l.find("option.attached.enabled").each(function(){var a=t(this).val();if(v===a)return m=!0,!1})),n>0&&v&&m&&"no"===_&&(l.find("option:first").remove(),d=""),l.find("option"+d+":not(.attached)").remove(),s.html(l.html()),s.find("option"+d+":not(.enabled)").prop("disabled",!0),v?m?s.val(v):s.val("").trigger("change"):s.val("")}),i.$form.trigger("woocommerce_update_variation_values"))},e.prototype.getChosenAttributes=function(){var a={},i=0,o=0;return this.$attributeFields.each(function(){var e=t(this).data("attribute_name")||t(this).attr("name"),r=t(this).val()||"";r.length>0&&o++,i++,a[e]=r}),{count:i,chosenCount:o,data:a}},e.prototype.findMatchingVariations=function(t,a){for(var i=[],o=0;o<t.length;o++){var e=t[o];this.isMatch(e.attributes,a)&&i.push(e)}return i},e.prototype.isMatch=function(t,a){var i=!0;for(var e in t)if(t.hasOwnProperty(e)){var r=t[e],n=a[e];r!==o&&n!==o&&0!==r.length&&0!==n.length&&r!==n&&(i=!1)}return i},e.prototype.toggleResetLink=function(t){t?"hidden"===this.$resetVariations.css("visibility")&&this.$resetVariations.css("visibility","visible").hide().fadeIn():this.$resetVariations.css("visibility","hidden")},e.prototype.showNoMatchingVariationsMsg=function(){this.$form.find(".single_variation").after('<div role="alert"><p class="wc-no-matching-variations woocommerce-info">'+wc_add_to_cart_variation_params.i18n_no_matching_variations_text+"</p></div>").next("div").find(".wc-no-matching-variations").slideDown(200)},e.prototype.onResetKeyDown=function(t){"Enter"!==t.code&&"Space"!==t.code||(t.preventDefault(),t.data.variationForm.onReset(t))},t.fn.wc_variation_form=function(){return new e(this),this},t.fn.wc_set_content=function(t){o===this.attr("data-o_content")&&this.attr("data-o_content",this.text()),this.text(t)},t.fn.wc_reset_content=function(){o!==this.attr("data-o_content")&&this.text(this.attr("data-o_content"))},t.fn.wc_set_variation_attr=function(t,a){o===this.attr("data-o_"+t)&&this.attr("data-o_"+t,this.attr(t)?this.attr(t):""),!1===a?this.removeAttr(t):this.attr(t,a)},t.fn.wc_reset_variation_attr=function(t){o!==this.attr("data-o_"+t)&&this.attr(t,this.attr("data-o_"+t))},t.fn.wc_maybe_trigger_slide_position_reset=function(a){var i=t(this),o=i.closest(".product").find(".images"),e=!1,r=a&&a.image_id?a.image_id:"";i.attr("current-image")!==r&&(e=!0),i.attr("current-image",r),e&&o.trigger("woocommerce_gallery_reset_slide_position")},t.fn.wc_variations_image_update=function(i){var o=this,e=o.closest(".product"),r=e.find(".images"),n=e.find(".flex-control-nav"),s=n.find("li:eq(0) img"),c=r.find(".woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder").eq(0),_=c.find(".wp-post-image"),d=c.find("a").eq(0);if(i&&i.image&&i.image.src&&i.image.src.length>1){n.find('li img[data-o_src="'+i.image.gallery_thumbnail_src+'"]').length>0&&o.wc_variations_image_reset();var l=n.find('li img[src="'+i.image.gallery_thumbnail_src+'"]');if(l.length>0)return l.trigger("click"),o.attr("current-image",i.image_id),void a.setTimeout(function(){t(a).trigger("resize"),r.trigger("woocommerce_gallery_init_zoom")},20);_.wc_set_variation_attr("src",i.image.src),_.wc_set_variation_attr("height",i.image.src_h),_.wc_set_variation_attr("width",i.image.src_w),_.wc_set_variation_attr("srcset",i.image.srcset),_.wc_set_variation_attr("sizes",i.image.sizes),_.wc_set_variation_attr("title",i.image.title),_.wc_set_variation_attr("data-caption",i.image.caption),_.wc_set_variation_attr("alt",i.image.alt),_.wc_set_variation_attr("data-src",i.image.full_src),_.wc_set_variation_attr("data-large_image",i.image.full_src),_.wc_set_variation_attr("data-large_image_width",i.image.full_src_w),_.wc_set_variation_attr("data-large_image_height",i.image.full_src_h),c.wc_set_variation_attr("data-thumb",i.image.src),s.wc_set_variation_attr("src",i.image.gallery_thumbnail_src),d.wc_set_variation_attr("href",i.image.full_src)}else o.wc_variations_image_reset();a.setTimeout(function(){t(a).trigger("resize"),o.wc_maybe_trigger_slide_position_reset(i),r.trigger("woocommerce_gallery_init_zoom")},20)},t.fn.wc_variations_image_reset=function(){var t=this.closest(".product"),a=t.find(".images"),i=t.find(".flex-control-nav").find("li:eq(0) img"),o=a.find(".woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder").eq(0),e=o.find(".wp-post-image"),r=o.find("a").eq(0);e.wc_reset_variation_attr("src"),e.wc_reset_variation_attr("width"),e.wc_reset_variation_attr("height"),e.wc_reset_variation_attr("srcset"),e.wc_reset_variation_attr("sizes"),e.wc_reset_variation_attr("title"),e.wc_reset_variation_attr("data-caption"),e.wc_reset_variation_attr("alt"),e.wc_reset_variation_attr("data-src"),e.wc_reset_variation_attr("data-large_image"),e.wc_reset_variation_attr("data-large_image_width"),e.wc_reset_variation_attr("data-large_image_height"),o.wc_reset_variation_attr("data-thumb"),i.wc_reset_variation_attr("src"),r.wc_reset_variation_attr("href")},t(function(){"undefined"!=typeof wc_add_to_cart_variation_params&&t(".variations_form").each(function(){t(this).wc_variation_form()})});var r=function(t){var o=i.getElementById("tmpl-"+t).textContent,e=!1;return(e=(e=(e=e||/<#\s?data\./.test(o))||/{{{?\s?data\.(?!variation\.).+}}}?/.test(o))||/{{{?\s?data\.variation\.[\w-]*[^\s}]/.test(o))?wp.template(t):function(t){var i=t.variation||{};return o.replace(/({{{?)\s?data\.variation\.([\w-]*)\s?(}}}?)/g,function(t,o,e,r){if(o.length!==r.length)return"";var n=i[e]||"";return 2===o.length?a.escape(n):n})}}}(jQuery,window,document);
// source --> https://mfrash.com/wp-content/plugins/woo-frequently-bought-together/assets/woo-fbt.js?ver=1774563132 
/**
 * Frequently Bought Together – woo-fbt.js
 * Adds only the 3 FBT products (NOT the main product).
 * Button text uses a dedicated .woo-fbt-btn-prefix span to avoid duplication bug.
 */
(function ($) {
    'use strict';

    var FBT = {

        /* ── init ── */
        init: function () {
            $('.woo-fbt-wrapper').each(function () {
                FBT.initWidget($(this));
            });

            if (!$('#woo-fbt-toast').length) {
                $('body').append('<div class="woo-fbt-toast" id="woo-fbt-toast"></div>');
            }
        },

        /* ── per-widget init ── */
        initWidget: function ($w) {
            // Calculate initial total (FBT products only, no main product)
            FBT.updateTotal($w);

            // Checkbox toggle
            $w.on('change', '.woo-fbt-check', function () {
                var $card = $(this).closest('.woo-fbt-card');
                if ($(this).is(':checked')) {
                    $card.removeClass('woo-fbt-card--unchecked');
                } else {
                    $card.addClass('woo-fbt-card--unchecked');
                }
                FBT.updateTotal($w);
            });

            // Add-to-cart button
            $w.on('click', '.woo-fbt-btn', function () {
                FBT.addToCart($w);
            });

            // Slider (mobile)
            FBT.initSlider($w);
        },

        /* ── calculate & update total (FBT products only) ── */
        updateTotal: function ($w) {
            var total = 0;
            var count = 0;

            $w.find('.woo-fbt-check:checked').each(function () {
                total += parseFloat($(this).data('price')) || 0;
                count++;
            });

            var data      = typeof wooFbtData !== 'undefined' ? wooFbtData : {};
            var currency  = data.currency || '';
            var num = parseFloat(total);
            var formatted = num % 1 === 0
                ? String(Math.round(num)).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
                : num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',');

            // Update total number
            $w.find('.woo-fbt-total').text(formatted);

            // Update prefix text via dedicated span (avoids text-node duplication bug)
            // Currency symbol is in a separate .woo-fbt-btn-currency span (after the total)
            var $prefix = $w.find('.woo-fbt-btn-prefix');
            if ($prefix.length) {
                var template = data.addText || 'اشترِ %d معاً بسعر';
                $prefix.text(template.replace('%d', count) + ' ');
            }
        },

        /* ── add FBT products to cart (main product excluded) ── */
        addToCart: function ($w) {
            var data   = typeof wooFbtData !== 'undefined' ? wooFbtData : {};
            var fbtIds = [];

            $w.find('.woo-fbt-check:checked').each(function () {
                fbtIds.push(parseInt($(this).data('id')));
            });

            if (fbtIds.length === 0) {
                FBT.showToast('يرجى تحديد منتج واحد على الأقل من القائمة.', 'error');
                return;
            }

            // Show loader
            var $btn    = $w.find('.woo-fbt-btn');
            var $text   = $btn.find('.woo-fbt-btn-text');
            var $loader = $btn.find('.woo-fbt-loader');

            $btn.prop('disabled', true);
            $text.hide();
            $loader.show();

            $.post(
                data.ajaxUrl || '/wp-admin/admin-ajax.php',
                {
                    action:      'woo_fbt_add_to_cart',
                    nonce:       data.nonce || '',
                    product_ids: fbtIds,
                },
                function (res) {
                    $btn.prop('disabled', false);
                    $text.show();
                    $loader.hide();

                    if (res.success) {
                        FBT.showToast(res.data.message || 'تمت الإضافة للسلة بنجاح', 'success');
                        if (typeof wc_cart_fragments_params !== 'undefined') {
                            $(document.body).trigger('wc_fragment_refresh');
                        }
                        $(document.body).trigger('added_to_cart', [{}, {}, $btn]);
                    } else {
                        FBT.showToast(
                            (res.data && res.data.message) ? res.data.message : 'حدث خطأ، يرجى المحاولة مجدداً.',
                            'error'
                        );
                    }
                }
            ).fail(function () {
                $btn.prop('disabled', false);
                $text.show();
                $loader.hide();
                FBT.showToast('تعذّر الاتصال بالخادم. يرجى المحاولة مرة أخرى.', 'error');
            });
        },

        /* ── slider (desktop only – mobile uses CSS scroll-snap) ── */
        initSlider: function ($w) {
            // Mobile: CSS scroll-snap handles touch scrolling natively. No JS needed.
            if (window.innerWidth < 768) {
                $w.find('.woo-fbt-nav').hide();
                return;
            }

            var $track  = $w.find('.woo-fbt-track');
            var $cards  = $track.find('.woo-fbt-card');
            var total   = $cards.length;
            var current = 0;
            var visible = 3; // desktop always shows 3

            if (total <= visible) {
                $w.find('.woo-fbt-nav').hide();
                return;
            }

            function cardWidth() {
                var gap = parseInt($track.css('gap')) || 12;
                return $cards.first().outerWidth(true) + gap;
            }

            function goTo(index) {
                var max = total - visible;
                current = Math.max(0, Math.min(index, max));
                $track.css('transform', 'translateX(' + (current * cardWidth()) + 'px)');
                $w.find('.woo-fbt-nav--prev').prop('disabled', current === 0);
                $w.find('.woo-fbt-nav--next').prop('disabled', current >= max);
            }

            $w.find('.woo-fbt-nav--next').on('click', function () { goTo(current + 1); });
            $w.find('.woo-fbt-nav--prev').on('click', function () { goTo(current - 1); });

            $(window).on('resize.woo-fbt', function () {
                if (window.innerWidth < 768) {
                    $track.css('transform', '');
                    $w.find('.woo-fbt-nav').hide();
                } else {
                    goTo(current);
                }
            });

            goTo(0);
        },

        /* ── how many cards fit ── */
        visibleCount: function () {
            return window.innerWidth >= 768 ? 3 : 2;
        },

        /* ── toast notification ── */
        showToast: function (msg, type) {
            var $t = $('#woo-fbt-toast');
            $t.removeClass('woo-fbt-toast--success woo-fbt-toast--error')
              .addClass(type === 'success' ? 'woo-fbt-toast--success' : 'woo-fbt-toast--error')
              .text(msg)
              .addClass('woo-fbt-toast--show');

            clearTimeout(FBT._toastTimer);
            FBT._toastTimer = setTimeout(function () {
                $t.removeClass('woo-fbt-toast--show');
            }, 4000);
        },

        _toastTimer: null,
    };

    $(function () { FBT.init(); });

}(jQuery));
// source --> https://mfrash.com/wp-content/themes/porto/js/sidebar-menu.min.js?ver=7.8.5 
(function(e,i){"use strict";e=e||{},i.extend(e,{SidebarMenu:{defaults:{menu:i(".sidebar-menu:not(.side-menu-accordion)"),toggle:i(".widget_sidebar_menu .widget-title .toggle"),menu_toggle:i("#main-toggle-menu .menu-title")},rtl:e.rtl,initialize:function(e,t,s){return this.$menu&&this.$menu.length&&e&&e.length?(this.$menu=i.uniqueSort(i.merge(this.$menu,e)),this.build(),this):(this.$menu=e||this.defaults.menu,this.$menu.length?(this.$toggle=t||this.defaults.toggle,this.$menu_toggle=s||this.defaults.menu_toggle,this.events(),this):this)},isRightSidebar:function(e){var t=!1;t=this.rtl?!(i("#main").hasClass("column2-right-sidebar")||i("#main").hasClass("column2-wide-right-sidebar")):i("#main").hasClass("column2-right-sidebar")||i("#main").hasClass("column2-wide-right-sidebar"),e.closest("#main-toggle-menu").length&&(t=!!this.rtl);var s=e.closest(".header-wrapper");return s.length&&s.hasClass("header-side-nav")&&(t=!!this.rtl,i(".page-wrapper").hasClass("side-nav-right")&&(t=!this.rtl)),t},popupWidth:function(){var t=window.innerWidth,s=e.bodyWidth-2*e.grid_gutter_width;return i("body").hasClass("wide")||(t>=1140+e.grid_gutter_width&&t<=e.container_width+2*e.grid_gutter_width-1&&e.container_width>=1360?s=1140-e.grid_gutter_width:t>=e.container_width+e.grid_gutter_width-1?s=e.container_width-e.grid_gutter_width:t>=992?s=960-e.grid_gutter_width:t>=768&&(s=720-e.grid_gutter_width)),s},build:function(t){var s=this;if(t||(t=s.$menu),t.length){t.find(".menu-item-has-children").each((function(){var e=i(this);e.find(">.popup").length>0&&0==e.find(">.popup>.inner>.sub-menu > li:not(.hidden-item)").length&&e.addClass("hidden-item")}));var n=t.parent(".toggle-menu-wrap"),a=null;if(n.length&&n.is(":hidden")&&((a=n.get(0)).style.display="block",a.style.visibility="hidden"),t.each((function(){var n,a=this,o=i(this);if(!a.classList.contains("side-menu-slide")){if(window.innerWidth<992)n=s.popupWidth();else{var l=this.offsetWidth?this.offsetWidth:o.width();n=s.popupWidth()-l-45}var d=s.isRightSidebar(o),h=o.children("li");h.each((function(){var s=i(this),l=s.children(".popup");if(l.length){var r=l.get(0),u=!1;if(l.is(":visible")?u=!0:r.style.display="block",s.hasClass("wide")){o.hasClass("side-menu-columns")||(r.style.left=0);var c=4;s.hasClass("col-1")&&(c=1),s.hasClass("col-2")&&(c=2),s.hasClass("col-3")&&(c=3),s.hasClass("col-4")&&(c=4),s.hasClass("col-5")&&(c=5),s.hasClass("col-6")&&(c=6),window.innerWidth<992&&(c=1);var m=0;l.find("> .inner > ul > li").each((function(){var e=parseFloat(i(this).data("cols"));(!e||e<=0)&&(e=1),e>c&&(e=c),m+=e})),m>c&&(m=c);var p=l.data("popup-mw")?l.data("popup-mw"):l.find(".inner").css("max-width"),f=n/c;"none"!==p&&parseInt(p)<n&&(f=parseInt(p)/c),l.find("> .inner > ul > li").each((function(){var e=parseFloat(i(this).data("cols"));e<=0&&(e=1),e>c&&(e=c),s.hasClass("pos-center")||s.hasClass("pos-left")||s.hasClass("pos-right")?this.style.width=100/m*e+"%":this.style.width=100/c*e+"%"})),r.children[0].children[0].style.width=f*m+1+"px",o.hasClass("side-menu-columns")||(d?(r.style.left="auto",r.style.right=(this.offsetWidth?this.offsetWidth:i(this).width())+"px"):(r.style.left=(this.offsetWidth?this.offsetWidth:i(this).width())+"px",r.style.right="auto"))}u||(r.style.display="none"),a.classList.contains("side-menu-accordion")||a.classList.contains("side-menu-slide")||s.hasClass("sub-ready")||(!("ontouchstart"in document)&&window.innerWidth>991?s.on("mouseenter",(function(){if(h.find(".popup").hide(),l.show(),l.parent().addClass("open"),!o.hasClass("side-menu-columns")&&"static"!==l.parent().css("position")){let i=this.getBoundingClientRect().top;if(this.offsetParent&&i+r.offsetHeight>e.innerHeight){let t=i+r.offsetHeight-e.innerHeight,s=i-this.parentNode.getBoundingClientRect().top;s<t&&(t=s),r.style.top=-1*t+"px",r.style.setProperty("--porto-sd-menu-popup-top",-1*t+"px")}else r.style.top="",r.style.setProperty("--porto-sd-menu-popup-top","")}l.find(".owl-carousel").length&&l.find(".owl-carousel").each((function(){var e,t=i(this);if(!t.hasClass("owl-loaded")){var s=t.data("plugin-options");s&&(e=s),t.themeCarousel(e)}}))})).on("mouseleave",(function(){l.hide(),l.parent().removeClass("open")})):s.on("click",".arrow",(function(){!o.hasClass("side-menu-columns")&&!l.parent().hasClass("open")&&window.innerWidth>991&&t.children("li.has-sub").removeClass("open").children(".popup").hide(),l.slideToggle(),l.parent().toggleClass("open")})),s.addClass("sub-ready"))}}))}})),t.hasClass("side-menu-slide")){var o={$mainNav:t,$mainNavItem:t.find("li"),build:function(){this.menuNav()},initSub:function(e){var i=e.closest("ul"),t=e.parent().find("ul").first();t.children(".menu-item").children(".go-back").length<1&&t.prepend('<li class="menu-item"><a class="go-back" href="#">'+js_porto_vars.submenu_back+"</a></li>"),i.addClass("next-menu"),t.addClass("visible"),i.css({overflow:"visible","overflow-y":"visible"}),t.outerHeight()<t.closest(".header-main").outerHeight()-100&&t.css({height:t.outerHeight()+t.find("> li").outerHeight()});var s=t.find("> li").length*t.find("> li").outerHeight()-t.outerHeight();s>0&&t.css({overflow:"hidden","overflow-y":"scroll"}),t.css({"padding-top":s+"px"})},menuNav:function(){var e=this;e.$mainNav.find(".menu-item-has-children > a.nolink").removeClass("nolink").attr("href",""),e.$mainNav.find(".menu-item-has-children > a:not(.go-back)").off("click").on("click",(function(t){t.stopImmediatePropagation(),t.preventDefault();var s=i(this);js_porto_vars.lazyload_menu&&!e.$mainNav.hasClass("sub-ready")?(e.initSub(s),e.$mainNav.on("sub-loaded",(function(){e.initSub(s)}))):e.initSub(s)}))}};o.build()}return a&&(a.style.display="",a.style.visibility=""),s}},events:function(){var e,t=this;(t.$toggle.on("click",(function(){var e=i(this).parent().parent(),s=i(this);s.hasClass("closed")?(s.removeClass("closed"),e.removeClass("closed"),e.find(".sidebar-menu-wrap").stop().slideDown(400,(function(){i(this).attr("style","").show(),t.build()}))):(s.addClass("closed"),e.addClass("closed"),e.find(".sidebar-menu-wrap").stop().slideUp(400,(function(){i(this).attr("style","").hide()})))})),this.$menu_toggle.on("click",(function(){var e=i(this).parent();if(!e.hasClass("show-always")&&!e.hasClass("show-hover")){var s=i(this);s.hasClass("closed")?(s.removeClass("closed"),e.removeClass("closed"),e.find(".toggle-menu-wrap").stop().slideDown(400,(function(){i(this).attr("style","").show()})),t.build()):(s.addClass("closed"),e.addClass("closed"),e.find(".toggle-menu-wrap").stop().slideUp(400,(function(){i(this).attr("style","").hide()})))}})),t.$menu.hasClass("side-menu-slide")&&t.$menu.on("click",".go-back",(function(e){e.preventDefault();var t=i(this).closest(".next-menu"),s=0;t.length&&t.find("> li").length&&(s=t.find("> li").length*t.find("> li").outerHeight()-t.outerHeight()),t.removeClass("next-menu"),i(this).closest("ul").removeClass("visible"),s>0&&t.css({overflow:"hidden","overflow-y":"scroll"})})),i(".sidebar-menu:not(.side-menu-accordion)").closest("[data-plugin-sticky]").length)?i(window).smartresize((function(){e&&clearTimeout(e),e=setTimeout((function(){t.build()}),800)})):i(window).smartresize((function(e){e.originalEvent&&t.build()}));return setTimeout((function(){t.build()}),400),"ontouchstart"in document&&i(document.body).on("click",(function(e){window.innerWidth>991&&(i(e.target).closest("li.has-sub.open").length||t.$menu.each((function(){var e=i(this);e.hasClass("side-menu-accordion")||e.hasClass("side-menu-slide")||e.hasClass("side-menu-columns")||e.children("li.has-sub").removeClass("open").children(".popup").hide()})))})),t}}})}).apply(this,[window.theme,jQuery]),jQuery(document).ready((function(e){void 0!==theme.SidebarMenu&&(theme.bodyWidth||(theme.bodyWidth=theme.bodyWidth||document.body.offsetWidth),theme.SidebarMenu.initialize(),e.fn.themeAccordionMenu&&e(".sidebar-menu.side-menu-accordion").themeAccordionMenu({open_one:!0}))}));