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.8 to 1.1.9

1650

dist/main.es.js

@@ -1,31 +0,1 @@

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 __accessCheck2 = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet2 = (obj, member, getter) => {
__accessCheck2(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd2 = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
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 __privateMethod2 = (obj, member, method) => {
__accessCheck2(obj, member, "access private method");
return method;
};
const import_meta = {};
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;

@@ -37,11 +7,11 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;

};
var __accessCheck$1 = (obj, member, msg) => {
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet$1 = (obj, member, getter) => {
__accessCheck$1(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 __privateAdd$1 = (obj, member, value) => {
var __privateAdd = (obj, member, value) => {
if (member.has(obj))

@@ -51,1058 +21,592 @@ throw TypeError("Cannot add the same private member more than once");

};
var __privateSet$1 = (obj, member, value, setter) => {
__accessCheck$1(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 __privateMethod$1 = (obj, member, method) => {
__accessCheck$1(obj, member, "access private method");
var __privateMethod = (obj, member, method) => {
__accessCheck(obj, member, "access private method");
return method;
};
var _designerUrl, _emitter$1, _initIframe$1, initIframe_fn$1, _registerEventListener, registerEventListener_fn, _createDesignUrl, createDesignUrl_fn, _emit$1, emit_fn$1;
var events$1 = { exports: {} };
var R$1 = typeof Reflect === "object" ? Reflect : null;
var ReflectApply$1 = R$1 && typeof R$1.apply === "function" ? R$1.apply : function ReflectApply2(target, receiver, args) {
return Function.prototype.apply.call(target, receiver, args);
};
var ReflectOwnKeys$1;
if (R$1 && typeof R$1.ownKeys === "function") {
ReflectOwnKeys$1 = R$1.ownKeys;
} else if (Object.getOwnPropertySymbols) {
ReflectOwnKeys$1 = function ReflectOwnKeys2(target) {
return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
const import_meta = {};
var _apiUrl, _designerUrl, _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;
const PrintcartDesigner = function() {
var He = Object.defineProperty;
var ze = (L2, p2, v2) => p2 in L2 ? He(L2, p2, { enumerable: true, configurable: true, writable: true, value: v2 }) : L2[p2] = v2;
var te = (L2, p2, v2) => (ze(L2, typeof p2 != "symbol" ? p2 + "" : p2, v2), v2);
var L = Object.defineProperty, p = (t, e, n) => e in t ? L(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n, v = (t, e, n) => (p(t, typeof e != "symbol" ? e + "" : e, n), n), H = (t, e, n) => {
if (!e.has(t))
throw TypeError("Cannot " + n);
}, R = (t, e, n) => (H(t, e, "read from private field"), n ? n.call(t) : e.get(t)), w = (t, e, n) => {
if (e.has(t))
throw TypeError("Cannot add the same private member more than once");
e instanceof WeakSet ? e.add(t) : e.set(t, n);
}, ne = (t, e, n, r) => (H(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n), l = (t, e, n) => (H(t, e, "access private method"), n), E, P, z, re, G, ie, U, V, d, m, Z = { exports: {} }, b = typeof Reflect == "object" ? Reflect : null, se = b && typeof b.apply == "function" ? b.apply : function(e, n, r) {
return Function.prototype.apply.call(e, n, r);
}, F;
b && typeof b.ownKeys == "function" ? F = b.ownKeys : Object.getOwnPropertySymbols ? F = function(e) {
return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
} : F = function(e) {
return Object.getOwnPropertyNames(e);
};
} else {
ReflectOwnKeys$1 = function ReflectOwnKeys2(target) {
return Object.getOwnPropertyNames(target);
function xe(t) {
console && console.warn && console.warn(t);
}
var oe = Number.isNaN || function(e) {
return e !== e;
};
}
function ProcessEmitWarning$1(warning) {
if (console && console.warn)
console.warn(warning);
}
var NumberIsNaN$1 = Number.isNaN || function NumberIsNaN2(value) {
return value !== value;
};
function EventEmitter$2() {
EventEmitter$2.init.call(this);
}
events$1.exports = EventEmitter$2;
events$1.exports.once = once2$1;
EventEmitter$2.EventEmitter = EventEmitter$2;
EventEmitter$2.prototype._events = void 0;
EventEmitter$2.prototype._eventsCount = 0;
EventEmitter$2.prototype._maxListeners = void 0;
var defaultMaxListeners$1 = 10;
function checkListener$1(listener) {
if (typeof listener !== "function") {
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
function a() {
a.init.call(this);
}
}
Object.defineProperty(EventEmitter$2, "defaultMaxListeners", {
enumerable: true,
get: function() {
return defaultMaxListeners$1;
},
set: function(arg) {
if (typeof arg !== "number" || arg < 0 || NumberIsNaN$1(arg)) {
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + ".");
}
defaultMaxListeners$1 = arg;
Z.exports = a, Z.exports.once = $e, a.EventEmitter = a, a.prototype._events = void 0, a.prototype._eventsCount = 0, a.prototype._maxListeners = void 0;
var ae = 10;
function S(t) {
if (typeof t != "function")
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof t);
}
});
EventEmitter$2.init = function() {
if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) {
this._events = /* @__PURE__ */ Object.create(null);
this._eventsCount = 0;
Object.defineProperty(a, "defaultMaxListeners", { enumerable: true, get: function() {
return ae;
}, set: function(t) {
if (typeof t != "number" || t < 0 || oe(t))
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + t + ".");
ae = t;
} }), a.init = function() {
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
}, a.prototype.setMaxListeners = function(e) {
if (typeof e != "number" || e < 0 || oe(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 fe(t) {
return t._maxListeners === void 0 ? a.defaultMaxListeners : t._maxListeners;
}
this._maxListeners = this._maxListeners || void 0;
};
EventEmitter$2.prototype.setMaxListeners = function setMaxListeners(n) {
if (typeof n !== "number" || n < 0 || NumberIsNaN$1(n)) {
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + ".");
}
this._maxListeners = n;
return this;
};
function _getMaxListeners$1(that) {
if (that._maxListeners === void 0)
return EventEmitter$2.defaultMaxListeners;
return that._maxListeners;
}
EventEmitter$2.prototype.getMaxListeners = function getMaxListeners() {
return _getMaxListeners$1(this);
};
EventEmitter$2.prototype.emit = function emit(type) {
var args = [];
for (var i = 1; i < arguments.length; i++)
args.push(arguments[i]);
var doError = type === "error";
var events2 = this._events;
if (events2 !== void 0)
doError = doError && events2.error === void 0;
else if (!doError)
return false;
if (doError) {
var er;
if (args.length > 0)
er = args[0];
if (er instanceof Error) {
throw er;
a.prototype.getMaxListeners = function() {
return fe(this);
}, a.prototype.emit = function(e) {
for (var n = [], r = 1; r < arguments.length; r++)
n.push(arguments[r]);
var i = e === "error", o = this._events;
if (o !== void 0)
i = i && o.error === void 0;
else if (!i)
return false;
if (i) {
var s;
if (n.length > 0 && (s = n[0]), s instanceof Error)
throw s;
var c = new Error("Unhandled error." + (s ? " (" + s.message + ")" : ""));
throw c.context = s, c;
}
var err = new Error("Unhandled error." + (er ? " (" + er.message + ")" : ""));
err.context = er;
throw err;
}
var handler = events2[type];
if (handler === void 0)
return false;
if (typeof handler === "function") {
ReflectApply$1(handler, this, args);
} else {
var len = handler.length;
var listeners22 = arrayClone$1(handler, len);
for (var i = 0; i < len; ++i)
ReflectApply$1(listeners22[i], this, args);
}
return true;
};
function _addListener$1(target, type, listener, prepend) {
var m;
var events2;
var existing;
checkListener$1(listener);
events2 = target._events;
if (events2 === void 0) {
events2 = target._events = /* @__PURE__ */ Object.create(null);
target._eventsCount = 0;
} else {
if (events2.newListener !== void 0) {
target.emit(
"newListener",
type,
listener.listener ? listener.listener : listener
);
events2 = target._events;
var h = o[e];
if (h === void 0)
return false;
if (typeof h == "function")
se(h, this, n);
else
for (var N = h.length, ee = de(h, N), r = 0; r < N; ++r)
se(ee[r], this, n);
return true;
};
function ce(t, e, n, r) {
var i, o, s;
if (S(n), o = t._events, o === void 0 ? (o = t._events = /* @__PURE__ */ Object.create(null), t._eventsCount = 0) : (o.newListener !== void 0 && (t.emit("newListener", e, n.listener ? n.listener : n), o = t._events), s = o[e]), s === void 0)
s = o[e] = n, ++t._eventsCount;
else if (typeof s == "function" ? s = o[e] = r ? [n, s] : [s, n] : r ? s.unshift(n) : s.push(n), i = fe(t), i > 0 && s.length > i && !s.warned) {
s.warned = true;
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 = t, c.type = e, c.count = s.length, xe(c);
}
existing = events2[type];
return t;
}
if (existing === void 0) {
existing = events2[type] = listener;
++target._eventsCount;
} else {
if (typeof existing === "function") {
existing = events2[type] = prepend ? [listener, existing] : [existing, listener];
} else if (prepend) {
existing.unshift(listener);
} else {
existing.push(listener);
}
m = _getMaxListeners$1(target);
if (m > 0 && existing.length > m && !existing.warned) {
existing.warned = true;
var w = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type) + " listeners added. Use emitter.setMaxListeners() to increase limit");
w.name = "MaxListenersExceededWarning";
w.emitter = target;
w.type = type;
w.count = existing.length;
ProcessEmitWarning$1(w);
}
a.prototype.addListener = function(e, n) {
return ce(this, e, n, false);
}, a.prototype.on = a.prototype.addListener, a.prototype.prependListener = function(e, n) {
return ce(this, e, n, true);
};
function Me() {
if (!this.fired)
return this.target.removeListener(this.type, this.wrapFn), this.fired = true, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
}
return target;
}
EventEmitter$2.prototype.addListener = function addListener(type, listener) {
return _addListener$1(this, type, listener, false);
};
EventEmitter$2.prototype.on = EventEmitter$2.prototype.addListener;
EventEmitter$2.prototype.prependListener = function prependListener(type, listener) {
return _addListener$1(this, type, listener, true);
};
function onceWrapper$1() {
if (!this.fired) {
this.target.removeListener(this.type, this.wrapFn);
this.fired = true;
if (arguments.length === 0)
return this.listener.call(this.target);
return this.listener.apply(this.target, arguments);
function ue(t, e, n) {
var r = { fired: false, wrapFn: void 0, target: t, type: e, listener: n }, i = Me.bind(r);
return i.listener = n, r.wrapFn = i, i;
}
}
function _onceWrap$1(target, type, listener) {
var state = { fired: false, wrapFn: void 0, target, type, listener };
var wrapped = onceWrapper$1.bind(state);
wrapped.listener = listener;
state.wrapFn = wrapped;
return wrapped;
}
EventEmitter$2.prototype.once = function once(type, listener) {
checkListener$1(listener);
this.on(type, _onceWrap$1(this, type, listener));
return this;
};
EventEmitter$2.prototype.prependOnceListener = function prependOnceListener(type, listener) {
checkListener$1(listener);
this.prependListener(type, _onceWrap$1(this, type, listener));
return this;
};
EventEmitter$2.prototype.removeListener = function removeListener(type, listener) {
var list, events2, position, i, originalListener;
checkListener$1(listener);
events2 = this._events;
if (events2 === void 0)
return this;
list = events2[type];
if (list === void 0)
return this;
if (list === listener || list.listener === listener) {
if (--this._eventsCount === 0)
this._events = /* @__PURE__ */ Object.create(null);
else {
delete events2[type];
if (events2.removeListener)
this.emit("removeListener", type, list.listener || listener);
}
} else if (typeof list !== "function") {
position = -1;
for (i = list.length - 1; i >= 0; i--) {
if (list[i] === listener || list[i].listener === listener) {
originalListener = list[i].listener;
position = i;
break;
}
}
if (position < 0)
a.prototype.once = function(e, n) {
return S(n), this.on(e, ue(this, e, n)), this;
}, a.prototype.prependOnceListener = function(e, n) {
return S(n), this.prependListener(e, ue(this, e, n)), this;
}, a.prototype.removeListener = function(e, n) {
var r, i, o, s, c;
if (S(n), i = this._events, i === void 0)
return this;
if (position === 0)
list.shift();
else {
spliceOne$1(list, position);
if (r = i[e], r === void 0)
return this;
if (r === n || r.listener === n)
--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete i[e], i.removeListener && this.emit("removeListener", e, r.listener || n));
else if (typeof r != "function") {
for (o = -1, s = r.length - 1; s >= 0; s--)
if (r[s] === n || r[s].listener === n) {
c = r[s].listener, o = s;
break;
}
if (o < 0)
return this;
o === 0 ? r.shift() : Re(r, o), r.length === 1 && (i[e] = r[0]), i.removeListener !== void 0 && this.emit("removeListener", e, c || n);
}
if (list.length === 1)
events2[type] = list[0];
if (events2.removeListener !== void 0)
this.emit("removeListener", type, originalListener || listener);
}
return this;
};
EventEmitter$2.prototype.off = EventEmitter$2.prototype.removeListener;
EventEmitter$2.prototype.removeAllListeners = function removeAllListeners(type) {
var listeners22, events2, i;
events2 = this._events;
if (events2 === void 0)
return this;
if (events2.removeListener === void 0) {
}, a.prototype.off = a.prototype.removeListener, a.prototype.removeAllListeners = function(e) {
var n, r, i;
if (r = this._events, r === void 0)
return this;
if (r.removeListener === void 0)
return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : r[e] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete r[e]), this;
if (arguments.length === 0) {
this._events = /* @__PURE__ */ Object.create(null);
this._eventsCount = 0;
} else if (events2[type] !== void 0) {
if (--this._eventsCount === 0)
this._events = /* @__PURE__ */ Object.create(null);
else
delete events2[type];
var o = Object.keys(r), s;
for (i = 0; i < o.length; ++i)
s = o[i], s !== "removeListener" && this.removeAllListeners(s);
return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
}
if (n = r[e], typeof n == "function")
this.removeListener(e, n);
else if (n !== void 0)
for (i = n.length - 1; i >= 0; i--)
this.removeListener(e, n[i]);
return this;
};
function le(t, e, n) {
var r = t._events;
if (r === void 0)
return [];
var i = r[e];
return i === void 0 ? [] : typeof i == "function" ? n ? [i.listener || i] : [i] : n ? Pe(i) : de(i, i.length);
}
if (arguments.length === 0) {
var keys = Object.keys(events2);
var key;
for (i = 0; i < keys.length; ++i) {
key = keys[i];
if (key === "removeListener")
continue;
this.removeAllListeners(key);
a.prototype.listeners = function(e) {
return le(this, e, true);
}, a.prototype.rawListeners = function(e) {
return le(this, e, false);
}, a.listenerCount = function(t, e) {
return typeof t.listenerCount == "function" ? t.listenerCount(e) : he.call(t, e);
}, a.prototype.listenerCount = he;
function he(t) {
var e = this._events;
if (e !== void 0) {
var n = e[t];
if (typeof n == "function")
return 1;
if (n !== void 0)
return n.length;
}
this.removeAllListeners("removeListener");
this._events = /* @__PURE__ */ Object.create(null);
this._eventsCount = 0;
return this;
return 0;
}
listeners22 = events2[type];
if (typeof listeners22 === "function") {
this.removeListener(type, listeners22);
} else if (listeners22 !== void 0) {
for (i = listeners22.length - 1; i >= 0; i--) {
this.removeListener(type, listeners22[i]);
}
a.prototype.eventNames = function() {
return this._eventsCount > 0 ? F(this._events) : [];
};
function de(t, e) {
for (var n = new Array(e), r = 0; r < e; ++r)
n[r] = t[r];
return n;
}
return this;
};
function _listeners$1(target, type, unwrap) {
var events2 = target._events;
if (events2 === void 0)
return [];
var evlistener = events2[type];
if (evlistener === void 0)
return [];
if (typeof evlistener === "function")
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
return unwrap ? unwrapListeners$1(evlistener) : arrayClone$1(evlistener, evlistener.length);
}
EventEmitter$2.prototype.listeners = function listeners(type) {
return _listeners$1(this, type, true);
};
EventEmitter$2.prototype.rawListeners = function rawListeners(type) {
return _listeners$1(this, type, false);
};
EventEmitter$2.listenerCount = function(emitter, type) {
if (typeof emitter.listenerCount === "function") {
return emitter.listenerCount(type);
} else {
return listenerCount$1.call(emitter, type);
function Re(t, e) {
for (; e + 1 < t.length; e++)
t[e] = t[e + 1];
t.pop();
}
};
EventEmitter$2.prototype.listenerCount = listenerCount$1;
function listenerCount$1(type) {
var events2 = this._events;
if (events2 !== void 0) {
var evlistener = events2[type];
if (typeof evlistener === "function") {
return 1;
} else if (evlistener !== void 0) {
return evlistener.length;
}
function Pe(t) {
for (var e = new Array(t.length), n = 0; n < e.length; ++n)
e[n] = t[n].listener || t[n];
return e;
}
return 0;
}
EventEmitter$2.prototype.eventNames = function eventNames() {
return this._eventsCount > 0 ? ReflectOwnKeys$1(this._events) : [];
};
function arrayClone$1(arr, n) {
var copy = new Array(n);
for (var i = 0; i < n; ++i)
copy[i] = arr[i];
return copy;
}
function spliceOne$1(list, index) {
for (; index + 1 < list.length; index++)
list[index] = list[index + 1];
list.pop();
}
function unwrapListeners$1(arr) {
var ret = new Array(arr.length);
for (var i = 0; i < ret.length; ++i) {
ret[i] = arr[i].listener || arr[i];
function $e(t, e) {
return new Promise(function(n, r) {
function i(s) {
t.removeListener(e, o), r(s);
}
function o() {
typeof t.removeListener == "function" && t.removeListener("error", i), n([].slice.call(arguments));
}
pe(t, e, o, { once: true }), e !== "error" && Te(t, i, { once: true });
});
}
return ret;
}
function once2$1(emitter, name) {
return new Promise(function(resolve, reject) {
function errorListener(err) {
emitter.removeListener(name, resolver);
reject(err);
function Te(t, e, n) {
typeof t.on == "function" && pe(t, "error", e, n);
}
function pe(t, e, n, r) {
if (typeof t.on == "function")
r.once ? t.once(e, n) : t.on(e, n);
else if (typeof t.addEventListener == "function")
t.addEventListener(e, function i(o) {
r.once && t.removeEventListener(e, i), n(o);
});
else
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof t);
}
var We = Z.exports;
const $ = "pc-designer-iframe-wrapper", j = "pc-designer-iframe";
class Ae {
constructor(e) {
w(this, z), w(this, G), w(this, U), w(this, d), v(this, "token"), v(this, "productId"), v(this, "options"), w(this, E, void 0), w(this, P, void 0);
var n;
if (this.token = e.token, this.productId = e.productId, this.options = e.options, ne(this, E, (n = this.options) != null && n.designerUrl ? this.options.designerUrl : {}.VITE_CUSTOMIZER_URL ? {}.VITE_CUSTOMIZER_URL : "https://customizer.printcart.com"), ne(this, P, new We()), !this.token || !this.productId) {
console.error("Missing Config Params");
return;
}
l(this, z, re).call(this), l(this, G, ie).call(this);
}
function resolver() {
if (typeof emitter.removeListener === "function") {
emitter.removeListener("error", errorListener);
render() {
const e = document.getElementById($), n = document.getElementById(j);
if (!n || !(n instanceof HTMLIFrameElement) || !e) {
console.error("Can not find iframe element");
return;
}
resolve([].slice.call(arguments));
const r = l(this, U, V).call(this);
n.src = r.href, e.style.opacity = "1", e.style.visibility = "visible", l(this, d, m).call(this, "rendered");
}
eventTargetAgnosticAddListener$1(emitter, name, resolver, { once: true });
if (name !== "error") {
addErrorHandlerIfEventEmitter$1(emitter, errorListener, { once: true });
close() {
const e = document.getElementById($);
if (!e) {
console.error("Can not find iframe element");
return;
}
e.style.opacity = "0", e.style.visibility = "hidden", l(this, d, m).call(this, "closed");
}
});
}
function addErrorHandlerIfEventEmitter$1(emitter, handler, flags) {
if (typeof emitter.on === "function") {
eventTargetAgnosticAddListener$1(emitter, "error", handler, flags);
}
}
function eventTargetAgnosticAddListener$1(emitter, name, listener, flags) {
if (typeof emitter.on === "function") {
if (flags.once) {
emitter.once(name, listener);
} else {
emitter.on(name, listener);
}
} else if (typeof emitter.addEventListener === "function") {
emitter.addEventListener(name, function wrapListener(arg) {
if (flags.once) {
emitter.removeEventListener(name, wrapListener);
editDesign(e) {
const n = l(this, U, V).call(this);
n.searchParams.set("design_id", e), n.searchParams.set("task", "edit");
const r = document.getElementById($), i = document.getElementById(j);
if (!i || !(i instanceof HTMLIFrameElement) || !r) {
console.error("Can not find iframe element");
return;
}
listener(arg);
});
} else {
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
}
}
var EE = events$1.exports;
const IFRAME_WRAPPER_ID$1 = "pc-designer-iframe-wrapper";
const IFRAME_ID$1 = "pc-designer-iframe";
class PrintcartDesigner {
constructor(config) {
__privateAdd$1(this, _initIframe$1);
__privateAdd$1(this, _registerEventListener);
__privateAdd$1(this, _createDesignUrl);
__privateAdd$1(this, _emit$1);
__publicField(this, "token");
__publicField(this, "productId");
__publicField(this, "options");
__privateAdd$1(this, _designerUrl, void 0);
__privateAdd$1(this, _emitter$1, void 0);
var _a;
this.token = config.token;
this.productId = config.productId;
this.options = config.options;
__privateSet$1(this, _designerUrl, ((_a = this.options) == null ? void 0 : _a.designerUrl) ? this.options.designerUrl : {}.VITE_CUSTOMIZER_URL ? {}.VITE_CUSTOMIZER_URL : "https://customizer.printcart.com");
__privateSet$1(this, _emitter$1, new EE());
if (!this.token || !this.productId) {
console.error("Missing Config Params");
return;
i.src = n.href, r.style.opacity = "1", r.style.visibility = "visible", l(this, d, m).call(this, "edit");
}
__privateMethod$1(this, _initIframe$1, initIframe_fn$1).call(this);
__privateMethod$1(this, _registerEventListener, registerEventListener_fn).call(this);
}
render() {
const wrapper = document.getElementById(IFRAME_WRAPPER_ID$1);
const iframe = document.getElementById(IFRAME_ID$1);
if (!iframe || !(iframe instanceof HTMLIFrameElement) || !wrapper) {
console.error("Can not find iframe element");
return;
on(e, n) {
return R(this, P).on(e, n), this;
}
const url = __privateMethod$1(this, _createDesignUrl, createDesignUrl_fn).call(this);
iframe.src = url.href;
wrapper.style.opacity = "1";
wrapper.style.visibility = "visible";
__privateMethod$1(this, _emit$1, emit_fn$1).call(this, "rendered");
}
close() {
const wrapper = document.getElementById(IFRAME_WRAPPER_ID$1);
if (!wrapper) {
console.error("Can not find iframe element");
return;
}
wrapper.style.opacity = "0";
wrapper.style.visibility = "hidden";
__privateMethod$1(this, _emit$1, emit_fn$1).call(this, "closed");
}
editDesign(designId) {
const url = __privateMethod$1(this, _createDesignUrl, createDesignUrl_fn).call(this);
url.searchParams.set("design_id", designId);
url.searchParams.set("task", "edit");
const wrapper = document.getElementById(IFRAME_WRAPPER_ID$1);
const iframe = document.getElementById(IFRAME_ID$1);
if (!iframe || !(iframe instanceof HTMLIFrameElement) || !wrapper) {
console.error("Can not find iframe element");
return;
}
iframe.src = url.href;
wrapper.style.opacity = "1";
wrapper.style.visibility = "visible";
__privateMethod$1(this, _emit$1, emit_fn$1).call(this, "edit");
}
on(event, callback) {
__privateGet$1(this, _emitter$1).on(event, callback);
return this;
}
}
_designerUrl = /* @__PURE__ */ new WeakMap();
_emitter$1 = /* @__PURE__ */ new WeakMap();
_initIframe$1 = /* @__PURE__ */ new WeakSet();
initIframe_fn$1 = function() {
const wrapper = document.createElement("div");
wrapper.id = IFRAME_WRAPPER_ID$1;
wrapper.style.cssText = "position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";
const iframe = document.createElement("iframe");
iframe.id = IFRAME_ID$1;
iframe.width = "100%";
iframe.height = "100%";
wrapper.appendChild(iframe);
document.body.appendChild(wrapper);
};
_registerEventListener = /* @__PURE__ */ new WeakSet();
registerEventListener_fn = function() {
window.addEventListener(
"message",
(event) => {
if (event.origin === __privateGet$1(this, _designerUrl) && event.data.message === "closeDesignTool") {
const wrapper = document.getElementById(IFRAME_WRAPPER_ID$1);
if (!wrapper)
E = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakSet(), re = function() {
const t = document.createElement("div");
t.id = $, t.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 = j, e.width = "100%", e.height = "100%", t.appendChild(e), document.body.appendChild(t);
}, G = /* @__PURE__ */ new WeakSet(), ie = function() {
window.addEventListener("message", (t) => {
if (t.origin === R(this, E) && t.data.message === "closeDesignTool") {
const e = document.getElementById($);
if (!e)
return;
wrapper.style.opacity = "0";
wrapper.style.visibility = "hidden";
__privateMethod$1(this, _emit$1, emit_fn$1).call(this, "closed");
e.style.opacity = "0", e.style.visibility = "hidden", l(this, d, m).call(this, "closed");
}
if (event.data.message === "finishLoad") {
const iframe = document.getElementById(IFRAME_ID$1);
__privateMethod$1(this, _emit$1, emit_fn$1).call(this, "render-finish");
if (iframe && iframe instanceof HTMLIFrameElement && iframe.contentWindow) {
iframe.contentWindow.postMessage(
{ message: "customSettings", settings: this.options },
__privateGet$1(this, _designerUrl)
);
}
if (t.data.message === "finishLoad") {
const e = document.getElementById(j);
l(this, d, m).call(this, "render-finish"), e && e instanceof HTMLIFrameElement && e.contentWindow && e.contentWindow.postMessage({ message: "customSettings", settings: this.options }, R(this, E));
}
if (event.data.message === "finishProcess") {
__privateMethod$1(this, _emit$1, emit_fn$1).call(this, "upload-success", event.data.data.data);
}
if (event.data.message === "finishUpdate") {
__privateMethod$1(this, _emit$1, emit_fn$1).call(this, "edit-success", event.data.data.data);
}
if (event.data.message === "uploadError") {
__privateMethod$1(this, _emit$1, emit_fn$1).call(this, "upload-error", event.data);
}
},
false
);
};
_createDesignUrl = /* @__PURE__ */ new WeakSet();
createDesignUrl_fn = function() {
const url = new URL(__privateGet$1(this, _designerUrl));
url.searchParams.set("api_key", this.token);
url.searchParams.set("product_id", this.productId);
url.searchParams.set("parentUrl", window.location.href);
return url;
};
_emit$1 = /* @__PURE__ */ new WeakSet();
emit_fn$1 = function(event, ...args) {
__privateGet$1(this, _emitter$1).emit(event, ...args);
};
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
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 __privateMethod = (obj, member, method) => {
__accessCheck(obj, member, "access private method");
return method;
};
var _unauthToken, _entityId, _iframeUrl, _emitter, _locale, _entityType, _emit, emit_fn, _initIframe, initIframe_fn, _messageEventListener, messageEventListener_fn;
var events = { exports: {} };
var R = typeof Reflect === "object" ? Reflect : null;
var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply22(target, receiver, args) {
return Function.prototype.apply.call(target, receiver, args);
};
var ReflectOwnKeys;
if (R && typeof R.ownKeys === "function") {
ReflectOwnKeys = R.ownKeys;
} else if (Object.getOwnPropertySymbols) {
ReflectOwnKeys = function ReflectOwnKeys2(target) {
return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
t.data.message === "finishProcess" && l(this, d, m).call(this, "upload-success", t.data.data.data), t.data.message === "finishUpdate" && l(this, d, m).call(this, "edit-success", t.data.data.data), t.data.message === "uploadError" && l(this, d, m).call(this, "upload-error", t.data);
}, false);
}, U = /* @__PURE__ */ new WeakSet(), V = function() {
const t = new URL(R(this, E));
return t.searchParams.set("api_key", this.token), t.searchParams.set("product_id", this.productId), t.searchParams.set("parentUrl", window.location.href), t;
}, d = /* @__PURE__ */ new WeakSet(), m = function(t, ...e) {
R(this, P).emit(t, ...e);
};
} else {
ReflectOwnKeys = function ReflectOwnKeys2(target) {
return Object.getOwnPropertyNames(target);
var q = (t, e, n) => {
if (!e.has(t))
throw TypeError("Cannot " + n);
}, u = (t, e, n) => (q(t, e, "read from private field"), n ? n.call(t) : e.get(t)), y = (t, e, n) => {
if (e.has(t))
throw TypeError("Cannot add the same private member more than once");
e instanceof WeakSet ? e.add(t) : e.set(t, n);
}, I = (t, e, n, r) => (q(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n), _ = (t, e, n) => (q(t, e, "access private method"), n), T, O, C, W, A, k, g, x, J, ve, Q, me, X = { exports: {} }, M = typeof Reflect == "object" ? Reflect : null, ye = M && typeof M.apply == "function" ? M.apply : function(e, n, r) {
return Function.prototype.apply.call(e, n, r);
}, B;
M && typeof M.ownKeys == "function" ? B = M.ownKeys : Object.getOwnPropertySymbols ? B = function(e) {
return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
} : B = function(e) {
return Object.getOwnPropertyNames(e);
};
}
function ProcessEmitWarning(warning) {
if (console && console.warn)
console.warn(warning);
}
var NumberIsNaN = Number.isNaN || function NumberIsNaN22(value) {
return value !== value;
};
function EventEmitter() {
EventEmitter.init.call(this);
}
events.exports = EventEmitter;
events.exports.once = once2;
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.prototype._events = void 0;
EventEmitter.prototype._eventsCount = 0;
EventEmitter.prototype._maxListeners = void 0;
var defaultMaxListeners = 10;
function checkListener(listener) {
if (typeof listener !== "function") {
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
function ke(t) {
console && console.warn && console.warn(t);
}
}
Object.defineProperty(EventEmitter, "defaultMaxListeners", {
enumerable: true,
get: function() {
return defaultMaxListeners;
},
set: function(arg) {
if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) {
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + ".");
}
defaultMaxListeners = arg;
var Le = Number.isNaN || function(e) {
return e !== e;
};
function f() {
f.init.call(this);
}
});
EventEmitter.init = function() {
if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) {
this._events = /* @__PURE__ */ Object.create(null);
this._eventsCount = 0;
X.exports = f, X.exports.once = Se, f.EventEmitter = f, f.prototype._events = void 0, f.prototype._eventsCount = 0, f.prototype._maxListeners = void 0;
var _e = 10;
function D(t) {
if (typeof t != "function")
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof t);
}
this._maxListeners = this._maxListeners || void 0;
};
EventEmitter.prototype.setMaxListeners = function setMaxListeners2(n) {
if (typeof n !== "number" || n < 0 || NumberIsNaN(n)) {
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + ".");
Object.defineProperty(f, "defaultMaxListeners", { enumerable: true, get: function() {
return _e;
}, set: function(t) {
if (typeof t != "number" || t < 0 || Le(t))
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + t + ".");
_e = t;
} }), f.init = function() {
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
}, f.prototype.setMaxListeners = function(e) {
if (typeof e != "number" || e < 0 || Le(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 ge(t) {
return t._maxListeners === void 0 ? f.defaultMaxListeners : t._maxListeners;
}
this._maxListeners = n;
return this;
};
function _getMaxListeners(that) {
if (that._maxListeners === void 0)
return EventEmitter.defaultMaxListeners;
return that._maxListeners;
}
EventEmitter.prototype.getMaxListeners = function getMaxListeners2() {
return _getMaxListeners(this);
};
EventEmitter.prototype.emit = function emit2(type) {
var args = [];
for (var i = 1; i < arguments.length; i++)
args.push(arguments[i]);
var doError = type === "error";
var events2 = this._events;
if (events2 !== void 0)
doError = doError && events2.error === void 0;
else if (!doError)
return false;
if (doError) {
var er;
if (args.length > 0)
er = args[0];
if (er instanceof Error) {
throw er;
f.prototype.getMaxListeners = function() {
return ge(this);
}, f.prototype.emit = function(e) {
for (var n = [], r = 1; r < arguments.length; r++)
n.push(arguments[r]);
var i = e === "error", o = this._events;
if (o !== void 0)
i = i && o.error === void 0;
else if (!i)
return false;
if (i) {
var s;
if (n.length > 0 && (s = n[0]), s instanceof Error)
throw s;
var c = new Error("Unhandled error." + (s ? " (" + s.message + ")" : ""));
throw c.context = s, c;
}
var err = new Error("Unhandled error." + (er ? " (" + er.message + ")" : ""));
err.context = er;
throw err;
}
var handler = events2[type];
if (handler === void 0)
return false;
if (typeof handler === "function") {
ReflectApply(handler, this, args);
} else {
var len = handler.length;
var listeners22 = arrayClone(handler, len);
for (var i = 0; i < len; ++i)
ReflectApply(listeners22[i], this, args);
}
return true;
};
function _addListener(target, type, listener, prepend) {
var m;
var events2;
var existing;
checkListener(listener);
events2 = target._events;
if (events2 === void 0) {
events2 = target._events = /* @__PURE__ */ Object.create(null);
target._eventsCount = 0;
} else {
if (events2.newListener !== void 0) {
target.emit(
"newListener",
type,
listener.listener ? listener.listener : listener
);
events2 = target._events;
var h = o[e];
if (h === void 0)
return false;
if (typeof h == "function")
ye(h, this, n);
else
for (var N = h.length, ee = Oe(h, N), r = 0; r < N; ++r)
ye(ee[r], this, n);
return true;
};
function we(t, e, n, r) {
var i, o, s;
if (D(n), o = t._events, o === void 0 ? (o = t._events = /* @__PURE__ */ Object.create(null), t._eventsCount = 0) : (o.newListener !== void 0 && (t.emit("newListener", e, n.listener ? n.listener : n), o = t._events), s = o[e]), s === void 0)
s = o[e] = n, ++t._eventsCount;
else if (typeof s == "function" ? s = o[e] = r ? [n, s] : [s, n] : r ? s.unshift(n) : s.push(n), i = ge(t), i > 0 && s.length > i && !s.warned) {
s.warned = true;
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 = t, c.type = e, c.count = s.length, ke(c);
}
existing = events2[type];
return t;
}
if (existing === void 0) {
existing = events2[type] = listener;
++target._eventsCount;
} else {
if (typeof existing === "function") {
existing = events2[type] = prepend ? [listener, existing] : [existing, listener];
} else if (prepend) {
existing.unshift(listener);
} else {
existing.push(listener);
}
m = _getMaxListeners(target);
if (m > 0 && existing.length > m && !existing.warned) {
existing.warned = true;
var w = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type) + " listeners added. Use emitter.setMaxListeners() to increase limit");
w.name = "MaxListenersExceededWarning";
w.emitter = target;
w.type = type;
w.count = existing.length;
ProcessEmitWarning(w);
}
f.prototype.addListener = function(e, n) {
return we(this, e, n, false);
}, f.prototype.on = f.prototype.addListener, f.prototype.prependListener = function(e, n) {
return we(this, e, n, true);
};
function Ne() {
if (!this.fired)
return this.target.removeListener(this.type, this.wrapFn), this.fired = true, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
}
return target;
}
EventEmitter.prototype.addListener = function addListener2(type, listener) {
return _addListener(this, type, listener, false);
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.prependListener = function prependListener2(type, listener) {
return _addListener(this, type, listener, true);
};
function onceWrapper() {
if (!this.fired) {
this.target.removeListener(this.type, this.wrapFn);
this.fired = true;
if (arguments.length === 0)
return this.listener.call(this.target);
return this.listener.apply(this.target, arguments);
function Ee(t, e, n) {
var r = { fired: false, wrapFn: void 0, target: t, type: e, listener: n }, i = Ne.bind(r);
return i.listener = n, r.wrapFn = i, i;
}
}
function _onceWrap(target, type, listener) {
var state = { fired: false, wrapFn: void 0, target, type, listener };
var wrapped = onceWrapper.bind(state);
wrapped.listener = listener;
state.wrapFn = wrapped;
return wrapped;
}
EventEmitter.prototype.once = function once3(type, listener) {
checkListener(listener);
this.on(type, _onceWrap(this, type, listener));
return this;
};
EventEmitter.prototype.prependOnceListener = function prependOnceListener2(type, listener) {
checkListener(listener);
this.prependListener(type, _onceWrap(this, type, listener));
return this;
};
EventEmitter.prototype.removeListener = function removeListener2(type, listener) {
var list, events2, position, i, originalListener;
checkListener(listener);
events2 = this._events;
if (events2 === void 0)
return this;
list = events2[type];
if (list === void 0)
return this;
if (list === listener || list.listener === listener) {
if (--this._eventsCount === 0)
this._events = /* @__PURE__ */ Object.create(null);
else {
delete events2[type];
if (events2.removeListener)
this.emit("removeListener", type, list.listener || listener);
}
} else if (typeof list !== "function") {
position = -1;
for (i = list.length - 1; i >= 0; i--) {
if (list[i] === listener || list[i].listener === listener) {
originalListener = list[i].listener;
position = i;
break;
}
}
if (position < 0)
f.prototype.once = function(e, n) {
return D(n), this.on(e, Ee(this, e, n)), this;
}, f.prototype.prependOnceListener = function(e, n) {
return D(n), this.prependListener(e, Ee(this, e, n)), this;
}, f.prototype.removeListener = function(e, n) {
var r, i, o, s, c;
if (D(n), i = this._events, i === void 0)
return this;
if (position === 0)
list.shift();
else {
spliceOne(list, position);
if (r = i[e], r === void 0)
return this;
if (r === n || r.listener === n)
--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete i[e], i.removeListener && this.emit("removeListener", e, r.listener || n));
else if (typeof r != "function") {
for (o = -1, s = r.length - 1; s >= 0; s--)
if (r[s] === n || r[s].listener === n) {
c = r[s].listener, o = s;
break;
}
if (o < 0)
return this;
o === 0 ? r.shift() : Ue(r, o), r.length === 1 && (i[e] = r[0]), i.removeListener !== void 0 && this.emit("removeListener", e, c || n);
}
if (list.length === 1)
events2[type] = list[0];
if (events2.removeListener !== void 0)
this.emit("removeListener", type, originalListener || listener);
}
return this;
};
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.removeAllListeners = function removeAllListeners2(type) {
var listeners22, events2, i;
events2 = this._events;
if (events2 === void 0)
return this;
if (events2.removeListener === void 0) {
}, f.prototype.off = f.prototype.removeListener, f.prototype.removeAllListeners = function(e) {
var n, r, i;
if (r = this._events, r === void 0)
return this;
if (r.removeListener === void 0)
return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : r[e] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete r[e]), this;
if (arguments.length === 0) {
this._events = /* @__PURE__ */ Object.create(null);
this._eventsCount = 0;
} else if (events2[type] !== void 0) {
if (--this._eventsCount === 0)
this._events = /* @__PURE__ */ Object.create(null);
else
delete events2[type];
var o = Object.keys(r), s;
for (i = 0; i < o.length; ++i)
s = o[i], s !== "removeListener" && this.removeAllListeners(s);
return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
}
if (n = r[e], typeof n == "function")
this.removeListener(e, n);
else if (n !== void 0)
for (i = n.length - 1; i >= 0; i--)
this.removeListener(e, n[i]);
return this;
};
function be(t, e, n) {
var r = t._events;
if (r === void 0)
return [];
var i = r[e];
return i === void 0 ? [] : typeof i == "function" ? n ? [i.listener || i] : [i] : n ? Fe(i) : Oe(i, i.length);
}
if (arguments.length === 0) {
var keys = Object.keys(events2);
var key;
for (i = 0; i < keys.length; ++i) {
key = keys[i];
if (key === "removeListener")
continue;
this.removeAllListeners(key);
f.prototype.listeners = function(e) {
return be(this, e, true);
}, f.prototype.rawListeners = function(e) {
return be(this, e, false);
}, f.listenerCount = function(t, e) {
return typeof t.listenerCount == "function" ? t.listenerCount(e) : Ie.call(t, e);
}, f.prototype.listenerCount = Ie;
function Ie(t) {
var e = this._events;
if (e !== void 0) {
var n = e[t];
if (typeof n == "function")
return 1;
if (n !== void 0)
return n.length;
}
this.removeAllListeners("removeListener");
this._events = /* @__PURE__ */ Object.create(null);
this._eventsCount = 0;
return this;
return 0;
}
listeners22 = events2[type];
if (typeof listeners22 === "function") {
this.removeListener(type, listeners22);
} else if (listeners22 !== void 0) {
for (i = listeners22.length - 1; i >= 0; i--) {
this.removeListener(type, listeners22[i]);
}
f.prototype.eventNames = function() {
return this._eventsCount > 0 ? B(this._events) : [];
};
function Oe(t, e) {
for (var n = new Array(e), r = 0; r < e; ++r)
n[r] = t[r];
return n;
}
return this;
};
function _listeners(target, type, unwrap) {
var events2 = target._events;
if (events2 === void 0)
return [];
var evlistener = events2[type];
if (evlistener === void 0)
return [];
if (typeof evlistener === "function")
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
}
EventEmitter.prototype.listeners = function listeners2(type) {
return _listeners(this, type, true);
};
EventEmitter.prototype.rawListeners = function rawListeners2(type) {
return _listeners(this, type, false);
};
EventEmitter.listenerCount = function(emitter, type) {
if (typeof emitter.listenerCount === "function") {
return emitter.listenerCount(type);
} else {
return listenerCount.call(emitter, type);
function Ue(t, e) {
for (; e + 1 < t.length; e++)
t[e] = t[e + 1];
t.pop();
}
};
EventEmitter.prototype.listenerCount = listenerCount;
function listenerCount(type) {
var events2 = this._events;
if (events2 !== void 0) {
var evlistener = events2[type];
if (typeof evlistener === "function") {
return 1;
} else if (evlistener !== void 0) {
return evlistener.length;
}
function Fe(t) {
for (var e = new Array(t.length), n = 0; n < e.length; ++n)
e[n] = t[n].listener || t[n];
return e;
}
return 0;
}
EventEmitter.prototype.eventNames = function eventNames2() {
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
};
function arrayClone(arr, n) {
var copy = new Array(n);
for (var i = 0; i < n; ++i)
copy[i] = arr[i];
return copy;
}
function spliceOne(list, index) {
for (; index + 1 < list.length; index++)
list[index] = list[index + 1];
list.pop();
}
function unwrapListeners(arr) {
var ret = new Array(arr.length);
for (var i = 0; i < ret.length; ++i) {
ret[i] = arr[i].listener || arr[i];
function Se(t, e) {
return new Promise(function(n, r) {
function i(s) {
t.removeListener(e, o), r(s);
}
function o() {
typeof t.removeListener == "function" && t.removeListener("error", i), n([].slice.call(arguments));
}
Ce(t, e, o, { once: true }), e !== "error" && je(t, i, { once: true });
});
}
return ret;
}
function once2(emitter, name) {
return new Promise(function(resolve, reject) {
function errorListener(err) {
emitter.removeListener(name, resolver);
reject(err);
}
function resolver() {
if (typeof emitter.removeListener === "function") {
emitter.removeListener("error", errorListener);
function je(t, e, n) {
typeof t.on == "function" && Ce(t, "error", e, n);
}
function Ce(t, e, n, r) {
if (typeof t.on == "function")
r.once ? t.once(e, n) : t.on(e, n);
else if (typeof t.addEventListener == "function")
t.addEventListener(e, function i(o) {
r.once && t.removeEventListener(e, i), n(o);
});
else
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof t);
}
var Be = X.exports;
const K = "pc-uploader-iframe-wrapper", Y = "pc-uploader-iframe";
class De {
constructor(e) {
if (y(this, g), y(this, J), y(this, Q), y(this, T, void 0), y(this, O, void 0), y(this, C, void 0), y(this, W, void 0), y(this, A, void 0), y(this, k, void 0), I(this, T, e.token), I(this, O, e.sideId || e.productId), I(this, k, e.productId ? "product" : "side"), I(this, C, e.uploaderUrl ? e.uploaderUrl : "https://upload-tool.pages.dev"), I(this, W, new Be()), I(this, A, e.locale), !u(this, T) || !u(this, O)) {
console.warn("Missing Config Params.");
return;
}
resolve([].slice.call(arguments));
_(this, J, ve).call(this), _(this, Q, me).call(this);
}
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
if (name !== "error") {
addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
get locale() {
return u(this, A);
}
});
}
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
if (typeof emitter.on === "function") {
eventTargetAgnosticAddListener(emitter, "error", handler, flags);
}
}
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
if (typeof emitter.on === "function") {
if (flags.once) {
emitter.once(name, listener);
} else {
emitter.on(name, listener);
open() {
let e = document.getElementById(K), n = document.getElementById(Y);
const r = new URL(u(this, C));
if (r.searchParams.set("token", u(this, T)), u(this, k) === "side" ? r.searchParams.set("sideId", u(this, O)) : u(this, k) === "product" && r.searchParams.set("productId", u(this, O)), r.searchParams.set("parentUrl", window.location.href), !n || !(n instanceof HTMLIFrameElement) || !e) {
console.warn("Can not find iframe element.");
return;
}
n.src = r.href, e.style.opacity = "1", e.style.visibility = "visible", _(this, g, x).call(this, "open");
}
} else if (typeof emitter.addEventListener === "function") {
emitter.addEventListener(name, function wrapListener(arg) {
if (flags.once) {
emitter.removeEventListener(name, wrapListener);
close() {
let e = document.getElementById(K);
if (!e) {
console.error("Can not find iframe element");
return;
}
listener(arg);
});
} else {
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
}
}
var EventEmitter$1 = events.exports;
const IFRAME_WRAPPER_ID = "pc-uploader-iframe-wrapper";
const IFRAME_ID = "pc-uploader-iframe";
class PrintcartUploader {
constructor(config) {
__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;
e.style.opacity = "0", e.style.visibility = "hidden";
}
__privateMethod(this, _initIframe, initIframe_fn).call(this);
__privateMethod(this, _messageEventListener, messageEventListener_fn).call(this);
}
get locale() {
return __privateGet(this, _locale);
}
open() {
let wrapper = document.getElementById(IFRAME_WRAPPER_ID);
let iframe = document.getElementById(IFRAME_ID);
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));
on(e, n) {
return u(this, W).on(e, n), this;
}
url.searchParams.set("parentUrl", window.location.href);
if (!iframe || !(iframe instanceof HTMLIFrameElement) || !wrapper) {
console.warn("Can not find iframe element.");
return;
}
iframe.src = url.href;
wrapper.style.opacity = "1";
wrapper.style.visibility = "visible";
__privateMethod(this, _emit, emit_fn).call(this, "open");
}
close() {
let wrapper = document.getElementById(IFRAME_WRAPPER_ID);
if (!wrapper) {
console.error("Can not find iframe element");
return;
T = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakSet(), x = function(t, ...e) {
u(this, W).emit(t, ...e);
}, J = /* @__PURE__ */ new WeakSet(), ve = function() {
let t = document.createElement("div");
t.id = K, t.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 = Y, e.width = "100%", e.height = "100%", e.style.borderWidth = "0", t.appendChild(e), document.body.appendChild(t);
}, Q = /* @__PURE__ */ new WeakSet(), me = function() {
let t = document.getElementById(K);
window.addEventListener("message", (e) => {
var n;
const r = new URL(e.origin), i = new URL(u(this, C));
if (r.host === i.host) {
e.data.uploaderEvent === "close" && t && (t.style.opacity = "0", t.style.visibility = "hidden", _(this, g, x).call(this, "close")), e.data.uploaderEvent === "upload-success" && _(this, g, x).call(this, "upload-success", e.data.data), e.data.uploaderEvent === "upload-error" && _(this, g, x).call(this, "upload-error", e.data.error);
const o = u(this, A), s = document.getElementById(Y);
s && s instanceof HTMLIFrameElement && (_(this, g, x).call(this, "onload"), o && e.data.uploaderEvent === "loaded" && e.data.finished && (console.log("test"), s.focus(), (n = s.contentWindow) == null || n.postMessage({ locale: o }, u(this, C))));
}
}, false);
};
class Ke {
constructor() {
te(this, "initDesignTool", (e) => new Ae(e));
te(this, "initUploader", (e) => new De(e));
}
wrapper.style.opacity = "0";
wrapper.style.visibility = "hidden";
}
on(event, callback) {
__privateGet(this, _emitter).on(event, callback);
return this;
}
}
_unauthToken = /* @__PURE__ */ new WeakMap();
_entityId = /* @__PURE__ */ new WeakMap();
_iframeUrl = /* @__PURE__ */ new WeakMap();
_emitter = /* @__PURE__ */ new WeakMap();
_locale = /* @__PURE__ */ new WeakMap();
_entityType = /* @__PURE__ */ new WeakMap();
_emit = /* @__PURE__ */ new WeakSet();
emit_fn = function(event, ...args) {
__privateGet(this, _emitter).emit(event, ...args);
};
_initIframe = /* @__PURE__ */ new WeakSet();
initIframe_fn = function() {
let wrapper = document.createElement("div");
wrapper.id = IFRAME_WRAPPER_ID;
wrapper.style.cssText = "position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";
let iframe = document.createElement("iframe");
iframe.id = IFRAME_ID;
iframe.width = "100%";
iframe.height = "100%";
iframe.style.borderWidth = "0";
wrapper.appendChild(iframe);
document.body.appendChild(wrapper);
};
_messageEventListener = /* @__PURE__ */ new WeakSet();
messageEventListener_fn = function() {
let wrapper = document.getElementById(IFRAME_WRAPPER_ID);
window.addEventListener(
"message",
(event) => {
var _a;
const originURL = new URL(event.origin);
const iframeURL = new URL(__privateGet(this, _iframeUrl));
if (originURL.host === iframeURL.host) {
if (event.data.uploaderEvent === "close" && wrapper) {
wrapper.style.opacity = "0";
wrapper.style.visibility = "hidden";
__privateMethod(this, _emit, emit_fn).call(this, "close");
}
if (event.data.uploaderEvent === "upload-success") {
__privateMethod(this, _emit, emit_fn).call(this, "upload-success", event.data.data);
}
if (event.data.uploaderEvent === "upload-error") {
__privateMethod(this, _emit, emit_fn).call(this, "upload-error", event.data.error);
}
const locale = __privateGet(this, _locale);
const iframe = document.getElementById(IFRAME_ID);
if (iframe && iframe instanceof HTMLIFrameElement) {
__privateMethod(this, _emit, emit_fn).call(this, "onload");
if (locale && event.data.uploaderEvent === "loaded" && event.data.finished) {
console.log("test");
iframe.focus();
(_a = iframe.contentWindow) == null ? void 0 : _a.postMessage(
{
locale
},
__privateGet(this, _iframeUrl)
);
}
}
}
},
false
);
};
return Ke;
}();
var main = "";
const printcartDesigner = new PrintcartDesigner();
class PrintcartDesignerWix {
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, "appID");
__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);
__privateAdd(this, _registerListener);
__privateAdd(this, _initializeProductTools);
__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, "appID");
__publicField(this, "productIdPC");
__publicField(this, "orderIdWix");
__publicField(this, "orderNumberWix");
__publicField(this, "options");
__privateAdd(this, _designerUrl, void 0);
__privateAdd(this, _designerInstance, void 0);
__privateAdd(this, _uploaderInstance, void 0);
__privateAdd(this, _productForm, void 0);
__publicField(this, "registerListener");
this.token = __privateMethod(this, _getUnauthToken, getUnauthToken_fn).call(this);
this.productIdPC = null;

@@ -1112,6 +616,6 @@ this.appID = "325c68a5-64c2-440d-b093-8cea369df06b";

this.orderNumberWix = null;
__privateSet2(this, _productForm, null);
__privateSet(this, _productForm, null);
this.options = window.PrintcartDesignerShopifyOptions;
__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");
__privateSet(this, _apiUrl, {}.VITE_API_URL ? {}.VITE_API_URL : "https://api.printcart.com/v1");
__privateSet(this, _designerUrl, {}.VITE_CUSTOMIZER_URL ? {}.VITE_CUSTOMIZER_URL : "https://customizer.printcart.com");
}

@@ -1121,5 +625,5 @@ init() {

const self = this;
(wd == null ? void 0 : wd.wixDevelopersAnalytics) ? __privateMethod2(this, _registerListener, registerListener_fn).call(this, "first") : wd.addEventListener("wixDevelopersAnalyticsReady", function() {
(wd == null ? void 0 : wd.wixDevelopersAnalytics) ? __privateMethod(this, _registerListener, registerListener_fn).call(this, "first") : wd.addEventListener("wixDevelopersAnalyticsReady", function() {
var _a;
__privateMethod2(_a = self, _registerListener, registerListener_fn).call(_a, "second");
__privateMethod(_a = self, _registerListener, registerListener_fn).call(_a, "second");
});

@@ -1129,3 +633,3 @@ }

_apiUrl = new WeakMap();
_designerUrl2 = new WeakMap();
_designerUrl = new WeakMap();
_designerInstance = new WeakMap();

@@ -1153,3 +657,3 @@ _uploaderInstance = new WeakMap();

}
__privateMethod2(_a = self, _initializeProductTools, initializeProductTools_fn).call(_a, data == null ? void 0 : data.productId);
__privateMethod(_a = self, _initializeProductTools, initializeProductTools_fn).call(_a, data == null ? void 0 : data.productId);
break;

@@ -1160,3 +664,3 @@ case "CustomizeProduct":

}
__privateMethod2(_b = self, _initializeProductTools, initializeProductTools_fn).call(_b, data == null ? void 0 : data.variantId);
__privateMethod(_b = self, _initializeProductTools, initializeProductTools_fn).call(_b, data == null ? void 0 : data.variantId);
break;

@@ -1179,3 +683,3 @@ case "Purchase":

}
__privateMethod2(_c = self, _createProjectPrintcart, createProjectPrintcart_fn).call(_c, self.orderNumberWix, self.orderIdWix, JSON.parse(designIds));
__privateMethod(_c = self, _createProjectPrintcart, createProjectPrintcart_fn).call(_c, self.orderNumberWix, self.orderIdWix, JSON.parse(designIds));
break;

@@ -1188,4 +692,4 @@ }

initializeProductTools_fn = function(productIdWix) {
__privateSet2(this, _productForm, document.querySelector("[data-hook='product-options']"));
if (!__privateGet2(this, _productForm)) {
__privateSet(this, _productForm, document.querySelector("[data-hook='product-options']"));
if (!__privateGet(this, _productForm)) {
throw new Error(

@@ -1198,3 +702,3 @@ "This script can only be used inside a Wix Product Page."

}
__privateMethod2(this, _getPrintcartProduct, getPrintcartProduct_fn).call(this, productIdWix).then((res) => {
__privateMethod(this, _getPrintcartProduct, getPrintcartProduct_fn).call(this, productIdWix).then((res) => {
var _a, _b;

@@ -1205,7 +709,7 @@ this.productIdPC = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.id;

}
__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);
__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");

@@ -1215,3 +719,3 @@ const isDesignEnabled = res.data.enable_design;

if (isDesignEnabled) {
__privateSet2(this, _designerInstance, new PrintcartDesigner({
__privateSet(this, _designerInstance, printcartDesigner.initDesignTool({
token: this.token,

@@ -1221,6 +725,6 @@ productId: this.productIdPC,

...(_b = this.options) == null ? void 0 : _b.designerOptions,
designerUrl: __privateGet2(this, _designerUrl2)
designerUrl: __privateGet(this, _designerUrl)
}
}));
__privateMethod2(this, _registerDesignerEvents, registerDesignerEvents_fn).call(this);
__privateMethod(this, _registerDesignerEvents, registerDesignerEvents_fn).call(this);
if (btn && btn instanceof HTMLButtonElement) {

@@ -1231,7 +735,7 @@ btn.disabled = false;

if (isUploadEnabled) {
__privateSet2(this, _uploaderInstance, new PrintcartUploader({
__privateSet(this, _uploaderInstance, printcartDesigner.initUploader({
token: this.token,
productId: this.productIdPC
}));
__privateMethod2(this, _registerUploaderEvents, registerUploaderEvents_fn).call(this);
__privateMethod(this, _registerUploaderEvents, registerUploaderEvents_fn).call(this);
if (btn && btn instanceof HTMLButtonElement) {

@@ -1242,10 +746,10 @@ btn.disabled = false;

const handleClick = () => {
if (__privateGet2(this, _designerInstance) && !__privateGet2(this, _uploaderInstance)) {
__privateGet2(this, _designerInstance).render();
if (__privateGet(this, _designerInstance) && !__privateGet(this, _uploaderInstance)) {
__privateGet(this, _designerInstance).render();
}
if (!__privateGet2(this, _designerInstance) && __privateGet2(this, _uploaderInstance)) {
__privateGet2(this, _uploaderInstance).open();
if (!__privateGet(this, _designerInstance) && __privateGet(this, _uploaderInstance)) {
__privateGet(this, _uploaderInstance).open();
}
if (__privateGet2(this, _designerInstance) && __privateGet2(this, _uploaderInstance)) {
__privateMethod2(this, _openModal, openModal_fn).call(this);
if (__privateGet(this, _designerInstance) && __privateGet(this, _uploaderInstance)) {
__privateMethod(this, _openModal, openModal_fn).call(this);
}

@@ -1271,5 +775,5 @@ };

const design = () => {
if (__privateGet2(this, _designerInstance)) {
__privateMethod2(this, _closeModal, closeModal_fn).call(this);
__privateGet2(this, _designerInstance).render();
if (__privateGet(this, _designerInstance)) {
__privateMethod(this, _closeModal, closeModal_fn).call(this);
__privateGet(this, _designerInstance).render();
document.body.classList.add("pc-overflow");

@@ -1279,5 +783,5 @@ }

const upload = () => {
if (__privateGet2(this, _uploaderInstance)) {
__privateMethod2(this, _closeModal, closeModal_fn).call(this);
__privateGet2(this, _uploaderInstance).open();
if (__privateGet(this, _uploaderInstance)) {
__privateMethod(this, _closeModal, closeModal_fn).call(this);
__privateGet(this, _uploaderInstance).open();
document.body.classList.add("pc-overflow");

@@ -1318,11 +822,11 @@ }

if (e.key === "Escape") {
__privateMethod2(this, _closeModal, closeModal_fn).call(this);
__privateMethod(this, _closeModal, closeModal_fn).call(this);
}
};
window.addEventListener("keydown", handleClose);
closeModalBtn == null ? void 0 : closeModalBtn.addEventListener("click", () => __privateMethod2(this, _closeModal, closeModal_fn).call(this));
closeModalBtn == null ? void 0 : closeModalBtn.addEventListener("click", () => __privateMethod(this, _closeModal, closeModal_fn).call(this));
backdropCloseModal == null ? void 0 : backdropCloseModal.addEventListener("click", () => {
const iframeWrap = document.getElementById("pc-designer-iframe-wrapper");
if ((iframeWrap == null ? void 0 : iframeWrap.style.visibility) !== "visible") {
__privateMethod2(this, _closeModal, closeModal_fn).call(this);
__privateMethod(this, _closeModal, closeModal_fn).call(this);
}

@@ -1367,3 +871,3 @@ });

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

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

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

@@ -1428,3 +932,3 @@ _handleDesignSuccess = new WeakSet();

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

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

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

@@ -1476,12 +980,12 @@ const removeBtn = document.createElement("button");

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

@@ -1493,11 +997,11 @@ });

registerDesignerEvents_fn = function() {
if (__privateGet2(this, _designerInstance)) {
__privateGet2(this, _designerInstance).on("upload-success", (data) => {
__privateMethod2(this, _handleDesignSuccess, handleDesignSuccess_fn).call(this, data);
__privateGet2(this, _designerInstance).close();
if (__privateGet(this, _designerInstance)) {
__privateGet(this, _designerInstance).on("upload-success", (data) => {
__privateMethod(this, _handleDesignSuccess, handleDesignSuccess_fn).call(this, data);
__privateGet(this, _designerInstance).close();
});
__privateGet2(this, _designerInstance).on("closed", () => {
__privateGet(this, _designerInstance).on("closed", () => {
document.body.classList.remove("pc-overflow");
});
__privateGet2(this, _designerInstance).on("edit-success", (data) => {
__privateGet(this, _designerInstance).on("edit-success", (data) => {
var _a;

@@ -1514,5 +1018,5 @@ if (!data.design_image.url)

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

@@ -1523,3 +1027,3 @@ }

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

@@ -1549,3 +1053,3 @@ const params = new URLSearchParams(url.search);

try {
const printcartApiUrl = `${__privateGet2(this, _apiUrl)}/integration/wix/products/${productIdWix}`;
const printcartApiUrl = `${__privateGet(this, _apiUrl)}/integration/wix/products/${productIdWix}`;
const token = this.token;

@@ -1573,3 +1077,3 @@ if (!token) {

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

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

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

@@ -1598,0 +1102,0 @@ if (!token) {

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

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 M=(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)),v=(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 h=(p,f,m)=>(Ne(p,f,"access private method"),m);(function(p){typeof define=="function"&&define.amd?define(p):p()})(function(){var q,te,y,w,P,ne,We,ie,$e,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)},Ae=(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,xe,De,Pe,Be,re,ke,I,C,Se={exports:{}},A=typeof Reflect=="object"?Reflect:null,je=A&&typeof A.apply=="function"?A.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},se;A&&typeof A.ownKeys=="function"?se=A.ownKeys:Object.getOwnPropertySymbols?se=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:se=function(e){return Object.getOwnPropertyNames(e)};function bt(n){console&&console.warn&&console.warn(n)}var Fe=Number.isNaN||function(e){return e!==e};function l(){l.init.call(this)}Se.exports=l,Se.exports.once=Pt,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var He=10;function oe(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 He},set:function(n){if(typeof n!="number"||n<0||Fe(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");He=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||Fe(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 qe(n){return n._maxListeners===void 0?l.defaultMaxListeners:n._maxListeners}l.prototype.getMaxListeners=function(){return qe(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")je(u,this,t);else for(var g=u.length,_=Je(u,g),i=0;i<g;++i)je(_[i],this,t);return!0};function Ke(n,e,t,i){var r,o,s;if(oe(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=qe(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 Ke(this,e,t,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(e,t){return Ke(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 Ve(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 oe(t),this.on(e,Ve(this,e,t)),this},l.prototype.prependOnceListener=function(e,t){return oe(t),this.prependListener(e,Ve(this,e,t)),this},l.prototype.removeListener=function(e,t){var i,r,o,s,c;if(oe(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 ze(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?xt(r):Je(r,r.length)}l.prototype.listeners=function(e){return ze(this,e,!0)},l.prototype.rawListeners=function(e){return ze(this,e,!1)},l.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):Xe.call(n,e)},l.prototype.listenerCount=Xe;function Xe(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?se(this._events):[]};function Je(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 xt(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function Pt(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))}Ze(n,e,o,{once:!0}),e!=="error"&&kt(n,r,{once:!0})})}function kt(n,e,t){typeof n.on=="function"&&Ze(n,"error",e,t)}function Ze(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",ce="pc-designer-iframe";class Tt{constructor(e){W(this,xe),W(this,Pe),W(this,re),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,Ae(this,$,(t=this.options)!=null&&t.designerUrl?this.options.designerUrl:{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),Ae(this,J,new St),!this.token||!this.productId){console.error("Missing Config Params");return}E(this,xe,De).call(this),E(this,Pe,Be).call(this)}render(){const e=document.getElementById(Z),t=document.getElementById(ce);if(!t||!(t instanceof HTMLIFrameElement)||!e){console.error("Can not find iframe element");return}const i=E(this,re,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,re,ke).call(this);t.searchParams.set("design_id",e),t.searchParams.set("task","edit");const i=document.getElementById(Z),r=document.getElementById(ce);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,xe=new WeakSet,De=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=ce,e.width="100%",e.height="100%",n.appendChild(e),document.body.appendChild(n)},Pe=new WeakSet,Be=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(ce);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)},re=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)},L=(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,B,j,Y,Q,ee,O,F,Me,Ge,Re,Ye,Oe={exports:{}},H=typeof Reflect=="object"?Reflect:null,Qe=H&&typeof H.apply=="function"?H.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},ae;H&&typeof H.ownKeys=="function"?ae=H.ownKeys:Object.getOwnPropertySymbols?ae=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ae=function(e){return Object.getOwnPropertyNames(e)};function Mt(n){console&&console.warn&&console.warn(n)}var et=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 tt=10;function le(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 tt},set:function(n){if(typeof n!="number"||n<0||et(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");tt=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||et(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 nt(n){return n._maxListeners===void 0?d.defaultMaxListeners:n._maxListeners}d.prototype.getMaxListeners=function(){return nt(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")Qe(u,this,t);else for(var g=u.length,_=ct(u,g),i=0;i<g;++i)Qe(_[i],this,t);return!0};function it(n,e,t,i){var r,o,s;if(le(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=nt(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 it(this,e,t,!1)},d.prototype.on=d.prototype.addListener,d.prototype.prependListener=function(e,t){return it(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 rt(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 le(t),this.on(e,rt(this,e,t)),this},d.prototype.prependOnceListener=function(e,t){return le(t),this.prependListener(e,rt(this,e,t)),this},d.prototype.removeListener=function(e,t){var i,r,o,s,c;if(le(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 st(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):ct(r,r.length)}d.prototype.listeners=function(e){return st(this,e,!0)},d.prototype.rawListeners=function(e){return st(this,e,!1)},d.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):ot.call(n,e)},d.prototype.listenerCount=ot;function ot(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?ae(this._events):[]};function ct(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))}at(n,e,o,{once:!0}),e!=="error"&&Wt(n,r,{once:!0})})}function Wt(n,e,t){typeof n.on=="function"&&at(n,"error",e,t)}function at(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 de="pc-uploader-iframe-wrapper",Ue="pc-uploader-iframe";class At{constructor(e){if(x(this,O),x(this,Me),x(this,Re),x(this,G,void 0),x(this,B,void 0),x(this,j,void 0),x(this,Y,void 0),x(this,Q,void 0),x(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),!L(this,G)||!L(this,B)){console.warn("Missing Config Params.");return}R(this,Me,Ge).call(this),R(this,Re,Ye).call(this)}get locale(){return L(this,Q)}open(){let e=document.getElementById(de),t=document.getElementById(Ue);const i=new URL(L(this,j));if(i.searchParams.set("token",L(this,G)),L(this,ee)==="side"?i.searchParams.set("sideId",L(this,B)):L(this,ee)==="product"&&i.searchParams.set("productId",L(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",R(this,O,F).call(this,"open")}close(){let e=document.getElementById(de);if(!e){console.error("Can not find iframe element");return}e.style.opacity="0",e.style.visibility="hidden"}on(e,t){return L(this,Y).on(e,t),this}}G=new WeakMap,B=new WeakMap,j=new WeakMap,Y=new WeakMap,Q=new WeakMap,ee=new WeakMap,O=new WeakSet,F=function(n,...e){L(this,Y).emit(n,...e)},Me=new WeakSet,Ge=function(){let n=document.createElement("div");n.id=de,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,Ye=function(){let n=document.getElementById(de);window.addEventListener("message",e=>{var t;const i=new URL(e.origin),r=new URL(L(this,j));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=L(this,Q),s=document.getElementById(Ue);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},L(this,j))))}},!1)};var qt="";class Dt{constructor(){v(this,ne);v(this,ie);v(this,ue);v(this,pe);v(this,T);v(this,fe);v(this,he);v(this,ve);v(this,me);v(this,ge);v(this,ye);v(this,_e);v(this,we);v(this,Le);v(this,Ee);v(this,be);v(this,Ie);v(this,q,void 0);M(this,"token");M(this,"appID");M(this,"productIdPC");M(this,"orderIdWix");M(this,"orderNumberWix");M(this,"options");v(this,te,void 0);v(this,y,void 0);v(this,w,void 0);v(this,P,void 0);M(this,"registerListener");this.token=h(this,_e,gt).call(this),this.productIdPC=null,this.appID="325c68a5-64c2-440d-b093-8cea369df06b",this.orderIdWix=null,this.orderNumberWix=null,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")}init(){const e=window,t=this;e!=null&&e.wixDevelopersAnalytics?h(this,ne,We).call(this,"first"):e.addEventListener("wixDevelopersAnalyticsReady",function(){var i;h(i=t,ne,We).call(i,"second")})}}q=new WeakMap,te=new WeakMap,y=new WeakMap,w=new WeakMap,P=new WeakMap,ne=new WeakSet,We=function(e){const t=this;console.log("Printcart start App "+e),window==null||window.wixDevelopersAnalytics.register(this.appID,function(r,o){var s,c,u;switch(r){case"ViewContent":localStorage.getItem("pc-product")&&localStorage.removeItem("pc-product");break;case"productPageLoaded":if(console.log("Printcart: productPageLoaded",o),o.variants&&o.variants.length>1)return;h(s=t,ie,$e).call(s,o==null?void 0:o.productId);break;case"CustomizeProduct":if(o.variants&&o.variants.length<1)return;h(c=t,ie,$e).call(c,o==null?void 0:o.variantId);break;case"Purchase":if(!localStorage.getItem("pc-design-ids"))return;const g=localStorage.getItem("pc-design-ids");if(t.orderIdWix=o==null?void 0:o.orderId,t.orderNumberWix=o==null?void 0:o.id,!t.orderIdWix)throw new Error("Can not find order ID WIX");if(!t.orderNumberWix)throw new Error("Can not find order number WIX");if(!g)throw new Error("Can not find design Ids");h(u=t,Ie,Et).call(u,t.orderNumberWix,t.orderIdWix,JSON.parse(g));break}})},ie=new WeakSet,$e=function(e){if(U(this,P,document.querySelector("[data-hook='product-options']")),!a(this,P))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");h(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");h(this,Le,_t).call(this),h(this,be,Lt).call(this),h(this,ue,lt).call(this),h(this,fe,ut).call(this),h(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,y,new Tt({token:this.token,productId:this.productIdPC,options:{...(u=this.options)==null?void 0:u.designerOptions,designerUrl:a(this,te)}})),h(this,ye,mt).call(this),i&&i instanceof HTMLButtonElement&&(i.disabled=!1)),o&&(U(this,w,new At({token:this.token,productId:this.productIdPC})),h(this,ge,vt).call(this),i&&i instanceof HTMLButtonElement&&(i.disabled=!1));const s=()=>{a(this,y)&&!a(this,w)&&a(this,y).render(),!a(this,y)&&a(this,w)&&a(this,w).open(),a(this,y)&&a(this,w)&&h(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><div class="pc-select-wrap" id="pc-content-overlay"><div class="pc-select-inner"><div id="pc-select_header">Choose a way to design this product</div><div id="pc-select_container"><button class="pc-select_btn" id="pc-select_btn_upload"><div aria-hidden="true" class="pc-select_btn_wrap"><div class="pc-select_btn_img"><div class="pc-select_btn_img_inner"><img src="https://files.printcart.com/common/upload.svg" alt="Printcart Uploader"></div></div><div class="pc-select_btn_content"><div class="pc-select_btn_content_inner"><h2 class="pc-title">Upload a full design</h2><ul><li>Have a complete design</li><li>Have your own designer</li></ul></div></div></div><div class="visually-hidden">Upload Design file</div></button><button class="pc-select_btn" id="pc-select_btn_design"><div aria-hidden="true" class="pc-select_btn_wrap"><div class="pc-select_btn_img"><div class="pc-select_btn_img_inner"><img src="https://files.printcart.com/common/design.svg" alt="Printcart Designer"></div></div><div class="pc-select_btn_content"><div class="pc-select_btn_content_inner"><h2 class="pc-title">Design here online</h2><ul><li>Already have your concept</li><li>Customize every details</li></ul></div></div></div><div class="visually-hidden">Upload Design file</div></button></div></div></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=()=>{a(this,y)&&(h(this,T,z).call(this),a(this,y).render(),document.body.classList.add("pc-overflow"))},s=()=>{a(this,w)&&(h(this,T,z).call(this),a(this,w).open(),document.body.classList.add("pc-overflow"))},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.add("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.remove("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"&&h(this,T,z).call(this)};window.addEventListener("keydown",i),e==null||e.addEventListener("click",()=>h(this,T,z).call(this)),t==null||t.addEventListener("click",()=>{const r=document.getElementById("pc-designer-iframe-wrapper");(r==null?void 0:r.style.visibility)!=="visible"&&h(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,P))==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 _=document.createElement("div");_.className="pc-preview",_.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(),_.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),_.appendChild(S),_.appendChild(k),r.appendChild(_)});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,w))},me=new WeakSet,ht=function(e){var u,g;const t=this,i=e.map(_=>_.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,P))==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(_=>{var Ce;if(!_.design_image.url)return;const b=document.createElement("div");b.className="pc-preview",b.setAttribute("data-pc-design-id",_.id);const k=document.createElement("button");k.className="pc-btn pc-primary-btn",k.style.borderRadius="5px",k.innerHTML="Edit",k.onclick=()=>{a(t,y).editDesign(_.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!==_.id);r.value=Bt.join(),b.remove()};const K=document.createElement("img");K.src=((Ce=_.preview_image)==null?void 0:Ce.url)||_.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,y))},ge=new WeakSet,vt=function(){a(this,w)&&(a(this,w).on("upload-success",e=>{h(this,ve,ft).call(this,e),a(this,w).close()}),a(this,w).on("close",()=>{document.body.classList.remove("pc-overflow")}))},ye=new WeakSet,mt=function(){a(this,y)&&(a(this,y).on("upload-success",e=>{h(this,me,ht).call(this,e),a(this,y).close()}),a(this,y).on("closed",()=>{document.body.classList.remove("pc-overflow")}),a(this,y).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,y).close(),i&&i(e,a(this,y))}))},_e=new WeakSet,gt=function(){const e=h(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,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)},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}},new Dt().init()});
var At=Object.defineProperty;var Ht=(g,w,I)=>w in g?At(g,w,{enumerable:!0,configurable:!0,writable:!0,value:I}):g[w]=I;var B=(g,w,I)=>(Ht(g,typeof w!="symbol"?w+"":w,I),I),We=(g,w,I)=>{if(!w.has(g))throw TypeError("Cannot "+I)};var p=(g,w,I)=>(We(g,w,"read from private field"),I?I.call(g):w.get(g)),E=(g,w,I)=>{if(w.has(g))throw TypeError("Cannot add the same private member more than once");w instanceof WeakSet?w.add(g):w.set(g,I)},q=(g,w,I,le)=>(We(g,w,"write to private field"),le?le.call(g,I):w.set(g,I),I);var y=(g,w,I)=>(We(g,w,"access private method"),I);(function(g){typeof define=="function"&&define.amd?define(g):g()})(function(){var $,Q,C,S,j,ee,Ne,te,Be,de,lt,ue,dt,N,G,pe,ut,he,pt,fe,ht,me,ft,ve,mt,ge,vt,ye,gt,we,yt,be,wt,_e,bt,Ee,_t,Le,Et;"use strict";const g=function(){var Ae=Object.defineProperty,c=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,o=(e,t,n)=>(c(e,typeof t!="symbol"?t+"":t,n),n),a=Object.defineProperty,d=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t,n)=>(d(e,typeof t!="symbol"?t+"":t,n),n),v=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},L=(e,t,n)=>(v(e,t,"read from private field"),n?n.call(e):t.get(e)),b=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},k=(e,t,n,i)=>(v(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),h=(e,t,n)=>(v(e,t,"access private method"),n),x,T,U,R,M,A,V,ne,O,D,Pe={exports:{}},z=typeof Reflect=="object"?Reflect:null,He=z&&typeof z.apply=="function"?z.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},Ie;z&&typeof z.ownKeys=="function"?Ie=z.ownKeys:Object.getOwnPropertySymbols?Ie=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ie=function(e){return Object.getOwnPropertyNames(e)};function Lt(e){console&&console.warn&&console.warn(e)}var Fe=Number.isNaN||function(e){return e!==e};function f(){f.init.call(this)}Pe.exports=f,Pe.exports.once=xt,f.EventEmitter=f,f.prototype._events=void 0,f.prototype._eventsCount=0,f.prototype._maxListeners=void 0;var qe=10;function Ce(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(f,"defaultMaxListeners",{enumerable:!0,get:function(){return qe},set:function(e){if(typeof e!="number"||e<0||Fe(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");qe=e}}),f.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},f.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Fe(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 $e(e){return e._maxListeners===void 0?f.defaultMaxListeners:e._maxListeners}f.prototype.getMaxListeners=function(){return $e(this)},f.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var l=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw l.context=s,l}var _=r[e];if(_===void 0)return!1;if(typeof _=="function")He(_,this,t);else for(var ae=_.length,De=Je(_,ae),n=0;n<ae;++n)He(De[n],this,t);return!0};function Ve(e,t,n,i){var r,s,l;if(Ce(n),s=e._events,s===void 0?(s=e._events=Object.create(null),e._eventsCount=0):(s.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),l=s[t]),l===void 0)l=s[t]=n,++e._eventsCount;else if(typeof l=="function"?l=s[t]=i?[n,l]:[l,n]:i?l.unshift(n):l.push(n),r=$e(e),r>0&&l.length>r&&!l.warned){l.warned=!0;var _=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");_.name="MaxListenersExceededWarning",_.emitter=e,_.type=t,_.count=l.length,Lt(_)}return e}f.prototype.addListener=function(e,t){return Ve(this,e,t,!1)},f.prototype.on=f.prototype.addListener,f.prototype.prependListener=function(e,t){return Ve(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 ze(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=It.bind(i);return r.listener=n,i.wrapFn=r,r}f.prototype.once=function(e,t){return Ce(t),this.on(e,ze(this,e,t)),this},f.prototype.prependOnceListener=function(e,t){return Ce(t),this.prependListener(e,ze(this,e,t)),this},f.prototype.removeListener=function(e,t){var n,i,r,s,l;if(Ce(t),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(r=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){l=n[s].listener,r=s;break}if(r<0)return this;r===0?n.shift():Ct(n,r),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,l||t)}return this},f.prototype.off=f.prototype.removeListener,f.prototype.removeAllListeners=function(e){var t,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var r=Object.keys(n),s;for(i=0;i<r.length;++i)s=r[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function Ke(e,t,n){var i=e._events;if(i===void 0)return[];var r=i[t];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?kt(r):Je(r,r.length)}f.prototype.listeners=function(e){return Ke(this,e,!0)},f.prototype.rawListeners=function(e){return Ke(this,e,!1)},f.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Xe.call(e,t)},f.prototype.listenerCount=Xe;function Xe(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}f.prototype.eventNames=function(){return this._eventsCount>0?Ie(this._events):[]};function Je(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function Ct(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function kt(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function xt(e,t){return new Promise(function(n,i){function r(l){e.removeListener(t,s),i(l)}function s(){typeof e.removeListener=="function"&&e.removeListener("error",r),n([].slice.call(arguments))}Ze(e,t,s,{once:!0}),t!=="error"&&St(e,r,{once:!0})})}function St(e,t,n){typeof e.on=="function"&&Ze(e,"error",t,n)}function Ze(e,t,n,i){if(typeof e.on=="function")i.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function r(s){i.once&&e.removeEventListener(t,r),n(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var Tt=Pe.exports;const ie="pc-designer-iframe-wrapper",ke="pc-designer-iframe";class Pt{constructor(t){b(this,U),b(this,M),b(this,V),b(this,O),u(this,"token"),u(this,"productId"),u(this,"options"),b(this,x,void 0),b(this,T,void 0);var n;if(this.token=t.token,this.productId=t.productId,this.options=t.options,k(this,x,(n=this.options)!=null&&n.designerUrl?this.options.designerUrl:{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),k(this,T,new Tt),!this.token||!this.productId){console.error("Missing Config Params");return}h(this,U,R).call(this),h(this,M,A).call(this)}render(){const t=document.getElementById(ie),n=document.getElementById(ke);if(!n||!(n instanceof HTMLIFrameElement)||!t){console.error("Can not find iframe element");return}const i=h(this,V,ne).call(this);n.src=i.href,t.style.opacity="1",t.style.visibility="visible",h(this,O,D).call(this,"rendered")}close(){const t=document.getElementById(ie);if(!t){console.error("Can not find iframe element");return}t.style.opacity="0",t.style.visibility="hidden",h(this,O,D).call(this,"closed")}editDesign(t){const n=h(this,V,ne).call(this);n.searchParams.set("design_id",t),n.searchParams.set("task","edit");const i=document.getElementById(ie),r=document.getElementById(ke);if(!r||!(r instanceof HTMLIFrameElement)||!i){console.error("Can not find iframe element");return}r.src=n.href,i.style.opacity="1",i.style.visibility="visible",h(this,O,D).call(this,"edit")}on(t,n){return L(this,T).on(t,n),this}}x=new WeakMap,T=new WeakMap,U=new WeakSet,R=function(){const e=document.createElement("div");e.id=ie,e.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";const t=document.createElement("iframe");t.id=ke,t.width="100%",t.height="100%",e.appendChild(t),document.body.appendChild(e)},M=new WeakSet,A=function(){window.addEventListener("message",e=>{if(e.origin===L(this,x)&&e.data.message==="closeDesignTool"){const t=document.getElementById(ie);if(!t)return;t.style.opacity="0",t.style.visibility="hidden",h(this,O,D).call(this,"closed")}if(e.data.message==="finishLoad"){const t=document.getElementById(ke);h(this,O,D).call(this,"render-finish"),t&&t instanceof HTMLIFrameElement&&t.contentWindow&&t.contentWindow.postMessage({message:"customSettings",settings:this.options},L(this,x))}e.data.message==="finishProcess"&&h(this,O,D).call(this,"upload-success",e.data.data.data),e.data.message==="finishUpdate"&&h(this,O,D).call(this,"edit-success",e.data.data.data),e.data.message==="uploadError"&&h(this,O,D).call(this,"upload-error",e.data)},!1)},V=new WeakSet,ne=function(){const e=new URL(L(this,x));return e.searchParams.set("api_key",this.token),e.searchParams.set("product_id",this.productId),e.searchParams.set("parentUrl",window.location.href),e},O=new WeakSet,D=function(e,...t){L(this,T).emit(e,...t)};var Ue=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},P=(e,t,n)=>(Ue(e,t,"read from private field"),n?n.call(e):t.get(e)),W=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},K=(e,t,n,i)=>(Ue(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),H=(e,t,n)=>(Ue(e,t,"access private method"),n),re,X,J,se,oe,ce,F,Z,Me,Ye,Oe,Ge,je={exports:{}},Y=typeof Reflect=="object"?Reflect:null,Qe=Y&&typeof Y.apply=="function"?Y.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},xe;Y&&typeof Y.ownKeys=="function"?xe=Y.ownKeys:Object.getOwnPropertySymbols?xe=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:xe=function(e){return Object.getOwnPropertyNames(e)};function Ut(e){console&&console.warn&&console.warn(e)}var et=Number.isNaN||function(e){return e!==e};function m(){m.init.call(this)}je.exports=m,je.exports.once=Rt,m.EventEmitter=m,m.prototype._events=void 0,m.prototype._eventsCount=0,m.prototype._maxListeners=void 0;var tt=10;function Se(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(m,"defaultMaxListeners",{enumerable:!0,get:function(){return tt},set:function(e){if(typeof e!="number"||e<0||et(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");tt=e}}),m.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},m.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||et(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 nt(e){return e._maxListeners===void 0?m.defaultMaxListeners:e._maxListeners}m.prototype.getMaxListeners=function(){return nt(this)},m.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var l=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw l.context=s,l}var _=r[e];if(_===void 0)return!1;if(typeof _=="function")Qe(_,this,t);else for(var ae=_.length,De=ct(_,ae),n=0;n<ae;++n)Qe(De[n],this,t);return!0};function it(e,t,n,i){var r,s,l;if(Se(n),s=e._events,s===void 0?(s=e._events=Object.create(null),e._eventsCount=0):(s.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),l=s[t]),l===void 0)l=s[t]=n,++e._eventsCount;else if(typeof l=="function"?l=s[t]=i?[n,l]:[l,n]:i?l.unshift(n):l.push(n),r=nt(e),r>0&&l.length>r&&!l.warned){l.warned=!0;var _=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");_.name="MaxListenersExceededWarning",_.emitter=e,_.type=t,_.count=l.length,Ut(_)}return e}m.prototype.addListener=function(e,t){return it(this,e,t,!1)},m.prototype.on=m.prototype.addListener,m.prototype.prependListener=function(e,t){return it(this,e,t,!0)};function Mt(){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 rt(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=Mt.bind(i);return r.listener=n,i.wrapFn=r,r}m.prototype.once=function(e,t){return Se(t),this.on(e,rt(this,e,t)),this},m.prototype.prependOnceListener=function(e,t){return Se(t),this.prependListener(e,rt(this,e,t)),this},m.prototype.removeListener=function(e,t){var n,i,r,s,l;if(Se(t),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(r=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){l=n[s].listener,r=s;break}if(r<0)return this;r===0?n.shift():Ot(n,r),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,l||t)}return this},m.prototype.off=m.prototype.removeListener,m.prototype.removeAllListeners=function(e){var t,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var r=Object.keys(n),s;for(i=0;i<r.length;++i)s=r[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function st(e,t,n){var i=e._events;if(i===void 0)return[];var r=i[t];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?jt(r):ct(r,r.length)}m.prototype.listeners=function(e){return st(this,e,!0)},m.prototype.rawListeners=function(e){return st(this,e,!1)},m.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):ot.call(e,t)},m.prototype.listenerCount=ot;function ot(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}m.prototype.eventNames=function(){return this._eventsCount>0?xe(this._events):[]};function ct(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function Ot(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function jt(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function Rt(e,t){return new Promise(function(n,i){function r(l){e.removeListener(t,s),i(l)}function s(){typeof e.removeListener=="function"&&e.removeListener("error",r),n([].slice.call(arguments))}at(e,t,s,{once:!0}),t!=="error"&&Dt(e,r,{once:!0})})}function Dt(e,t,n){typeof e.on=="function"&&at(e,"error",t,n)}function at(e,t,n,i){if(typeof e.on=="function")i.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function r(s){i.once&&e.removeEventListener(t,r),n(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var Wt=je.exports;const Te="pc-uploader-iframe-wrapper",Re="pc-uploader-iframe";class Nt{constructor(t){if(W(this,F),W(this,Me),W(this,Oe),W(this,re,void 0),W(this,X,void 0),W(this,J,void 0),W(this,se,void 0),W(this,oe,void 0),W(this,ce,void 0),K(this,re,t.token),K(this,X,t.sideId||t.productId),K(this,ce,t.productId?"product":"side"),K(this,J,t.uploaderUrl?t.uploaderUrl:"https://upload-tool.pages.dev"),K(this,se,new Wt),K(this,oe,t.locale),!P(this,re)||!P(this,X)){console.warn("Missing Config Params.");return}H(this,Me,Ye).call(this),H(this,Oe,Ge).call(this)}get locale(){return P(this,oe)}open(){let t=document.getElementById(Te),n=document.getElementById(Re);const i=new URL(P(this,J));if(i.searchParams.set("token",P(this,re)),P(this,ce)==="side"?i.searchParams.set("sideId",P(this,X)):P(this,ce)==="product"&&i.searchParams.set("productId",P(this,X)),i.searchParams.set("parentUrl",window.location.href),!n||!(n instanceof HTMLIFrameElement)||!t){console.warn("Can not find iframe element.");return}n.src=i.href,t.style.opacity="1",t.style.visibility="visible",H(this,F,Z).call(this,"open")}close(){let t=document.getElementById(Te);if(!t){console.error("Can not find iframe element");return}t.style.opacity="0",t.style.visibility="hidden"}on(t,n){return P(this,se).on(t,n),this}}re=new WeakMap,X=new WeakMap,J=new WeakMap,se=new WeakMap,oe=new WeakMap,ce=new WeakMap,F=new WeakSet,Z=function(e,...t){P(this,se).emit(e,...t)},Me=new WeakSet,Ye=function(){let e=document.createElement("div");e.id=Te,e.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";let t=document.createElement("iframe");t.id=Re,t.width="100%",t.height="100%",t.style.borderWidth="0",e.appendChild(t),document.body.appendChild(e)},Oe=new WeakSet,Ge=function(){let e=document.getElementById(Te);window.addEventListener("message",t=>{var n;const i=new URL(t.origin),r=new URL(P(this,J));if(i.host===r.host){t.data.uploaderEvent==="close"&&e&&(e.style.opacity="0",e.style.visibility="hidden",H(this,F,Z).call(this,"close")),t.data.uploaderEvent==="upload-success"&&H(this,F,Z).call(this,"upload-success",t.data.data),t.data.uploaderEvent==="upload-error"&&H(this,F,Z).call(this,"upload-error",t.data.error);const s=P(this,oe),l=document.getElementById(Re);l&&l instanceof HTMLIFrameElement&&(H(this,F,Z).call(this,"onload"),s&&t.data.uploaderEvent==="loaded"&&t.data.finished&&(console.log("test"),l.focus(),(n=l.contentWindow)==null||n.postMessage({locale:s},P(this,J))))}},!1)};class Bt{constructor(){o(this,"initDesignTool",t=>new Pt(t)),o(this,"initUploader",t=>new Nt(t))}}return Bt}();var w="";const I=new g;class le{constructor(){E(this,ee);E(this,te);E(this,de);E(this,ue);E(this,N);E(this,pe);E(this,he);E(this,fe);E(this,me);E(this,ve);E(this,ge);E(this,ye);E(this,we);E(this,be);E(this,_e);E(this,Ee);E(this,Le);E(this,$,void 0);B(this,"token");B(this,"appID");B(this,"productIdPC");B(this,"orderIdWix");B(this,"orderNumberWix");B(this,"options");E(this,Q,void 0);E(this,C,void 0);E(this,S,void 0);E(this,j,void 0);B(this,"registerListener");this.token=y(this,ye,gt).call(this),this.productIdPC=null,this.appID="325c68a5-64c2-440d-b093-8cea369df06b",this.orderIdWix=null,this.orderNumberWix=null,q(this,j,null),this.options=window.PrintcartDesignerShopifyOptions,q(this,$,{}.VITE_API_URL?{}.VITE_API_URL:"https://api.printcart.com/v1"),q(this,Q,{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com")}init(){const c=window,o=this;c!=null&&c.wixDevelopersAnalytics?y(this,ee,Ne).call(this,"first"):c.addEventListener("wixDevelopersAnalyticsReady",function(){var a;y(a=o,ee,Ne).call(a,"second")})}}$=new WeakMap,Q=new WeakMap,C=new WeakMap,S=new WeakMap,j=new WeakMap,ee=new WeakSet,Ne=function(c){const o=this;console.log("Printcart start App "+c),window==null||window.wixDevelopersAnalytics.register(this.appID,function(d,u){var v,L,b;switch(d){case"ViewContent":localStorage.getItem("pc-product")&&localStorage.removeItem("pc-product");break;case"productPageLoaded":if(console.log("Printcart: productPageLoaded",u),u.variants&&u.variants.length>1)return;y(v=o,te,Be).call(v,u==null?void 0:u.productId);break;case"CustomizeProduct":if(u.variants&&u.variants.length<1)return;y(L=o,te,Be).call(L,u==null?void 0:u.variantId);break;case"Purchase":if(!localStorage.getItem("pc-design-ids"))return;const k=localStorage.getItem("pc-design-ids");if(o.orderIdWix=u==null?void 0:u.orderId,o.orderNumberWix=u==null?void 0:u.id,!o.orderIdWix)throw new Error("Can not find order ID WIX");if(!o.orderNumberWix)throw new Error("Can not find order number WIX");if(!k)throw new Error("Can not find design Ids");y(b=o,Le,Et).call(b,o.orderNumberWix,o.orderIdWix,JSON.parse(k));break}})},te=new WeakSet,Be=function(c){if(q(this,j,document.querySelector("[data-hook='product-options']")),!p(this,j))throw new Error("This script can only be used inside a Wix Product Page.");if(!c)throw new Error("Can not find product ID WIX");y(this,_e,bt).call(this,c).then(o=>{var L,b;if(this.productIdPC=(L=o==null?void 0:o.data)==null?void 0:L.id,!this.productIdPC)throw new Error("Can not find product ID Printcart");y(this,be,wt).call(this),y(this,Ee,_t).call(this),y(this,de,lt).call(this),y(this,pe,ut).call(this),y(this,he,pt).call(this);const a=document.querySelector("button#pc-btn"),d=o.data.enable_design,u=o.data.enable_upload;d&&(q(this,C,I.initDesignTool({token:this.token,productId:this.productIdPC,options:{...(b=this.options)==null?void 0:b.designerOptions,designerUrl:p(this,Q)}})),y(this,ge,vt).call(this),a&&a instanceof HTMLButtonElement&&(a.disabled=!1)),u&&(q(this,S,I.initUploader({token:this.token,productId:this.productIdPC})),y(this,ve,mt).call(this),a&&a instanceof HTMLButtonElement&&(a.disabled=!1));const v=()=>{p(this,C)&&!p(this,S)&&p(this,C).render(),!p(this,C)&&p(this,S)&&p(this,S).open(),p(this,C)&&p(this,S)&&y(this,ue,dt).call(this)};a&&a instanceof HTMLButtonElement&&(a.onclick=v)})},de=new WeakSet,lt=function(){const a='<button aria-label="Close" id="pc-select_close-btn"><span data-modal-x></span></button><div class="pc-select-wrap" id="pc-content-overlay"><div class="pc-select-inner"><div id="pc-select_header">Choose a way to design this product</div><div id="pc-select_container"><button class="pc-select_btn" id="pc-select_btn_upload"><div aria-hidden="true" class="pc-select_btn_wrap"><div class="pc-select_btn_img"><div class="pc-select_btn_img_inner"><img src="https://files.printcart.com/common/upload.svg" alt="Printcart Uploader"></div></div><div class="pc-select_btn_content"><div class="pc-select_btn_content_inner"><h2 class="pc-title">Upload a full design</h2><ul><li>Have a complete design</li><li>Have your own designer</li></ul></div></div></div><div class="visually-hidden">Upload Design file</div></button><button class="pc-select_btn" id="pc-select_btn_design"><div aria-hidden="true" class="pc-select_btn_wrap"><div class="pc-select_btn_img"><div class="pc-select_btn_img_inner"><img src="https://files.printcart.com/common/design.svg" alt="Printcart Designer"></div></div><div class="pc-select_btn_content"><div class="pc-select_btn_content_inner"><h2 class="pc-title">Design here online</h2><ul><li>Already have your concept</li><li>Customize every details</li></ul></div></div></div><div class="visually-hidden">Upload Design file</div></button></div></div></div>',d=document.createElement("div");d.id="pc-select_wrap",d.setAttribute("role","dialog"),d.setAttribute("aria-modal","true"),d.setAttribute("tabIndex","-1"),d.innerHTML=a,document.body.appendChild(d);const u=()=>{p(this,C)&&(y(this,N,G).call(this),p(this,C).render(),document.body.classList.add("pc-overflow"))},v=()=>{p(this,S)&&(y(this,N,G).call(this),p(this,S).open(),document.body.classList.add("pc-overflow"))},L=document.getElementById("pc-select_btn_upload"),b=document.getElementById("pc-select_btn_design");L&&(L==null||L.addEventListener("click",v)),b&&(b==null||b.addEventListener("click",u))},ue=new WeakSet,dt=function(){const c=document.getElementById("pc-select_wrap");c&&(c.style.display="flex",document.body.classList.add("pc-overflow"));const o=c==null?void 0:c.querySelector("#pc-select_close-btn");o&&o instanceof HTMLButtonElement&&o.focus()},N=new WeakSet,G=function(){const c=document.getElementById("pc-select_wrap");c&&(c.style.display="none"),document.body.classList.remove("pc-overflow")},pe=new WeakSet,ut=function(){const c=document.getElementById("pc-select_close-btn"),o=document.getElementById("pc-content-overlay"),a=d=>{d.key==="Escape"&&y(this,N,G).call(this)};window.addEventListener("keydown",a),c==null||c.addEventListener("click",()=>y(this,N,G).call(this)),o==null||o.addEventListener("click",()=>{const d=document.getElementById("pc-designer-iframe-wrapper");(d==null?void 0:d.style.visibility)!=="visible"&&y(this,N,G).call(this)})},he=new WeakSet,pt=function(){const c=document.getElementById("pc-select_wrap"),o=c==null?void 0:c.querySelectorAll("button"),a=o&&o[0],d=o&&o[o.length-1],u=v=>{v.key==="Tab"&&(v.shiftKey?d&&document.activeElement===a&&(d.focus(),v.preventDefault()):a&&document.activeElement===d&&(a.focus(),v.preventDefault()))};window.addEventListener("keydown",u)},fe=new WeakSet,ht=function(c){var L,b;const o=c.map(k=>k.data.id);let a=document.querySelector('input[name="properties[_pcDesignIds]"]');a?a.value+=`,${o.join()}`:(a=document.createElement("input"),a.type="hidden",a.name="properties[_pcDesignIds]",a.className="pc-designer_input",a.value=o.join(),(L=p(this,j))==null||L.appendChild(a));const d=document.querySelector(".pc-preview-wrap")||document.createElement("div");d.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(o)),c.forEach(k=>{var R;if(!k.data.design_image.url)return;const h=document.createElement("div");h.className="pc-preview",h.setAttribute("data-pc-design-id",k.data.id);const x=document.createElement("button");x.className="pc-btn pc-danger-btn",x.innerHTML=(R=this.options)!=null&&R.removeUploaderBtnText?this.options.removeUploaderBtnText:"Remove",x.onclick=()=>{const M=a.value.split(",").filter(A=>A!==k.data.id);a.value=M.join(),h.remove()};const T=document.createElement("img");T.src=k.data.design_image.url,T.className="pc-uploader-image";const U=document.createElement("div");U.className="pc-preview-overlay",U.appendChild(x),h.appendChild(U),h.appendChild(T),d.appendChild(h)});const u=document.querySelector("div#pc-designer_wrap");if(!document.querySelector(".princart-preview-heading")){const k=document.createElement("h5");k.className="princart-preview-heading",k.innerHTML="Your artworks",u==null||u.appendChild(k)}u==null||u.appendChild(d);const v=(b=this.options)==null?void 0:b.onUploadSuccess;v&&v(c,p(this,S))},me=new WeakSet,ft=function(c){var b,k;const o=this,a=c.map(h=>h.id);let d=document.querySelector('input[name="properties[_pcDesignIds]"]');d?d.value+=`,${a.join()}`:(d=document.createElement("input"),d.type="hidden",d.name="properties[_pcDesignIds]",d.className="pc-designer_input",d.value=a.join(),(b=p(this,j))==null||b.appendChild(d));const u=document.querySelector(".pc-preview-wrap")||document.createElement("div");u.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(a)),c.forEach(h=>{var A;if(!h.design_image.url)return;const x=document.createElement("div");x.className="pc-preview",x.setAttribute("data-pc-design-id",h.id);const T=document.createElement("button");T.className="pc-btn pc-primary-btn",T.style.borderRadius="5px",T.innerHTML="Edit",T.onclick=()=>{p(o,C).editDesign(h.id)};const U=document.createElement("button");U.className="pc-btn pc-danger-btn",U.style.borderRadius="5px",U.innerHTML="Remove",U.onclick=()=>{const V=d.value.split(",").filter(ne=>ne!==h.id);d.value=V.join(),x.remove()};const R=document.createElement("img");R.src=((A=h.preview_image)==null?void 0:A.url)||h.design_image.url,R.className="pc-uploader-image";const M=document.createElement("div");M.className="pc-preview-overlay",M.appendChild(T),M.appendChild(U),x.appendChild(M),x.appendChild(R),u.appendChild(x)});const v=document.querySelector("div#pc-designer_wrap");v==null||v.appendChild(u);const L=(k=this.options)==null?void 0:k.onDesignCreateSuccess;L&&L(c,p(this,C))},ve=new WeakSet,mt=function(){p(this,S)&&(p(this,S).on("upload-success",c=>{y(this,fe,ht).call(this,c),p(this,S).close()}),p(this,S).on("close",()=>{document.body.classList.remove("pc-overflow")}))},ge=new WeakSet,vt=function(){p(this,C)&&(p(this,C).on("upload-success",c=>{y(this,me,ft).call(this,c),p(this,C).close()}),p(this,C).on("closed",()=>{document.body.classList.remove("pc-overflow")}),p(this,C).on("edit-success",c=>{var d;if(!c.design_image.url)return;const o=document.querySelector(`[data-pc-design-id="${c.id}"] img`);if(!o||!(o instanceof HTMLImageElement))throw new Error("Can't find image element");o.src=c.design_image.url;const a=(d=this.options)==null?void 0:d.onDesignEditSuccess;p(this,C).close(),a&&a(c,p(this,C))}))},ye=new WeakSet,gt=function(){const c=y(this,we,yt).call(this),o=new URL(c);return new URLSearchParams(o.search).get("shopT")},we=new WeakSet,yt=function(){return document.querySelector("[id='pc-wix-integration-sdk']").src},be=new WeakSet,wt=function(){const c={}.VITE_SDK_URL?{}.VITE_SDK_URL:"https://unpkg.com/@printcart/wix-integration/dist",o=document.createElement("link");o.rel="stylesheet",o.href=`${c}/style.css`,document.head.appendChild(o)},_e=new WeakSet,bt=async function(c){try{const o=`${p(this,$)}/integration/wix/products/${c}`,a=this.token;if(!a)throw new Error("Missing Printcart Unauth Token");return await(await fetch(o,{headers:{"X-PrintCart-Unauth-Token":a}})).json()}catch(o){console.error("There has been a problem with your fetch operation:",o);return}},Ee=new WeakSet,_t=function(){var d,u,v;const c=p(this,j);if(!(c!=null&&c.parentNode)){console.log("Can not find cart form");return}if(document.getElementById("pc-designer_wrap")!==null)return;const o=document.createElement("div");o.id="pc-designer_wrap";const a=document.createElement("button");a.id="pc-btn",a.className=(d=this.options)!=null&&d.designClassName?(u=this.options)==null?void 0:u.designClassName:"",a.innerHTML=(v=this.options)!=null&&v.designBtnText?this.options.designBtnText:"Start Design",a.disabled=!0,o.appendChild(a),c.appendChild(o)},Le=new WeakSet,Et=async function(c,o,a){try{const d=`${p(this,$)}/projects`,u=this.token;if(!u)throw new Error("Missing Printcart Unauth Token");const v={name:`${c}`,status:"processing",design_ids:a,order_detail:{id:o}};await fetch(d,{method:"POST",headers:{"Content-Type":"application/json","X-PrintCart-Unauth-Token":u},body:JSON.stringify(v)})}catch(d){console.error("There has been a problem with your fetch operation:",d);return}},new le().init()});

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

],
"version": "1.1.8",
"version": "1.1.9",
"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