Flatlogic Bot 30fe60f3ea Fazliddin
2026-01-29 11:42:42 +00:00

1 line
11 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(()=>{var t,e,o,i={4587:(t,e,o)=>{"use strict";const i=window.wp.blocks,r=window.wp.data,n=window.wp.editor,s=window.wc.wcTypes;class c{blocks=new Map;initialized=!1;attemptedRegisteredBlocks=new Set;constructor(){this.initializeSubscriptions()}static getInstance(){return c.instance||(c.instance=new c),c.instance}initializeSubscriptions(){if(this.initialized)return;const t=(0,r.subscribe)((()=>{const e=(0,r.select)(n.store);if(!e)return;const o=e.getCurrentPostType();if(o)if("post"===o||"page"===o)t(),this.blocks.forEach((t=>{if(t.isAvailableOnPostEditor){const e=t.variationName||t.blockName;this.hasAttemptedRegistration(e)||this.registerBlock(t)}})),this.initialized=!0;else{t();const o=String(e.getEditedPostSlug());this.currentTemplateId=o,this.handleTemplateChange(void 0),(0,r.subscribe)((()=>{const t=this.currentTemplateId;this.currentTemplateId=String(e.getEditedPostSlug()),t!==this.currentTemplateId&&this.handleTemplateChange(t)}),n.store),this.initialized=!0}}))}handleTemplateChange(t){(this.currentTemplateId?.includes("single-product")||t?.includes("single-product"))&&this.blocks.forEach((t=>{this.unregisterBlock(t),this.registerBlock(t)}))}hasAttemptedRegistration(t){return this.attemptedRegisteredBlocks.has(t)}unregisterBlock(t){const{blockName:e,isVariationBlock:o,variationName:r}=t;try{o&&r?((0,i.unregisterBlockVariation)(e,r),this.attemptedRegisteredBlocks.delete(r)):((0,i.unregisterBlockType)(e),this.attemptedRegisteredBlocks.delete(e))}catch(t){console.debug(`Failed to unregister block ${e}:`,t)}}registerBlock(t){const{blockName:e,settings:o,isVariationBlock:n,variationName:c,isAvailableOnPostEditor:a}=t;try{const t=c||e;if(this.hasAttemptedRegistration(t))return;const l=(0,r.select)("core/edit-site");if(!l&&!a)return;if(n)(0,i.registerBlockVariation)(e,o);else{const t=(0,s.isEmpty)(o?.ancestor)?["woocommerce/single-product"]:o?.ancestor,r=l&&this.currentTemplateId?.includes("single-product");(0,i.registerBlockType)(e,{...o,ancestor:r?void 0:t})}this.attemptedRegisteredBlocks.add(t)}catch(t){console.error(`Failed to register block ${e}:`,t)}}registerBlockConfig(t){const e=t.variationName||t.blockName;this.blocks.set(e,t),this.registerBlock(t)}}var a=o(4530),l=o(6012);const d=JSON.parse('{"name":"woocommerce/add-to-cart-form","title":"Add to Cart with Options","description":"Display a button that lets customers add a product to their cart. Use the added options to optimize for different product types.","category":"woocommerce-product-elements","attributes":{"quantitySelectorStyle":{"type":"string","enum":["input","stepper"],"default":"input"}},"keywords":["WooCommerce"],"usesContext":["postId"],"textdomain":"woocommerce","supports":{"interactivity":true},"apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json","viewScriptModule":"woocommerce/add-to-cart-form","style":"file:../woocommerce/add-to-cart-form-style.css","editorStyle":"file:../woocommerce/add-to-cart-form-editor.css"}'),u=window.wp.blockEditor;var p=o(7723),m=o(4921),b=(o(2405),o(790));const w=({tag:t="div",width:e="100%",height:o="8px",maxWidth:i="",className:r="",borderRadius:n="",isStatic:s=!1,ariaMessage:c})=>(0,b.jsx)(t,{className:(0,m.A)("wc-block-components-skeleton__element",{"wc-block-components-skeleton__element--static":s},r),...c?{"aria-live":"polite","aria-label":c}:{"aria-hidden":"true"},style:{width:e,height:o,borderRadius:n,maxWidth:i}}),h=({isStatic:t=!1})=>(0,b.jsxs)("div",{className:"wc-block-components-skeleton",children:[(0,b.jsx)(w,{height:"16px",isStatic:t}),(0,b.jsx)(w,{height:"16px",isStatic:t}),(0,b.jsx)(w,{height:"16px",width:"80%",isStatic:t})]}),k=window.wp.components,g=window.wc.wcSettings;let f=function(t){return t.Input="input",t.Stepper="stepper",t}({});const _=t=>t===f.Input?(0,p.__)("Shoppers can enter a number of items to add to cart.","woocommerce"):t===f.Stepper?(0,p.__)("Shoppers can use buttons to change the number of items to add to cart.","woocommerce"):void 0,y=({quantitySelectorStyle:t,setAttributes:e})=>(0,b.jsx)(u.InspectorControls,{children:(0,b.jsx)(k.PanelBody,{title:(0,p.__)("Quantity Selector","woocommerce"),children:(0,b.jsxs)(k.__experimentalToggleGroupControl,{__nextHasNoMarginBottom:!0,value:t,isBlock:!0,onChange:t=>{e({quantitySelectorStyle:t})},help:_(t),children:[(0,b.jsx)(k.__experimentalToggleGroupControlOption,{label:(0,p.__)("Input","woocommerce"),value:f.Input}),(0,b.jsx)(k.__experimentalToggleGroupControlOption,{label:(0,p.__)("Stepper","woocommerce"),value:f.Stepper})]})})});var x=o(6087),v=o(2381),j=o.n(v);j()("wc-admin:tracks:stats");const S=j()("wc-admin:tracks");function B({children:t,className:e,actionLabel:o,onActionClick:i,...r}){return(0,b.jsx)(k.Notice,{...r,className:(0,m.$)("wc-block-editor-components-upgrade-downgrade-notice",e),actions:[{label:o,onClick:i,noDefaultClasses:!0,variant:"link"}],children:(0,b.jsx)("div",{className:"wc-block-editor-components-upgrade-downgrade-notice__text",children:t})})}o(9969);const N=({blocks:t,findCondition:e})=>{for(const o of t){if(e(o))return o;if(o.innerBlocks){const t=N({blocks:o.innerBlocks,findCondition:e});if(t)return t}}},O=({blockClientId:t})=>{const e=(0,x.createInterpolateElement)((0,p.__)("Upgrade to the <strongText /> for more flexibility. You can switch back anytime.","woocommerce"),{strongText:(0,b.jsx)("strong",{children:(0,p.__)("Add to Cart + Options block","woocommerce")})}),o=(0,p.__)("Use the Add to Cart + Options block","woocommerce");return(0,b.jsx)(B,{isDismissible:!1,actionLabel:o,onActionClick:async()=>{const e=await(async t=>{const e=(0,r.select)("core/block-editor").getBlocks(),o=N({blocks:e,findCondition:e=>e.name===d.name&&e.clientId===t});if(!o)return!1;const n=(0,i.createBlock)("woocommerce/add-to-cart-with-options");return(0,r.dispatch)("core/block-editor").replaceBlock(o.clientId,n),!0})(t);e&&function(t,e){if(S("recordevent %s %o","wcadmin_"+t,e,{_tqk:window._tkq,shouldRecord:!!window._tkq&&!!window.wcTracks&&!!window.wcTracks.isEnabled}),!window.wcTracks||"function"!=typeof window.wcTracks.recordEvent)return!1;window.wcTracks.recordEvent(t,e)}("blocks_add_to_cart_with_options_migration",{transform_to:"blockified"})},children:e})};(t=>{const e=t.name;if(!e)return void console.error("registerProductBlockType: Block name is required for registration");const o=(({name:t,...e})=>e)(t),{isVariationBlock:i,variationName:r,isAvailableOnPostEditor:n,...s}={...o,...{isAvailableOnPostEditor:!0}||{}},a={blockName:e,settings:{...s},isVariationBlock:null!=i&&i,variationName:null!=r?r:void 0,isAvailableOnPostEditor:null!=n&&n};c.getInstance().registerBlockConfig(a)})({...d,edit:t=>{const{setAttributes:e}=t,o=t.attributes.quantitySelectorStyle===f.Input?"wc-block-add-to-cart-form--input":"wc-block-add-to-cart-form--stepper",i=(0,u.useBlockProps)({className:`wc-block-add-to-cart-form ${o}`}),s=(()=>{const t=(0,r.select)(n.store)?.getCurrentPostType();return"wp_template"===t||"wp_template_part"===t})(),c=(0,g.getSetting)("isBlockTheme",!1),a=c?"":"wp-block-button",l=c?"":"wp-block-button__link wc-block-components-button";return(0,b.jsxs)(b.Fragment,{children:[c&&(0,b.jsx)(u.InspectorControls,{children:(0,b.jsx)(O,{blockClientId:t.clientId})}),(0,b.jsx)(y,{quantitySelectorStyle:t.attributes.quantitySelectorStyle,setAttributes:e}),(0,b.jsx)("div",{...i,children:(0,b.jsx)(k.Tooltip,{text:(0,p.__)("Customer will see product add-to-cart options in this space, dependent on the product type.","woocommerce"),position:"bottom right",children:(0,b.jsxs)("div",{className:"wc-block-editor-add-to-cart-form-container",children:[(0,b.jsx)(h,{isStatic:!0}),(0,b.jsxs)(k.Disabled,{children:[t.attributes.quantitySelectorStyle===f.Input&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"quantity",children:(0,b.jsx)("input",{style:s?{}:{backgroundColor:"#ffffff",lineHeight:"normal",minHeight:"unset",boxSizing:"unset",borderRadius:"unset"},type:"number",value:"1",className:"input-text qty text",readOnly:!0})}),(0,b.jsx)("div",{className:a,children:(0,b.jsx)("button",{className:`single_add_to_cart_button alt wp-element-button ${l}`,children:(0,p.__)("Add to cart","woocommerce")})})]}),t.attributes.quantitySelectorStyle===f.Stepper&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"quantity wc-block-components-quantity-selector",children:[(0,b.jsx)("button",{className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--minus",children:""}),(0,b.jsx)("input",{style:s?{}:{backgroundColor:"#ffffff",lineHeight:"normal",minHeight:"unset",boxSizing:"unset",borderRadius:"unset"},type:"number",value:"1",className:"input-text qty text",readOnly:!0}),(0,b.jsx)("button",{className:"wc-block-components-quantity-selector__button wc-block-components-quantity-selector__button--plus",children:"+"})]}),(0,b.jsx)("div",{className:a,children:(0,b.jsx)("button",{className:`single_add_to_cart_button alt wp-element-button ${l}`,children:(0,p.__)("Add to cart","woocommerce")})})]})]})]})})})]})},icon:{src:(0,b.jsx)(a.A,{icon:l.A,className:"wc-block-editor-components-block-icon"})},ancestor:["woocommerce/single-product"],transforms:{to:[{type:"block",blocks:["woocommerce/add-to-cart-with-options"],transform:()=>(0,i.createBlock)("woocommerce/add-to-cart-with-options")}]},save:()=>null})},2405:()=>{},9969:()=>{},1609:t=>{"use strict";t.exports=window.React},790:t=>{"use strict";t.exports=window.ReactJSXRuntime},6087:t=>{"use strict";t.exports=window.wp.element},7723:t=>{"use strict";t.exports=window.wp.i18n},5573:t=>{"use strict";t.exports=window.wp.primitives}},r={};function n(t){var e=r[t];if(void 0!==e)return e.exports;var o=r[t]={exports:{}};return i[t](o,o.exports,n),o.exports}n.m=i,t=[],n.O=(e,o,i,r)=>{if(!o){var s=1/0;for(d=0;d<t.length;d++){for(var[o,i,r]=t[d],c=!0,a=0;a<o.length;a++)(!1&r||s>=r)&&Object.keys(n.O).every((t=>n.O[t](o[a])))?o.splice(a--,1):(c=!1,r<s&&(s=r));if(c){t.splice(d--,1);var l=i();void 0!==l&&(e=l)}}return e}r=r||0;for(var d=t.length;d>0&&t[d-1][2]>r;d--)t[d]=t[d-1];t[d]=[o,i,r]},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},o=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,n.t=function(t,i){if(1&i&&(t=this(t)),8&i)return t;if("object"==typeof t&&t){if(4&i&&t.__esModule)return t;if(16&i&&"function"==typeof t.then)return t}var r=Object.create(null);n.r(r);var s={};e=e||[null,o({}),o([]),o(o)];for(var c=2&i&&t;"object"==typeof c&&!~e.indexOf(c);c=o(c))Object.getOwnPropertyNames(c).forEach((e=>s[e]=()=>t[e]));return s.default=()=>t,n.d(r,s),r},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.j=2100,(()=>{var t={2100:0};n.O.j=e=>0===t[e];var e=(e,o)=>{var i,r,[s,c,a]=o,l=0;if(s.some((e=>0!==t[e]))){for(i in c)n.o(c,i)&&(n.m[i]=c[i]);if(a)var d=a(n)}for(e&&e(o);l<s.length;l++)r=s[l],n.o(t,r)&&t[r]&&t[r][0](),t[r]=0;return n.O(d)},o=globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))})();var s=n.O(void 0,[94],(()=>n(4587)));s=n.O(s),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["add-to-cart-form"]=s})();