New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@printcart/wix-integration

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@printcart/wix-integration - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

474

dist/main.es.js

@@ -1,16 +0,16 @@

var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var __defProp2 = Object.defineProperty;
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField2 = (obj, key, value) => {
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __accessCheck = (obj, member, msg) => {
var __accessCheck2 = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
var __privateGet2 = (obj, member, getter) => {
__accessCheck2(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
var __privateAdd2 = (obj, member, value) => {
if (member.has(obj))

@@ -20,17 +20,17 @@ throw TypeError("Cannot add the same private member more than once");

};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
var __privateSet2 = (obj, member, value, setter) => {
__accessCheck2(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var __privateMethod = (obj, member, method) => {
__accessCheck(obj, member, "access private method");
var __privateMethod2 = (obj, member, method) => {
__accessCheck2(obj, member, "access private method");
return method;
};
const import_meta = {};
var _apiUrl, _designerUrl2, _designerInstance, _uploaderInstance, _productForm, _openSelectModal, openSelectModal_fn, _openModal, openModal_fn, _closeModal, closeModal_fn, _registerCloseModal, registerCloseModal_fn, _modalTrap, modalTrap_fn, _handleUploadSuccess, handleUploadSuccess_fn, _handleDesignSuccess, handleDesignSuccess_fn, _registerUploaderEvents, registerUploaderEvents_fn, _registerDesignerEvents, registerDesignerEvents_fn, _getUnauthToken, getUnauthToken_fn, _getScriptSrc, getScriptSrc_fn, _addStyle, addStyle_fn, _getPrintcartProduct, getPrintcartProduct_fn, _createBtn, createBtn_fn, _createProjectPrintcart, createProjectPrintcart_fn;
var __defProp2 = Object.defineProperty;
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField2 = (obj, key, value) => {
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
var _apiUrl, _designerUrl2, _designerInstance, _uploaderInstance, _productForm, _registerListener, registerListener_fn, _initializeProductTools, initializeProductTools_fn, _openSelectModal, openSelectModal_fn, _openModal, openModal_fn, _closeModal, closeModal_fn, _registerCloseModal, registerCloseModal_fn, _modalTrap, modalTrap_fn, _handleUploadSuccess, handleUploadSuccess_fn, _handleDesignSuccess, handleDesignSuccess_fn, _registerUploaderEvents, registerUploaderEvents_fn, _registerDesignerEvents, registerDesignerEvents_fn, _getUnauthToken, getUnauthToken_fn, _getScriptSrc, getScriptSrc_fn, _addStyle, addStyle_fn, _getPrintcartProduct, getPrintcartProduct_fn, _createBtn, createBtn_fn, _createProjectPrintcart, createProjectPrintcart_fn;
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;

@@ -435,5 +435,5 @@ };

__privateAdd$1(this, _emit$1);
__publicField2(this, "token");
__publicField2(this, "productId");
__publicField2(this, "options");
__publicField(this, "token");
__publicField(this, "productId");
__publicField(this, "options");
__privateAdd$1(this, _designerUrl, void 0);

@@ -559,11 +559,11 @@ __privateAdd$1(this, _emitter$1, void 0);

};
var __accessCheck2 = (obj, member, msg) => {
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet2 = (obj, member, getter) => {
__accessCheck2(obj, member, "read from private field");
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd2 = (obj, member, value) => {
var __privateAdd = (obj, member, value) => {
if (member.has(obj))

@@ -573,9 +573,9 @@ throw TypeError("Cannot add the same private member more than once");

};
var __privateSet2 = (obj, member, value, setter) => {
__accessCheck2(obj, member, "write to private field");
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var __privateMethod2 = (obj, member, method) => {
__accessCheck2(obj, member, "access private method");
var __privateMethod = (obj, member, method) => {
__accessCheck(obj, member, "access private method");
return method;

@@ -612,3 +612,3 @@ };

events.exports = EventEmitter;
events.exports.once = once22;
events.exports.once = once2;
EventEmitter.EventEmitter = EventEmitter;

@@ -759,3 +759,3 @@ EventEmitter.prototype._events = void 0;

}
EventEmitter.prototype.once = function once2(type, listener) {
EventEmitter.prototype.once = function once3(type, listener) {
checkListener(listener);

@@ -910,3 +910,3 @@ this.on(type, _onceWrap(this, type, listener));

}
function once22(emitter, name) {
function once2(emitter, name) {
return new Promise(function(resolve, reject) {

@@ -957,26 +957,26 @@ function errorListener(err) {

constructor(config) {
__privateAdd2(this, _emit);
__privateAdd2(this, _initIframe);
__privateAdd2(this, _messageEventListener);
__privateAdd2(this, _unauthToken, void 0);
__privateAdd2(this, _entityId, void 0);
__privateAdd2(this, _iframeUrl, void 0);
__privateAdd2(this, _emitter, void 0);
__privateAdd2(this, _locale, void 0);
__privateAdd2(this, _entityType, void 0);
__privateSet2(this, _unauthToken, config.token);
__privateSet2(this, _entityId, config.sideId || config.productId);
__privateSet2(this, _entityType, config.productId ? "product" : "side");
__privateSet2(this, _iframeUrl, config.uploaderUrl ? config.uploaderUrl : "https://upload-tool.pages.dev");
__privateSet2(this, _emitter, new EventEmitter$1());
__privateSet2(this, _locale, config.locale);
if (!__privateGet2(this, _unauthToken) || !__privateGet2(this, _entityId)) {
__privateAdd(this, _emit);
__privateAdd(this, _initIframe);
__privateAdd(this, _messageEventListener);
__privateAdd(this, _unauthToken, void 0);
__privateAdd(this, _entityId, void 0);
__privateAdd(this, _iframeUrl, void 0);
__privateAdd(this, _emitter, void 0);
__privateAdd(this, _locale, void 0);
__privateAdd(this, _entityType, void 0);
__privateSet(this, _unauthToken, config.token);
__privateSet(this, _entityId, config.sideId || config.productId);
__privateSet(this, _entityType, config.productId ? "product" : "side");
__privateSet(this, _iframeUrl, config.uploaderUrl ? config.uploaderUrl : "https://upload-tool.pages.dev");
__privateSet(this, _emitter, new EventEmitter$1());
__privateSet(this, _locale, config.locale);
if (!__privateGet(this, _unauthToken) || !__privateGet(this, _entityId)) {
console.warn("Missing Config Params.");
return;
}
__privateMethod2(this, _initIframe, initIframe_fn).call(this);
__privateMethod2(this, _messageEventListener, messageEventListener_fn).call(this);
__privateMethod(this, _initIframe, initIframe_fn).call(this);
__privateMethod(this, _messageEventListener, messageEventListener_fn).call(this);
}
get locale() {
return __privateGet2(this, _locale);
return __privateGet(this, _locale);
}

@@ -986,8 +986,8 @@ open() {

let iframe = document.getElementById(IFRAME_ID);
const url = new URL(__privateGet2(this, _iframeUrl));
url.searchParams.set("token", __privateGet2(this, _unauthToken));
if (__privateGet2(this, _entityType) === "side") {
url.searchParams.set("sideId", __privateGet2(this, _entityId));
} else if (__privateGet2(this, _entityType) === "product") {
url.searchParams.set("productId", __privateGet2(this, _entityId));
const url = new URL(__privateGet(this, _iframeUrl));
url.searchParams.set("token", __privateGet(this, _unauthToken));
if (__privateGet(this, _entityType) === "side") {
url.searchParams.set("sideId", __privateGet(this, _entityId));
} else if (__privateGet(this, _entityType) === "product") {
url.searchParams.set("productId", __privateGet(this, _entityId));
}

@@ -1002,3 +1002,3 @@ url.searchParams.set("parentUrl", window.location.href);

wrapper.style.visibility = "visible";
__privateMethod2(this, _emit, emit_fn).call(this, "open");
__privateMethod(this, _emit, emit_fn).call(this, "open");
}

@@ -1015,3 +1015,3 @@ close() {

on(event, callback) {
__privateGet2(this, _emitter).on(event, callback);
__privateGet(this, _emitter).on(event, callback);
return this;

@@ -1028,3 +1028,3 @@ }

emit_fn = function(event, ...args) {
__privateGet2(this, _emitter).emit(event, ...args);
__privateGet(this, _emitter).emit(event, ...args);
};

@@ -1052,3 +1052,3 @@ _initIframe = /* @__PURE__ */ new WeakSet();

const originURL = new URL(event.origin);
const iframeURL = new URL(__privateGet2(this, _iframeUrl));
const iframeURL = new URL(__privateGet(this, _iframeUrl));
if (originURL.host === iframeURL.host) {

@@ -1058,14 +1058,14 @@ if (event.data.uploaderEvent === "close" && wrapper) {

wrapper.style.visibility = "hidden";
__privateMethod2(this, _emit, emit_fn).call(this, "close");
__privateMethod(this, _emit, emit_fn).call(this, "close");
}
if (event.data.uploaderEvent === "upload-success") {
__privateMethod2(this, _emit, emit_fn).call(this, "upload-success", event.data.data);
__privateMethod(this, _emit, emit_fn).call(this, "upload-success", event.data.data);
}
if (event.data.uploaderEvent === "upload-error") {
__privateMethod2(this, _emit, emit_fn).call(this, "upload-error", event.data.error);
__privateMethod(this, _emit, emit_fn).call(this, "upload-error", event.data.error);
}
const locale = __privateGet2(this, _locale);
const locale = __privateGet(this, _locale);
const iframe = document.getElementById(IFRAME_ID);
if (iframe && iframe instanceof HTMLIFrameElement) {
__privateMethod2(this, _emit, emit_fn).call(this, "onload");
__privateMethod(this, _emit, emit_fn).call(this, "onload");
if (locale && event.data.uploaderEvent === "loaded" && event.data.finished) {

@@ -1078,3 +1078,3 @@ console.log("test");

},
__privateGet2(this, _iframeUrl)
__privateGet(this, _iframeUrl)
);

@@ -1090,125 +1090,165 @@ }

class PrintcartDesignerWix {
constructor(_eventName, _productIdWix, _orderIdWix, _orderNumberWix) {
__privateAdd(this, _openSelectModal);
__privateAdd(this, _openModal);
__privateAdd(this, _closeModal);
__privateAdd(this, _registerCloseModal);
__privateAdd(this, _modalTrap);
__privateAdd(this, _handleUploadSuccess);
__privateAdd(this, _handleDesignSuccess);
__privateAdd(this, _registerUploaderEvents);
__privateAdd(this, _registerDesignerEvents);
__privateAdd(this, _getUnauthToken);
__privateAdd(this, _getScriptSrc);
__privateAdd(this, _addStyle);
__privateAdd(this, _getPrintcartProduct);
__privateAdd(this, _createBtn);
__privateAdd(this, _createProjectPrintcart);
__privateAdd(this, _apiUrl, void 0);
__publicField(this, "token");
__publicField(this, "eventName");
__publicField(this, "productIdPrintcart");
__publicField(this, "productIdWix");
__publicField(this, "orderIdWix");
__publicField(this, "orderNumberWix");
__publicField(this, "options");
__privateAdd(this, _designerUrl2, void 0);
__privateAdd(this, _designerInstance, void 0);
__privateAdd(this, _uploaderInstance, void 0);
__privateAdd(this, _productForm, void 0);
this.token = __privateMethod(this, _getUnauthToken, getUnauthToken_fn).call(this);
this.eventName = _eventName;
this.productIdPrintcart = null;
this.productIdWix = _productIdWix;
this.orderIdWix = _orderIdWix;
this.orderNumberWix = _orderNumberWix;
__privateSet(this, _productForm, null);
constructor() {
__privateAdd2(this, _registerListener);
__privateAdd2(this, _initializeProductTools);
__privateAdd2(this, _openSelectModal);
__privateAdd2(this, _openModal);
__privateAdd2(this, _closeModal);
__privateAdd2(this, _registerCloseModal);
__privateAdd2(this, _modalTrap);
__privateAdd2(this, _handleUploadSuccess);
__privateAdd2(this, _handleDesignSuccess);
__privateAdd2(this, _registerUploaderEvents);
__privateAdd2(this, _registerDesignerEvents);
__privateAdd2(this, _getUnauthToken);
__privateAdd2(this, _getScriptSrc);
__privateAdd2(this, _addStyle);
__privateAdd2(this, _getPrintcartProduct);
__privateAdd2(this, _createBtn);
__privateAdd2(this, _createProjectPrintcart);
__privateAdd2(this, _apiUrl, void 0);
__publicField2(this, "token");
__publicField2(this, "productIdPC");
__publicField2(this, "orderIdWix");
__publicField2(this, "orderNumberWix");
__publicField2(this, "options");
__privateAdd2(this, _designerUrl2, void 0);
__privateAdd2(this, _designerInstance, void 0);
__privateAdd2(this, _uploaderInstance, void 0);
__privateAdd2(this, _productForm, void 0);
__publicField2(this, "registerListener");
this.token = __privateMethod2(this, _getUnauthToken, getUnauthToken_fn).call(this);
this.productIdPC = null;
this.orderIdWix = null;
this.orderNumberWix = null;
__privateSet2(this, _productForm, null);
this.options = window.PrintcartDesignerShopifyOptions;
__privateSet(this, _apiUrl, {}.VITE_API_URL ? {}.VITE_API_URL : "https://api.printcart.com/v1");
__privateSet(this, _designerUrl2, {}.VITE_CUSTOMIZER_URL ? {}.VITE_CUSTOMIZER_URL : "https://customizer.printcart.com");
if (this.eventName === "productPageLoaded" || this.eventName === "CustomizeProduct") {
__privateSet(this, _productForm, document.querySelector("[data-hook='product-options']"));
if (!__privateGet(this, _productForm)) {
throw new Error("This script can only be used inside a Wix Product Page.");
}
if (!this.productIdWix) {
throw new Error("Can not find product ID WIX");
}
__privateMethod(this, _getPrintcartProduct, getPrintcartProduct_fn).call(this).then((res) => {
var _a, _b;
this.productIdPrintcart = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.id;
if (!this.productIdPrintcart) {
throw new Error("Can not find product ID Printcart");
}
__privateMethod(this, _addStyle, addStyle_fn).call(this);
__privateMethod(this, _createBtn, createBtn_fn).call(this);
__privateMethod(this, _openSelectModal, openSelectModal_fn).call(this);
__privateMethod(this, _registerCloseModal, registerCloseModal_fn).call(this);
__privateMethod(this, _modalTrap, modalTrap_fn).call(this);
const btn = document.querySelector("button#pc-btn");
const isDesignEnabled = res.data.enable_design;
const isUploadEnabled = res.data.enable_upload;
if (isDesignEnabled) {
__privateSet(this, _designerInstance, new PrintcartDesigner({
token: this.token,
productId: this.productIdPrintcart,
options: {
...(_b = this.options) == null ? void 0 : _b.designerOptions,
designerUrl: __privateGet(this, _designerUrl2)
}
}));
__privateMethod(this, _registerDesignerEvents, registerDesignerEvents_fn).call(this);
if (btn && btn instanceof HTMLButtonElement) {
btn.disabled = false;
__privateSet2(this, _apiUrl, {}.VITE_API_URL ? {}.VITE_API_URL : "https://api.printcart.com/v1");
__privateSet2(this, _designerUrl2, {}.VITE_CUSTOMIZER_URL ? {}.VITE_CUSTOMIZER_URL : "https://customizer.printcart.com");
this.registerListener = __privateMethod2(this, _registerListener, registerListener_fn).bind(this);
window.addEventListener(
"wixDevelopersAnalyticsReady",
this.registerListener
);
}
}
_apiUrl = new WeakMap();
_designerUrl2 = new WeakMap();
_designerInstance = new WeakMap();
_uploaderInstance = new WeakMap();
_productForm = new WeakMap();
_registerListener = new WeakSet();
registerListener_fn = function() {
const self = this;
window == null ? void 0 : window.wixDevelopersAnalytics.register(
{}.APP_ID,
function report(eventName, data) {
var _a, _b, _c;
console.log(eventName);
switch (eventName) {
case "ViewContent":
if (localStorage.getItem("pc-product")) {
localStorage.removeItem("pc-product");
}
}
if (isUploadEnabled) {
__privateSet(this, _uploaderInstance, new PrintcartUploader({
token: this.token,
productId: this.productIdPrintcart
}));
__privateMethod(this, _registerUploaderEvents, registerUploaderEvents_fn).call(this);
if (btn && btn instanceof HTMLButtonElement) {
btn.disabled = false;
break;
case "productPageLoaded":
console.log(data);
if (data.variants && data.variants.length > 1) {
return;
}
}
const handleClick = () => {
if (__privateGet(this, _designerInstance) && !__privateGet(this, _uploaderInstance)) {
__privateGet(this, _designerInstance).render();
__privateMethod2(_a = self, _initializeProductTools, initializeProductTools_fn).call(_a, data == null ? void 0 : data.productId);
break;
case "CustomizeProduct":
if (data.variants && data.variants.length < 1) {
return;
}
if (!__privateGet(this, _designerInstance) && __privateGet(this, _uploaderInstance)) {
__privateGet(this, _uploaderInstance).open();
__privateMethod2(_b = self, _initializeProductTools, initializeProductTools_fn).call(_b, data == null ? void 0 : data.variantId);
break;
case "Purchase":
if (!localStorage.getItem("pc-design-ids")) {
return;
}
if (__privateGet(this, _designerInstance) && __privateGet(this, _uploaderInstance)) {
__privateMethod(this, _openModal, openModal_fn).call(this);
const designIds = localStorage.getItem("pc-design-ids");
self.orderIdWix = data == null ? void 0 : data.orderId;
self.orderNumberWix = data == null ? void 0 : data.id;
if (!self.orderIdWix) {
throw new Error("Can not find order ID WIX");
}
};
if (btn && btn instanceof HTMLButtonElement) {
btn.onclick = handleClick;
if (!self.orderNumberWix) {
throw new Error("Can not find order number WIX");
}
if (!designIds) {
throw new Error("Can not find design Ids");
}
__privateMethod2(_c = self, _createProjectPrintcart, createProjectPrintcart_fn).call(_c, self.orderNumberWix, self.orderIdWix, JSON.parse(designIds));
break;
}
}
);
};
_initializeProductTools = new WeakSet();
initializeProductTools_fn = function(productIdWix) {
__privateSet2(this, _productForm, document.querySelector("[data-hook='product-options']"));
if (!__privateGet2(this, _productForm)) {
throw new Error(
"This script can only be used inside a Wix Product Page."
);
}
if (!productIdWix) {
throw new Error("Can not find product ID WIX");
}
__privateMethod2(this, _getPrintcartProduct, getPrintcartProduct_fn).call(this, productIdWix).then((res) => {
var _a, _b;
this.productIdPC = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.id;
if (!this.productIdPC) {
throw new Error("Can not find product ID Printcart");
}
__privateMethod2(this, _addStyle, addStyle_fn).call(this);
__privateMethod2(this, _createBtn, createBtn_fn).call(this);
__privateMethod2(this, _openSelectModal, openSelectModal_fn).call(this);
__privateMethod2(this, _registerCloseModal, registerCloseModal_fn).call(this);
__privateMethod2(this, _modalTrap, modalTrap_fn).call(this);
const btn = document.querySelector("button#pc-btn");
const isDesignEnabled = res.data.enable_design;
const isUploadEnabled = res.data.enable_upload;
if (isDesignEnabled) {
__privateSet2(this, _designerInstance, new PrintcartDesigner({
token: this.token,
productId: this.productIdPC,
options: {
...(_b = this.options) == null ? void 0 : _b.designerOptions,
designerUrl: __privateGet2(this, _designerUrl2)
}
});
}));
__privateMethod2(this, _registerDesignerEvents, registerDesignerEvents_fn).call(this);
if (btn && btn instanceof HTMLButtonElement) {
btn.disabled = false;
}
}
if (this.eventName === "Purchase") {
if (!localStorage.getItem("pc-design-ids")) {
return;
if (isUploadEnabled) {
__privateSet2(this, _uploaderInstance, new PrintcartUploader({
token: this.token,
productId: this.productIdPC
}));
__privateMethod2(this, _registerUploaderEvents, registerUploaderEvents_fn).call(this);
if (btn && btn instanceof HTMLButtonElement) {
btn.disabled = false;
}
const designIds = localStorage.getItem("pc-design-ids");
if (!this.orderIdWix) {
throw new Error("Can not find order ID WIX");
}
const handleClick = () => {
if (__privateGet2(this, _designerInstance) && !__privateGet2(this, _uploaderInstance)) {
__privateGet2(this, _designerInstance).render();
}
if (!this.orderNumberWix) {
throw new Error("Can not find order number WIX");
if (!__privateGet2(this, _designerInstance) && __privateGet2(this, _uploaderInstance)) {
__privateGet2(this, _uploaderInstance).open();
}
if (!designIds) {
throw new Error("Can not find design Ids");
if (__privateGet2(this, _designerInstance) && __privateGet2(this, _uploaderInstance)) {
__privateMethod2(this, _openModal, openModal_fn).call(this);
}
__privateMethod(this, _createProjectPrintcart, createProjectPrintcart_fn).call(this, this.orderNumberWix, this.orderIdWix, JSON.parse(designIds));
};
if (btn && btn instanceof HTMLButtonElement) {
btn.onclick = handleClick;
}
}
}
_apiUrl = new WeakMap();
_designerUrl2 = new WeakMap();
_designerInstance = new WeakMap();
_uploaderInstance = new WeakMap();
_productForm = new WeakMap();
});
};
_openSelectModal = new WeakSet();

@@ -1274,11 +1314,11 @@ openSelectModal_fn = function() {

const design = () => {
if (__privateGet(this, _designerInstance)) {
__privateMethod(this, _closeModal, closeModal_fn).call(this);
__privateGet(this, _designerInstance).render();
if (__privateGet2(this, _designerInstance)) {
__privateMethod2(this, _closeModal, closeModal_fn).call(this);
__privateGet2(this, _designerInstance).render();
}
};
const upload = () => {
if (__privateGet(this, _uploaderInstance)) {
__privateMethod(this, _closeModal, closeModal_fn).call(this);
__privateGet(this, _uploaderInstance).open();
if (__privateGet2(this, _uploaderInstance)) {
__privateMethod2(this, _closeModal, closeModal_fn).call(this);
__privateGet2(this, _uploaderInstance).open();
}

@@ -1318,8 +1358,8 @@ };

if (e.key === "Escape") {
__privateMethod(this, _closeModal, closeModal_fn).call(this);
__privateMethod2(this, _closeModal, closeModal_fn).call(this);
}
};
window.addEventListener("keydown", handleClose);
closeModalBtn == null ? void 0 : closeModalBtn.addEventListener("click", () => __privateMethod(this, _closeModal, closeModal_fn).call(this));
backdropCloseModal == null ? void 0 : backdropCloseModal.addEventListener("click", () => __privateMethod(this, _closeModal, closeModal_fn).call(this));
closeModalBtn == null ? void 0 : closeModalBtn.addEventListener("click", () => __privateMethod2(this, _closeModal, closeModal_fn).call(this));
backdropCloseModal == null ? void 0 : backdropCloseModal.addEventListener("click", () => __privateMethod2(this, _closeModal, closeModal_fn).call(this));
};

@@ -1362,3 +1402,3 @@ _modalTrap = new WeakSet();

input.value = ids.join();
(_a = __privateGet(this, _productForm)) == null ? void 0 : _a.appendChild(input);
(_a = __privateGet2(this, _productForm)) == null ? void 0 : _a.appendChild(input);
}

@@ -1406,3 +1446,3 @@ const previewWrap = document.querySelector(".pc-preview-wrap") || document.createElement("div");

if (callback)
callback(data, __privateGet(this, _uploaderInstance));
callback(data, __privateGet2(this, _uploaderInstance));
};

@@ -1423,3 +1463,3 @@ _handleDesignSuccess = new WeakSet();

input.value = ids.join();
(_a = __privateGet(this, _productForm)) == null ? void 0 : _a.appendChild(input);
(_a = __privateGet2(this, _productForm)) == null ? void 0 : _a.appendChild(input);
}

@@ -1444,3 +1484,3 @@ const previewWrap = document.querySelector(".pc-preview-wrap") || document.createElement("div");

editBtn.onclick = () => {
__privateGet(self, _designerInstance).editDesign(design.id);
__privateGet2(self, _designerInstance).editDesign(design.id);
};

@@ -1471,10 +1511,10 @@ const removeBtn = document.createElement("button");

if (callback)
callback(data, __privateGet(this, _designerInstance));
callback(data, __privateGet2(this, _designerInstance));
};
_registerUploaderEvents = new WeakSet();
registerUploaderEvents_fn = function() {
if (__privateGet(this, _uploaderInstance)) {
__privateGet(this, _uploaderInstance).on("upload-success", (data) => {
__privateMethod(this, _handleUploadSuccess, handleUploadSuccess_fn).call(this, data);
__privateGet(this, _uploaderInstance).close();
if (__privateGet2(this, _uploaderInstance)) {
__privateGet2(this, _uploaderInstance).on("upload-success", (data) => {
__privateMethod2(this, _handleUploadSuccess, handleUploadSuccess_fn).call(this, data);
__privateGet2(this, _uploaderInstance).close();
});

@@ -1485,12 +1525,14 @@ }

registerDesignerEvents_fn = function() {
if (__privateGet(this, _designerInstance)) {
__privateGet(this, _designerInstance).on("upload-success", (data) => {
__privateMethod(this, _handleDesignSuccess, handleDesignSuccess_fn).call(this, data);
__privateGet(this, _designerInstance).close();
if (__privateGet2(this, _designerInstance)) {
__privateGet2(this, _designerInstance).on("upload-success", (data) => {
__privateMethod2(this, _handleDesignSuccess, handleDesignSuccess_fn).call(this, data);
__privateGet2(this, _designerInstance).close();
});
__privateGet(this, _designerInstance).on("edit-success", (data) => {
__privateGet2(this, _designerInstance).on("edit-success", (data) => {
var _a;
if (!data.design_image.url)
return;
const img = document.querySelector(`[data-pc-design-id="${data.id}"] img`);
const img = document.querySelector(
`[data-pc-design-id="${data.id}"] img`
);
if (!img || !(img instanceof HTMLImageElement)) {

@@ -1501,5 +1543,5 @@ throw new Error("Can't find image element");

const callback = (_a = this.options) == null ? void 0 : _a.onDesignEditSuccess;
__privateGet(this, _designerInstance).close();
__privateGet2(this, _designerInstance).close();
if (callback)
callback(data, __privateGet(this, _designerInstance));
callback(data, __privateGet2(this, _designerInstance));
});

@@ -1510,3 +1552,3 @@ }

getUnauthToken_fn = function() {
const src = __privateMethod(this, _getScriptSrc, getScriptSrc_fn).call(this);
const src = __privateMethod2(this, _getScriptSrc, getScriptSrc_fn).call(this);
const url = new URL(src);

@@ -1520,3 +1562,5 @@ const params = new URLSearchParams(url.search);

const isDev = false;
const src = isDev ? import_meta.url : document.querySelector("[id='pc-wix-integration-sdk']").src;
const src = isDev ? import_meta.url : document.querySelector(
"[id='pc-wix-integration-sdk']"
).src;
return src;

@@ -1533,5 +1577,5 @@ };

_getPrintcartProduct = new WeakSet();
getPrintcartProduct_fn = async function() {
getPrintcartProduct_fn = async function(productIdWix) {
try {
const printcartApiUrl = `${__privateGet(this, _apiUrl)}/integration/wix/products/${this.productIdWix}`;
const printcartApiUrl = `${__privateGet2(this, _apiUrl)}/integration/wix/products/${productIdWix}`;
const token = this.token;

@@ -1549,3 +1593,6 @@ if (!token) {

} catch (error) {
console.error("There has been a problem with your fetch operation:", error);
console.error(
"There has been a problem with your fetch operation:",
error
);
return;

@@ -1557,3 +1604,3 @@ }

var _a, _b, _c;
const cartForm = __privateGet(this, _productForm);
const cartForm = __privateGet2(this, _productForm);
if (!(cartForm == null ? void 0 : cartForm.parentNode)) {

@@ -1579,3 +1626,3 @@ console.log("Can not find cart form");

try {
const createProjectApiUrl = `${__privateGet(this, _apiUrl)}/projects`;
const createProjectApiUrl = `${__privateGet2(this, _apiUrl)}/projects`;
const token = this.token;

@@ -1602,6 +1649,11 @@ if (!token) {

} catch (error) {
console.error("There has been a problem with your fetch operation:", error);
console.error(
"There has been a problem with your fetch operation:",
error
);
return;
}
};
export { PrintcartDesignerWix as default };
const prepare = async () => {
};
prepare().then(() => new PrintcartDesignerWix());

@@ -1,2 +0,2 @@

var At=Object.defineProperty;var Dt=(p,d,h)=>d in p?At(p,d,{enumerable:!0,configurable:!0,writable:!0,value:h}):p[d]=h;var M=(p,d,h)=>(Dt(p,typeof d!="symbol"?d+"":d,h),h),Oe=(p,d,h)=>{if(!d.has(p))throw TypeError("Cannot "+h)};var c=(p,d,h)=>(Oe(p,d,"read from private field"),h?h.call(p):d.get(p)),g=(p,d,h)=>{if(d.has(p))throw TypeError("Cannot add the same private member more than once");d instanceof WeakSet?d.add(p):d.set(p,h)},U=(p,d,h,N)=>(Oe(p,d,"write to private field"),N?N.call(p,h):d.set(p,h),h);var y=(p,d,h)=>(Oe(p,d,"access private method"),h);(function(p,d){typeof exports=="object"&&typeof module!="undefined"?module.exports=d():typeof define=="function"&&define.amd?define(d):(p=typeof globalThis!="undefined"?globalThis:p||self,p.PrintcartDesignerWix=d())})(this,function(){var q,te,_,L,P,de,st,le,ot,k,z,ue,at,pe,ct,fe,dt,he,lt,ve,ut,me,pt,ge,ft,ye,ht,_e,vt,we,mt,Le,gt,Ee,yt;"use strict";var p=Object.defineProperty,d=(n,e,t)=>e in n?p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e,t)=>(d(n,typeof e!="symbol"?e+"":e,t),t),N=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},X=(n,e,t)=>(N(n,e,"read from private field"),t?t.call(n):e.get(n)),W=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},Ue=(n,e,t,i)=>(N(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),b=(n,e,t)=>(N(n,e,"access private method"),t),$,J,Ie,Ne,Ce,We,ne,xe,I,C,Pe={exports:{}},A=typeof Reflect=="object"?Reflect:null,$e=A&&typeof A.apply=="function"?A.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},ie;A&&typeof A.ownKeys=="function"?ie=A.ownKeys:Object.getOwnPropertySymbols?ie=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ie=function(e){return Object.getOwnPropertyNames(e)};function _t(n){console&&console.warn&&console.warn(n)}var Ae=Number.isNaN||function(e){return e!==e};function l(){l.init.call(this)}Pe.exports=l,Pe.exports.once=bt,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var De=10;function re(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return De},set:function(n){if(typeof n!="number"||n<0||Ae(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");De=n}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ae(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function je(n){return n._maxListeners===void 0?l.defaultMaxListeners:n._maxListeners}l.prototype.getMaxListeners=function(){return je(this)},l.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=o[e];if(f===void 0)return!1;if(typeof f=="function")$e(f,this,t);else for(var m=f.length,v=Ke(f,m),i=0;i<m;++i)$e(v[i],this,t);return!0};function Be(n,e,t,i){var r,o,s;if(re(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),s=o[e]),s===void 0)s=o[e]=t,++n._eventsCount;else if(typeof s=="function"?s=o[e]=i?[t,s]:[s,t]:i?s.unshift(t):s.push(t),r=je(n),r>0&&s.length>r&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=s.length,_t(a)}return n}l.prototype.addListener=function(e,t){return Be(this,e,t,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(e,t){return Be(this,e,t,!0)};function wt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Fe(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=wt.bind(i);return r.listener=t,i.wrapFn=r,r}l.prototype.once=function(e,t){return re(t),this.on(e,Fe(this,e,t)),this},l.prototype.prependOnceListener=function(e,t){return re(t),this.prependListener(e,Fe(this,e,t)),this},l.prototype.removeListener=function(e,t){var i,r,o,s,a;if(re(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():Lt(i,o),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(r=0;r<o.length;++r)s=o[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function He(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?Et(r):Ke(r,r.length)}l.prototype.listeners=function(e){return He(this,e,!0)},l.prototype.rawListeners=function(e){return He(this,e,!1)},l.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):qe.call(n,e)},l.prototype.listenerCount=qe;function qe(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?ie(this._events):[]};function Ke(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function Lt(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Et(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function bt(n,e){return new Promise(function(t,i){function r(s){n.removeListener(e,o),i(s)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}Ve(n,e,o,{once:!0}),e!=="error"&&It(n,r,{once:!0})})}function It(n,e,t){typeof n.on=="function"&&Ve(n,"error",e,t)}function Ve(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){i.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var Ct=Pe.exports;const Z="pc-designer-iframe-wrapper",se="pc-designer-iframe";class xt{constructor(e){W(this,Ie),W(this,Ce),W(this,ne),W(this,I),h(this,"token"),h(this,"productId"),h(this,"options"),W(this,$,void 0),W(this,J,void 0);var t;if(this.token=e.token,this.productId=e.productId,this.options=e.options,Ue(this,$,(t=this.options)!=null&&t.designerUrl?this.options.designerUrl:{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),Ue(this,J,new Ct),!this.token||!this.productId){console.error("Missing Config Params");return}b(this,Ie,Ne).call(this),b(this,Ce,We).call(this)}render(){const e=document.getElementById(Z),t=document.getElementById(se);if(!t||!(t instanceof HTMLIFrameElement)||!e){console.error("Can not find iframe element");return}const i=b(this,ne,xe).call(this);t.src=i.href,e.style.opacity="1",e.style.visibility="visible",b(this,I,C).call(this,"rendered")}close(){const e=document.getElementById(Z);if(!e){console.error("Can not find iframe element");return}e.style.opacity="0",e.style.visibility="hidden",b(this,I,C).call(this,"closed")}editDesign(e){const t=b(this,ne,xe).call(this);t.searchParams.set("design_id",e),t.searchParams.set("task","edit");const i=document.getElementById(Z),r=document.getElementById(se);if(!r||!(r instanceof HTMLIFrameElement)||!i){console.error("Can not find iframe element");return}r.src=t.href,i.style.opacity="1",i.style.visibility="visible",b(this,I,C).call(this,"edit")}on(e,t){return X(this,J).on(e,t),this}}$=new WeakMap,J=new WeakMap,Ie=new WeakSet,Ne=function(){const n=document.createElement("div");n.id=Z,n.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";const e=document.createElement("iframe");e.id=se,e.width="100%",e.height="100%",n.appendChild(e),document.body.appendChild(n)},Ce=new WeakSet,We=function(){window.addEventListener("message",n=>{if(n.origin===X(this,$)&&n.data.message==="closeDesignTool"){const e=document.getElementById(Z);if(!e)return;e.style.opacity="0",e.style.visibility="hidden",b(this,I,C).call(this,"closed")}if(n.data.message==="finishLoad"){const e=document.getElementById(se);b(this,I,C).call(this,"render-finish"),e&&e instanceof HTMLIFrameElement&&e.contentWindow&&e.contentWindow.postMessage({message:"customSettings",settings:this.options},X(this,$))}n.data.message==="finishProcess"&&b(this,I,C).call(this,"upload-success",n.data.data.data),n.data.message==="finishUpdate"&&b(this,I,C).call(this,"edit-success",n.data.data.data),n.data.message==="uploadError"&&b(this,I,C).call(this,"upload-error",n.data)},!1)},ne=new WeakSet,xe=function(){const n=new URL(X(this,$));return n.searchParams.set("api_key",this.token),n.searchParams.set("product_id",this.productId),n.searchParams.set("parentUrl",window.location.href),n},I=new WeakSet,C=function(n,...e){X(this,J).emit(n,...e)};var Te=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},w=(n,e,t)=>(Te(n,e,"read from private field"),t?t.call(n):e.get(n)),x=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},D=(n,e,t,i)=>(Te(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),R=(n,e,t)=>(Te(n,e,"access private method"),t),G,j,B,Y,Q,ee,O,F,Se,ze,ke,Xe,Me={exports:{}},H=typeof Reflect=="object"?Reflect:null,Je=H&&typeof H.apply=="function"?H.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},oe;H&&typeof H.ownKeys=="function"?oe=H.ownKeys:Object.getOwnPropertySymbols?oe=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:oe=function(e){return Object.getOwnPropertyNames(e)};function Pt(n){console&&console.warn&&console.warn(n)}var Ze=Number.isNaN||function(e){return e!==e};function u(){u.init.call(this)}Me.exports=u,Me.exports.once=Mt,u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var Ge=10;function ae(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return Ge},set:function(n){if(typeof n!="number"||n<0||Ze(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");Ge=n}}),u.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},u.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ze(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Ye(n){return n._maxListeners===void 0?u.defaultMaxListeners:n._maxListeners}u.prototype.getMaxListeners=function(){return Ye(this)},u.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=o[e];if(f===void 0)return!1;if(typeof f=="function")Je(f,this,t);else for(var m=f.length,v=it(f,m),i=0;i<m;++i)Je(v[i],this,t);return!0};function Qe(n,e,t,i){var r,o,s;if(ae(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),s=o[e]),s===void 0)s=o[e]=t,++n._eventsCount;else if(typeof s=="function"?s=o[e]=i?[t,s]:[s,t]:i?s.unshift(t):s.push(t),r=Ye(n),r>0&&s.length>r&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=s.length,Pt(a)}return n}u.prototype.addListener=function(e,t){return Qe(this,e,t,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(e,t){return Qe(this,e,t,!0)};function Tt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function et(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=Tt.bind(i);return r.listener=t,i.wrapFn=r,r}u.prototype.once=function(e,t){return ae(t),this.on(e,et(this,e,t)),this},u.prototype.prependOnceListener=function(e,t){return ae(t),this.prependListener(e,et(this,e,t)),this},u.prototype.removeListener=function(e,t){var i,r,o,s,a;if(ae(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():St(i,o),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this},u.prototype.off=u.prototype.removeListener,u.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(r=0;r<o.length;++r)s=o[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function tt(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?kt(r):it(r,r.length)}u.prototype.listeners=function(e){return tt(this,e,!0)},u.prototype.rawListeners=function(e){return tt(this,e,!1)},u.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):nt.call(n,e)},u.prototype.listenerCount=nt;function nt(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}u.prototype.eventNames=function(){return this._eventsCount>0?oe(this._events):[]};function it(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function St(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function kt(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function Mt(n,e){return new Promise(function(t,i){function r(s){n.removeListener(e,o),i(s)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}rt(n,e,o,{once:!0}),e!=="error"&&Rt(n,r,{once:!0})})}function Rt(n,e,t){typeof n.on=="function"&&rt(n,"error",e,t)}function rt(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){i.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var Ot=Me.exports;const ce="pc-uploader-iframe-wrapper",Re="pc-uploader-iframe";class Ut{constructor(e){if(x(this,O),x(this,Se),x(this,ke),x(this,G,void 0),x(this,j,void 0),x(this,B,void 0),x(this,Y,void 0),x(this,Q,void 0),x(this,ee,void 0),D(this,G,e.token),D(this,j,e.sideId||e.productId),D(this,ee,e.productId?"product":"side"),D(this,B,e.uploaderUrl?e.uploaderUrl:"https://upload-tool.pages.dev"),D(this,Y,new Ot),D(this,Q,e.locale),!w(this,G)||!w(this,j)){console.warn("Missing Config Params.");return}R(this,Se,ze).call(this),R(this,ke,Xe).call(this)}get locale(){return w(this,Q)}open(){let e=document.getElementById(ce),t=document.getElementById(Re);const i=new URL(w(this,B));if(i.searchParams.set("token",w(this,G)),w(this,ee)==="side"?i.searchParams.set("sideId",w(this,j)):w(this,ee)==="product"&&i.searchParams.set("productId",w(this,j)),i.searchParams.set("parentUrl",window.location.href),!t||!(t instanceof HTMLIFrameElement)||!e){console.warn("Can not find iframe element.");return}t.src=i.href,e.style.opacity="1",e.style.visibility="visible",R(this,O,F).call(this,"open")}close(){let e=document.getElementById(ce);if(!e){console.error("Can not find iframe element");return}e.style.opacity="0",e.style.visibility="hidden"}on(e,t){return w(this,Y).on(e,t),this}}G=new WeakMap,j=new WeakMap,B=new WeakMap,Y=new WeakMap,Q=new WeakMap,ee=new WeakMap,O=new WeakSet,F=function(n,...e){w(this,Y).emit(n,...e)},Se=new WeakSet,ze=function(){let n=document.createElement("div");n.id=ce,n.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";let e=document.createElement("iframe");e.id=Re,e.width="100%",e.height="100%",e.style.borderWidth="0",n.appendChild(e),document.body.appendChild(n)},ke=new WeakSet,Xe=function(){let n=document.getElementById(ce);window.addEventListener("message",e=>{var t;const i=new URL(e.origin),r=new URL(w(this,B));if(i.host===r.host){e.data.uploaderEvent==="close"&&n&&(n.style.opacity="0",n.style.visibility="hidden",R(this,O,F).call(this,"close")),e.data.uploaderEvent==="upload-success"&&R(this,O,F).call(this,"upload-success",e.data.data),e.data.uploaderEvent==="upload-error"&&R(this,O,F).call(this,"upload-error",e.data.error);const o=w(this,Q),s=document.getElementById(Re);s&&s instanceof HTMLIFrameElement&&(R(this,O,F).call(this,"onload"),o&&e.data.uploaderEvent==="loaded"&&e.data.finished&&(console.log("test"),s.focus(),(t=s.contentWindow)==null||t.postMessage({locale:o},w(this,B))))}},!1)};var jt="";class Nt{constructor(e,t,i,r){g(this,de);g(this,le);g(this,k);g(this,ue);g(this,pe);g(this,fe);g(this,he);g(this,ve);g(this,me);g(this,ge);g(this,ye);g(this,_e);g(this,we);g(this,Le);g(this,Ee);g(this,q,void 0);M(this,"token");M(this,"eventName");M(this,"productIdPrintcart");M(this,"productIdWix");M(this,"orderIdWix");M(this,"orderNumberWix");M(this,"options");g(this,te,void 0);g(this,_,void 0);g(this,L,void 0);g(this,P,void 0);if(this.token=y(this,ge,ft).call(this),this.eventName=e,this.productIdPrintcart=null,this.productIdWix=t,this.orderIdWix=i,this.orderNumberWix=r,U(this,P,null),this.options=window.PrintcartDesignerShopifyOptions,U(this,q,{}.VITE_API_URL?{}.VITE_API_URL:"https://api.printcart.com/v1"),U(this,te,{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),this.eventName==="productPageLoaded"||this.eventName==="CustomizeProduct"){if(U(this,P,document.querySelector("[data-hook='product-options']")),!c(this,P))throw new Error("This script can only be used inside a Wix Product Page.");if(!this.productIdWix)throw new Error("Can not find product ID WIX");y(this,we,mt).call(this).then(o=>{var v,E;if(this.productIdPrintcart=(v=o==null?void 0:o.data)==null?void 0:v.id,!this.productIdPrintcart)throw new Error("Can not find product ID Printcart");y(this,_e,vt).call(this),y(this,Le,gt).call(this),y(this,de,st).call(this),y(this,ue,at).call(this),y(this,pe,ct).call(this);const s=document.querySelector("button#pc-btn"),a=o.data.enable_design,f=o.data.enable_upload;a&&(U(this,_,new xt({token:this.token,productId:this.productIdPrintcart,options:{...(E=this.options)==null?void 0:E.designerOptions,designerUrl:c(this,te)}})),y(this,me,pt).call(this),s&&s instanceof HTMLButtonElement&&(s.disabled=!1)),f&&(U(this,L,new Ut({token:this.token,productId:this.productIdPrintcart})),y(this,ve,ut).call(this),s&&s instanceof HTMLButtonElement&&(s.disabled=!1));const m=()=>{c(this,_)&&!c(this,L)&&c(this,_).render(),!c(this,_)&&c(this,L)&&c(this,L).open(),c(this,_)&&c(this,L)&&y(this,le,ot).call(this)};s&&s instanceof HTMLButtonElement&&(s.onclick=m)})}if(this.eventName==="Purchase"){if(!localStorage.getItem("pc-design-ids"))return;const o=localStorage.getItem("pc-design-ids");if(!this.orderIdWix)throw new Error("Can not find order ID WIX");if(!this.orderNumberWix)throw new Error("Can not find order number WIX");if(!o)throw new Error("Can not find design Ids");y(this,Ee,yt).call(this,this.orderNumberWix,this.orderIdWix,JSON.parse(o))}}}return q=new WeakMap,te=new WeakMap,_=new WeakMap,L=new WeakMap,P=new WeakMap,de=new WeakSet,st=function(){const i=`
var Ft=Object.defineProperty;var Ht=(p,f,m)=>f in p?Ft(p,f,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[f]=m;var O=(p,f,m)=>(Ht(p,typeof f!="symbol"?f+"":f,m),m),Ne=(p,f,m)=>{if(!f.has(p))throw TypeError("Cannot "+m)};var a=(p,f,m)=>(Ne(p,f,"read from private field"),m?m.call(p):f.get(p)),h=(p,f,m)=>{if(f.has(p))throw TypeError("Cannot add the same private member more than once");f instanceof WeakSet?f.add(p):f.set(p,m)},U=(p,f,m,N)=>(Ne(p,f,"write to private field"),N?N.call(p,m):f.set(p,m),m);var v=(p,f,m)=>(Ne(p,f,"access private method"),m);(function(p){typeof define=="function"&&define.amd?define(p):p()})(function(){var q,te,_,L,x,de,at,ne,We,ue,lt,pe,dt,T,z,fe,ut,he,pt,ve,ft,me,ht,ge,vt,ye,mt,_e,gt,we,yt,Le,_t,Ee,wt,be,Lt,Ie,Et;"use strict";var p=Object.defineProperty,f=(n,e,t)=>e in n?p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,m=(n,e,t)=>(f(n,typeof e!="symbol"?e+"":e,t),t),N=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},X=(n,e,t)=>(N(n,e,"read from private field"),t?t.call(n):e.get(n)),W=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},$e=(n,e,t,i)=>(N(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),E=(n,e,t)=>(N(n,e,"access private method"),t),$,J,Pe,Ae,xe,De,ie,ke,I,C,Se={exports:{}},A=typeof Reflect=="object"?Reflect:null,Be=A&&typeof A.apply=="function"?A.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},re;A&&typeof A.ownKeys=="function"?re=A.ownKeys:Object.getOwnPropertySymbols?re=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:re=function(e){return Object.getOwnPropertyNames(e)};function bt(n){console&&console.warn&&console.warn(n)}var je=Number.isNaN||function(e){return e!==e};function l(){l.init.call(this)}Se.exports=l,Se.exports.once=xt,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var Fe=10;function se(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return Fe},set:function(n){if(typeof n!="number"||n<0||je(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");Fe=n}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||je(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function He(n){return n._maxListeners===void 0?l.defaultMaxListeners:n._maxListeners}l.prototype.getMaxListeners=function(){return He(this)},l.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var c=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw c.context=s,c}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")Be(u,this,t);else for(var g=u.length,y=Xe(u,g),i=0;i<g;++i)Be(y[i],this,t);return!0};function qe(n,e,t,i){var r,o,s;if(se(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),s=o[e]),s===void 0)s=o[e]=t,++n._eventsCount;else if(typeof s=="function"?s=o[e]=i?[t,s]:[s,t]:i?s.unshift(t):s.push(t),r=He(n),r>0&&s.length>r&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=n,c.type=e,c.count=s.length,bt(c)}return n}l.prototype.addListener=function(e,t){return qe(this,e,t,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(e,t){return qe(this,e,t,!0)};function It(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ke(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=It.bind(i);return r.listener=t,i.wrapFn=r,r}l.prototype.once=function(e,t){return se(t),this.on(e,Ke(this,e,t)),this},l.prototype.prependOnceListener=function(e,t){return se(t),this.prependListener(e,Ke(this,e,t)),this},l.prototype.removeListener=function(e,t){var i,r,o,s,c;if(se(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){c=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():Ct(i,o),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,c||t)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(r=0;r<o.length;++r)s=o[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function Ve(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?Pt(r):Xe(r,r.length)}l.prototype.listeners=function(e){return Ve(this,e,!0)},l.prototype.rawListeners=function(e){return Ve(this,e,!1)},l.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):ze.call(n,e)},l.prototype.listenerCount=ze;function ze(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?re(this._events):[]};function Xe(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function Ct(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Pt(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function xt(n,e){return new Promise(function(t,i){function r(s){n.removeListener(e,o),i(s)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}Je(n,e,o,{once:!0}),e!=="error"&&kt(n,r,{once:!0})})}function kt(n,e,t){typeof n.on=="function"&&Je(n,"error",e,t)}function Je(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){i.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var St=Se.exports;const Z="pc-designer-iframe-wrapper",oe="pc-designer-iframe";class Tt{constructor(e){W(this,Pe),W(this,xe),W(this,ie),W(this,I),m(this,"token"),m(this,"productId"),m(this,"options"),W(this,$,void 0),W(this,J,void 0);var t;if(this.token=e.token,this.productId=e.productId,this.options=e.options,$e(this,$,(t=this.options)!=null&&t.designerUrl?this.options.designerUrl:{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),$e(this,J,new St),!this.token||!this.productId){console.error("Missing Config Params");return}E(this,Pe,Ae).call(this),E(this,xe,De).call(this)}render(){const e=document.getElementById(Z),t=document.getElementById(oe);if(!t||!(t instanceof HTMLIFrameElement)||!e){console.error("Can not find iframe element");return}const i=E(this,ie,ke).call(this);t.src=i.href,e.style.opacity="1",e.style.visibility="visible",E(this,I,C).call(this,"rendered")}close(){const e=document.getElementById(Z);if(!e){console.error("Can not find iframe element");return}e.style.opacity="0",e.style.visibility="hidden",E(this,I,C).call(this,"closed")}editDesign(e){const t=E(this,ie,ke).call(this);t.searchParams.set("design_id",e),t.searchParams.set("task","edit");const i=document.getElementById(Z),r=document.getElementById(oe);if(!r||!(r instanceof HTMLIFrameElement)||!i){console.error("Can not find iframe element");return}r.src=t.href,i.style.opacity="1",i.style.visibility="visible",E(this,I,C).call(this,"edit")}on(e,t){return X(this,J).on(e,t),this}}$=new WeakMap,J=new WeakMap,Pe=new WeakSet,Ae=function(){const n=document.createElement("div");n.id=Z,n.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";const e=document.createElement("iframe");e.id=oe,e.width="100%",e.height="100%",n.appendChild(e),document.body.appendChild(n)},xe=new WeakSet,De=function(){window.addEventListener("message",n=>{if(n.origin===X(this,$)&&n.data.message==="closeDesignTool"){const e=document.getElementById(Z);if(!e)return;e.style.opacity="0",e.style.visibility="hidden",E(this,I,C).call(this,"closed")}if(n.data.message==="finishLoad"){const e=document.getElementById(oe);E(this,I,C).call(this,"render-finish"),e&&e instanceof HTMLIFrameElement&&e.contentWindow&&e.contentWindow.postMessage({message:"customSettings",settings:this.options},X(this,$))}n.data.message==="finishProcess"&&E(this,I,C).call(this,"upload-success",n.data.data.data),n.data.message==="finishUpdate"&&E(this,I,C).call(this,"edit-success",n.data.data.data),n.data.message==="uploadError"&&E(this,I,C).call(this,"upload-error",n.data)},!1)},ie=new WeakSet,ke=function(){const n=new URL(X(this,$));return n.searchParams.set("api_key",this.token),n.searchParams.set("product_id",this.productId),n.searchParams.set("parentUrl",window.location.href),n},I=new WeakSet,C=function(n,...e){X(this,J).emit(n,...e)};var Te=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},w=(n,e,t)=>(Te(n,e,"read from private field"),t?t.call(n):e.get(n)),P=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},D=(n,e,t,i)=>(Te(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),M=(n,e,t)=>(Te(n,e,"access private method"),t),G,B,j,Y,Q,ee,R,F,Me,Ze,Re,Ge,Oe={exports:{}},H=typeof Reflect=="object"?Reflect:null,Ye=H&&typeof H.apply=="function"?H.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},ce;H&&typeof H.ownKeys=="function"?ce=H.ownKeys:Object.getOwnPropertySymbols?ce=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ce=function(e){return Object.getOwnPropertyNames(e)};function Mt(n){console&&console.warn&&console.warn(n)}var Qe=Number.isNaN||function(e){return e!==e};function d(){d.init.call(this)}Oe.exports=d,Oe.exports.once=Nt,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._eventsCount=0,d.prototype._maxListeners=void 0;var et=10;function ae(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return et},set:function(n){if(typeof n!="number"||n<0||Qe(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");et=n}}),d.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},d.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Qe(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function tt(n){return n._maxListeners===void 0?d.defaultMaxListeners:n._maxListeners}d.prototype.getMaxListeners=function(){return tt(this)},d.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var c=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw c.context=s,c}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")Ye(u,this,t);else for(var g=u.length,y=ot(u,g),i=0;i<g;++i)Ye(y[i],this,t);return!0};function nt(n,e,t,i){var r,o,s;if(ae(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),s=o[e]),s===void 0)s=o[e]=t,++n._eventsCount;else if(typeof s=="function"?s=o[e]=i?[t,s]:[s,t]:i?s.unshift(t):s.push(t),r=tt(n),r>0&&s.length>r&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=n,c.type=e,c.count=s.length,Mt(c)}return n}d.prototype.addListener=function(e,t){return nt(this,e,t,!1)},d.prototype.on=d.prototype.addListener,d.prototype.prependListener=function(e,t){return nt(this,e,t,!0)};function Rt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function it(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=Rt.bind(i);return r.listener=t,i.wrapFn=r,r}d.prototype.once=function(e,t){return ae(t),this.on(e,it(this,e,t)),this},d.prototype.prependOnceListener=function(e,t){return ae(t),this.prependListener(e,it(this,e,t)),this},d.prototype.removeListener=function(e,t){var i,r,o,s,c;if(ae(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){c=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():Ot(i,o),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,c||t)}return this},d.prototype.off=d.prototype.removeListener,d.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(r=0;r<o.length;++r)s=o[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function rt(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?Ut(r):ot(r,r.length)}d.prototype.listeners=function(e){return rt(this,e,!0)},d.prototype.rawListeners=function(e){return rt(this,e,!1)},d.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):st.call(n,e)},d.prototype.listenerCount=st;function st(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}d.prototype.eventNames=function(){return this._eventsCount>0?ce(this._events):[]};function ot(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function Ot(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Ut(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function Nt(n,e){return new Promise(function(t,i){function r(s){n.removeListener(e,o),i(s)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}ct(n,e,o,{once:!0}),e!=="error"&&Wt(n,r,{once:!0})})}function Wt(n,e,t){typeof n.on=="function"&&ct(n,"error",e,t)}function ct(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){i.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var $t=Oe.exports;const le="pc-uploader-iframe-wrapper",Ue="pc-uploader-iframe";class At{constructor(e){if(P(this,R),P(this,Me),P(this,Re),P(this,G,void 0),P(this,B,void 0),P(this,j,void 0),P(this,Y,void 0),P(this,Q,void 0),P(this,ee,void 0),D(this,G,e.token),D(this,B,e.sideId||e.productId),D(this,ee,e.productId?"product":"side"),D(this,j,e.uploaderUrl?e.uploaderUrl:"https://upload-tool.pages.dev"),D(this,Y,new $t),D(this,Q,e.locale),!w(this,G)||!w(this,B)){console.warn("Missing Config Params.");return}M(this,Me,Ze).call(this),M(this,Re,Ge).call(this)}get locale(){return w(this,Q)}open(){let e=document.getElementById(le),t=document.getElementById(Ue);const i=new URL(w(this,j));if(i.searchParams.set("token",w(this,G)),w(this,ee)==="side"?i.searchParams.set("sideId",w(this,B)):w(this,ee)==="product"&&i.searchParams.set("productId",w(this,B)),i.searchParams.set("parentUrl",window.location.href),!t||!(t instanceof HTMLIFrameElement)||!e){console.warn("Can not find iframe element.");return}t.src=i.href,e.style.opacity="1",e.style.visibility="visible",M(this,R,F).call(this,"open")}close(){let e=document.getElementById(le);if(!e){console.error("Can not find iframe element");return}e.style.opacity="0",e.style.visibility="hidden"}on(e,t){return w(this,Y).on(e,t),this}}G=new WeakMap,B=new WeakMap,j=new WeakMap,Y=new WeakMap,Q=new WeakMap,ee=new WeakMap,R=new WeakSet,F=function(n,...e){w(this,Y).emit(n,...e)},Me=new WeakSet,Ze=function(){let n=document.createElement("div");n.id=le,n.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";let e=document.createElement("iframe");e.id=Ue,e.width="100%",e.height="100%",e.style.borderWidth="0",n.appendChild(e),document.body.appendChild(n)},Re=new WeakSet,Ge=function(){let n=document.getElementById(le);window.addEventListener("message",e=>{var t;const i=new URL(e.origin),r=new URL(w(this,j));if(i.host===r.host){e.data.uploaderEvent==="close"&&n&&(n.style.opacity="0",n.style.visibility="hidden",M(this,R,F).call(this,"close")),e.data.uploaderEvent==="upload-success"&&M(this,R,F).call(this,"upload-success",e.data.data),e.data.uploaderEvent==="upload-error"&&M(this,R,F).call(this,"upload-error",e.data.error);const o=w(this,Q),s=document.getElementById(Ue);s&&s instanceof HTMLIFrameElement&&(M(this,R,F).call(this,"onload"),o&&e.data.uploaderEvent==="loaded"&&e.data.finished&&(console.log("test"),s.focus(),(t=s.contentWindow)==null||t.postMessage({locale:o},w(this,j))))}},!1)};var qt="";class Dt{constructor(){h(this,de);h(this,ne);h(this,ue);h(this,pe);h(this,T);h(this,fe);h(this,he);h(this,ve);h(this,me);h(this,ge);h(this,ye);h(this,_e);h(this,we);h(this,Le);h(this,Ee);h(this,be);h(this,Ie);h(this,q,void 0);O(this,"token");O(this,"productIdPC");O(this,"orderIdWix");O(this,"orderNumberWix");O(this,"options");h(this,te,void 0);h(this,_,void 0);h(this,L,void 0);h(this,x,void 0);O(this,"registerListener");this.token=v(this,_e,gt).call(this),this.productIdPC=null,this.orderIdWix=null,this.orderNumberWix=null,U(this,x,null),this.options=window.PrintcartDesignerShopifyOptions,U(this,q,{}.VITE_API_URL?{}.VITE_API_URL:"https://api.printcart.com/v1"),U(this,te,{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),this.registerListener=v(this,de,at).bind(this),window.addEventListener("wixDevelopersAnalyticsReady",this.registerListener)}}q=new WeakMap,te=new WeakMap,_=new WeakMap,L=new WeakMap,x=new WeakMap,de=new WeakSet,at=function(){const e=this;window==null||window.wixDevelopersAnalytics.register({}.APP_ID,function(i,r){var o,s,c;switch(console.log(i),i){case"ViewContent":localStorage.getItem("pc-product")&&localStorage.removeItem("pc-product");break;case"productPageLoaded":if(console.log(r),r.variants&&r.variants.length>1)return;v(o=e,ne,We).call(o,r==null?void 0:r.productId);break;case"CustomizeProduct":if(r.variants&&r.variants.length<1)return;v(s=e,ne,We).call(s,r==null?void 0:r.variantId);break;case"Purchase":if(!localStorage.getItem("pc-design-ids"))return;const u=localStorage.getItem("pc-design-ids");if(e.orderIdWix=r==null?void 0:r.orderId,e.orderNumberWix=r==null?void 0:r.id,!e.orderIdWix)throw new Error("Can not find order ID WIX");if(!e.orderNumberWix)throw new Error("Can not find order number WIX");if(!u)throw new Error("Can not find design Ids");v(c=e,Ie,Et).call(c,e.orderNumberWix,e.orderIdWix,JSON.parse(u));break}})},ne=new WeakSet,We=function(e){if(U(this,x,document.querySelector("[data-hook='product-options']")),!a(this,x))throw new Error("This script can only be used inside a Wix Product Page.");if(!e)throw new Error("Can not find product ID WIX");v(this,Ee,wt).call(this,e).then(t=>{var c,u;if(this.productIdPC=(c=t==null?void 0:t.data)==null?void 0:c.id,!this.productIdPC)throw new Error("Can not find product ID Printcart");v(this,Le,_t).call(this),v(this,be,Lt).call(this),v(this,ue,lt).call(this),v(this,fe,ut).call(this),v(this,he,pt).call(this);const i=document.querySelector("button#pc-btn"),r=t.data.enable_design,o=t.data.enable_upload;r&&(U(this,_,new Tt({token:this.token,productId:this.productIdPC,options:{...(u=this.options)==null?void 0:u.designerOptions,designerUrl:a(this,te)}})),v(this,ye,mt).call(this),i&&i instanceof HTMLButtonElement&&(i.disabled=!1)),o&&(U(this,L,new At({token:this.token,productId:this.productIdPC})),v(this,ge,vt).call(this),i&&i instanceof HTMLButtonElement&&(i.disabled=!1));const s=()=>{a(this,_)&&!a(this,L)&&a(this,_).render(),!a(this,_)&&a(this,L)&&a(this,L).open(),a(this,_)&&a(this,L)&&v(this,pe,dt).call(this)};i&&i instanceof HTMLButtonElement&&(i.onclick=s)})},ue=new WeakSet,lt=function(){const i=`
<button aria-label="Close" id="pc-select_close-btn"><span data-modal-x></span></button>

@@ -48,2 +48,2 @@ <div class="pc-select-wrap" id="pc-content-overlay">

</div>
`,r=document.createElement("div");r.id="pc-select_wrap",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("tabIndex","-1"),r.innerHTML=i,document.body.appendChild(r);const o=()=>{c(this,_)&&(y(this,k,z).call(this),c(this,_).render())},s=()=>{c(this,L)&&(y(this,k,z).call(this),c(this,L).open())},a=document.getElementById("pc-select_btn_upload"),f=document.getElementById("pc-select_btn_design");a&&(a==null||a.addEventListener("click",s)),f&&(f==null||f.addEventListener("click",o))},le=new WeakSet,ot=function(){const e=document.getElementById("pc-select_wrap");e&&(e.style.display="flex",document.body.classList.toggle("pc-overflow"));const t=e==null?void 0:e.querySelector("#pc-select_close-btn");t&&t instanceof HTMLButtonElement&&t.focus()},k=new WeakSet,z=function(){const e=document.getElementById("pc-select_wrap");e&&(e.style.display="none",document.body.classList.toggle("pc-overflow"))},ue=new WeakSet,at=function(){const e=document.getElementById("pc-select_close-btn"),t=document.getElementById("pc-content-overlay"),i=r=>{r.key==="Escape"&&y(this,k,z).call(this)};window.addEventListener("keydown",i),e==null||e.addEventListener("click",()=>y(this,k,z).call(this)),t==null||t.addEventListener("click",()=>y(this,k,z).call(this))},pe=new WeakSet,ct=function(){const e=document.getElementById("pc-select_wrap"),t=e==null?void 0:e.querySelectorAll("button"),i=t&&t[0],r=t&&t[t.length-1],o=s=>{s.key==="Tab"&&(s.shiftKey?r&&document.activeElement===i&&(r.focus(),s.preventDefault()):i&&document.activeElement===r&&(i.focus(),s.preventDefault()))};window.addEventListener("keydown",o)},fe=new WeakSet,dt=function(e){var a,f;const t=e.map(m=>m.data.id);let i=document.querySelector('input[name="properties[_pcDesignIds]"]');i?i.value+=`,${t.join()}`:(i=document.createElement("input"),i.type="hidden",i.name="properties[_pcDesignIds]",i.className="pc-designer_input",i.value=t.join(),(a=c(this,P))==null||a.appendChild(i));const r=document.querySelector(".pc-preview-wrap")||document.createElement("div");r.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(t)),e.forEach(m=>{var K;if(!m.data.design_image.url)return;const v=document.createElement("div");v.className="pc-preview",v.setAttribute("data-pc-design-id",m.data.id);const E=document.createElement("button");E.className="pc-btn pc-danger-btn",E.innerHTML=(K=this.options)!=null&&K.removeUploaderBtnText?this.options.removeUploaderBtnText:"Remove",E.onclick=()=>{const V=i.value.split(",").filter(be=>be!==m.data.id);i.value=V.join(),v.remove()};const T=document.createElement("img");T.src=m.data.design_image.url,T.className="pc-uploader-image";const S=document.createElement("div");S.className="pc-preview-overlay",S.appendChild(E),v.appendChild(S),v.appendChild(T),r.appendChild(v)});const o=document.querySelector("div#pc-designer_wrap");if(!document.querySelector(".princart-preview-heading")){const m=document.createElement("h5");m.className="princart-preview-heading",m.innerHTML="Your artworks",o==null||o.appendChild(m)}o==null||o.appendChild(r);const s=(f=this.options)==null?void 0:f.onUploadSuccess;s&&s(e,c(this,L))},he=new WeakSet,lt=function(e){var f,m;const t=this,i=e.map(v=>v.id);let r=document.querySelector('input[name="properties[_pcDesignIds]"]');r?r.value+=`,${i.join()}`:(r=document.createElement("input"),r.type="hidden",r.name="properties[_pcDesignIds]",r.className="pc-designer_input",r.value=i.join(),(f=c(this,P))==null||f.appendChild(r));const o=document.querySelector(".pc-preview-wrap")||document.createElement("div");o.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(i)),e.forEach(v=>{var be;if(!v.design_image.url)return;const E=document.createElement("div");E.className="pc-preview",E.setAttribute("data-pc-design-id",v.id);const T=document.createElement("button");T.className="pc-btn pc-primary-btn",T.style.borderRadius="5px",T.innerHTML="Edit",T.onclick=()=>{c(t,_).editDesign(v.id)};const S=document.createElement("button");S.className="pc-btn pc-danger-btn",S.style.borderRadius="5px",S.innerHTML="Remove",S.onclick=()=>{const Wt=r.value.split(",").filter($t=>$t!==v.id);r.value=Wt.join(),E.remove()};const K=document.createElement("img");K.src=((be=v.preview_image)==null?void 0:be.url)||v.design_image.url,K.className="pc-uploader-image";const V=document.createElement("div");V.className="pc-preview-overlay",V.appendChild(T),V.appendChild(S),E.appendChild(V),E.appendChild(K),o.appendChild(E)});const s=document.querySelector("div#pc-designer_wrap");s==null||s.appendChild(o);const a=(m=this.options)==null?void 0:m.onDesignCreateSuccess;a&&a(e,c(this,_))},ve=new WeakSet,ut=function(){c(this,L)&&c(this,L).on("upload-success",e=>{y(this,fe,dt).call(this,e),c(this,L).close()})},me=new WeakSet,pt=function(){c(this,_)&&(c(this,_).on("upload-success",e=>{y(this,he,lt).call(this,e),c(this,_).close()}),c(this,_).on("edit-success",e=>{var r;if(!e.design_image.url)return;const t=document.querySelector(`[data-pc-design-id="${e.id}"] img`);if(!t||!(t instanceof HTMLImageElement))throw new Error("Can't find image element");t.src=e.design_image.url;const i=(r=this.options)==null?void 0:r.onDesignEditSuccess;c(this,_).close(),i&&i(e,c(this,_))}))},ge=new WeakSet,ft=function(){const e=y(this,ye,ht).call(this),t=new URL(e);return new URLSearchParams(t.search).get("shopT")},ye=new WeakSet,ht=function(){return document.querySelector("[id='pc-wix-integration-sdk']").src},_e=new WeakSet,vt=function(){const e={}.VITE_SDK_URL?{}.VITE_SDK_URL:"https://unpkg.com/@printcart/wix-integration/dist",t=document.createElement("link");t.rel="stylesheet",t.href=`${e}/style.css`,document.head.appendChild(t)},we=new WeakSet,mt=async function(){try{const e=`${c(this,q)}/integration/wix/products/${this.productIdWix}`,t=this.token;if(!t)throw new Error("Missing Printcart Unauth Token");return await(await fetch(e,{headers:{"X-PrintCart-Unauth-Token":t}})).json()}catch(e){console.error("There has been a problem with your fetch operation:",e);return}},Le=new WeakSet,gt=function(){var r,o,s;const e=c(this,P);if(!(e!=null&&e.parentNode)){console.log("Can not find cart form");return}if(document.getElementById("pc-designer_wrap")!==null)return;const t=document.createElement("div");t.id="pc-designer_wrap";const i=document.createElement("button");i.id="pc-btn",i.className=(r=this.options)!=null&&r.designClassName?(o=this.options)==null?void 0:o.designClassName:"",i.innerHTML=(s=this.options)!=null&&s.designBtnText?this.options.designBtnText:"Start Design",i.disabled=!0,t.appendChild(i),e.appendChild(t)},Ee=new WeakSet,yt=async function(e,t,i){try{const r=`${c(this,q)}/projects`,o=this.token;if(!o)throw new Error("Missing Printcart Unauth Token");const s={name:`${e}`,status:"processing",design_ids:i,order_detail:{id:t}};await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-PrintCart-Unauth-Token":o},body:JSON.stringify(s)})}catch(r){console.error("There has been a problem with your fetch operation:",r);return}},Nt});
`,r=document.createElement("div");r.id="pc-select_wrap",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("tabIndex","-1"),r.innerHTML=i,document.body.appendChild(r);const o=()=>{a(this,_)&&(v(this,T,z).call(this),a(this,_).render())},s=()=>{a(this,L)&&(v(this,T,z).call(this),a(this,L).open())},c=document.getElementById("pc-select_btn_upload"),u=document.getElementById("pc-select_btn_design");c&&(c==null||c.addEventListener("click",s)),u&&(u==null||u.addEventListener("click",o))},pe=new WeakSet,dt=function(){const e=document.getElementById("pc-select_wrap");e&&(e.style.display="flex",document.body.classList.toggle("pc-overflow"));const t=e==null?void 0:e.querySelector("#pc-select_close-btn");t&&t instanceof HTMLButtonElement&&t.focus()},T=new WeakSet,z=function(){const e=document.getElementById("pc-select_wrap");e&&(e.style.display="none",document.body.classList.toggle("pc-overflow"))},fe=new WeakSet,ut=function(){const e=document.getElementById("pc-select_close-btn"),t=document.getElementById("pc-content-overlay"),i=r=>{r.key==="Escape"&&v(this,T,z).call(this)};window.addEventListener("keydown",i),e==null||e.addEventListener("click",()=>v(this,T,z).call(this)),t==null||t.addEventListener("click",()=>v(this,T,z).call(this))},he=new WeakSet,pt=function(){const e=document.getElementById("pc-select_wrap"),t=e==null?void 0:e.querySelectorAll("button"),i=t&&t[0],r=t&&t[t.length-1],o=s=>{s.key==="Tab"&&(s.shiftKey?r&&document.activeElement===i&&(r.focus(),s.preventDefault()):i&&document.activeElement===r&&(i.focus(),s.preventDefault()))};window.addEventListener("keydown",o)},ve=new WeakSet,ft=function(e){var c,u;const t=e.map(g=>g.data.id);let i=document.querySelector('input[name="properties[_pcDesignIds]"]');i?i.value+=`,${t.join()}`:(i=document.createElement("input"),i.type="hidden",i.name="properties[_pcDesignIds]",i.className="pc-designer_input",i.value=t.join(),(c=a(this,x))==null||c.appendChild(i));const r=document.querySelector(".pc-preview-wrap")||document.createElement("div");r.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(t)),e.forEach(g=>{var K;if(!g.data.design_image.url)return;const y=document.createElement("div");y.className="pc-preview",y.setAttribute("data-pc-design-id",g.data.id);const b=document.createElement("button");b.className="pc-btn pc-danger-btn",b.innerHTML=(K=this.options)!=null&&K.removeUploaderBtnText?this.options.removeUploaderBtnText:"Remove",b.onclick=()=>{const V=i.value.split(",").filter(Ce=>Ce!==g.data.id);i.value=V.join(),y.remove()};const k=document.createElement("img");k.src=g.data.design_image.url,k.className="pc-uploader-image";const S=document.createElement("div");S.className="pc-preview-overlay",S.appendChild(b),y.appendChild(S),y.appendChild(k),r.appendChild(y)});const o=document.querySelector("div#pc-designer_wrap");if(!document.querySelector(".princart-preview-heading")){const g=document.createElement("h5");g.className="princart-preview-heading",g.innerHTML="Your artworks",o==null||o.appendChild(g)}o==null||o.appendChild(r);const s=(u=this.options)==null?void 0:u.onUploadSuccess;s&&s(e,a(this,L))},me=new WeakSet,ht=function(e){var u,g;const t=this,i=e.map(y=>y.id);let r=document.querySelector('input[name="properties[_pcDesignIds]"]');r?r.value+=`,${i.join()}`:(r=document.createElement("input"),r.type="hidden",r.name="properties[_pcDesignIds]",r.className="pc-designer_input",r.value=i.join(),(u=a(this,x))==null||u.appendChild(r));const o=document.querySelector(".pc-preview-wrap")||document.createElement("div");o.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(i)),e.forEach(y=>{var Ce;if(!y.design_image.url)return;const b=document.createElement("div");b.className="pc-preview",b.setAttribute("data-pc-design-id",y.id);const k=document.createElement("button");k.className="pc-btn pc-primary-btn",k.style.borderRadius="5px",k.innerHTML="Edit",k.onclick=()=>{a(t,_).editDesign(y.id)};const S=document.createElement("button");S.className="pc-btn pc-danger-btn",S.style.borderRadius="5px",S.innerHTML="Remove",S.onclick=()=>{const Bt=r.value.split(",").filter(jt=>jt!==y.id);r.value=Bt.join(),b.remove()};const K=document.createElement("img");K.src=((Ce=y.preview_image)==null?void 0:Ce.url)||y.design_image.url,K.className="pc-uploader-image";const V=document.createElement("div");V.className="pc-preview-overlay",V.appendChild(k),V.appendChild(S),b.appendChild(V),b.appendChild(K),o.appendChild(b)});const s=document.querySelector("div#pc-designer_wrap");s==null||s.appendChild(o);const c=(g=this.options)==null?void 0:g.onDesignCreateSuccess;c&&c(e,a(this,_))},ge=new WeakSet,vt=function(){a(this,L)&&a(this,L).on("upload-success",e=>{v(this,ve,ft).call(this,e),a(this,L).close()})},ye=new WeakSet,mt=function(){a(this,_)&&(a(this,_).on("upload-success",e=>{v(this,me,ht).call(this,e),a(this,_).close()}),a(this,_).on("edit-success",e=>{var r;if(!e.design_image.url)return;const t=document.querySelector(`[data-pc-design-id="${e.id}"] img`);if(!t||!(t instanceof HTMLImageElement))throw new Error("Can't find image element");t.src=e.design_image.url;const i=(r=this.options)==null?void 0:r.onDesignEditSuccess;a(this,_).close(),i&&i(e,a(this,_))}))},_e=new WeakSet,gt=function(){const e=v(this,we,yt).call(this),t=new URL(e);return new URLSearchParams(t.search).get("shopT")},we=new WeakSet,yt=function(){return document.querySelector("[id='pc-wix-integration-sdk']").src},Le=new WeakSet,_t=function(){const e={}.VITE_SDK_URL?{}.VITE_SDK_URL:"https://unpkg.com/@printcart/wix-integration/dist",t=document.createElement("link");t.rel="stylesheet",t.href=`${e}/style.css`,document.head.appendChild(t)},Ee=new WeakSet,wt=async function(e){try{const t=`${a(this,q)}/integration/wix/products/${e}`,i=this.token;if(!i)throw new Error("Missing Printcart Unauth Token");return await(await fetch(t,{headers:{"X-PrintCart-Unauth-Token":i}})).json()}catch(t){console.error("There has been a problem with your fetch operation:",t);return}},be=new WeakSet,Lt=function(){var r,o,s;const e=a(this,x);if(!(e!=null&&e.parentNode)){console.log("Can not find cart form");return}if(document.getElementById("pc-designer_wrap")!==null)return;const t=document.createElement("div");t.id="pc-designer_wrap";const i=document.createElement("button");i.id="pc-btn",i.className=(r=this.options)!=null&&r.designClassName?(o=this.options)==null?void 0:o.designClassName:"",i.innerHTML=(s=this.options)!=null&&s.designBtnText?this.options.designBtnText:"Start Design",i.disabled=!0,t.appendChild(i),e.appendChild(t)},Ie=new WeakSet,Et=async function(e,t,i){try{const r=`${a(this,q)}/projects`,o=this.token;if(!o)throw new Error("Missing Printcart Unauth Token");const s={name:`${e}`,status:"processing",design_ids:i,order_detail:{id:t}};await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-PrintCart-Unauth-Token":o},body:JSON.stringify(s)})}catch(r){console.error("There has been a problem with your fetch operation:",r);return}},(async()=>{})().then(()=>new Dt)});

@@ -7,3 +7,3 @@ {

],
"version": "1.1.1",
"version": "1.1.2",
"scripts": {

@@ -10,0 +10,0 @@ "dev": "vite --port 3102",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc