@pairbo/ui-kit 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui-kit.js CHANGED
@@ -10,13 +10,13 @@
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */const Ls=globalThis,pa=n=>n,zr=Ls.trustedTypes,ga=zr?zr.createPolicy("lit-html",{createHTML:n=>n}):void 0,$l="$lit$",fi=`lit$${Math.random().toFixed(9).slice(2)}$`,Rl="?"+fi,$h=`<${Rl}>`,Bi=document,Hs=()=>Bi.createComment(""),Vs=n=>n===null||typeof n!="object"&&typeof n!="function",To=Array.isArray,Rh=n=>To(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Pn=`[
14
- \f\r]`,ys=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,fa=/-->/g,ma=/>/g,Pi=RegExp(`>|${Pn}(?:([^\\s"'>=/]+)(${Pn}*=${Pn}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),ba=/'/g,va=/"/g,Bl=/^(?:script|style|textarea|title)$/i,Bh=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),F=Bh(1),ye=Symbol.for("lit-noChange"),Z=Symbol.for("lit-nothing"),ya=new WeakMap,Li=Bi.createTreeWalker(Bi,129);function zl(n,t){if(!To(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return ga!==void 0?ga.createHTML(t):t}const zh=(n,t)=>{const e=n.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=ys;for(let a=0;a<e;a++){const l=n[a];let c,h,d=-1,u=0;for(;u<l.length&&(o.lastIndex=u,h=o.exec(l),h!==null);)u=o.lastIndex,o===ys?h[1]==="!--"?o=fa:h[1]!==void 0?o=ma:h[2]!==void 0?(Bl.test(h[2])&&(s=RegExp("</"+h[2],"g")),o=Pi):h[3]!==void 0&&(o=Pi):o===Pi?h[0]===">"?(o=s??ys,d=-1):h[1]===void 0?d=-2:(d=o.lastIndex-h[2].length,c=h[1],o=h[3]===void 0?Pi:h[3]==='"'?va:ba):o===va||o===ba?o=Pi:o===fa||o===ma?o=ys:(o=Pi,s=void 0);const p=o===Pi&&n[a+1].startsWith("/>")?" ":"";r+=o===ys?l+$h:d>=0?(i.push(c),l.slice(0,d)+$l+l.slice(d)+fi+p):l+fi+(d===-2?a:p)}return[zl(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Zn=class Hl{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const a=t.length-1,l=this.parts,[c,h]=zh(t,e);if(this.el=Hl.createElement(c,i),Li.currentNode=this.el.content,e===2||e===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=Li.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith($l)){const u=h[o++],p=s.getAttribute(d).split(fi),g=/([.?@])?(.*)/.exec(u);l.push({type:1,index:r,name:g[2],strings:p,ctor:g[1]==="."?Vh:g[1]==="?"?Nh:g[1]==="@"?Uh:rn}),s.removeAttribute(d)}else d.startsWith(fi)&&(l.push({type:6,index:r}),s.removeAttribute(d));if(Bl.test(s.tagName)){const d=s.textContent.split(fi),u=d.length-1;if(u>0){s.textContent=zr?zr.emptyScript:"";for(let p=0;p<u;p++)s.append(d[p],Hs()),Li.nextNode(),l.push({type:2,index:++r});s.append(d[u],Hs())}}}else if(s.nodeType===8)if(s.data===Rl)l.push({type:2,index:r});else{let d=-1;for(;(d=s.data.indexOf(fi,d+1))!==-1;)l.push({type:7,index:r}),d+=fi.length-1}r++}}static createElement(t,e){const i=Bi.createElement("template");return i.innerHTML=t,i}};function os(n,t,e=n,i){var o,a;if(t===ye)return t;let s=i!==void 0?(o=e._$Co)==null?void 0:o[i]:e._$Cl;const r=Vs(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=os(n,s._$AS(n,t.values),s,i)),t}let Hh=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Bi).importNode(e,!0);Li.currentNode=s;let r=Li.nextNode(),o=0,a=0,l=i[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new sn(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new Wh(r,this,t)),this._$AV.push(c),l=i[++a]}o!==(l==null?void 0:l.index)&&(r=Li.nextNode(),o++)}return Li.currentNode=Bi,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},sn=class Vl{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=Z,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=os(this,t,e),Vs(t)?t===Z||t==null||t===""?(this._$AH!==Z&&this._$AR(),this._$AH=Z):t!==this._$AH&&t!==ye&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Rh(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==Z&&Vs(this._$AH)?this._$AA.nextSibling.data=t:this.T(Bi.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Zn.createElement(zl(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(e);else{const o=new Hh(s,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=ya.get(t.strings);return e===void 0&&ya.set(t.strings,e=new Zn(t)),e}k(t){To(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new Vl(this.O(Hs()),this.O(Hs()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t!==this._$AB;){const s=pa(t).nextSibling;pa(t).remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},rn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=Z,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(r===void 0)t=os(this,t,e,0),o=!Vs(t)||t!==this._$AH&&t!==ye,o&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=os(this,a[i+l],e,l),c===ye&&(c=this._$AH[l]),o||(o=!Vs(c)||c!==this._$AH[l]),c===Z?t=Z:t!==Z&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}o&&!s&&this.j(t)}j(t){t===Z?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Vh=class extends rn{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Z?void 0:t}},Nh=class extends rn{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Z)}},Uh=class extends rn{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=os(this,t,e,0)??Z)===ye)return;const i=this._$AH,s=t===Z&&i!==Z||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==Z&&(i===Z||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},Wh=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){os(this,t)}};const Gh={I:sn},Dn=Ls.litHtmlPolyfillSupport;Dn==null||Dn(Zn,sn),(Ls.litHtmlVersions??(Ls.litHtmlVersions=[])).push("3.3.2");const Nl=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new sn(t.insertBefore(Hs(),r),r,void 0,e??{})}return s._$AI(n),s};/**
13
+ */const Ls=globalThis,pa=n=>n,zr=Ls.trustedTypes,ga=zr?zr.createPolicy("lit-html",{createHTML:n=>n}):void 0,$l="$lit$",fi=`lit$${Math.random().toFixed(9).slice(2)}$`,Rl="?"+fi,$h=`<${Rl}>`,zi=document,Hs=()=>zi.createComment(""),Vs=n=>n===null||typeof n!="object"&&typeof n!="function",To=Array.isArray,Rh=n=>To(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Pn=`[
14
+ \f\r]`,ys=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,fa=/-->/g,ma=/>/g,Di=RegExp(`>|${Pn}(?:([^\\s"'>=/]+)(${Pn}*=${Pn}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),ba=/'/g,va=/"/g,Bl=/^(?:script|style|textarea|title)$/i,Bh=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),F=Bh(1),ye=Symbol.for("lit-noChange"),Z=Symbol.for("lit-nothing"),ya=new WeakMap,Fi=zi.createTreeWalker(zi,129);function zl(n,t){if(!To(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return ga!==void 0?ga.createHTML(t):t}const zh=(n,t)=>{const e=n.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=ys;for(let a=0;a<e;a++){const l=n[a];let c,h,d=-1,u=0;for(;u<l.length&&(o.lastIndex=u,h=o.exec(l),h!==null);)u=o.lastIndex,o===ys?h[1]==="!--"?o=fa:h[1]!==void 0?o=ma:h[2]!==void 0?(Bl.test(h[2])&&(s=RegExp("</"+h[2],"g")),o=Di):h[3]!==void 0&&(o=Di):o===Di?h[0]===">"?(o=s??ys,d=-1):h[1]===void 0?d=-2:(d=o.lastIndex-h[2].length,c=h[1],o=h[3]===void 0?Di:h[3]==='"'?va:ba):o===va||o===ba?o=Di:o===fa||o===ma?o=ys:(o=Di,s=void 0);const p=o===Di&&n[a+1].startsWith("/>")?" ":"";r+=o===ys?l+$h:d>=0?(i.push(c),l.slice(0,d)+$l+l.slice(d)+fi+p):l+fi+(d===-2?a:p)}return[zl(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Zn=class Hl{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const a=t.length-1,l=this.parts,[c,h]=zh(t,e);if(this.el=Hl.createElement(c,i),Fi.currentNode=this.el.content,e===2||e===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=Fi.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith($l)){const u=h[o++],p=s.getAttribute(d).split(fi),g=/([.?@])?(.*)/.exec(u);l.push({type:1,index:r,name:g[2],strings:p,ctor:g[1]==="."?Vh:g[1]==="?"?Nh:g[1]==="@"?Uh:rn}),s.removeAttribute(d)}else d.startsWith(fi)&&(l.push({type:6,index:r}),s.removeAttribute(d));if(Bl.test(s.tagName)){const d=s.textContent.split(fi),u=d.length-1;if(u>0){s.textContent=zr?zr.emptyScript:"";for(let p=0;p<u;p++)s.append(d[p],Hs()),Fi.nextNode(),l.push({type:2,index:++r});s.append(d[u],Hs())}}}else if(s.nodeType===8)if(s.data===Rl)l.push({type:2,index:r});else{let d=-1;for(;(d=s.data.indexOf(fi,d+1))!==-1;)l.push({type:7,index:r}),d+=fi.length-1}r++}}static createElement(t,e){const i=zi.createElement("template");return i.innerHTML=t,i}};function os(n,t,e=n,i){var o,a;if(t===ye)return t;let s=i!==void 0?(o=e._$Co)==null?void 0:o[i]:e._$Cl;const r=Vs(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=os(n,s._$AS(n,t.values),s,i)),t}let Hh=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??zi).importNode(e,!0);Fi.currentNode=s;let r=Fi.nextNode(),o=0,a=0,l=i[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new sn(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new Wh(r,this,t)),this._$AV.push(c),l=i[++a]}o!==(l==null?void 0:l.index)&&(r=Fi.nextNode(),o++)}return Fi.currentNode=zi,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},sn=class Vl{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=Z,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=os(this,t,e),Vs(t)?t===Z||t==null||t===""?(this._$AH!==Z&&this._$AR(),this._$AH=Z):t!==this._$AH&&t!==ye&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Rh(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==Z&&Vs(this._$AH)?this._$AA.nextSibling.data=t:this.T(zi.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Zn.createElement(zl(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(e);else{const o=new Hh(s,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=ya.get(t.strings);return e===void 0&&ya.set(t.strings,e=new Zn(t)),e}k(t){To(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new Vl(this.O(Hs()),this.O(Hs()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t!==this._$AB;){const s=pa(t).nextSibling;pa(t).remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},rn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=Z,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(r===void 0)t=os(this,t,e,0),o=!Vs(t)||t!==this._$AH&&t!==ye,o&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=os(this,a[i+l],e,l),c===ye&&(c=this._$AH[l]),o||(o=!Vs(c)||c!==this._$AH[l]),c===Z?t=Z:t!==Z&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}o&&!s&&this.j(t)}j(t){t===Z?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Vh=class extends rn{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Z?void 0:t}},Nh=class extends rn{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Z)}},Uh=class extends rn{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=os(this,t,e,0)??Z)===ye)return;const i=this._$AH,s=t===Z&&i!==Z||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==Z&&(i===Z||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},Wh=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){os(this,t)}};const Gh={I:sn},Dn=Ls.litHtmlPolyfillSupport;Dn==null||Dn(Zn,sn),(Ls.litHtmlVersions??(Ls.litHtmlVersions=[])).push("3.3.2");const Nl=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new sn(t.insertBefore(Hs(),r),r,void 0,e??{})}return s._$AI(n),s};/**
16
16
  * @license
17
17
  * Copyright 2017 Google LLC
18
18
  * SPDX-License-Identifier: BSD-3-Clause
19
- */const Ri=globalThis;let is=class extends Ki{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Nl(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return ye}};var Fl;is._$litElement$=!0,is.finalized=!0,(Fl=Ri.litElementHydrateSupport)==null||Fl.call(Ri,{LitElement:is});const An=Ri.litElementPolyfillSupport;An==null||An({LitElement:is});(Ri.litElementVersions??(Ri.litElementVersions=[])).push("4.2.2");/**
19
+ */const Bi=globalThis;let is=class extends Ki{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Nl(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return ye}};var Fl;is._$litElement$=!0,is.finalized=!0,(Fl=Bi.litElementHydrateSupport)==null||Fl.call(Bi,{LitElement:is});const An=Bi.litElementPolyfillSupport;An==null||An({LitElement:is});(Bi.litElementVersions??(Bi.litElementVersions=[])).push("4.2.2");/**
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
@@ -164,7 +164,7 @@
164
164
  .form-control__label > slot {
165
165
  font-size: 16.5px;
166
166
  }
167
- `;/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Jn=function(n,t){return Jn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},Jn(n,t)};function Wl(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Jn(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Qt=function(){return Qt=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},Qt.apply(this,arguments)};function td(n,t,e){for(var i=0,s=t.length,r;i<s;i++)(r||!(i in t))&&(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return n.concat(r||Array.prototype.slice.call(t))}var xt={ADD_CHOICE:"ADD_CHOICE",REMOVE_CHOICE:"REMOVE_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM"},Jt={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Vt={TAB_KEY:9,SHIFT_KEY:16,BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},ed=["fuseOptions","classNames"],mi={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},_a=function(n){return{type:xt.ADD_CHOICE,choice:n}},id=function(n){return{type:xt.REMOVE_CHOICE,choice:n}},sd=function(n){return{type:xt.FILTER_CHOICES,results:n}},rd=function(n){return{type:xt.ACTIVATE_CHOICES,active:n}},nd=function(n){return{type:xt.ADD_GROUP,group:n}},xa=function(n){return{type:xt.ADD_ITEM,item:n}},wa=function(n){return{type:xt.REMOVE_ITEM,item:n}},nr=function(n,t){return{type:xt.HIGHLIGHT_ITEM,item:n,highlighted:t}},od=function(n,t){return Math.floor(Math.random()*(t-n)+n)},Ca=function(n){return Array.from({length:n},function(){return od(0,36).toString(36)}).join("")},ad=function(n,t){var e=n.id||n.name&&"".concat(n.name,"-").concat(Ca(2))||Ca(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},ld=function(n,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=n[i];s;){if(s.matches(t))return s;s=s[i]}return null},cd=function(n,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=n.offsetTop+n.offsetHeight:i=n.offsetTop>=t.scrollTop,i},nn=function(n){if(typeof n!="string"){if(n==null)return"";if(typeof n=="object"){if("raw"in n)return nn(n.raw);if("trusted"in n)return n.trusted}return n}return n.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;")},hd=(function(){var n=document.createElement("div");return function(t){n.innerHTML=t.trim();for(var e=n.children[0];n.firstChild;)n.removeChild(n.firstChild);return e}})(),Fs=function(n,t){return typeof n=="function"?n(nn(t),t):n},Sa=function(n){return typeof n=="function"?n():n},Fi=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("trusted"in n)return n.trusted;if("raw"in n)return n.raw}return""},Gl=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("escaped"in n)return n.escaped;if("trusted"in n)return n.trusted}return""},ko=function(n,t){return n?Gl(t):nn(t)},Xe=function(n,t,e){n.innerHTML=ko(t,e)},dd=function(n,t){var e=n.value,i=n.label,s=i===void 0?e:i,r=t.value,o=t.label,a=o===void 0?r:o;return Fi(s).localeCompare(Fi(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},ud=function(n,t){return n.rank-t.rank},pd=function(n,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return n.dispatchEvent(i)},gd=function(n,t){var e=Object.keys(n).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},on=function(n){return Array.isArray(n)?n:[n]},_s=function(n){return n&&Array.isArray(n)?n.map(function(t){return".".concat(t)}).join(""):".".concat(n)},z=function(n,t){var e;(e=n.classList).add.apply(e,on(t))},$e=function(n,t){var e;(e=n.classList).remove.apply(e,on(t))},fd=function(n){if(typeof n<"u")try{return JSON.parse(n)}catch{return n}return{}},md=function(n,t,e){var i=n.itemEl;i&&($e(i,e),z(i,t))},bd=(function(){function n(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return n.prototype.show=function(){return z(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},n.prototype.hide=function(){return $e(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},n})(),Ta=(function(){function n(t){var e=t.element,i=t.type,s=t.classNames,r=t.position;this.element=e,this.classNames=s,this.type=i,this.position=r,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return n.prototype.shouldFlip=function(t,e){var i=!1;return this.position==="auto"?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:this.position==="top"&&(i=!0),i},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype.open=function(t,e){z(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(z(this.element,this.classNames.flippedState),this.isFlipped=!0)},n.prototype.close=function(){$e(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&($e(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){z(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){$e(this.element,this.classNames.focusState)},n.prototype.enable=function(){$e(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===mi.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},n.prototype.disable=function(){z(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===mi.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},n.prototype.wrap=function(t){var e=this.element,i=t.parentNode;i&&(t.nextSibling?i.insertBefore(e,t.nextSibling):i.appendChild(e)),e.appendChild(t)},n.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},n.prototype.addLoadingState=function(){z(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},n.prototype.removeLoadingState=function(){$e(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},n})(),vd=(function(){function n(t){var e=t.element,i=t.type,s=t.classNames,r=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=r,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=e.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(n.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),n.prototype.addEventListeners=function(){var t=this.element;t.addEventListener("paste",this._onPaste),t.addEventListener("input",this._onInput,{passive:!0}),t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})},n.prototype.removeEventListeners=function(){var t=this.element;t.removeEventListener("input",this._onInput),t.removeEventListener("paste",this._onPaste),t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)},n.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},n.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},n.prototype.focus=function(){this.isFocussed||this.element.focus()},n.prototype.blur=function(){this.isFocussed&&this.element.blur()},n.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},n.prototype.setWidth=function(){var t=this.element;t.style.minWidth="".concat(t.placeholder.length+1,"ch"),t.style.width="".concat(t.value.length+1,"ch")},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype._onInput=function(){this.type!==mi.SelectOne&&this.setWidth()},n.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},n.prototype._onFocus=function(){this.isFocussed=!0},n.prototype._onBlur=function(){this.isFocussed=!1},n})(),yd=4,Ea=(function(){function n(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return n.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},n.prototype.scrollToTop=function(){this.element.scrollTop=0},n.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,r=this.element.scrollTop+s,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-r:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},n.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,r=s>1?s:1;this.element.scrollTop=t+r},n.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,r=s>1?s:1;this.element.scrollTop=t-r},n.prototype._animateScroll=function(t,e){var i=this,s=yd,r=this.element.scrollTop,o=!1;e>0?(this._scrollDown(r,s,t),r<t&&(o=!0)):(this._scrollUp(r,s,t),r>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},n})(),Yl=(function(){function n(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(n.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),n.prototype.conceal=function(){var t=this.element;z(t,this.classNames.input),t.hidden=!0,t.tabIndex=-1;var e=t.getAttribute("style");e&&t.setAttribute("data-choice-orig-style",e),t.setAttribute("data-choice","active")},n.prototype.reveal=function(){var t=this.element;$e(t,this.classNames.input),t.hidden=!1,t.removeAttribute("tabindex");var e=t.getAttribute("data-choice-orig-style");e?(t.removeAttribute("data-choice-orig-style"),t.setAttribute("style",e)):t.removeAttribute("style"),t.removeAttribute("data-choice")},n.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},n.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},n.prototype.triggerEvent=function(t,e){pd(this.element,t,e||{})},n})(),_d=(function(n){Wl(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(Yl),Ds=function(n,t){return t===void 0&&(t=!0),typeof n>"u"?t:!!n},Xl=function(n){if(typeof n=="string"&&(n=n.split(" ").filter(function(t){return t.length})),Array.isArray(n)&&n.length)return n},je=function(n,t,e){if(e===void 0&&(e=!0),typeof n=="string"){var i=nn(n),s=e||i===n?n:{escaped:i,raw:n},r=je({value:n,label:s,selected:!0},!1);return r}var o=n;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(u){return je(u,!1)}),c={id:0,label:Fi(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,d={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Ds(h.active),selected:Ds(h.selected,!1),disabled:Ds(h.disabled,!1),placeholder:Ds(h.placeholder,!1),highlighted:!1,labelClass:Xl(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return d},xd=function(n){return n.tagName==="INPUT"},ql=function(n){return n.tagName==="SELECT"},wd=function(n){return n.tagName==="OPTION"},Cd=function(n){return n.tagName==="OPTGROUP"},Sd=(function(n){Wl(t,n);function t(e){var i=e.element,s=e.classNames,r=e.template,o=e.extractPlaceholder,a=n.call(this,{element:i,classNames:s})||this;return a.template=r,a.extractPlaceholder=o,a}return Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),t.prototype.addOptions=function(e){var i=this,s=document.createDocumentFragment();e.forEach(function(r){var o=r;if(!o.element){var a=i.template(o);s.appendChild(a),o.element=a}}),this.element.appendChild(s)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(s){wd(s)?i.push(e._optionToChoice(s)):Cd(s)&&i.push(e._optgroupToChoice(s))}),i},t.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:typeof e.dataset.labelClass<"u"?Xl(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:fd(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),r=Array.from(s).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!r.length,disabled:e.disabled,choices:r}},t})(Yl),Td={containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},ka={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(n){return!!n&&n!==""},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:dd,shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(n){return'Press Enter to add <b>"'.concat(n,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(n){return"Remove item: ".concat(n)},maxItemText:function(n){return"Only ".concat(n," values can be added")},valueComparer:function(n,t){return n===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:Td,appendGroupInSearch:!1},Oa=function(n){var t=n.itemEl;t&&(t.remove(),n.itemEl=void 0)};function Ed(n,t,e){var i=n,s=!0;switch(t.type){case xt.ADD_ITEM:{t.item.selected=!0;var r=t.item.element;r&&(r.selected=!0,r.setAttribute("selected","")),i.push(t.item);break}case xt.REMOVE_ITEM:{t.item.selected=!1;var r=t.item.element;if(r){r.selected=!1,r.removeAttribute("selected");var o=r.parentElement;o&&ql(o)&&o.type===mi.SelectOne&&(o.value="")}Oa(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case xt.REMOVE_CHOICE:{Oa(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case xt.HIGHLIGHT_ITEM:{var a=t.highlighted,l=i.find(function(c){return c.id===t.item.id});l&&l.highlighted!==a&&(l.highlighted=a,e&&md(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{s=!1;break}}return{state:i,update:s}}function kd(n,t){var e=n,i=!0;switch(t.type){case xt.ADD_GROUP:{e.push(t.group);break}case xt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function Od(n,t,e){var i=n,s=!0;switch(t.type){case xt.ADD_CHOICE:{i.push(t.choice);break}case xt.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(o){return o.id!==t.choice.id})),i=i.filter(function(o){return o.id!==t.choice.id});break}case xt.ADD_ITEM:case xt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case xt.FILTER_CHOICES:{var r=[];t.results.forEach(function(o){r[o.item.id]=o}),i.forEach(function(o){var a=r[o.id];a!==void 0?(o.score=a.score,o.rank=a.rank,o.active=!0):(o.score=0,o.rank=0,o.active=!1),e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case xt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case xt.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var Pa={groups:kd,items:Ed,choices:Od},Pd=(function(){function n(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(n.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),n.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},n.prototype.reset=function(){this._state=this.defaultState;var t=this.changeSet(!0);this._txn?this._changeSet=t:this._listeners.forEach(function(e){return e(t)})},n.prototype.subscribe=function(t){return this._listeners.push(t),this},n.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,r=this._changeSet||this.changeSet(!1);Object.keys(Pa).forEach(function(o){var a=Pa[o](i[o],t,e._context);a.update&&(s=!0,r[o]=!0,i[o]=a.state)}),s&&(this._txn?this._changeSet=r:this._listeners.forEach(function(o){return o(r)}))},n.prototype.withTxn=function(t){this._txn++;try{t()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var e=this._changeSet;e&&(this._changeSet=void 0,this._listeners.forEach(function(i){return i(e)}))}}},Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter(function(e){var i=e.active&&!e.disabled,s=t.state.choices.some(function(r){return r.active&&!r.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),n.prototype.inTxn=function(){return this._txn>0},n.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},n.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},n})(),Rt={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function Dd(n,t,e){return(t=Md(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Da(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function Ji(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Da(Object(e),!0).forEach(function(i){Dd(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Da(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function Ad(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function Md(n){var t=Ad(n,"string");return typeof t=="symbol"?t:t+""}function si(n){return Array.isArray?Array.isArray(n):Jl(n)==="[object Array]"}function Id(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function Ld(n){return n==null?"":Id(n)}function Be(n){return typeof n=="string"}function Kl(n){return typeof n=="number"}function Fd(n){return n===!0||n===!1||jd(n)&&Jl(n)=="[object Boolean]"}function Zl(n){return typeof n=="object"}function jd(n){return Zl(n)&&n!==null}function pe(n){return n!=null}function Mn(n){return!n.trim().length}function Jl(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const $d="Incorrect 'index' type",Rd=n=>`Invalid value for key ${n}`,Bd=n=>`Pattern length exceeds max of ${n}.`,zd=n=>`Missing ${n} property in key`,Hd=n=>`Property 'weight' in key '${n}' must be a positive integer`,Aa=Object.prototype.hasOwnProperty;class Vd{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=Ql(i);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ql(n){let t=null,e=null,i=null,s=1,r=null;if(Be(n)||si(n))i=n,t=Ma(n),e=Qn(n);else{if(!Aa.call(n,"name"))throw new Error(zd("name"));const o=n.name;if(i=o,Aa.call(n,"weight")&&(s=n.weight,s<=0))throw new Error(Hd(o));t=Ma(o),e=Qn(o),r=n.getFn}return{path:t,id:e,weight:s,src:i,getFn:r}}function Ma(n){return si(n)?n:n.split(".")}function Qn(n){return si(n)?n.join("."):n}function Nd(n,t){let e=[],i=!1;const s=(r,o,a)=>{if(pe(r))if(!o[a])e.push(r);else{let l=o[a];const c=r[l];if(!pe(c))return;if(a===o.length-1&&(Be(c)||Kl(c)||Fd(c)))e.push(Ld(c));else if(si(c)){i=!0;for(let h=0,d=c.length;h<d;h+=1)s(c[h],o,a+1)}else o.length&&s(c,o,a+1)}};return s(n,Be(t)?t.split("."):t,0),i?e:e[0]}const Ud={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Wd={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},Gd={location:0,threshold:.6,distance:100},Yd={useExtendedSearch:!1,getFn:Nd,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var $=Ji(Ji(Ji(Ji({},Wd),Ud),Gd),Yd);const Xd=/[^ ]+/g;function qd(n=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const r=s.match(Xd).length;if(e.has(r))return e.get(r);const o=1/Math.pow(r,.5*n),a=parseFloat(Math.round(o*i)/i);return e.set(r,a),a},clear(){e.clear()}}}class Oo{constructor({getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){this.norm=qd(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,i)=>{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Be(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();Be(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e<i;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!pe(t)||Mn(t))return;let i={v:t,i:e,n:this.norm.get(t)};this.records.push(i)}_addObject(t,e){let i={i:e,$:{}};this.keys.forEach((s,r)=>{let o=s.getFn?s.getFn(t):this.getFn(t,s.path);if(pe(o)){if(si(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(pe(h))if(Be(h)&&!Mn(h)){let d={v:h,i:c,n:this.norm.get(h)};a.push(d)}else si(h)&&h.forEach((d,u)=>{l.push({nestedArrIndex:u,value:d})})}i.$[r]=a}else if(Be(o)&&!Mn(o)){let a={v:o,n:this.norm.get(o)};i.$[r]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function tc(n,t,{getFn:e=$.getFn,fieldNormWeight:i=$.fieldNormWeight}={}){const s=new Oo({getFn:e,fieldNormWeight:i});return s.setKeys(n.map(Ql)),s.setSources(t),s.create(),s}function Kd(n,{getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){const{keys:i,records:s}=n,r=new Oo({getFn:t,fieldNormWeight:e});return r.setKeys(i),r.setIndexRecords(s),r}function or(n,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=$.distance,ignoreLocation:r=$.ignoreLocation}={}){const o=t/n.length;if(r)return o;const a=Math.abs(i-e);return s?o+a/s:a?1:o}function Zd(n=[],t=$.minMatchCharLength){let e=[],i=-1,s=-1,r=0;for(let o=n.length;r<o;r+=1){let a=n[r];a&&i===-1?i=r:!a&&i!==-1&&(s=r-1,s-i+1>=t&&e.push([i,s]),i=-1)}return n[r-1]&&r-i>=t&&e.push([i,r-1]),e}const Di=32;function Jd(n,t,e,{location:i=$.location,distance:s=$.distance,threshold:r=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,includeMatches:l=$.includeMatches,ignoreLocation:c=$.ignoreLocation}={}){if(t.length>Di)throw new Error(Bd(Di));const h=t.length,d=n.length,u=Math.max(0,Math.min(i,d));let p=r,g=u;const f=a>1||l,b=f?Array(d):[];let m;for(;(m=n.indexOf(t,g))>-1;){let k=or(t,{currentLocation:m,expectedLocation:u,distance:s,ignoreLocation:c});if(p=Math.min(k,p),g=m+h,f){let E=0;for(;E<h;)b[m+E]=1,E+=1}}g=-1;let _=[],x=1,S=h+d;const T=1<<h-1;for(let k=0;k<h;k+=1){let E=0,P=S;for(;E<P;)or(t,{errors:k,currentLocation:u+P,expectedLocation:u,distance:s,ignoreLocation:c})<=p?E=P:S=P,P=Math.floor((S-E)/2+E);S=P;let R=Math.max(1,u-P+1),L=o?d:Math.min(u+P,d)+h,j=Array(L+2);j[L+1]=(1<<k)-1;for(let M=L;M>=R;M-=1){let U=M-1,q=e[n.charAt(U)];if(f&&(b[U]=+!!q),j[M]=(j[M+1]<<1|1)&q,k&&(j[M]|=(_[M+1]|_[M])<<1|1|_[M+1]),j[M]&T&&(x=or(t,{errors:k,currentLocation:U,expectedLocation:u,distance:s,ignoreLocation:c}),x<=p)){if(p=x,g=U,g<=u)break;R=Math.max(1,2*u-g)}}if(or(t,{errors:k+1,currentLocation:u,expectedLocation:u,distance:s,ignoreLocation:c})>p)break;_=j}const O={isMatch:g>=0,score:Math.max(.001,x)};if(f){const k=Zd(b,a);k.length?l&&(O.indices=k):O.isMatch=!1}return O}function Qd(n){let t={};for(let e=0,i=n.length;e<i;e+=1){const s=n.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class ec{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:r=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(u,p)=>{this.chunks.push({pattern:u,alphabet:Qd(u),startIndex:p})},d=this.pattern.length;if(d>Di){let u=0;const p=d%Di,g=d-p;for(;u<g;)h(this.pattern.substr(u,Di),u),u+=Di;if(p){const f=d-Di;h(this.pattern.substr(f),f)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let g={isMatch:!0,score:0};return i&&(g.indices=[[0,t.length-1]]),g}const{location:s,distance:r,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],d=0,u=!1;this.chunks.forEach(({pattern:g,alphabet:f,startIndex:b})=>{const{isMatch:m,score:_,indices:x}=Jd(t,g,f,{location:s+b,distance:r,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});m&&(u=!0),d+=_,m&&x&&(h=[...h,...x])});let p={isMatch:u,score:u?d/this.chunks.length:1};return u&&i&&(p.indices=h),p}}class Si{constructor(t){this.pattern=t}static isMultiMatch(t){return Ia(t,this.multiRegex)}static isSingleMatch(t){return Ia(t,this.singleRegex)}search(){}}function Ia(n,t){const e=n.match(t);return e?e[1]:null}class tu extends Si{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class eu extends Si{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class iu extends Si{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class su extends Si{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class ru extends Si{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class nu extends Si{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class ic extends Si{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:r=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){super(t),this._bitapSearch=new ec(t,{location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class sc extends Si{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const s=[],r=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+r,s.push([i,e-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const to=[tu,sc,iu,su,nu,ru,eu,ic],La=to.length,ou=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,au="|";function lu(n,t={}){return n.split(au).map(e=>{let i=e.trim().split(ou).filter(r=>r&&!!r.trim()),s=[];for(let r=0,o=i.length;r<o;r+=1){const a=i[r];let l=!1,c=-1;for(;!l&&++c<La;){const h=to[c];let d=h.isMultiMatch(a);d&&(s.push(new h(d,t)),l=!0)}if(!l)for(c=-1;++c<La;){const h=to[c];let d=h.isSingleMatch(a);if(d){s.push(new h(d,t));break}}}return s})}const cu=new Set([ic.type,sc.type]);class hu{constructor(t,{isCaseSensitive:e=$.isCaseSensitive,includeMatches:i=$.includeMatches,minMatchCharLength:s=$.minMatchCharLength,ignoreLocation:r=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:a=$.location,threshold:l=$.threshold,distance:c=$.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:o,ignoreLocation:r,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=lu(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let r=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,r=0;for(let d=0,u=h.length;d<u;d+=1){const p=h[d],{isMatch:g,indices:f,score:b}=p.search(t);if(g){if(r+=1,a+=b,i){const m=p.constructor.type;cu.has(m)?o=[...o,...f]:o.push(f)}}else{a=0,r=0,o.length=0;break}}if(r){let d={isMatch:!0,score:a/r};return i&&(d.indices=o),d}}return{isMatch:!1,score:1}}}const eo=[];function du(...n){eo.push(...n)}function io(n,t){for(let e=0,i=eo.length;e<i;e+=1){let s=eo[e];if(s.condition(n,t))return new s(n,t)}return new ec(n,t)}const Vr={AND:"$and",OR:"$or"},so={PATH:"$path",PATTERN:"$val"},ro=n=>!!(n[Vr.AND]||n[Vr.OR]),uu=n=>!!n[so.PATH],pu=n=>!si(n)&&Zl(n)&&!ro(n),Fa=n=>({[Vr.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function rc(n,t,{auto:e=!0}={}){const i=s=>{let r=Object.keys(s);const o=uu(s);if(!o&&r.length>1&&!ro(s))return i(Fa(s));if(pu(s)){const l=o?s[so.PATH]:r[0],c=o?s[so.PATTERN]:s[l];if(!Be(c))throw new Error(Rd(l));const h={keyId:Qn(l),pattern:c};return e&&(h.searcher=io(c,t)),h}let a={children:[],operator:r[0]};return r.forEach(l=>{const c=s[l];si(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return ro(n)||(n=Fa(n)),i(n)}function gu(n,{ignoreFieldNorm:t=$.ignoreFieldNorm}){n.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:r,score:o})=>{const a=s?s.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:r))}),e.score=i})}function fu(n,t){const e=n.matches;t.matches=[],pe(e)&&e.forEach(i=>{if(!pe(i.indices)||!i.indices.length)return;const{indices:s,value:r}=i;let o={indices:s,value:r};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function mu(n,t){t.score=n.score}function bu(n,t,{includeMatches:e=$.includeMatches,includeScore:i=$.includeScore}={}){const s=[];return e&&s.push(fu),i&&s.push(mu),n.map(r=>{const{idx:o}=r,a={item:t[o],refIndex:o};return s.length&&s.forEach(l=>{l(r,a)}),a})}class cs{constructor(t,e={},i){this.options=Ji(Ji({},$),e),this.options.useExtendedSearch,this._keyStore=new Vd(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Oo))throw new Error($d);this._myIndex=e||tc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){pe(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,s=this._docs.length;i<s;i+=1){const r=this._docs[i];t(r,i)&&(this.removeAt(i),i-=1,s-=1,e.push(r))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:r,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Be(t)?Be(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return gu(l,{ignoreFieldNorm:a}),r&&l.sort(o),Kl(e)&&e>-1&&(l=l.slice(0,e)),bu(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=io(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:r,i:o,n:a})=>{if(!pe(r))return;const{isMatch:l,score:c,indices:h}=e.searchIn(r);l&&s.push({item:r,idx:o,matches:[{score:c,value:r,norm:a,indices:h}]})}),s}_searchLogical(t){const e=rc(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:d,searcher:u}=a,p=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:u});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let d=0,u=a.children.length;d<u;d+=1){const p=a.children[d],g=i(p,l,c);if(g.length)h.push(...g);else if(a.operator===Vr.AND)return[]}return h},s=this._myIndex.records,r={},o=[];return s.forEach(({$:a,i:l})=>{if(pe(a)){let c=i(e,a,l);c.length&&(r[l]||(r[l]={idx:l,item:a,matches:[]},o.push(r[l])),c.forEach(({matches:h})=>{r[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=io(t,this.options),{keys:i,records:s}=this._myIndex,r=[];return s.forEach(({$:o,i:a})=>{if(!pe(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&r.push({idx:a,item:o,matches:l})}),r}_findMatches({key:t,value:e,searcher:i}){if(!pe(e))return[];let s=[];if(si(e))e.forEach(({v:r,i:o,n:a})=>{if(!pe(r))return;const{isMatch:l,score:c,indices:h}=i.searchIn(r);l&&s.push({score:c,key:t,value:r,idx:o,norm:a,indices:h})});else{const{v:r,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(r);a&&s.push({score:l,key:t,value:r,norm:o,indices:c})}return s}}cs.version="7.0.0";cs.createIndex=tc;cs.parseIndex=Kd;cs.config=$;cs.parseQuery=rc;du(hu);var vu=(function(){function n(t){this._haystack=[],this._fuseOptions=Qt(Qt({},t.fuseOptions),{keys:td([],t.searchFields),includeMatches:!0})}return n.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},n.prototype.reset=function(){this._haystack=[],this._fuse=void 0},n.prototype.isEmptyIndex=function(){return!this._haystack.length},n.prototype.search=function(t){this._fuse||(this._fuse=new cs(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,s){return{item:i.item,score:i.score||0,rank:s+1}})},n})();function yu(n){return new vu(n)}var _u=function(n){for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0},In=function(n,t,e){var i=n.dataset,s=t.customProperties,r=t.labelClass,o=t.labelDescription;r&&(i.labelClass=on(r).join(" ")),o&&(i.labelDescription=o),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!_u(s)&&(i.customProperties=JSON.stringify(s)))},ja=function(n,t,e){var i=t&&n.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},xu={containerOuter:function(n,t,e,i,s,r,o){var a=n.classNames.containerOuter,l=document.createElement("div");return z(l,a),l.dataset.type=r,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):o||ja(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),o&&l.setAttribute("aria-labelledby",o),l},containerInner:function(n){var t=n.classNames.containerInner,e=document.createElement("div");return z(e,t),e},itemList:function(n,t){var e=n.searchEnabled,i=n.classNames,s=i.list,r=i.listSingle,o=i.listItems,a=document.createElement("div");return z(a,s),z(a,t?r:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(n,t){var e=n.allowHTML,i=n.classNames.placeholder,s=document.createElement("div");return z(s,i),Xe(s,e,t),s},item:function(n,t,e){var i=n.allowHTML,s=n.removeItemButtonAlignLeft,r=n.removeItemIconText,o=n.removeItemLabelText,a=n.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,p=Fi(t.value),g=document.createElement("div");if(z(g,l),t.labelClass){var f=document.createElement("span");Xe(f,i,t.label),z(f,t.labelClass),g.appendChild(f)}else Xe(g,i,t.label);if(g.dataset.item="",g.dataset.id=t.id,g.dataset.value=p,In(g,t,!0),(t.disabled||this.containerOuter.isDisabled)&&g.setAttribute("aria-disabled","true"),this._isSelectElement&&(g.setAttribute("aria-selected","true"),g.setAttribute("role","option")),t.placeholder&&(z(g,u),g.dataset.placeholder=""),z(g,t.highlighted?h:d),e){t.disabled&&$e(g,d),g.dataset.deletable="";var b=document.createElement("button");b.type="button",z(b,c),Xe(b,!0,Fs(r,t.value));var m=Fs(o,t.value);m&&b.setAttribute("aria-label",m),b.dataset.button="",s?g.insertAdjacentElement("afterbegin",b):g.appendChild(b)}return g},choiceList:function(n,t){var e=n.classNames.list,i=document.createElement("div");return z(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(n,t){var e=n.allowHTML,i=n.classNames,s=i.group,r=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Fi(l),d=document.createElement("div");z(d,s),c&&z(d,o),d.setAttribute("role","group"),d.dataset.group="",d.dataset.id=a,d.dataset.value=h,c&&d.setAttribute("aria-disabled","true");var u=document.createElement("div");return z(u,r),Xe(u,e,l||""),d.appendChild(u),d},choice:function(n,t,e,i){var s=n.allowHTML,r=n.classNames,o=r.item,a=r.itemChoice,l=r.itemSelectable,c=r.selectedState,h=r.itemDisabled,d=r.description,u=r.placeholder,p=t.label,g=Fi(t.value),f=document.createElement("div");f.id=t.elementId,z(f,o),z(f,a),i&&typeof p=="string"&&(p=ko(s,p),p+=" (".concat(i,")"),p={trusted:p});var b=f;if(t.labelClass){var m=document.createElement("span");Xe(m,s,p),z(m,t.labelClass),b=m,f.appendChild(m)}else Xe(f,s,p);if(t.labelDescription){var _="".concat(t.elementId,"-description");b.setAttribute("aria-describedby",_);var x=document.createElement("span");Xe(x,s,t.labelDescription),x.id=_,z(x,d),f.appendChild(x)}return t.selected&&z(f,c),t.placeholder&&z(f,u),f.setAttribute("role",t.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=t.id,f.dataset.value=g,e&&(f.dataset.selectText=e),t.group&&(f.dataset.groupId="".concat(t.group.id)),In(f,t,!1),t.disabled?(z(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(z(f,l),f.dataset.choiceSelectable=""),f},input:function(n,t){var e=n.classNames,i=e.input,s=e.inputCloned,r=n.labelId,o=document.createElement("input");return o.type="search",z(o,i),z(o,s),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):r||ja(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(n){var t=n.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return z(s,e),z(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(n,t,e){var i=n.classNames,s=i.item,r=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=Rt.generic);var h=document.createElement("div");switch(Xe(h,!0,t),z(h,s),z(h,r),z(h,c),e){case Rt.addChoice:z(h,o);break;case Rt.noResults:z(h,a);break;case Rt.noChoices:z(h,l);break}return e===Rt.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(n){var t=Fi(n.label),e=new Option(t,n.value,!1,n.selected);return In(e,n,!0),e.disabled=n.disabled,n.selected&&e.setAttribute("selected",""),e}},wu="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Cu={},Ln=function(n){if(n)return n.dataset.id?parseInt(n.dataset.id,10):void 0},xs="[data-choice-selectable]",nc=(function(){function n(t,e){t===void 0&&(t="[data-choice]"),e===void 0&&(e={});var i=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var s=n.defaults;this.config=Qt(Qt(Qt({},s.allOptions),s.options),e),ed.forEach(function(m){i.config[m]=Qt(Qt(Qt({},s.allOptions[m]),s.options[m]),e[m])});var r=this.config;r.silent||this._validateConfig();var o=r.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(xd(a)||ql(a)))throw TypeError(!a&&typeof t=="string"?"Selector ".concat(t," failed to find an element"):"Expected one of the following types text|select-one|select-multiple");var l=a.type,c=l===mi.Text;(c||r.maxItemCount!==1)&&(r.singleModeForMultiSelect=!1),r.singleModeForMultiSelect&&(l=mi.SelectMultiple);var h=l===mi.SelectOne,d=l===mi.SelectMultiple,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&r.addItems||u&&r.addChoices,typeof r.renderSelectedChoices!="boolean"&&(r.renderSelectedChoices=r.renderSelectedChoices==="always"||h),r.closeDropdownOnSelect==="auto"?r.closeDropdownOnSelect=c||h||r.singleModeForMultiSelect:r.closeDropdownOnSelect=Ds(r.closeDropdownOnSelect),r.placeholder&&(r.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,r.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);r.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new _d({element:a,classNames:r.classNames});else{var g=a;this.passedElement=new Sd({element:g,classNames:r.classNames,template:function(m){return i._templates.option(m)},extractPlaceholder:r.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new Pd(r),this._currentValue="",r.searchEnabled=!c&&r.searchEnabled||d,this._canSearch=r.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=ad(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction,b=window.getComputedStyle(document.documentElement).direction;f!==b&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=s.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive){r.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,this.initialisedOK=!1;return}this.init(),this._initialItems=this._store.items.map(function(m){return m.value})}return Object.defineProperty(n,"defaults",{get:function(){return Object.preventExtensions({get options(){return Cu},get allOptions(){return ka},get templates(){return xu}})},enumerable:!1,configurable:!0}),n.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=yu(this.config),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var t=this.config.callbackOnInit;typeof t=="function"&&t.call(this)}},n.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=n.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},n.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},n.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},n.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(nr(i,!0)),e&&this.passedElement.triggerEvent(Jt.highlightItem,this._getChoiceForOutput(i)),this)},n.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(nr(i,!1)),e&&this.passedElement.triggerEvent(Jt.unhighlightItem,this._getChoiceForOutput(i)),this)},n.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(nr(e,!0)),t.passedElement.triggerEvent(Jt.highlightItem,t._getChoiceForOutput(e)))})}),this},n.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(nr(e,!1)),t.passedElement.triggerEvent(Jt.highlightItem,t._getChoiceForOutput(e)))})}),this},n.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){return i.value===t}).forEach(function(i){return e._removeItem(i)})}),this},n.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var s=i.id;return s!==t}).forEach(function(i){return e._removeItem(i)})}),this},n.prototype.removeHighlightedItems=function(t){var e=this;return t===void 0&&(t=!1),this._store.withTxn(function(){e._store.highlightedActiveItems.forEach(function(i){e._removeItem(i),t&&e._triggerChange(i.value)})}),this},n.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive?this:(t===void 0&&(t=!this._canSearch),requestAnimationFrame(function(){e.dropdown.show();var i=e.dropdown.element.getBoundingClientRect();e.containerOuter.open(i.bottom,i.height),t||e.input.focus(),e.passedElement.triggerEvent(Jt.showDropdown)}),this)},n.prototype.hideDropdown=function(t){var e=this;return this.dropdown.isActive?(requestAnimationFrame(function(){e.dropdown.hide(),e.containerOuter.close(),!t&&e._canSearch&&(e.input.removeActiveDescendant(),e.input.blur()),e.passedElement.triggerEvent(Jt.hideDropdown)}),this):this},n.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(s){return t?s.value:e._getChoiceForOutput(s)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},n.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(je(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},n.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?this._isTextElement?this:(this._store.withTxn(function(){var i=Array.isArray(t)?t:[t];i.forEach(function(s){return e._findAndSelectChoiceByValue(s)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},n.prototype.setChoices=function(t,e,i,s,r,o){var a=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),r===void 0&&(r=!0),o===void 0&&(o=!1),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if(typeof e!="string"||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(typeof t=="function"){var l=t(this);if(typeof Promise=="function"&&l instanceof Promise)return new Promise(function(c){return requestAnimationFrame(c)}).then(function(){return a._handleLoadingState(!0)}).then(function(){return l}).then(function(c){return a.setChoices(c,e,i,s,r,o)}).catch(function(c){a.config.silent||console.error(c)}).then(function(){return a._handleLoadingState(!1)}).then(function(){return a});if(!Array.isArray(l))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof l));return this.setChoices(l,e,i,!1)}if(!Array.isArray(t))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn(function(){r&&(a._isSearching=!1),s&&a.clearChoices(!0,o);var c=e==="value",h=i==="label";t.forEach(function(d){if("choices"in d){var u=d;h||(u=Qt(Qt({},u),{label:u[i]})),a._addGroup(je(u,!0))}else{var p=d;(!h||!c)&&(p=Qt(Qt({},p),{value:p[e],label:p[i]}));var g=je(p,!1);a._addChoice(g),g.placeholder&&!a._hasNonChoicePlaceholder&&(a._placeholderValue=Gl(g.label))}}),a.unhighlightAll()}),this._searcher.reset(),this},n.prototype.refresh=function(t,e,i){var s=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var r=s.passedElement.optionsAsChoices(),o={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&(o[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(wa(l)):o[l.value]&&(l.selected=!0)};r.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),s._addPredefinedChoices(r,e,t),s._isSearching&&s._searchChoices(s.input.value)}),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},n.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(id(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Jt.removeItem,this._getChoiceForOutput(e)),this):this},n.prototype.clearChoices=function(t,e){var i=this;return t===void 0&&(t=!0),e===void 0&&(e=!1),t&&(e?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach(function(s){s.remove()})),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn(function(){var s=e?[]:i._store.items;i._store.reset(),s.forEach(function(r){i._store.dispatch(_a(r)),i._store.dispatch(xa(r))})}),this._searcher.reset(),this},n.prototype.clearStore=function(t){return t===void 0&&(t=!0),this.clearChoices(t,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},n.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},n.prototype._validateConfig=function(){var t=this.config,e=gd(t,ka);e.length&&console.warn("Unknown config option(s) passed",e.join(", ")),t.allowHTML&&t.allowHtmlUserInput&&(t.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),t.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},n.prototype._render=function(t){t===void 0&&(t={choices:!0,groups:!0,items:!0}),!this._store.inTxn()&&(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},n.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,r=this._store,o=r.activeGroups,a=r.activeChoices,l=0;if(s&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(g){return!g.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),d=function(g){return g.filter(function(f){return!f.placeholder&&(s?!!f.rank:i.renderSelectedChoices||!f.selected)})},u=!1,p=function(g,f,b){s?g.sort(ud):i.shouldSort&&g.sort(i.sorter);var m=g.length;m=!f&&l&&m>l?l:m,m--,g.every(function(_,x){var S=_.choiceEl||t._templates.choice(i,_,i.itemSelectText,b);return _.choiceEl=S,h.appendChild(S),(s||!_.selected)&&(u=!0),x<m})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!s&&this._isSelectOneElement&&p(a.filter(function(g){return g.placeholder&&!g.group}),!1,void 0),o.length&&!s?(i.shouldSort&&o.sort(i.sorter),p(a.filter(function(g){return!g.placeholder&&!g.group}),!1,void 0),o.forEach(function(g){var f=d(g.choices);if(f.length){if(g.label){var b=g.groupEl||t._templates.choiceGroup(t.config,g);g.groupEl=b,b.remove(),h.appendChild(b)}p(f,!0,i.appendGroupInSearch&&s?g.label:void 0)}})):p(d(a),!1,void 0)),!u&&(s||!h.children.length||!i.renderSelectedChoices)&&(this._notice||(this._notice={text:Sa(s?i.noResultsText:i.noChoicesText),type:s?Rt.noResults:Rt.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),u&&this._highlightChoice()}},n.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,r=document.createDocumentFragment(),o=function(d){return i.querySelector('[data-item][data-id="'.concat(d.id,'"]'))},a=function(d){var u=d.itemEl;u&&u.parentElement||(u=o(d)||t._templates.item(s,d,s.removeItemButton),d.itemEl=u,r.appendChild(u))};e.forEach(a);var l=!!r.childNodes.length;if(this._isSelectOneElement){var c=i.children.length;if(l||c>1){var h=i.querySelector(_s(s.classNames.placeholder));h&&h.remove()}else!l&&!c&&this._placeholderValue&&(l=!0,a(je({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}l&&(i.append(r),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(d){var u=o(d);u&&(u.remove(),r.append(u))}),i.append(r))),this._isTextElement&&(this.passedElement.value=e.map(function(d){var u=d.value;return u}).join(s.delimiter))},n.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var s=this._notice;if(s&&(s.type===e&&s.text===t||s.type===Rt.addChoice&&(e===Rt.noResults||e===Rt.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},n.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(_s(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},n.prototype._renderNotice=function(t){var e=this._notice;if(e){var i=this._templates.notice(this.config,e.text,e.type);t?t.append(i):this.choiceList.prepend(i)}},n.prototype._getChoiceForOutput=function(t,e){return{id:t.id,highlighted:t.highlighted,labelClass:t.labelClass,labelDescription:t.labelDescription,customProperties:t.customProperties,disabled:t.disabled,active:t.active,label:t.label,placeholder:t.placeholder,value:t.value,groupValue:t.group?t.group.label:void 0,element:t.element,keyCode:e}},n.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(Jt.change,{value:t})},n.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&Ln(t.parentElement),r=s&&i.find(function(o){return o.id===s});r&&this._store.withTxn(function(){if(e._removeItem(r),e._triggerChange(r.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=(e.config.shouldSort?e._store.choices.reverse():e._store.choices).find(function(a){return a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},n.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.items;if(!(!s.length||!this.config.removeItems||this._isSelectOneElement)){var r=Ln(t);r&&(s.forEach(function(o){o.id===r&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},n.prototype._handleChoiceAction=function(t){var e=this,i=Ln(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var r=this.dropdown.isActive;if(!s.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(s,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(s.value)}return r&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},n.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(r){return r.highlighted});e.editItems&&!s&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(s||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},n.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return je(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return je(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return je(o,!0)});var r=this.passedElement.optionsAsChoices();r&&(t=this._presetChoices).push.apply(t,r)}},n.prototype._handleLoadingState=function(t){t===void 0&&(t=!0);var e=this.itemList.element;t?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?e.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(e.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},n.prototype._handleSearch=function(t){if(this.input.isFocussed)if(t!==null&&typeof t<"u"&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;e!==null&&this.passedElement.triggerEvent(Jt.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},n.prototype._canAddItems=function(){var t=this.config,e=t.maxItemCount,i=t.maxItemText;return!t.singleModeForMultiSelect&&e>0&&e<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice(typeof i=="function"?i(e):i,Rt.addChoice),!1):(this._notice&&this._notice.type===Rt.addChoice&&this._clearNotice(),!0)},n.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=Fs(e.customAddItemText,t)),i){var r=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(r){if(this._isSelectElement)return this._displayNotice("",Rt.addChoice),!1;e.duplicateItemsAllowed||(i=!1,s=Fs(e.uniqueItemText,t))}}return i&&(s=Fs(e.addItemText,t)),s&&this._displayNotice(s,Rt.addChoice),i},n.prototype._searchChoices=function(t){var e=t.trim().replace(/\s{2,}/," ");if(!e.length||e===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var s=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var r=this._notice,o=r&&r.type;return o!==Rt.addChoice&&(s.length?this._clearNotice():this._displayNotice(Sa(this.config.noResultsText),Rt.noResults)),this._store.dispatch(sd(s)),s.length},n.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(rd(!0)),this.passedElement.triggerEvent(Jt.search,{value:"",resultCount:0}))},n.prototype._addEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.addEventListener("touchend",this._onTouchEnd,!0),e.addEventListener("keydown",this._onKeyDown,!0),e.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("click",this._onClick,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},n.prototype._removeEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.removeEventListener("touchend",this._onTouchEnd,!0),e.removeEventListener("keydown",this._onKeyDown,!0),e.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("click",this._onClick),t.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},n.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==Vt.ESC_KEY&&e!==Vt.TAB_KEY&&e!==Vt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Vt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Vt.ENTER_KEY:return this._onEnterKey(t,i);case Vt.ESC_KEY:return this._onEscapeKey(t,i);case Vt.UP_KEY:case Vt.PAGE_UP_KEY:case Vt.DOWN_KEY:case Vt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Vt.DELETE_KEY:case Vt.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},n.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},n.prototype._onInput=function(){var t=this.input.value;if(!t){this._isTextElement?this.hideDropdown(!0):this._stopSearch();return}this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice())))},n.prototype._onSelectKey=function(t,e){if((t.ctrlKey||t.metaKey)&&e){this._canSearch=!1;var i=this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement;i&&this.highlightAll()}},n.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,r=t.target;if(t.preventDefault(),r&&r.hasAttribute("data-button")){this._handleButtonAction(r);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(_s(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!r||!s){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(s,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(s))return;i._addChoice(je(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},n.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},n.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===Vt.DOWN_KEY||i===Vt.PAGE_DOWN_KEY?1:-1,r=t.metaKey||i===Vt.PAGE_DOWN_KEY||i===Vt.PAGE_UP_KEY,o=void 0;if(r)s>0?o=this.dropdown.element.querySelector("".concat(xs,":last-of-type")):o=this.dropdown.element.querySelector(xs);else{var a=this.dropdown.element.querySelector(_s(this.config.classNames.highlightedState));a?o=ld(a,xs,s):o=this.dropdown.element.querySelector(xs)}o&&(cd(o,this.choiceList.element,s)||this.choiceList.scrollToChildElement(o,s),this._highlightChoice(o)),t.preventDefault()}},n.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},n.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},n.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var s=e===this.containerOuter.element||e===this.containerInner.element;s&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},n.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(wu&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe=this._direction==="ltr"?t.offsetX>=i.offsetWidth:t.offsetX<i.offsetLeft}if(e!==this.input.element){var s=e.closest("[data-button],[data-item],[data-choice]");s instanceof HTMLElement&&("button"in s.dataset?this._handleButtonAction(s):"item"in s.dataset?this._handleItemAction(s,t.shiftKey):"choice"in s.dataset&&this._handleChoiceAction(s)),t.preventDefault()}}},n.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},n.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,s=i.element.contains(e);s?!this.dropdown.isActive&&!i.isDisabled?this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},n.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var r=e===this.input.element;this._isTextElement?r&&i.addFocusState():this._isSelectMultipleElement?r&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),r&&this.showDropdown(!0))}},n.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);s&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&(i.removeFocusState(),this._canSearch||this.hideDropdown(!0)):(this._isScrollingOnIe=!1,this.input.element.focus())},n.prototype._onFormReset=function(){var t=this;this._store.withTxn(function(){t.clearInput(),t.hideDropdown(),t.refresh(!1,!1,!0),t._initialItems.length&&t.setChoiceByValue(t._initialItems)})},n.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(xs));if(e.length){var i=t,s=this.config.classNames.highlightedState,r=Array.from(this.dropdown.element.querySelectorAll(_s(s)));r.forEach(function(o){$e(o,s),o.setAttribute("aria-selected","false")}),i?this._highlightPosition=e.indexOf(i):(e.length>this._highlightPosition?i=e[this._highlightPosition]:i=e[e.length-1],i||(i=e[0])),z(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Jt.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},n.prototype._addItem=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),!t.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(t.id),this._store.dispatch(xa(t)),e&&(this.passedElement.triggerEvent(Jt.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(Jt.choice,this._getChoiceForOutput(t)))},n.prototype._removeItem=function(t){if(t.id){this._store.dispatch(wa(t));var e=this._notice;e&&e.type===Rt.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(Jt.removeItem,this._getChoiceForOutput(t))}},n.prototype._addChoice=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),t.id)throw new TypeError("Can not re-add a choice which has already been added");var s=this.config;if(!(!s.duplicateItemsAllowed&&this._store.choices.find(function(a){return s.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var r=s.prependValue,o=s.appendValue;r&&(t.value=r+t.value),o&&(t.value+=o.toString()),(r||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(_a(t)),t.selected&&this._addItem(t,e,i)}},n.prototype._addGroup=function(t,e){var i=this;if(e===void 0&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(nd(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(s){s.group=t,t.disabled&&(s.disabled=!0),i._addChoice(s,e)}))},n.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,hd,ko,on));var s={};Object.keys(this._templates).forEach(function(r){r in i?s[r]=i[r].bind(t):s[r]=t._templates[r].bind(t)}),this._templates=s},n.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,r=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Ta({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:r}),this.containerInner=new Ta({element:t.containerInner(i),classNames:o,type:a,position:r}),this.input=new vd({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Ea({element:t.choiceList(i,s)}),this.itemList=new Ea({element:t.itemList(i,s)}),this.dropdown=new bd({element:t.dropdown(i),classNames:o,type:a})},n.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,r=this.dropdown.element;s.conceal(),e.wrap(s.element),i.wrap(e.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(e.element),i.element.appendChild(r),e.element.appendChild(this.itemList.element),r.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&r.insertBefore(this.input.element,r.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},n.prototype._initStore=function(){var t=this;this._store.subscribe(this._render).withTxn(function(){t._addPredefinedChoices(t._presetChoices,t._isSelectOneElement&&!t._hasNonChoicePlaceholder,!1)}),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},n.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var r=t.findIndex(function(o){return o.selected})===-1;r&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?s._isSelectElement&&s._addGroup(o,i):s._addChoice(o,i)})},n.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(r){return i.config.valueComparer(r.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},n.prototype._generatePlaceholderValue=function(){var t=this.config;if(!t.placeholder)return null;if(this._hasNonChoicePlaceholder)return t.placeholderValue;if(this._isSelectElement){var e=this.passedElement.placeholderOption;return e?e.text:null}return null},n.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent)if(this.initialised){if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}else throw new TypeError("".concat(t," called on a non-initialised instance of Choices"))},n.version="11.1.0",n})();const oc='.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:none}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:hover,.choices[data-type*=select-one] .choices__button:focus{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]:after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=text] .choices__button:hover,.choices[data-type*=text] .choices__button:focus{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media(min-width:640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]:after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted:after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus{outline:none}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input:focus{outline:0}.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}';class Ni{constructor(t,...e){this.slotNames=[],this.handleSlotChange=i=>{const s=i.target;(this.slotNames.includes("[default]")&&!s.name||s.name&&this.slotNames.includes(s.name))&&this.host.requestUpdate()},(this.host=t).addController(this),this.slotNames=e}hasDefaultSlot(){return[...this.host.childNodes].some(t=>{var e;if(t.nodeType===t.TEXT_NODE&&((e=t.textContent)==null?void 0:e.trim())!=="")return!0;if(t.nodeType===t.ELEMENT_NODE){const i=t;if(i.tagName.toLowerCase()==="pbo-visually-hidden")return!1;if(!i.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(t){return this.host.querySelector(`:scope > [slot="${t}"]`)!==null}test(t){return t==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(t)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}}/**
167
+ `;/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Jn=function(n,t){return Jn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},Jn(n,t)};function Wl(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Jn(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var ee=function(){return ee=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},ee.apply(this,arguments)};function td(n,t,e){for(var i=0,s=t.length,r;i<s;i++)(r||!(i in t))&&(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return n.concat(r||Array.prototype.slice.call(t))}var xt={ADD_CHOICE:"ADD_CHOICE",REMOVE_CHOICE:"REMOVE_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM"},te={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Vt={TAB_KEY:9,SHIFT_KEY:16,BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},ed=["fuseOptions","classNames"],mi={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},_a=function(n){return{type:xt.ADD_CHOICE,choice:n}},id=function(n){return{type:xt.REMOVE_CHOICE,choice:n}},sd=function(n){return{type:xt.FILTER_CHOICES,results:n}},rd=function(n){return{type:xt.ACTIVATE_CHOICES,active:n}},nd=function(n){return{type:xt.ADD_GROUP,group:n}},xa=function(n){return{type:xt.ADD_ITEM,item:n}},wa=function(n){return{type:xt.REMOVE_ITEM,item:n}},nr=function(n,t){return{type:xt.HIGHLIGHT_ITEM,item:n,highlighted:t}},od=function(n,t){return Math.floor(Math.random()*(t-n)+n)},Ca=function(n){return Array.from({length:n},function(){return od(0,36).toString(36)}).join("")},ad=function(n,t){var e=n.id||n.name&&"".concat(n.name,"-").concat(Ca(2))||Ca(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},ld=function(n,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=n[i];s;){if(s.matches(t))return s;s=s[i]}return null},cd=function(n,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=n.offsetTop+n.offsetHeight:i=n.offsetTop>=t.scrollTop,i},nn=function(n){if(typeof n!="string"){if(n==null)return"";if(typeof n=="object"){if("raw"in n)return nn(n.raw);if("trusted"in n)return n.trusted}return n}return n.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;")},hd=(function(){var n=document.createElement("div");return function(t){n.innerHTML=t.trim();for(var e=n.children[0];n.firstChild;)n.removeChild(n.firstChild);return e}})(),Fs=function(n,t){return typeof n=="function"?n(nn(t),t):n},Sa=function(n){return typeof n=="function"?n():n},ji=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("trusted"in n)return n.trusted;if("raw"in n)return n.raw}return""},Gl=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("escaped"in n)return n.escaped;if("trusted"in n)return n.trusted}return""},ko=function(n,t){return n?Gl(t):nn(t)},Xe=function(n,t,e){n.innerHTML=ko(t,e)},dd=function(n,t){var e=n.value,i=n.label,s=i===void 0?e:i,r=t.value,o=t.label,a=o===void 0?r:o;return ji(s).localeCompare(ji(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},ud=function(n,t){return n.rank-t.rank},pd=function(n,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return n.dispatchEvent(i)},gd=function(n,t){var e=Object.keys(n).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},on=function(n){return Array.isArray(n)?n:[n]},_s=function(n){return n&&Array.isArray(n)?n.map(function(t){return".".concat(t)}).join(""):".".concat(n)},z=function(n,t){var e;(e=n.classList).add.apply(e,on(t))},$e=function(n,t){var e;(e=n.classList).remove.apply(e,on(t))},fd=function(n){if(typeof n<"u")try{return JSON.parse(n)}catch{return n}return{}},md=function(n,t,e){var i=n.itemEl;i&&($e(i,e),z(i,t))},bd=(function(){function n(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return n.prototype.show=function(){return z(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},n.prototype.hide=function(){return $e(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},n})(),Ta=(function(){function n(t){var e=t.element,i=t.type,s=t.classNames,r=t.position;this.element=e,this.classNames=s,this.type=i,this.position=r,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return n.prototype.shouldFlip=function(t,e){var i=!1;return this.position==="auto"?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:this.position==="top"&&(i=!0),i},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype.open=function(t,e){z(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(z(this.element,this.classNames.flippedState),this.isFlipped=!0)},n.prototype.close=function(){$e(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&($e(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){z(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){$e(this.element,this.classNames.focusState)},n.prototype.enable=function(){$e(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===mi.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},n.prototype.disable=function(){z(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===mi.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},n.prototype.wrap=function(t){var e=this.element,i=t.parentNode;i&&(t.nextSibling?i.insertBefore(e,t.nextSibling):i.appendChild(e)),e.appendChild(t)},n.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},n.prototype.addLoadingState=function(){z(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},n.prototype.removeLoadingState=function(){$e(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},n})(),vd=(function(){function n(t){var e=t.element,i=t.type,s=t.classNames,r=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=r,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=e.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(n.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),n.prototype.addEventListeners=function(){var t=this.element;t.addEventListener("paste",this._onPaste),t.addEventListener("input",this._onInput,{passive:!0}),t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})},n.prototype.removeEventListeners=function(){var t=this.element;t.removeEventListener("input",this._onInput),t.removeEventListener("paste",this._onPaste),t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)},n.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},n.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},n.prototype.focus=function(){this.isFocussed||this.element.focus()},n.prototype.blur=function(){this.isFocussed&&this.element.blur()},n.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},n.prototype.setWidth=function(){var t=this.element;t.style.minWidth="".concat(t.placeholder.length+1,"ch"),t.style.width="".concat(t.value.length+1,"ch")},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype._onInput=function(){this.type!==mi.SelectOne&&this.setWidth()},n.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},n.prototype._onFocus=function(){this.isFocussed=!0},n.prototype._onBlur=function(){this.isFocussed=!1},n})(),yd=4,Ea=(function(){function n(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return n.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},n.prototype.scrollToTop=function(){this.element.scrollTop=0},n.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,r=this.element.scrollTop+s,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-r:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},n.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,r=s>1?s:1;this.element.scrollTop=t+r},n.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,r=s>1?s:1;this.element.scrollTop=t-r},n.prototype._animateScroll=function(t,e){var i=this,s=yd,r=this.element.scrollTop,o=!1;e>0?(this._scrollDown(r,s,t),r<t&&(o=!0)):(this._scrollUp(r,s,t),r>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},n})(),Yl=(function(){function n(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(n.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),n.prototype.conceal=function(){var t=this.element;z(t,this.classNames.input),t.hidden=!0,t.tabIndex=-1;var e=t.getAttribute("style");e&&t.setAttribute("data-choice-orig-style",e),t.setAttribute("data-choice","active")},n.prototype.reveal=function(){var t=this.element;$e(t,this.classNames.input),t.hidden=!1,t.removeAttribute("tabindex");var e=t.getAttribute("data-choice-orig-style");e?(t.removeAttribute("data-choice-orig-style"),t.setAttribute("style",e)):t.removeAttribute("style"),t.removeAttribute("data-choice")},n.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},n.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},n.prototype.triggerEvent=function(t,e){pd(this.element,t,e||{})},n})(),_d=(function(n){Wl(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(Yl),Ds=function(n,t){return t===void 0&&(t=!0),typeof n>"u"?t:!!n},Xl=function(n){if(typeof n=="string"&&(n=n.split(" ").filter(function(t){return t.length})),Array.isArray(n)&&n.length)return n},je=function(n,t,e){if(e===void 0&&(e=!0),typeof n=="string"){var i=nn(n),s=e||i===n?n:{escaped:i,raw:n},r=je({value:n,label:s,selected:!0},!1);return r}var o=n;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(u){return je(u,!1)}),c={id:0,label:ji(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,d={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Ds(h.active),selected:Ds(h.selected,!1),disabled:Ds(h.disabled,!1),placeholder:Ds(h.placeholder,!1),highlighted:!1,labelClass:Xl(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return d},xd=function(n){return n.tagName==="INPUT"},ql=function(n){return n.tagName==="SELECT"},wd=function(n){return n.tagName==="OPTION"},Cd=function(n){return n.tagName==="OPTGROUP"},Sd=(function(n){Wl(t,n);function t(e){var i=e.element,s=e.classNames,r=e.template,o=e.extractPlaceholder,a=n.call(this,{element:i,classNames:s})||this;return a.template=r,a.extractPlaceholder=o,a}return Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),t.prototype.addOptions=function(e){var i=this,s=document.createDocumentFragment();e.forEach(function(r){var o=r;if(!o.element){var a=i.template(o);s.appendChild(a),o.element=a}}),this.element.appendChild(s)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(s){wd(s)?i.push(e._optionToChoice(s)):Cd(s)&&i.push(e._optgroupToChoice(s))}),i},t.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:typeof e.dataset.labelClass<"u"?Xl(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:fd(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),r=Array.from(s).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!r.length,disabled:e.disabled,choices:r}},t})(Yl),Td={containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},ka={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(n){return!!n&&n!==""},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:dd,shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(n){return'Press Enter to add <b>"'.concat(n,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(n){return"Remove item: ".concat(n)},maxItemText:function(n){return"Only ".concat(n," values can be added")},valueComparer:function(n,t){return n===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:Td,appendGroupInSearch:!1},Oa=function(n){var t=n.itemEl;t&&(t.remove(),n.itemEl=void 0)};function Ed(n,t,e){var i=n,s=!0;switch(t.type){case xt.ADD_ITEM:{t.item.selected=!0;var r=t.item.element;r&&(r.selected=!0,r.setAttribute("selected","")),i.push(t.item);break}case xt.REMOVE_ITEM:{t.item.selected=!1;var r=t.item.element;if(r){r.selected=!1,r.removeAttribute("selected");var o=r.parentElement;o&&ql(o)&&o.type===mi.SelectOne&&(o.value="")}Oa(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case xt.REMOVE_CHOICE:{Oa(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case xt.HIGHLIGHT_ITEM:{var a=t.highlighted,l=i.find(function(c){return c.id===t.item.id});l&&l.highlighted!==a&&(l.highlighted=a,e&&md(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{s=!1;break}}return{state:i,update:s}}function kd(n,t){var e=n,i=!0;switch(t.type){case xt.ADD_GROUP:{e.push(t.group);break}case xt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function Od(n,t,e){var i=n,s=!0;switch(t.type){case xt.ADD_CHOICE:{i.push(t.choice);break}case xt.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(o){return o.id!==t.choice.id})),i=i.filter(function(o){return o.id!==t.choice.id});break}case xt.ADD_ITEM:case xt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case xt.FILTER_CHOICES:{var r=[];t.results.forEach(function(o){r[o.item.id]=o}),i.forEach(function(o){var a=r[o.id];a!==void 0?(o.score=a.score,o.rank=a.rank,o.active=!0):(o.score=0,o.rank=0,o.active=!1),e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case xt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case xt.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var Pa={groups:kd,items:Ed,choices:Od},Pd=(function(){function n(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(n.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),n.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},n.prototype.reset=function(){this._state=this.defaultState;var t=this.changeSet(!0);this._txn?this._changeSet=t:this._listeners.forEach(function(e){return e(t)})},n.prototype.subscribe=function(t){return this._listeners.push(t),this},n.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,r=this._changeSet||this.changeSet(!1);Object.keys(Pa).forEach(function(o){var a=Pa[o](i[o],t,e._context);a.update&&(s=!0,r[o]=!0,i[o]=a.state)}),s&&(this._txn?this._changeSet=r:this._listeners.forEach(function(o){return o(r)}))},n.prototype.withTxn=function(t){this._txn++;try{t()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var e=this._changeSet;e&&(this._changeSet=void 0,this._listeners.forEach(function(i){return i(e)}))}}},Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter(function(e){var i=e.active&&!e.disabled,s=t.state.choices.some(function(r){return r.active&&!r.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),n.prototype.inTxn=function(){return this._txn>0},n.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},n.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},n})(),Rt={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function Dd(n,t,e){return(t=Md(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Da(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function Ji(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Da(Object(e),!0).forEach(function(i){Dd(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Da(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function Ad(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function Md(n){var t=Ad(n,"string");return typeof t=="symbol"?t:t+""}function si(n){return Array.isArray?Array.isArray(n):Jl(n)==="[object Array]"}function Id(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function Ld(n){return n==null?"":Id(n)}function Be(n){return typeof n=="string"}function Kl(n){return typeof n=="number"}function Fd(n){return n===!0||n===!1||jd(n)&&Jl(n)=="[object Boolean]"}function Zl(n){return typeof n=="object"}function jd(n){return Zl(n)&&n!==null}function pe(n){return n!=null}function Mn(n){return!n.trim().length}function Jl(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const $d="Incorrect 'index' type",Rd=n=>`Invalid value for key ${n}`,Bd=n=>`Pattern length exceeds max of ${n}.`,zd=n=>`Missing ${n} property in key`,Hd=n=>`Property 'weight' in key '${n}' must be a positive integer`,Aa=Object.prototype.hasOwnProperty;class Vd{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=Ql(i);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ql(n){let t=null,e=null,i=null,s=1,r=null;if(Be(n)||si(n))i=n,t=Ma(n),e=Qn(n);else{if(!Aa.call(n,"name"))throw new Error(zd("name"));const o=n.name;if(i=o,Aa.call(n,"weight")&&(s=n.weight,s<=0))throw new Error(Hd(o));t=Ma(o),e=Qn(o),r=n.getFn}return{path:t,id:e,weight:s,src:i,getFn:r}}function Ma(n){return si(n)?n:n.split(".")}function Qn(n){return si(n)?n.join("."):n}function Nd(n,t){let e=[],i=!1;const s=(r,o,a)=>{if(pe(r))if(!o[a])e.push(r);else{let l=o[a];const c=r[l];if(!pe(c))return;if(a===o.length-1&&(Be(c)||Kl(c)||Fd(c)))e.push(Ld(c));else if(si(c)){i=!0;for(let h=0,d=c.length;h<d;h+=1)s(c[h],o,a+1)}else o.length&&s(c,o,a+1)}};return s(n,Be(t)?t.split("."):t,0),i?e:e[0]}const Ud={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Wd={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},Gd={location:0,threshold:.6,distance:100},Yd={useExtendedSearch:!1,getFn:Nd,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var $=Ji(Ji(Ji(Ji({},Wd),Ud),Gd),Yd);const Xd=/[^ ]+/g;function qd(n=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const r=s.match(Xd).length;if(e.has(r))return e.get(r);const o=1/Math.pow(r,.5*n),a=parseFloat(Math.round(o*i)/i);return e.set(r,a),a},clear(){e.clear()}}}class Oo{constructor({getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){this.norm=qd(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,i)=>{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Be(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();Be(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e<i;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!pe(t)||Mn(t))return;let i={v:t,i:e,n:this.norm.get(t)};this.records.push(i)}_addObject(t,e){let i={i:e,$:{}};this.keys.forEach((s,r)=>{let o=s.getFn?s.getFn(t):this.getFn(t,s.path);if(pe(o)){if(si(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(pe(h))if(Be(h)&&!Mn(h)){let d={v:h,i:c,n:this.norm.get(h)};a.push(d)}else si(h)&&h.forEach((d,u)=>{l.push({nestedArrIndex:u,value:d})})}i.$[r]=a}else if(Be(o)&&!Mn(o)){let a={v:o,n:this.norm.get(o)};i.$[r]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function tc(n,t,{getFn:e=$.getFn,fieldNormWeight:i=$.fieldNormWeight}={}){const s=new Oo({getFn:e,fieldNormWeight:i});return s.setKeys(n.map(Ql)),s.setSources(t),s.create(),s}function Kd(n,{getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){const{keys:i,records:s}=n,r=new Oo({getFn:t,fieldNormWeight:e});return r.setKeys(i),r.setIndexRecords(s),r}function or(n,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=$.distance,ignoreLocation:r=$.ignoreLocation}={}){const o=t/n.length;if(r)return o;const a=Math.abs(i-e);return s?o+a/s:a?1:o}function Zd(n=[],t=$.minMatchCharLength){let e=[],i=-1,s=-1,r=0;for(let o=n.length;r<o;r+=1){let a=n[r];a&&i===-1?i=r:!a&&i!==-1&&(s=r-1,s-i+1>=t&&e.push([i,s]),i=-1)}return n[r-1]&&r-i>=t&&e.push([i,r-1]),e}const Ai=32;function Jd(n,t,e,{location:i=$.location,distance:s=$.distance,threshold:r=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,includeMatches:l=$.includeMatches,ignoreLocation:c=$.ignoreLocation}={}){if(t.length>Ai)throw new Error(Bd(Ai));const h=t.length,d=n.length,u=Math.max(0,Math.min(i,d));let p=r,g=u;const f=a>1||l,b=f?Array(d):[];let m;for(;(m=n.indexOf(t,g))>-1;){let O=or(t,{currentLocation:m,expectedLocation:u,distance:s,ignoreLocation:c});if(p=Math.min(O,p),g=m+h,f){let E=0;for(;E<h;)b[m+E]=1,E+=1}}g=-1;let y=[],w=1,S=h+d;const T=1<<h-1;for(let O=0;O<h;O+=1){let E=0,P=S;for(;E<P;)or(t,{errors:O,currentLocation:u+P,expectedLocation:u,distance:s,ignoreLocation:c})<=p?E=P:S=P,P=Math.floor((S-E)/2+E);S=P;let R=Math.max(1,u-P+1),L=o?d:Math.min(u+P,d)+h,j=Array(L+2);j[L+1]=(1<<O)-1;for(let M=L;M>=R;M-=1){let U=M-1,q=e[n.charAt(U)];if(f&&(b[U]=+!!q),j[M]=(j[M+1]<<1|1)&q,O&&(j[M]|=(y[M+1]|y[M])<<1|1|y[M+1]),j[M]&T&&(w=or(t,{errors:O,currentLocation:U,expectedLocation:u,distance:s,ignoreLocation:c}),w<=p)){if(p=w,g=U,g<=u)break;R=Math.max(1,2*u-g)}}if(or(t,{errors:O+1,currentLocation:u,expectedLocation:u,distance:s,ignoreLocation:c})>p)break;y=j}const k={isMatch:g>=0,score:Math.max(.001,w)};if(f){const O=Zd(b,a);O.length?l&&(k.indices=O):k.isMatch=!1}return k}function Qd(n){let t={};for(let e=0,i=n.length;e<i;e+=1){const s=n.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class ec{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:r=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(u,p)=>{this.chunks.push({pattern:u,alphabet:Qd(u),startIndex:p})},d=this.pattern.length;if(d>Ai){let u=0;const p=d%Ai,g=d-p;for(;u<g;)h(this.pattern.substr(u,Ai),u),u+=Ai;if(p){const f=d-Ai;h(this.pattern.substr(f),f)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let g={isMatch:!0,score:0};return i&&(g.indices=[[0,t.length-1]]),g}const{location:s,distance:r,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],d=0,u=!1;this.chunks.forEach(({pattern:g,alphabet:f,startIndex:b})=>{const{isMatch:m,score:y,indices:w}=Jd(t,g,f,{location:s+b,distance:r,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});m&&(u=!0),d+=y,m&&w&&(h=[...h,...w])});let p={isMatch:u,score:u?d/this.chunks.length:1};return u&&i&&(p.indices=h),p}}class Ti{constructor(t){this.pattern=t}static isMultiMatch(t){return Ia(t,this.multiRegex)}static isSingleMatch(t){return Ia(t,this.singleRegex)}search(){}}function Ia(n,t){const e=n.match(t);return e?e[1]:null}class tu extends Ti{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class eu extends Ti{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class iu extends Ti{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class su extends Ti{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class ru extends Ti{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class nu extends Ti{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class ic extends Ti{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:r=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){super(t),this._bitapSearch=new ec(t,{location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class sc extends Ti{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const s=[],r=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+r,s.push([i,e-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const to=[tu,sc,iu,su,nu,ru,eu,ic],La=to.length,ou=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,au="|";function lu(n,t={}){return n.split(au).map(e=>{let i=e.trim().split(ou).filter(r=>r&&!!r.trim()),s=[];for(let r=0,o=i.length;r<o;r+=1){const a=i[r];let l=!1,c=-1;for(;!l&&++c<La;){const h=to[c];let d=h.isMultiMatch(a);d&&(s.push(new h(d,t)),l=!0)}if(!l)for(c=-1;++c<La;){const h=to[c];let d=h.isSingleMatch(a);if(d){s.push(new h(d,t));break}}}return s})}const cu=new Set([ic.type,sc.type]);class hu{constructor(t,{isCaseSensitive:e=$.isCaseSensitive,includeMatches:i=$.includeMatches,minMatchCharLength:s=$.minMatchCharLength,ignoreLocation:r=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:a=$.location,threshold:l=$.threshold,distance:c=$.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:o,ignoreLocation:r,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=lu(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let r=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,r=0;for(let d=0,u=h.length;d<u;d+=1){const p=h[d],{isMatch:g,indices:f,score:b}=p.search(t);if(g){if(r+=1,a+=b,i){const m=p.constructor.type;cu.has(m)?o=[...o,...f]:o.push(f)}}else{a=0,r=0,o.length=0;break}}if(r){let d={isMatch:!0,score:a/r};return i&&(d.indices=o),d}}return{isMatch:!1,score:1}}}const eo=[];function du(...n){eo.push(...n)}function io(n,t){for(let e=0,i=eo.length;e<i;e+=1){let s=eo[e];if(s.condition(n,t))return new s(n,t)}return new ec(n,t)}const Vr={AND:"$and",OR:"$or"},so={PATH:"$path",PATTERN:"$val"},ro=n=>!!(n[Vr.AND]||n[Vr.OR]),uu=n=>!!n[so.PATH],pu=n=>!si(n)&&Zl(n)&&!ro(n),Fa=n=>({[Vr.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function rc(n,t,{auto:e=!0}={}){const i=s=>{let r=Object.keys(s);const o=uu(s);if(!o&&r.length>1&&!ro(s))return i(Fa(s));if(pu(s)){const l=o?s[so.PATH]:r[0],c=o?s[so.PATTERN]:s[l];if(!Be(c))throw new Error(Rd(l));const h={keyId:Qn(l),pattern:c};return e&&(h.searcher=io(c,t)),h}let a={children:[],operator:r[0]};return r.forEach(l=>{const c=s[l];si(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return ro(n)||(n=Fa(n)),i(n)}function gu(n,{ignoreFieldNorm:t=$.ignoreFieldNorm}){n.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:r,score:o})=>{const a=s?s.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:r))}),e.score=i})}function fu(n,t){const e=n.matches;t.matches=[],pe(e)&&e.forEach(i=>{if(!pe(i.indices)||!i.indices.length)return;const{indices:s,value:r}=i;let o={indices:s,value:r};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function mu(n,t){t.score=n.score}function bu(n,t,{includeMatches:e=$.includeMatches,includeScore:i=$.includeScore}={}){const s=[];return e&&s.push(fu),i&&s.push(mu),n.map(r=>{const{idx:o}=r,a={item:t[o],refIndex:o};return s.length&&s.forEach(l=>{l(r,a)}),a})}class cs{constructor(t,e={},i){this.options=Ji(Ji({},$),e),this.options.useExtendedSearch,this._keyStore=new Vd(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Oo))throw new Error($d);this._myIndex=e||tc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){pe(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,s=this._docs.length;i<s;i+=1){const r=this._docs[i];t(r,i)&&(this.removeAt(i),i-=1,s-=1,e.push(r))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:r,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Be(t)?Be(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return gu(l,{ignoreFieldNorm:a}),r&&l.sort(o),Kl(e)&&e>-1&&(l=l.slice(0,e)),bu(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=io(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:r,i:o,n:a})=>{if(!pe(r))return;const{isMatch:l,score:c,indices:h}=e.searchIn(r);l&&s.push({item:r,idx:o,matches:[{score:c,value:r,norm:a,indices:h}]})}),s}_searchLogical(t){const e=rc(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:d,searcher:u}=a,p=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:u});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let d=0,u=a.children.length;d<u;d+=1){const p=a.children[d],g=i(p,l,c);if(g.length)h.push(...g);else if(a.operator===Vr.AND)return[]}return h},s=this._myIndex.records,r={},o=[];return s.forEach(({$:a,i:l})=>{if(pe(a)){let c=i(e,a,l);c.length&&(r[l]||(r[l]={idx:l,item:a,matches:[]},o.push(r[l])),c.forEach(({matches:h})=>{r[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=io(t,this.options),{keys:i,records:s}=this._myIndex,r=[];return s.forEach(({$:o,i:a})=>{if(!pe(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&r.push({idx:a,item:o,matches:l})}),r}_findMatches({key:t,value:e,searcher:i}){if(!pe(e))return[];let s=[];if(si(e))e.forEach(({v:r,i:o,n:a})=>{if(!pe(r))return;const{isMatch:l,score:c,indices:h}=i.searchIn(r);l&&s.push({score:c,key:t,value:r,idx:o,norm:a,indices:h})});else{const{v:r,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(r);a&&s.push({score:l,key:t,value:r,norm:o,indices:c})}return s}}cs.version="7.0.0";cs.createIndex=tc;cs.parseIndex=Kd;cs.config=$;cs.parseQuery=rc;du(hu);var vu=(function(){function n(t){this._haystack=[],this._fuseOptions=ee(ee({},t.fuseOptions),{keys:td([],t.searchFields),includeMatches:!0})}return n.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},n.prototype.reset=function(){this._haystack=[],this._fuse=void 0},n.prototype.isEmptyIndex=function(){return!this._haystack.length},n.prototype.search=function(t){this._fuse||(this._fuse=new cs(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,s){return{item:i.item,score:i.score||0,rank:s+1}})},n})();function yu(n){return new vu(n)}var _u=function(n){for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0},In=function(n,t,e){var i=n.dataset,s=t.customProperties,r=t.labelClass,o=t.labelDescription;r&&(i.labelClass=on(r).join(" ")),o&&(i.labelDescription=o),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!_u(s)&&(i.customProperties=JSON.stringify(s)))},ja=function(n,t,e){var i=t&&n.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},xu={containerOuter:function(n,t,e,i,s,r,o){var a=n.classNames.containerOuter,l=document.createElement("div");return z(l,a),l.dataset.type=r,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):o||ja(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),o&&l.setAttribute("aria-labelledby",o),l},containerInner:function(n){var t=n.classNames.containerInner,e=document.createElement("div");return z(e,t),e},itemList:function(n,t){var e=n.searchEnabled,i=n.classNames,s=i.list,r=i.listSingle,o=i.listItems,a=document.createElement("div");return z(a,s),z(a,t?r:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(n,t){var e=n.allowHTML,i=n.classNames.placeholder,s=document.createElement("div");return z(s,i),Xe(s,e,t),s},item:function(n,t,e){var i=n.allowHTML,s=n.removeItemButtonAlignLeft,r=n.removeItemIconText,o=n.removeItemLabelText,a=n.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,p=ji(t.value),g=document.createElement("div");if(z(g,l),t.labelClass){var f=document.createElement("span");Xe(f,i,t.label),z(f,t.labelClass),g.appendChild(f)}else Xe(g,i,t.label);if(g.dataset.item="",g.dataset.id=t.id,g.dataset.value=p,In(g,t,!0),(t.disabled||this.containerOuter.isDisabled)&&g.setAttribute("aria-disabled","true"),this._isSelectElement&&(g.setAttribute("aria-selected","true"),g.setAttribute("role","option")),t.placeholder&&(z(g,u),g.dataset.placeholder=""),z(g,t.highlighted?h:d),e){t.disabled&&$e(g,d),g.dataset.deletable="";var b=document.createElement("button");b.type="button",z(b,c),Xe(b,!0,Fs(r,t.value));var m=Fs(o,t.value);m&&b.setAttribute("aria-label",m),b.dataset.button="",s?g.insertAdjacentElement("afterbegin",b):g.appendChild(b)}return g},choiceList:function(n,t){var e=n.classNames.list,i=document.createElement("div");return z(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(n,t){var e=n.allowHTML,i=n.classNames,s=i.group,r=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=ji(l),d=document.createElement("div");z(d,s),c&&z(d,o),d.setAttribute("role","group"),d.dataset.group="",d.dataset.id=a,d.dataset.value=h,c&&d.setAttribute("aria-disabled","true");var u=document.createElement("div");return z(u,r),Xe(u,e,l||""),d.appendChild(u),d},choice:function(n,t,e,i){var s=n.allowHTML,r=n.classNames,o=r.item,a=r.itemChoice,l=r.itemSelectable,c=r.selectedState,h=r.itemDisabled,d=r.description,u=r.placeholder,p=t.label,g=ji(t.value),f=document.createElement("div");f.id=t.elementId,z(f,o),z(f,a),i&&typeof p=="string"&&(p=ko(s,p),p+=" (".concat(i,")"),p={trusted:p});var b=f;if(t.labelClass){var m=document.createElement("span");Xe(m,s,p),z(m,t.labelClass),b=m,f.appendChild(m)}else Xe(f,s,p);if(t.labelDescription){var y="".concat(t.elementId,"-description");b.setAttribute("aria-describedby",y);var w=document.createElement("span");Xe(w,s,t.labelDescription),w.id=y,z(w,d),f.appendChild(w)}return t.selected&&z(f,c),t.placeholder&&z(f,u),f.setAttribute("role",t.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=t.id,f.dataset.value=g,e&&(f.dataset.selectText=e),t.group&&(f.dataset.groupId="".concat(t.group.id)),In(f,t,!1),t.disabled?(z(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(z(f,l),f.dataset.choiceSelectable=""),f},input:function(n,t){var e=n.classNames,i=e.input,s=e.inputCloned,r=n.labelId,o=document.createElement("input");return o.type="search",z(o,i),z(o,s),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):r||ja(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(n){var t=n.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return z(s,e),z(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(n,t,e){var i=n.classNames,s=i.item,r=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=Rt.generic);var h=document.createElement("div");switch(Xe(h,!0,t),z(h,s),z(h,r),z(h,c),e){case Rt.addChoice:z(h,o);break;case Rt.noResults:z(h,a);break;case Rt.noChoices:z(h,l);break}return e===Rt.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(n){var t=ji(n.label),e=new Option(t,n.value,!1,n.selected);return In(e,n,!0),e.disabled=n.disabled,n.selected&&e.setAttribute("selected",""),e}},wu="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Cu={},Ln=function(n){if(n)return n.dataset.id?parseInt(n.dataset.id,10):void 0},xs="[data-choice-selectable]",nc=(function(){function n(t,e){t===void 0&&(t="[data-choice]"),e===void 0&&(e={});var i=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var s=n.defaults;this.config=ee(ee(ee({},s.allOptions),s.options),e),ed.forEach(function(m){i.config[m]=ee(ee(ee({},s.allOptions[m]),s.options[m]),e[m])});var r=this.config;r.silent||this._validateConfig();var o=r.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(xd(a)||ql(a)))throw TypeError(!a&&typeof t=="string"?"Selector ".concat(t," failed to find an element"):"Expected one of the following types text|select-one|select-multiple");var l=a.type,c=l===mi.Text;(c||r.maxItemCount!==1)&&(r.singleModeForMultiSelect=!1),r.singleModeForMultiSelect&&(l=mi.SelectMultiple);var h=l===mi.SelectOne,d=l===mi.SelectMultiple,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&r.addItems||u&&r.addChoices,typeof r.renderSelectedChoices!="boolean"&&(r.renderSelectedChoices=r.renderSelectedChoices==="always"||h),r.closeDropdownOnSelect==="auto"?r.closeDropdownOnSelect=c||h||r.singleModeForMultiSelect:r.closeDropdownOnSelect=Ds(r.closeDropdownOnSelect),r.placeholder&&(r.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,r.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);r.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new _d({element:a,classNames:r.classNames});else{var g=a;this.passedElement=new Sd({element:g,classNames:r.classNames,template:function(m){return i._templates.option(m)},extractPlaceholder:r.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new Pd(r),this._currentValue="",r.searchEnabled=!c&&r.searchEnabled||d,this._canSearch=r.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=ad(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction,b=window.getComputedStyle(document.documentElement).direction;f!==b&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=s.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive){r.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,this.initialisedOK=!1;return}this.init(),this._initialItems=this._store.items.map(function(m){return m.value})}return Object.defineProperty(n,"defaults",{get:function(){return Object.preventExtensions({get options(){return Cu},get allOptions(){return ka},get templates(){return xu}})},enumerable:!1,configurable:!0}),n.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=yu(this.config),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var t=this.config.callbackOnInit;typeof t=="function"&&t.call(this)}},n.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=n.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},n.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},n.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},n.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(nr(i,!0)),e&&this.passedElement.triggerEvent(te.highlightItem,this._getChoiceForOutput(i)),this)},n.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(nr(i,!1)),e&&this.passedElement.triggerEvent(te.unhighlightItem,this._getChoiceForOutput(i)),this)},n.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(nr(e,!0)),t.passedElement.triggerEvent(te.highlightItem,t._getChoiceForOutput(e)))})}),this},n.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(nr(e,!1)),t.passedElement.triggerEvent(te.highlightItem,t._getChoiceForOutput(e)))})}),this},n.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){return i.value===t}).forEach(function(i){return e._removeItem(i)})}),this},n.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var s=i.id;return s!==t}).forEach(function(i){return e._removeItem(i)})}),this},n.prototype.removeHighlightedItems=function(t){var e=this;return t===void 0&&(t=!1),this._store.withTxn(function(){e._store.highlightedActiveItems.forEach(function(i){e._removeItem(i),t&&e._triggerChange(i.value)})}),this},n.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive?this:(t===void 0&&(t=!this._canSearch),requestAnimationFrame(function(){e.dropdown.show();var i=e.dropdown.element.getBoundingClientRect();e.containerOuter.open(i.bottom,i.height),t||e.input.focus(),e.passedElement.triggerEvent(te.showDropdown)}),this)},n.prototype.hideDropdown=function(t){var e=this;return this.dropdown.isActive?(requestAnimationFrame(function(){e.dropdown.hide(),e.containerOuter.close(),!t&&e._canSearch&&(e.input.removeActiveDescendant(),e.input.blur()),e.passedElement.triggerEvent(te.hideDropdown)}),this):this},n.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(s){return t?s.value:e._getChoiceForOutput(s)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},n.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(je(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},n.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?this._isTextElement?this:(this._store.withTxn(function(){var i=Array.isArray(t)?t:[t];i.forEach(function(s){return e._findAndSelectChoiceByValue(s)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},n.prototype.setChoices=function(t,e,i,s,r,o){var a=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),r===void 0&&(r=!0),o===void 0&&(o=!1),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if(typeof e!="string"||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(typeof t=="function"){var l=t(this);if(typeof Promise=="function"&&l instanceof Promise)return new Promise(function(c){return requestAnimationFrame(c)}).then(function(){return a._handleLoadingState(!0)}).then(function(){return l}).then(function(c){return a.setChoices(c,e,i,s,r,o)}).catch(function(c){a.config.silent||console.error(c)}).then(function(){return a._handleLoadingState(!1)}).then(function(){return a});if(!Array.isArray(l))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof l));return this.setChoices(l,e,i,!1)}if(!Array.isArray(t))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn(function(){r&&(a._isSearching=!1),s&&a.clearChoices(!0,o);var c=e==="value",h=i==="label";t.forEach(function(d){if("choices"in d){var u=d;h||(u=ee(ee({},u),{label:u[i]})),a._addGroup(je(u,!0))}else{var p=d;(!h||!c)&&(p=ee(ee({},p),{value:p[e],label:p[i]}));var g=je(p,!1);a._addChoice(g),g.placeholder&&!a._hasNonChoicePlaceholder&&(a._placeholderValue=Gl(g.label))}}),a.unhighlightAll()}),this._searcher.reset(),this},n.prototype.refresh=function(t,e,i){var s=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var r=s.passedElement.optionsAsChoices(),o={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&(o[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(wa(l)):o[l.value]&&(l.selected=!0)};r.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),s._addPredefinedChoices(r,e,t),s._isSearching&&s._searchChoices(s.input.value)}),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},n.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(id(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(te.removeItem,this._getChoiceForOutput(e)),this):this},n.prototype.clearChoices=function(t,e){var i=this;return t===void 0&&(t=!0),e===void 0&&(e=!1),t&&(e?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach(function(s){s.remove()})),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn(function(){var s=e?[]:i._store.items;i._store.reset(),s.forEach(function(r){i._store.dispatch(_a(r)),i._store.dispatch(xa(r))})}),this._searcher.reset(),this},n.prototype.clearStore=function(t){return t===void 0&&(t=!0),this.clearChoices(t,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},n.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},n.prototype._validateConfig=function(){var t=this.config,e=gd(t,ka);e.length&&console.warn("Unknown config option(s) passed",e.join(", ")),t.allowHTML&&t.allowHtmlUserInput&&(t.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),t.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},n.prototype._render=function(t){t===void 0&&(t={choices:!0,groups:!0,items:!0}),!this._store.inTxn()&&(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},n.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,r=this._store,o=r.activeGroups,a=r.activeChoices,l=0;if(s&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(g){return!g.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),d=function(g){return g.filter(function(f){return!f.placeholder&&(s?!!f.rank:i.renderSelectedChoices||!f.selected)})},u=!1,p=function(g,f,b){s?g.sort(ud):i.shouldSort&&g.sort(i.sorter);var m=g.length;m=!f&&l&&m>l?l:m,m--,g.every(function(y,w){var S=y.choiceEl||t._templates.choice(i,y,i.itemSelectText,b);return y.choiceEl=S,h.appendChild(S),(s||!y.selected)&&(u=!0),w<m})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!s&&this._isSelectOneElement&&p(a.filter(function(g){return g.placeholder&&!g.group}),!1,void 0),o.length&&!s?(i.shouldSort&&o.sort(i.sorter),p(a.filter(function(g){return!g.placeholder&&!g.group}),!1,void 0),o.forEach(function(g){var f=d(g.choices);if(f.length){if(g.label){var b=g.groupEl||t._templates.choiceGroup(t.config,g);g.groupEl=b,b.remove(),h.appendChild(b)}p(f,!0,i.appendGroupInSearch&&s?g.label:void 0)}})):p(d(a),!1,void 0)),!u&&(s||!h.children.length||!i.renderSelectedChoices)&&(this._notice||(this._notice={text:Sa(s?i.noResultsText:i.noChoicesText),type:s?Rt.noResults:Rt.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),u&&this._highlightChoice()}},n.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,r=document.createDocumentFragment(),o=function(d){return i.querySelector('[data-item][data-id="'.concat(d.id,'"]'))},a=function(d){var u=d.itemEl;u&&u.parentElement||(u=o(d)||t._templates.item(s,d,s.removeItemButton),d.itemEl=u,r.appendChild(u))};e.forEach(a);var l=!!r.childNodes.length;if(this._isSelectOneElement){var c=i.children.length;if(l||c>1){var h=i.querySelector(_s(s.classNames.placeholder));h&&h.remove()}else!l&&!c&&this._placeholderValue&&(l=!0,a(je({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}l&&(i.append(r),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(d){var u=o(d);u&&(u.remove(),r.append(u))}),i.append(r))),this._isTextElement&&(this.passedElement.value=e.map(function(d){var u=d.value;return u}).join(s.delimiter))},n.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var s=this._notice;if(s&&(s.type===e&&s.text===t||s.type===Rt.addChoice&&(e===Rt.noResults||e===Rt.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},n.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(_s(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},n.prototype._renderNotice=function(t){var e=this._notice;if(e){var i=this._templates.notice(this.config,e.text,e.type);t?t.append(i):this.choiceList.prepend(i)}},n.prototype._getChoiceForOutput=function(t,e){return{id:t.id,highlighted:t.highlighted,labelClass:t.labelClass,labelDescription:t.labelDescription,customProperties:t.customProperties,disabled:t.disabled,active:t.active,label:t.label,placeholder:t.placeholder,value:t.value,groupValue:t.group?t.group.label:void 0,element:t.element,keyCode:e}},n.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(te.change,{value:t})},n.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&Ln(t.parentElement),r=s&&i.find(function(o){return o.id===s});r&&this._store.withTxn(function(){if(e._removeItem(r),e._triggerChange(r.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=(e.config.shouldSort?e._store.choices.reverse():e._store.choices).find(function(a){return a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},n.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.items;if(!(!s.length||!this.config.removeItems||this._isSelectOneElement)){var r=Ln(t);r&&(s.forEach(function(o){o.id===r&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},n.prototype._handleChoiceAction=function(t){var e=this,i=Ln(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var r=this.dropdown.isActive;if(!s.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(s,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(s.value)}return r&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},n.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(r){return r.highlighted});e.editItems&&!s&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(s||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},n.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return je(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return je(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return je(o,!0)});var r=this.passedElement.optionsAsChoices();r&&(t=this._presetChoices).push.apply(t,r)}},n.prototype._handleLoadingState=function(t){t===void 0&&(t=!0);var e=this.itemList.element;t?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?e.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(e.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},n.prototype._handleSearch=function(t){if(this.input.isFocussed)if(t!==null&&typeof t<"u"&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;e!==null&&this.passedElement.triggerEvent(te.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},n.prototype._canAddItems=function(){var t=this.config,e=t.maxItemCount,i=t.maxItemText;return!t.singleModeForMultiSelect&&e>0&&e<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice(typeof i=="function"?i(e):i,Rt.addChoice),!1):(this._notice&&this._notice.type===Rt.addChoice&&this._clearNotice(),!0)},n.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=Fs(e.customAddItemText,t)),i){var r=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(r){if(this._isSelectElement)return this._displayNotice("",Rt.addChoice),!1;e.duplicateItemsAllowed||(i=!1,s=Fs(e.uniqueItemText,t))}}return i&&(s=Fs(e.addItemText,t)),s&&this._displayNotice(s,Rt.addChoice),i},n.prototype._searchChoices=function(t){var e=t.trim().replace(/\s{2,}/," ");if(!e.length||e===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var s=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var r=this._notice,o=r&&r.type;return o!==Rt.addChoice&&(s.length?this._clearNotice():this._displayNotice(Sa(this.config.noResultsText),Rt.noResults)),this._store.dispatch(sd(s)),s.length},n.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(rd(!0)),this.passedElement.triggerEvent(te.search,{value:"",resultCount:0}))},n.prototype._addEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.addEventListener("touchend",this._onTouchEnd,!0),e.addEventListener("keydown",this._onKeyDown,!0),e.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("click",this._onClick,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},n.prototype._removeEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.removeEventListener("touchend",this._onTouchEnd,!0),e.removeEventListener("keydown",this._onKeyDown,!0),e.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("click",this._onClick),t.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},n.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==Vt.ESC_KEY&&e!==Vt.TAB_KEY&&e!==Vt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Vt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Vt.ENTER_KEY:return this._onEnterKey(t,i);case Vt.ESC_KEY:return this._onEscapeKey(t,i);case Vt.UP_KEY:case Vt.PAGE_UP_KEY:case Vt.DOWN_KEY:case Vt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Vt.DELETE_KEY:case Vt.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},n.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},n.prototype._onInput=function(){var t=this.input.value;if(!t){this._isTextElement?this.hideDropdown(!0):this._stopSearch();return}this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice())))},n.prototype._onSelectKey=function(t,e){if((t.ctrlKey||t.metaKey)&&e){this._canSearch=!1;var i=this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement;i&&this.highlightAll()}},n.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,r=t.target;if(t.preventDefault(),r&&r.hasAttribute("data-button")){this._handleButtonAction(r);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(_s(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!r||!s){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(s,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(s))return;i._addChoice(je(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},n.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},n.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===Vt.DOWN_KEY||i===Vt.PAGE_DOWN_KEY?1:-1,r=t.metaKey||i===Vt.PAGE_DOWN_KEY||i===Vt.PAGE_UP_KEY,o=void 0;if(r)s>0?o=this.dropdown.element.querySelector("".concat(xs,":last-of-type")):o=this.dropdown.element.querySelector(xs);else{var a=this.dropdown.element.querySelector(_s(this.config.classNames.highlightedState));a?o=ld(a,xs,s):o=this.dropdown.element.querySelector(xs)}o&&(cd(o,this.choiceList.element,s)||this.choiceList.scrollToChildElement(o,s),this._highlightChoice(o)),t.preventDefault()}},n.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},n.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},n.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var s=e===this.containerOuter.element||e===this.containerInner.element;s&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},n.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(wu&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe=this._direction==="ltr"?t.offsetX>=i.offsetWidth:t.offsetX<i.offsetLeft}if(e!==this.input.element){var s=e.closest("[data-button],[data-item],[data-choice]");s instanceof HTMLElement&&("button"in s.dataset?this._handleButtonAction(s):"item"in s.dataset?this._handleItemAction(s,t.shiftKey):"choice"in s.dataset&&this._handleChoiceAction(s)),t.preventDefault()}}},n.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},n.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,s=i.element.contains(e);s?!this.dropdown.isActive&&!i.isDisabled?this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},n.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var r=e===this.input.element;this._isTextElement?r&&i.addFocusState():this._isSelectMultipleElement?r&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),r&&this.showDropdown(!0))}},n.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);s&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&(i.removeFocusState(),this._canSearch||this.hideDropdown(!0)):(this._isScrollingOnIe=!1,this.input.element.focus())},n.prototype._onFormReset=function(){var t=this;this._store.withTxn(function(){t.clearInput(),t.hideDropdown(),t.refresh(!1,!1,!0),t._initialItems.length&&t.setChoiceByValue(t._initialItems)})},n.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(xs));if(e.length){var i=t,s=this.config.classNames.highlightedState,r=Array.from(this.dropdown.element.querySelectorAll(_s(s)));r.forEach(function(o){$e(o,s),o.setAttribute("aria-selected","false")}),i?this._highlightPosition=e.indexOf(i):(e.length>this._highlightPosition?i=e[this._highlightPosition]:i=e[e.length-1],i||(i=e[0])),z(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(te.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},n.prototype._addItem=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),!t.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(t.id),this._store.dispatch(xa(t)),e&&(this.passedElement.triggerEvent(te.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(te.choice,this._getChoiceForOutput(t)))},n.prototype._removeItem=function(t){if(t.id){this._store.dispatch(wa(t));var e=this._notice;e&&e.type===Rt.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(te.removeItem,this._getChoiceForOutput(t))}},n.prototype._addChoice=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),t.id)throw new TypeError("Can not re-add a choice which has already been added");var s=this.config;if(!(!s.duplicateItemsAllowed&&this._store.choices.find(function(a){return s.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var r=s.prependValue,o=s.appendValue;r&&(t.value=r+t.value),o&&(t.value+=o.toString()),(r||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(_a(t)),t.selected&&this._addItem(t,e,i)}},n.prototype._addGroup=function(t,e){var i=this;if(e===void 0&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(nd(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(s){s.group=t,t.disabled&&(s.disabled=!0),i._addChoice(s,e)}))},n.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,hd,ko,on));var s={};Object.keys(this._templates).forEach(function(r){r in i?s[r]=i[r].bind(t):s[r]=t._templates[r].bind(t)}),this._templates=s},n.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,r=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Ta({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:r}),this.containerInner=new Ta({element:t.containerInner(i),classNames:o,type:a,position:r}),this.input=new vd({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Ea({element:t.choiceList(i,s)}),this.itemList=new Ea({element:t.itemList(i,s)}),this.dropdown=new bd({element:t.dropdown(i),classNames:o,type:a})},n.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,r=this.dropdown.element;s.conceal(),e.wrap(s.element),i.wrap(e.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(e.element),i.element.appendChild(r),e.element.appendChild(this.itemList.element),r.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&r.insertBefore(this.input.element,r.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},n.prototype._initStore=function(){var t=this;this._store.subscribe(this._render).withTxn(function(){t._addPredefinedChoices(t._presetChoices,t._isSelectOneElement&&!t._hasNonChoicePlaceholder,!1)}),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},n.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var r=t.findIndex(function(o){return o.selected})===-1;r&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?s._isSelectElement&&s._addGroup(o,i):s._addChoice(o,i)})},n.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(r){return i.config.valueComparer(r.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},n.prototype._generatePlaceholderValue=function(){var t=this.config;if(!t.placeholder)return null;if(this._hasNonChoicePlaceholder)return t.placeholderValue;if(this._isSelectElement){var e=this.passedElement.placeholderOption;return e?e.text:null}return null},n.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent)if(this.initialised){if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}else throw new TypeError("".concat(t," called on a non-initialised instance of Choices"))},n.version="11.1.0",n})();const oc='.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:none}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:hover,.choices[data-type*=select-one] .choices__button:focus{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]:after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=text] .choices__button:hover,.choices[data-type*=text] .choices__button:focus{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media(min-width:640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]:after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted:after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus{outline:none}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input:focus{outline:0}.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}';class Ni{constructor(t,...e){this.slotNames=[],this.handleSlotChange=i=>{const s=i.target;(this.slotNames.includes("[default]")&&!s.name||s.name&&this.slotNames.includes(s.name))&&this.host.requestUpdate()},(this.host=t).addController(this),this.slotNames=e}hasDefaultSlot(){return[...this.host.childNodes].some(t=>{var e;if(t.nodeType===t.TEXT_NODE&&((e=t.textContent)==null?void 0:e.trim())!=="")return!0;if(t.nodeType===t.ELEMENT_NODE){const i=t;if(i.tagName.toLowerCase()==="pbo-visually-hidden")return!1;if(!i.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(t){return this.host.querySelector(`:scope > [slot="${t}"]`)!==null}test(t){return t==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(t)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}}/**
168
168
  * @license
169
169
  * Copyright 2017 Google LLC
170
170
  * SPDX-License-Identifier: BSD-3-Clause
@@ -1009,7 +1009,7 @@
1009
1009
  <slot part="label" class="button__label"></slot>
1010
1010
  <slot name="suffix" part="suffix" class="button__suffix"></slot>
1011
1011
  ${this.loading?Ba`<pbo-spinner part="spinner"></pbo-spinner>`:""}
1012
- </${e}>`}};at.styles=[bt,ac];at.dependencies={"pbo-spinner":as};zt([B(".button")],at.prototype,"button",2);zt([B(".button--loading pbo-spinner")],at.prototype,"spinner",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"disabled",2);zt([C()],at.prototype,"href",2);zt([C()],at.prototype,"name",2);zt([C()],at.prototype,"value",2);zt([C({reflect:!0})],at.prototype,"variant",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"outline",2);zt([C({reflect:!0})],at.prototype,"size",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"circle",2);zt([C({reflect:!0})],at.prototype,"type",2);zt([C({type:Boolean,reflect:!0,attribute:"color-block"})],at.prototype,"colorBlock",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"loading",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"error",2);zt([I()],at.prototype,"isIconButton",2);zt([I()],at.prototype,"hasFocus",2);at=zt([mt("pbo-button")],at);const Tb=at,Fu=it`
1012
+ </${e}>`}};at.styles=[bt,ac];at.dependencies={"pbo-spinner":as};zt([B(".button")],at.prototype,"button",2);zt([B(".button--loading pbo-spinner")],at.prototype,"spinner",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"disabled",2);zt([C()],at.prototype,"href",2);zt([C()],at.prototype,"name",2);zt([C()],at.prototype,"value",2);zt([C({reflect:!0})],at.prototype,"variant",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"outline",2);zt([C({reflect:!0})],at.prototype,"size",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"circle",2);zt([C({reflect:!0})],at.prototype,"type",2);zt([C({type:Boolean,reflect:!0,attribute:"color-block"})],at.prototype,"colorBlock",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"loading",2);zt([C({type:Boolean,reflect:!0})],at.prototype,"error",2);zt([I()],at.prototype,"isIconButton",2);zt([I()],at.prototype,"hasFocus",2);at=zt([mt("pbo-button")],at);const kb=at,Fu=it`
1013
1013
  :host {
1014
1014
  display: inline-block;
1015
1015
  }
@@ -1031,7 +1031,7 @@
1031
1031
  >
1032
1032
  <slot @slotchange=${this.handleSlotChange}></slot>
1033
1033
  </div>
1034
- `}};xi.styles=[bt,Fu];hn([B("slot")],xi.prototype,"defaultSlot",2);hn([I()],xi.prototype,"disableRole",2);hn([C()],xi.prototype,"label",2);xi=hn([mt("pbo-button-group")],xi);function Ts(n){const t="pbo-button, pbo-radio-button";return n.closest(t)??n.querySelector(t)}const kb=xi,Ru=it`
1034
+ `}};xi.styles=[bt,Fu];hn([B("slot")],xi.prototype,"defaultSlot",2);hn([I()],xi.prototype,"disableRole",2);hn([C()],xi.prototype,"label",2);xi=hn([mt("pbo-button-group")],xi);function Ts(n){const t="pbo-button, pbo-radio-button";return n.closest(t)??n.querySelector(t)}const Pb=xi,Ru=it`
1035
1035
  ${ac}
1036
1036
 
1037
1037
  .button__prefix,
@@ -1052,7 +1052,7 @@
1052
1052
  * @license
1053
1053
  * Copyright 2018 Google LLC
1054
1054
  * SPDX-License-Identifier: BSD-3-Clause
1055
- */const cc="important",Bu=" !"+cc,ge=an(class extends ln{constructor(n){var t;if(super(n),n.type!==gi.ATTRIBUTE||n.name!=="style"||((t=n.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(n){return Object.keys(n).reduce((t,e)=>{const i=n[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(n,[t]){const{style:e}=n.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(const i of this.ft)t[i]==null&&(this.ft.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(const i in t){const s=t[i];if(s!=null){this.ft.add(i);const r=typeof s=="string"&&s.endsWith(Bu);i.includes("-")||r?e.setProperty(i,r?s.slice(0,-11):s,r?cc:""):e[i]=s}}return ye}});var zu=Object.defineProperty,Hu=Object.getOwnPropertyDescriptor,Ae=(n,t,e,i)=>{for(var s=i>1?void 0:i?Hu(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&zu(t,e,s),s};let oe=class extends vt{constructor(){super(...arguments),this.hasSlotController=new Ni(this,"[prefix]","prefix","suffix"),this.checked=!1,this.disabled=!1,this.size="medium",this.circle=!1,this.iconOnly=!1,this.ariaLabel=void 0,this.hasFocus=!1,this.handleClick=t=>{if(this.disabled){t.preventDefault(),t.stopPropagation();return}this.checked=!0}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){}focus(t){this.input.focus(t)}blur(){this.input.blur()}isColorString(t){if(!t)return!1;if(t.startsWith("#"))return/^#([A-Fa-f0-9]{3}){1,2}$/.test(t);const e=new Option().style;return e.color=t,e.color!==""}render(){return F`
1055
+ */const cc="important",Bu=" !"+cc,ge=an(class extends ln{constructor(n){var t;if(super(n),n.type!==gi.ATTRIBUTE||n.name!=="style"||((t=n.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(n){return Object.keys(n).reduce((t,e)=>{const i=n[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(n,[t]){const{style:e}=n.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(const i of this.ft)t[i]==null&&(this.ft.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(const i in t){const s=t[i];if(s!=null){this.ft.add(i);const r=typeof s=="string"&&s.endsWith(Bu);i.includes("-")||r?e.setProperty(i,r?s.slice(0,-11):s,r?cc:""):e[i]=s}}return ye}});var zu=Object.defineProperty,Hu=Object.getOwnPropertyDescriptor,Ae=(n,t,e,i)=>{for(var s=i>1?void 0:i?Hu(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&zu(t,e,s),s};let le=class extends vt{constructor(){super(...arguments),this.hasSlotController=new Ni(this,"[prefix]","prefix","suffix"),this.checked=!1,this.disabled=!1,this.size="medium",this.circle=!1,this.iconOnly=!1,this.ariaLabel=void 0,this.hasFocus=!1,this.handleClick=t=>{if(this.disabled){t.preventDefault(),t.stopPropagation();return}this.checked=!0}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){}focus(t){this.input.focus(t)}blur(){this.input.blur()}isColorString(t){if(!t)return!1;if(t.startsWith("#"))return/^#([A-Fa-f0-9]{3}){1,2}$/.test(t);const e=new Option().style;return e.color=t,e.color!==""}render(){return F`
1056
1056
  <div part="base" role="presentation">
1057
1057
  <button
1058
1058
  part="${`button${this.checked?"button--checked":""}`}"
@@ -1072,7 +1072,7 @@
1072
1072
  <slot name="suffix" part="suffix" class="button__suffix"></slot>
1073
1073
  </button>
1074
1074
  </div>
1075
- `}};oe.styles=[bt,Ru];Ae([B(".button")],oe.prototype,"input",2);Ae([B(".hidden-input")],oe.prototype,"hiddenInput",2);Ae([C({type:Boolean,reflect:!0})],oe.prototype,"checked",2);Ae([C()],oe.prototype,"value",2);Ae([C({type:Boolean,reflect:!0})],oe.prototype,"disabled",2);Ae([C({reflect:!0})],oe.prototype,"size",2);Ae([C({type:Boolean,reflect:!0})],oe.prototype,"circle",2);Ae([C({type:Boolean,reflect:!0,attribute:"icon-only"})],oe.prototype,"iconOnly",2);Ae([C({attribute:"aria-label"})],oe.prototype,"ariaLabel",2);Ae([I()],oe.prototype,"hasFocus",2);oe=Ae([mt("pbo-radio-button")],oe);const Pb=oe,Vu=it`
1075
+ `}};le.styles=[bt,Ru];Ae([B(".button")],le.prototype,"input",2);Ae([B(".hidden-input")],le.prototype,"hiddenInput",2);Ae([C({type:Boolean,reflect:!0})],le.prototype,"checked",2);Ae([C()],le.prototype,"value",2);Ae([C({type:Boolean,reflect:!0})],le.prototype,"disabled",2);Ae([C({reflect:!0})],le.prototype,"size",2);Ae([C({type:Boolean,reflect:!0})],le.prototype,"circle",2);Ae([C({type:Boolean,reflect:!0,attribute:"icon-only"})],le.prototype,"iconOnly",2);Ae([C({attribute:"aria-label"})],le.prototype,"ariaLabel",2);Ae([I()],le.prototype,"hasFocus",2);le=Ae([mt("pbo-radio-button")],le);const Ab=le,Vu=it`
1076
1076
  :host {
1077
1077
  display: block;
1078
1078
  }
@@ -1108,7 +1108,7 @@
1108
1108
  .form-control__label > slot {
1109
1109
  font-size: 16.5px;
1110
1110
  }
1111
- `;var Nu=Object.defineProperty,Uu=Object.getOwnPropertyDescriptor,Ut=(n,t,e,i)=>{for(var s=i>1?void 0:i?Uu(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Nu(t,e,s),s};let gt=class extends vt{constructor(){super(...arguments),this.formControlController=new Po(this),this.hasSlotController=new Ni(this,"help-text","label"),this.customValidityMessage="",this._value="",this.hasButtonGroup=!0,this.errorMessage="",this.defaultValue="",this.required=!1,this.name="option",this.value="",this.helpText="",this.label="",this.iconGroup=!1,this.size="medium",this.disabled=!1,this.form=""}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}get validity(){const t=this.required&&!this.value;return this.customValidityMessage!==""?Pu:t?Ou:cn}get validationMessage(){const t=this.required&&!this.value;return this.customValidityMessage!==""?this.customValidityMessage:t?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}checkValidity(){const t=this.required&&!this.value,e=this.customValidityMessage!=="";return t||e?(this.formControlController.emitInvalidEvent(),!1):!0}getForm(){return this.formControlController.getForm()}reportValidity(){const t=this.validity.valid;return this.errorMessage=this.customValidityMessage||t?"":this.validationInput.validationMessage,this.formControlController.setValidity(t),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),t||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout(()=>this.validationInput.hidden=!0,1e4)),t}setCustomValidity(t){this.customValidityMessage=t,this.errorMessage=t,this.validationInput.setCustomValidity(t),this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("pbo-radio, pbo-radio-button")]}updateCheckedRadio(){this.getAllRadios().forEach(e=>e.checked=e.value===this.value),this.formControlController.setValidity(this.validity.valid)}handleRadioClick(t){const e=t.target.closest("pbo-radio-button"),i=this.getAllRadios(),s=this.value;!e||e.disabled||(this.value=e.value,i.forEach(r=>r.checked=r===e),this.value!==s&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleLabelClick(){this.focus()}handleKeyDown(t){const e=this.getAllRadios().filter(o=>!o.disabled);if(e.length===0)return;const i=e.findIndex(o=>o.checked);let s=i;if(t.key==="ArrowRight"||t.key==="ArrowDown")t.preventDefault(),s=(i+1)%e.length;else if(t.key==="ArrowLeft"||t.key==="ArrowUp")t.preventDefault(),s=(i-1+e.length)%e.length;else return;const r=this.value;this.value=e[s].value,e.forEach(o=>o.checked=o===e[s]),e[s].focus(),this.value!==r&&(this.emit("pbo-change"),this.emit("pbo-input"))}syncRadios(){if(customElements.get("pbo-radio")&&customElements.get("pbo-radio-button")){this.syncRadioElements();return}if(customElements.get("pbo-radio")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio").then(()=>{this.syncRadios()});if(customElements.get("pbo-radio-button")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio-button").then(()=>{this.syncRadios()})}async syncRadioElements(){var e;const t=this.getAllRadios();if(await Promise.all(t.map(async i=>{await i.updateComplete,i.checked=i.value===this.value})),this.hasButtonGroup=t.some(i=>i.tagName.toLowerCase()==="pbo-radio-button"),t.length>0&&!t.some(i=>i.checked))if(this.hasButtonGroup){const i=(e=t[0].shadowRoot)==null?void 0:e.querySelector("button");i&&i.setAttribute("tabindex","0")}else t[0].setAttribute("tabindex","0")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}render(){const t=this.hasSlotController.test("label"),e=this.hasSlotController.test("help-text"),i=this.helpText?!0:!!e,s=this.label?!0:!!t;return F`
1111
+ `;var Nu=Object.defineProperty,Uu=Object.getOwnPropertyDescriptor,Wt=(n,t,e,i)=>{for(var s=i>1?void 0:i?Uu(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Nu(t,e,s),s};let gt=class extends vt{constructor(){super(...arguments),this.formControlController=new Po(this),this.hasSlotController=new Ni(this,"help-text","label"),this.customValidityMessage="",this._value="",this.hasButtonGroup=!0,this.errorMessage="",this.defaultValue="",this.required=!1,this.name="option",this.value="",this.helpText="",this.label="",this.iconGroup=!1,this.size="medium",this.disabled=!1,this.form=""}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}get validity(){const t=this.required&&!this.value;return this.customValidityMessage!==""?Pu:t?Ou:cn}get validationMessage(){const t=this.required&&!this.value;return this.customValidityMessage!==""?this.customValidityMessage:t?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}checkValidity(){const t=this.required&&!this.value,e=this.customValidityMessage!=="";return t||e?(this.formControlController.emitInvalidEvent(),!1):!0}getForm(){return this.formControlController.getForm()}reportValidity(){const t=this.validity.valid;return this.errorMessage=this.customValidityMessage||t?"":this.validationInput.validationMessage,this.formControlController.setValidity(t),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),t||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout(()=>this.validationInput.hidden=!0,1e4)),t}setCustomValidity(t){this.customValidityMessage=t,this.errorMessage=t,this.validationInput.setCustomValidity(t),this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("pbo-radio, pbo-radio-button")]}updateCheckedRadio(){this.getAllRadios().forEach(e=>e.checked=e.value===this.value),this.formControlController.setValidity(this.validity.valid)}handleRadioClick(t){const e=t.target.closest("pbo-radio-button"),i=this.getAllRadios(),s=this.value;!e||e.disabled||(this.value=e.value,i.forEach(r=>r.checked=r===e),this.value!==s&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleLabelClick(){this.focus()}handleKeyDown(t){const e=this.getAllRadios().filter(o=>!o.disabled);if(e.length===0)return;const i=e.findIndex(o=>o.checked);let s=i;if(t.key==="ArrowRight"||t.key==="ArrowDown")t.preventDefault(),s=(i+1)%e.length;else if(t.key==="ArrowLeft"||t.key==="ArrowUp")t.preventDefault(),s=(i-1+e.length)%e.length;else return;const r=this.value;this.value=e[s].value,e.forEach(o=>o.checked=o===e[s]),e[s].focus(),this.value!==r&&(this.emit("pbo-change"),this.emit("pbo-input"))}syncRadios(){if(customElements.get("pbo-radio")&&customElements.get("pbo-radio-button")){this.syncRadioElements();return}if(customElements.get("pbo-radio")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio").then(()=>{this.syncRadios()});if(customElements.get("pbo-radio-button")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio-button").then(()=>{this.syncRadios()})}async syncRadioElements(){var e;const t=this.getAllRadios();if(await Promise.all(t.map(async i=>{await i.updateComplete,i.checked=i.value===this.value})),this.hasButtonGroup=t.some(i=>i.tagName.toLowerCase()==="pbo-radio-button"),t.length>0&&!t.some(i=>i.checked))if(this.hasButtonGroup){const i=(e=t[0].shadowRoot)==null?void 0:e.querySelector("button");i&&i.setAttribute("tabindex","0")}else t[0].setAttribute("tabindex","0")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}render(){const t=this.hasSlotController.test("label"),e=this.hasSlotController.test("help-text"),i=this.helpText?!0:!!e,s=this.label?!0:!!t;return F`
1112
1112
  <fieldset
1113
1113
  role="radiogroup"
1114
1114
  part="form-control"
@@ -1162,7 +1162,7 @@
1162
1162
  <slot name="help-text">${this.helpText}</slot>
1163
1163
  </div>
1164
1164
  </fieldset>
1165
- `}};gt.styles=[bt,Vu,Js];gt.dependencies={"pbo-button-group":xi};Ut([B("slot:not([name])")],gt.prototype,"defaultSlot",2);Ut([B(".radio-group__validation-input")],gt.prototype,"validationInput",2);Ut([I()],gt.prototype,"hasButtonGroup",2);Ut([I()],gt.prototype,"errorMessage",2);Ut([I()],gt.prototype,"defaultValue",2);Ut([C({type:Boolean,reflect:!0})],gt.prototype,"required",2);Ut([C()],gt.prototype,"name",2);Ut([C({reflect:!0})],gt.prototype,"value",2);Ut([C({attribute:"help-text"})],gt.prototype,"helpText",2);Ut([C()],gt.prototype,"label",2);Ut([C({type:Boolean,reflect:!0,attribute:"icon-group"})],gt.prototype,"iconGroup",2);Ut([C()],gt.prototype,"size",2);Ut([C({type:Boolean,reflect:!0})],gt.prototype,"disabled",2);Ut([C({reflect:!0})],gt.prototype,"form",2);Ut([G("value")],gt.prototype,"handleValueChange",1);gt=Ut([mt("pbo-radio-group")],gt);const Ab=gt,Wu=it`
1165
+ `}};gt.styles=[bt,Vu,Js];gt.dependencies={"pbo-button-group":xi};Wt([B("slot:not([name])")],gt.prototype,"defaultSlot",2);Wt([B(".radio-group__validation-input")],gt.prototype,"validationInput",2);Wt([I()],gt.prototype,"hasButtonGroup",2);Wt([I()],gt.prototype,"errorMessage",2);Wt([I()],gt.prototype,"defaultValue",2);Wt([C({type:Boolean,reflect:!0})],gt.prototype,"required",2);Wt([C()],gt.prototype,"name",2);Wt([C({reflect:!0})],gt.prototype,"value",2);Wt([C({attribute:"help-text"})],gt.prototype,"helpText",2);Wt([C()],gt.prototype,"label",2);Wt([C({type:Boolean,reflect:!0,attribute:"icon-group"})],gt.prototype,"iconGroup",2);Wt([C()],gt.prototype,"size",2);Wt([C({type:Boolean,reflect:!0})],gt.prototype,"disabled",2);Wt([C({reflect:!0})],gt.prototype,"form",2);Wt([G("value")],gt.prototype,"handleValueChange",1);gt=Wt([mt("pbo-radio-group")],gt);const Ib=gt,Wu=it`
1166
1166
  :host {
1167
1167
  display: block;
1168
1168
  position: relative;
@@ -1401,7 +1401,7 @@
1401
1401
  >
1402
1402
  <slot name="help-text">${this.helpText}</slot>
1403
1403
  </div>
1404
- </div>`}};lt.styles=[bt,Wu,Js];Lt([B(".textarea__control")],lt.prototype,"input",2);Lt([B(".textarea__size-adjuster")],lt.prototype,"sizeAdjuster",2);Lt([I()],lt.prototype,"hasFocus",2);Lt([C()],lt.prototype,"name",2);Lt([C()],lt.prototype,"value",2);Lt([C({reflect:!0})],lt.prototype,"size",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"filled",2);Lt([C()],lt.prototype,"title",2);Lt([C()],lt.prototype,"placeholder",2);Lt([C({type:Number})],lt.prototype,"rows",2);Lt([C()],lt.prototype,"resize",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"disabled",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"readonly",2);Lt([C({reflect:!0})],lt.prototype,"form",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"required",2);Lt([C({type:Number})],lt.prototype,"minlength",2);Lt([C({type:Number})],lt.prototype,"maxlength",2);Lt([C({attribute:"help-text"})],lt.prototype,"helpText",2);lt=Lt([mt("pbo-textarea")],lt);const Ib=lt,tp=it`
1404
+ </div>`}};lt.styles=[bt,Wu,Js];Lt([B(".textarea__control")],lt.prototype,"input",2);Lt([B(".textarea__size-adjuster")],lt.prototype,"sizeAdjuster",2);Lt([I()],lt.prototype,"hasFocus",2);Lt([C()],lt.prototype,"name",2);Lt([C()],lt.prototype,"value",2);Lt([C({reflect:!0})],lt.prototype,"size",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"filled",2);Lt([C()],lt.prototype,"title",2);Lt([C()],lt.prototype,"placeholder",2);Lt([C({type:Number})],lt.prototype,"rows",2);Lt([C()],lt.prototype,"resize",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"disabled",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"readonly",2);Lt([C({reflect:!0})],lt.prototype,"form",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"required",2);Lt([C({type:Number})],lt.prototype,"minlength",2);Lt([C({type:Number})],lt.prototype,"maxlength",2);Lt([C({attribute:"help-text"})],lt.prototype,"helpText",2);lt=Lt([mt("pbo-textarea")],lt);const Fb=lt,tp=it`
1405
1405
  :host {
1406
1406
  display: block;
1407
1407
  }
@@ -1854,7 +1854,7 @@
1854
1854
  background-color: #f3f3f3;
1855
1855
  }
1856
1856
  }
1857
- `;var ap=Object.defineProperty,lp=Object.getOwnPropertyDescriptor,We=(n,t,e,i)=>{for(var s=i>1?void 0:i?lp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&ap(t,e,s),s};let ae=class extends vt{constructor(){super(...arguments),this.skeletonHeight="2000px",this.skeletonWidth="1429px",this.src="",this.alt="",this.placeholder="",this.skeleton=!1,this.loaded=!1}handleSrcChange(){this.loaded=!1}handleError(){this.loaded=!0,this.placeholder&&(this.src=this.placeholder)}handleOnLoad(){this.loaded=!0}firstUpdated(){this.skeleton||(this.imgEl.onload=()=>this.handleOnLoad())}render(){return this.skeleton?F`<div class="skeleton"></div>`:F`
1857
+ `;var ap=Object.defineProperty,lp=Object.getOwnPropertyDescriptor,We=(n,t,e,i)=>{for(var s=i>1?void 0:i?lp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&ap(t,e,s),s};let Jt=class extends vt{constructor(){super(...arguments),this.skeletonHeight="2000px",this.skeletonWidth="1429px",this.src="",this.alt="",this.placeholder="",this.skeleton=!1,this.loaded=!1}handleSrcChange(){this.loaded=!1}handleError(){this.loaded=!0,this.placeholder&&(this.src=this.placeholder)}handleOnLoad(){this.loaded=!0}firstUpdated(){this.skeleton||(this.imgEl.onload=()=>this.handleOnLoad())}render(){return this.skeleton?F`<div class="skeleton"></div>`:F`
1858
1858
  ${this.loaded?"":F` <div class="skeleton"></div>`}
1859
1859
  <img
1860
1860
  src=${this.src}
@@ -1862,7 +1862,7 @@
1862
1862
  class=${fe({loaded:this.loaded,hidden:!this.loaded})}
1863
1863
  @error=${()=>this.handleError()}
1864
1864
  />
1865
- `}};ae.styles=[bt,op];We([C()],ae.prototype,"skeletonHeight",2);We([C()],ae.prototype,"skeletonWidth",2);We([C()],ae.prototype,"src",2);We([C()],ae.prototype,"alt",2);We([C()],ae.prototype,"placeholder",2);We([C({type:Boolean})],ae.prototype,"skeleton",2);We([I()],ae.prototype,"loaded",2);We([B("img")],ae.prototype,"imgEl",2);We([G("src")],ae.prototype,"handleSrcChange",1);ae=We([mt("pbo-image")],ae);var cp=Object.defineProperty,hp=Object.getOwnPropertyDescriptor,Ft=(n,t,e,i)=>{for(var s=i>1?void 0:i?hp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&cp(t,e,s),s};let ct=class extends vt{constructor(){super(...arguments),this.card=null,this.focusIndex=0,this.livePreviewProps={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenPreviewProps={isLoading:!1,processedFileUrl:null},this.type="type",this.allowPinchToToggle=!0,this.distance=0,this.mainImageTemplates=[],this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1),this.emit("pbo_close_live_preview",{detail:{editor:this.type}})},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0),this.emit("pbo_open_live_preview",{detail:{editor:this.type}})},this.handleOpenZoomedClick=t=>{if(!bi()){t.preventDefault(),t.stopPropagation();return}this.openZoomedPreview()},this.handleTouchMove=t=>{if(this.allowPinchToToggle===!1)return;t.preventDefault();const e=t.touches[0],i=t.touches[1];if(!(e&&!i)&&e&&i){const s={x:e.clientX,y:e.clientY},r={x:i.clientX,y:i.clientY},o=dc(s,r);this.distance||(this.distance=o),o-this.distance>10&&this.openZoomedPreview()}},this.handleTouchEnd=()=>{this.allowPinchToToggle!==!1&&(this.distance=null)}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",t=>{var r,o;const{detail:e}=t,i=(r=this.shadowRoot)==null?void 0:r.querySelector("#handwritten-main-canvas"),s=(o=this.shadowRoot)==null?void 0:o.querySelector("#handwritten-zoomed-preview-canvas");i&&s&&(i.imageWidth=e.width,i.imageHeight=e.height,i.imageTop=e.top,i.imageLeft=e.left,s.imageWidth=e.width,s.imageHeight=e.height,s.imageTop=e.top,s.imageLeft=e.left)}),this.updateComplete,this.thumbnailElements[this.focusIndex].classList.add("active"),this.mainSlideElements[this.focusIndex].classList.add("active")}handleCardChange(t,e){var i,s,r,o;e&&(this.mainImageTemplates=[F`<pbo-image src="${e.medias.cover.url}" alt="" />`,F`<pbo-type-canvas
1865
+ `}};Jt.styles=[bt,op];We([C()],Jt.prototype,"skeletonHeight",2);We([C()],Jt.prototype,"skeletonWidth",2);We([C()],Jt.prototype,"src",2);We([C()],Jt.prototype,"alt",2);We([C()],Jt.prototype,"placeholder",2);We([C({type:Boolean})],Jt.prototype,"skeleton",2);We([I()],Jt.prototype,"loaded",2);We([B("img")],Jt.prototype,"imgEl",2);We([G("src")],Jt.prototype,"handleSrcChange",1);Jt=We([mt("pbo-image")],Jt);var cp=Object.defineProperty,hp=Object.getOwnPropertyDescriptor,Ft=(n,t,e,i)=>{for(var s=i>1?void 0:i?hp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&cp(t,e,s),s};let ct=class extends vt{constructor(){super(...arguments),this.card=null,this.focusIndex=0,this.livePreviewProps={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenPreviewProps={isLoading:!1,processedFileUrl:null},this.type="type",this.allowPinchToToggle=!0,this.distance=0,this.mainImageTemplates=[],this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1),this.emit("pbo_close_live_preview",{detail:{editor:this.type}})},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0),this.emit("pbo_open_live_preview",{detail:{editor:this.type}})},this.handleOpenZoomedClick=t=>{if(!bi()){t.preventDefault(),t.stopPropagation();return}this.openZoomedPreview()},this.handleTouchMove=t=>{if(this.allowPinchToToggle===!1)return;t.preventDefault();const e=t.touches[0],i=t.touches[1];if(!(e&&!i)&&e&&i){const s={x:e.clientX,y:e.clientY},r={x:i.clientX,y:i.clientY},o=dc(s,r);this.distance||(this.distance=o),o-this.distance>10&&this.openZoomedPreview()}},this.handleTouchEnd=()=>{this.allowPinchToToggle!==!1&&(this.distance=null)}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",t=>{var r,o;const{detail:e}=t,i=(r=this.shadowRoot)==null?void 0:r.querySelector("#handwritten-main-canvas"),s=(o=this.shadowRoot)==null?void 0:o.querySelector("#handwritten-zoomed-preview-canvas");i&&s&&(i.imageWidth=e.width,i.imageHeight=e.height,i.imageTop=e.top,i.imageLeft=e.left,s.imageWidth=e.width,s.imageHeight=e.height,s.imageTop=e.top,s.imageLeft=e.left)}),this.updateComplete,this.thumbnailElements[this.focusIndex].classList.add("active"),this.mainSlideElements[this.focusIndex].classList.add("active")}handleCardChange(t,e){var i,s,r,o;e&&(this.mainImageTemplates=[F`<pbo-image src="${e.medias.cover.url}" alt="" />`,F`<pbo-type-canvas
1866
1866
  background-url=${e.medias.insert.url}
1867
1867
  message=${(i=this.livePreviewProps)==null?void 0:i.text}
1868
1868
  alignment=${((s=this.livePreviewProps)==null?void 0:s.alignment)||"left"}
@@ -1895,7 +1895,7 @@
1895
1895
  <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
1896
1896
  <line x1="11" y1="8" x2="11" y2="14"></line>
1897
1897
  <line x1="8" y1="11" x2="14" y2="11"></line>
1898
- </svg>`}render(){var t,e,i,s,r,o,a,l,c,h,d,u,p,g,f,b,m,_,x,S,T,O,k,E;return F`
1898
+ </svg>`}render(){var t,e,i,s,r,o,a,l,c,h,d,u,p,g,f,b,m,y,w,S,T,k,O,E;return F`
1899
1899
  <div class="card--slider--wrapper">
1900
1900
  <div id="thumbnails" class="thumbnails">
1901
1901
  <button
@@ -2012,8 +2012,8 @@
2012
2012
  ${jn(this.type==="type"?F`<pbo-type-canvas
2013
2013
  background-url=${(b=this.card)==null?void 0:b.medias.insert.url}
2014
2014
  message=${(m=this.livePreviewProps)==null?void 0:m.text}
2015
- alignment=${((_=this.livePreviewProps)==null?void 0:_.alignment)||"left"}
2016
- color=${(x=this.livePreviewProps)==null?void 0:x.color}
2015
+ alignment=${((y=this.livePreviewProps)==null?void 0:y.alignment)||"left"}
2016
+ color=${(w=this.livePreviewProps)==null?void 0:w.color}
2017
2017
  font=${(S=this.livePreviewProps)==null?void 0:S.font}
2018
2018
  display-type=${(T=this.card)!=null&&T.hasEditorial?"default":"fullSize"}
2019
2019
  @click="${this.handleOpenZoomedClick}"
@@ -2021,9 +2021,9 @@
2021
2021
  ></pbo-type-canvas>`:Z)}
2022
2022
  ${jn(this.type==="handwritten"?F`<pbo-handwritten-canvas
2023
2023
  id="handwritten-zoomed-preview-canvas"
2024
- background-url=${(O=this.card)==null?void 0:O.medias.insert.url}
2024
+ background-url=${(k=this.card)==null?void 0:k.medias.insert.url}
2025
2025
  handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
2026
- display-type=${(k=this.card)!=null&&k.hasEditorial?"default":"fullSize"}
2026
+ display-type=${(O=this.card)!=null&&O.hasEditorial?"default":"fullSize"}
2027
2027
  @click="${this.handleOpenZoomedClick}"
2028
2028
  style=${ge({display:this.focusIndex===1?"block":"none"})}
2029
2029
  ></pbo-handwritten-canvas>`:Z)}
@@ -2034,1204 +2034,1204 @@
2034
2034
  />
2035
2035
  </pbo-zoomed-preview>
2036
2036
  </pbo-drawer>
2037
- `}};ct.styles=[bt,np];ct.dependencies={"pbo-image":ae};Ft([C({type:Object})],ct.prototype,"card",2);Ft([C({type:Number,reflect:!0})],ct.prototype,"focusIndex",2);Ft([C({type:Object})],ct.prototype,"livePreviewProps",2);Ft([C()],ct.prototype,"handwrittenPreviewProps",2);Ft([C()],ct.prototype,"type",2);Ft([I()],ct.prototype,"allowPinchToToggle",2);Ft([I()],ct.prototype,"distance",2);Ft([B("#thumbnails")],ct.prototype,"thumbnailCarousel",2);Ft([B("#main-carousel")],ct.prototype,"mainCarousel",2);Ft([B(".editor__zoomed")],ct.prototype,"zoomedPreview",2);Ft([B(".main-slide.active")],ct.prototype,"activeMainSlide",2);Ft([B("pbo-type-canvas")],ct.prototype,"typeCanvas",2);Ft([Eo(".thumbnail")],ct.prototype,"thumbnailElements",2);Ft([Eo(".main-slide")],ct.prototype,"mainSlideElements",2);Ft([I()],ct.prototype,"mainImageTemplates",2);Ft([G("card")],ct.prototype,"handleCardChange",1);Ft([G("focusIndex")],ct.prototype,"handleFocusIndexChange",1);Ft([G("type"),G("focusIndex")],ct.prototype,"handleAllowPinchToToggle",1);ct=Ft([mt("pbo-editor-card-slider")],ct);var dp=Object.defineProperty,up=Object.getOwnPropertyDescriptor,Wt=(n,t,e,i)=>{for(var s=i>1?void 0:i?up(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&dp(t,e,s),s};let St=class extends vt{constructor(){super(...arguments),this.card=null,this.onClose=()=>{},this.typeFormCtaLabel="",this.handwrittenFormCtaLabel="",this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenFormState={isLoading:!1,processedFileUrl:""},this.editorType="type",this.handleTypingFormChange=()=>{this.formData=this.typeForm.formData},this.handleHandwrittenFormChange=t=>{this.handwrittenFormState=t.detail,this.slider.focusOn(1),bi()&&t.detail.processedFileUrl!==""&&t.detail.isLoading===!1&&(this.slider.openZoomedPreview(),this.slider.scrollIntoView({behavior:"smooth",block:"start"}))},this.handleHandwrittenImageDimensionsChanged=t=>{this.handwrittenForm.setDimensions(t.detail)},this.handleEditorChange=t=>{this.emit("pbo-switch-editor",{detail:{fromEditor:this.editorType,toEditor:t.detail.editor},bubbles:!0,composed:!0}),this.editorType=t.detail.editor}}async handleCardChange(){await this.updateComplete,this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}handleEditorTypeChange(){this.updateComplete.then(()=>{var t,e;if(this.editorType==="handwritten"&&bi()&&this.handwrittenForm.scrollIntoView(!0),this.editorType==="type"){const i=(t=this.typeForm.shadowRoot)==null?void 0:t.querySelector("textarea");i==null||i.focus()}else{const i=(e=this.handwrittenForm.shadowRoot)==null?void 0:e.querySelector("pbo-button[name='upload']");i==null||i.focus()}})}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",this.handleHandwrittenImageDimensionsChanged),this.typeForm.addEventListener("pbo-type-form-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-handwritten-form-change",this.handleHandwrittenFormChange)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-type-form-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-handwritten-form-change",this.handleHandwrittenFormChange)}render(){return F`
2038
- <div class="editor">
2039
- <div class="editor__card" part="editor-card-slider-container">
2040
- <pbo-editor-card-slider
2041
- part="editor-card-slider"
2042
- focusIndex="0"
2043
- .livePreviewProps=${this.formData}
2044
- .handwrittenPreviewProps=${this.handwrittenFormState}
2045
- type=${this.editorType}
2046
- ></pbo-editor-card-slider>
2047
- </div>
2048
-
2049
- <div class="editor__form" part="editor-form-container">
2050
- <div aria-live="polite" aria-atomic="true" class="visually-hidden">
2051
- ${this.editorType==="type"?"Text message editor active":"Handwritten image editor active"}
2052
- </div>
2053
- <pbo-editor-selector
2054
- @pbo-editor-selector-change=${this.handleEditorChange}
2055
- part="editor-selector"
2056
- ></pbo-editor-selector>
2057
-
2058
- <pbo-type-form
2059
- part="type-form"
2060
- exportparts="
2061
- editor-textarea,
2062
- font-selector-label,
2063
- color-selector-label,
2064
- alignment-selector-label,
2065
- type-form-label,
2066
- cta-button-base,
2067
- cta-button-label,
2068
- cta-link-button-label,
2069
- cta-link-button-base
2070
- "
2071
- cta-primary-label=${this.typeFormCtaLabel}
2072
- .submitTypeForm=${this.submitTypeForm}
2073
- .onClose=${this.onClose}
2074
- style=${ge({display:this.editorType==="type"?"block":"none"})}
2075
- ></pbo-type-form>
2076
- <pbo-handwritten-form
2077
- part="handwritten-form"
2078
- exportparts="
2079
- cta-button-base,
2080
- cta-button-label,
2081
- cta-link-button-base,
2082
- cta-link-button-label
2083
- "
2084
- cta-primary-label=${this.handwrittenFormCtaLabel}
2085
- style=${ge({display:this.editorType==="handwritten"?"block":"none"})}
2086
- .submitHandwrittenForm=${this.submitHandwrittenForm}
2087
- .onClose=${this.onClose}
2088
- .getProcessedImg=${this.getProcessedImg}
2089
- ></pbo-handwritten-form>
2090
- </div>
2091
- </div>
2092
- `}};St.styles=[bt,tp];St.dependencies={"editor-card-slider":ct,"pbo-type-form":J};Wt([C({type:Object})],St.prototype,"card",2);Wt([C()],St.prototype,"submitTypeForm",2);Wt([C()],St.prototype,"submitHandwrittenForm",2);Wt([C()],St.prototype,"getProcessedImg",2);Wt([C({type:Function})],St.prototype,"onClose",2);Wt([C({type:String,attribute:"type-form-cta-primary-label"})],St.prototype,"typeFormCtaLabel",2);Wt([C({type:String,attribute:"handwritten-form-cta-primary-label"})],St.prototype,"handwrittenFormCtaLabel",2);Wt([B("pbo-type-form")],St.prototype,"typeForm",2);Wt([B("pbo-handwritten-form")],St.prototype,"handwrittenForm",2);Wt([B("pbo-editor-card-slider")],St.prototype,"slider",2);Wt([I()],St.prototype,"formData",2);Wt([I()],St.prototype,"handwrittenFormState",2);Wt([I()],St.prototype,"editorType",2);Wt([G("card")],St.prototype,"handleCardChange",1);Wt([G("editorType")],St.prototype,"handleEditorTypeChange",1);St=Wt([mt("pbo-editor")],St);const Rb=St,Bb=J,zb=ct,pp=it`
2037
+ `}};ct.styles=[bt,np];ct.dependencies={"pbo-image":Jt,"pbo-type-canvas":nt,"pbo-handwritten-canvas":ft,"pbo-drawer":De,"pbo-zoomed-preview":Ne};Ft([C({type:Object})],ct.prototype,"card",2);Ft([C({type:Number,reflect:!0})],ct.prototype,"focusIndex",2);Ft([C({type:Object})],ct.prototype,"livePreviewProps",2);Ft([C()],ct.prototype,"handwrittenPreviewProps",2);Ft([C()],ct.prototype,"type",2);Ft([I()],ct.prototype,"allowPinchToToggle",2);Ft([I()],ct.prototype,"distance",2);Ft([B("#thumbnails")],ct.prototype,"thumbnailCarousel",2);Ft([B("#main-carousel")],ct.prototype,"mainCarousel",2);Ft([B(".editor__zoomed")],ct.prototype,"zoomedPreview",2);Ft([B(".main-slide.active")],ct.prototype,"activeMainSlide",2);Ft([B("pbo-type-canvas")],ct.prototype,"typeCanvas",2);Ft([Eo(".thumbnail")],ct.prototype,"thumbnailElements",2);Ft([Eo(".main-slide")],ct.prototype,"mainSlideElements",2);Ft([I()],ct.prototype,"mainImageTemplates",2);Ft([G("card")],ct.prototype,"handleCardChange",1);Ft([G("focusIndex")],ct.prototype,"handleFocusIndexChange",1);Ft([G("type"),G("focusIndex")],ct.prototype,"handleAllowPinchToToggle",1);ct=Ft([mt("pbo-editor-card-slider")],ct);const dp=it`
2093
2038
  :host {
2094
2039
  display: block;
2095
- --title-font-size: 18.75px;
2096
- --title-font-weight: var(--pbo-font-weight-normal);
2097
- --title-margin: var(--pbo-spacing-medium) 0 var(--pbo-spacing-x-small) 0;
2098
2040
  }
2099
2041
 
2100
- .title {
2101
- font-size: var(--title-font-size);
2102
- font-weight: var(--title-font-weight);
2103
- margin: 16px 0 0 4px;
2104
- grid-column-start: 2;
2105
- grid-column-end: 2;
2042
+ .pixel-input {
2043
+ display: none;
2044
+ height: 1;
2045
+ width: 1;
2046
+ opacity: 0;
2106
2047
  }
2107
2048
 
2108
- :host(:first-of-type) .title {
2109
- margin-top: 4px; /* 4px more on the mobile */
2049
+ .buttons-container {
2050
+ display: flex;
2051
+ flex-direction: column;
2110
2052
  }
2111
2053
 
2112
- @media screen and (min-width: 640px) {
2113
- :host(:first-of-type) .title {
2114
- margin-top: 0px; /* Remove top margin for first category */
2115
- }
2054
+ .buttons-container pbo-button::part(base) {
2055
+ font-size: var(--pbo-font-size-medium);
2116
2056
  }
2117
2057
 
2118
- .category-container {
2119
- margin-left: auto;
2120
- margin-right: auto;
2121
- display: grid;
2122
- grid-template-columns: 30px 1fr 30px;
2123
- grid-template-rows: auto auto;
2124
- }
2125
- /* -------------------------------- skeleton -------------------------------- */
2126
- .skeleton .splide__slide {
2127
- border: none;
2128
- border-radius: var(--pbo-border-radius-large);
2058
+ .step-title {
2059
+ margin: 0;
2060
+ margin-bottom: 4.5px;
2061
+ font-size: 17.5px;
2062
+ font-weight: 800;
2063
+ font-style: normal;
2064
+ line-height: normal;
2129
2065
  }
2130
2066
 
2131
- .skeleton .title {
2132
- border-radius: var(--pbo-border-radius-large);
2133
- font-size: var(--pbo-font-size-x-large);
2134
- font-weight: var(--pbo-font-weight-normal);
2135
- margin-top: var(--pbo-spacing-medium);
2136
- margin-bottom: var(--pbo-spacing-x-small);
2137
- animation: pulse 1.5s infinite;
2138
- height: var(--pbo-spacing-x-large);
2139
- width: 100%;
2140
- background: var(--pbo-color-gray-200);
2141
- grid-column: 2/3;
2067
+ .step-description {
2068
+ margin: 0;
2069
+ font-size: 17.5px;
2070
+ font-weight: 400;
2071
+ font-style: normal;
2072
+ line-height: normal;
2142
2073
  }
2143
2074
 
2144
- @keyframes pulse {
2145
- 0% {
2146
- background-color: #f3f3f3;
2147
- }
2148
- 50% {
2149
- background-color: #e0e0e0;
2150
- }
2151
- 100% {
2152
- background-color: #f3f3f3;
2153
- }
2154
- }
2155
- .embla__button_container {
2156
- grid-row: 2/3;
2157
- justify-self: center;
2158
- }
2159
- .embla {
2160
- grid-row: 2/3;
2161
- grid-column: 2/3;
2162
- --slide-size: 50%;
2163
- --slide-spacing: calc(var(--slide-size) * 0.05);
2164
- --detail-high-contrast: rgb(101, 101, 101);
2165
- --detail-medium-contrast: rgb(25, 25, 25);
2166
- --detail-low-contrast: rgb(21, 21, 21);
2075
+ .fake-loading-container {
2076
+ display: flex;
2077
+ justify-content: center;
2078
+ align-items: center;
2167
2079
  }
2168
2080
 
2169
- @media screen and (min-width: 640px) {
2170
- .embla {
2171
- --slide-size: 33.33%;
2172
- }
2081
+ .handwritten-form {
2082
+ display: flex;
2083
+ flex-direction: column;
2084
+ gap: var(--pbo-spacing-medium);
2085
+ padding: 0;
2173
2086
  }
2174
2087
 
2175
- @media screen and (min-width: 768px) {
2176
- .embla {
2177
- --slide-size: 25%;
2178
- }
2088
+ .reupload-cta::part(base) {
2089
+ color: black;
2179
2090
  }
2180
2091
 
2181
- .embla__viewport {
2182
- overflow: hidden;
2183
- width: 100%;
2184
- padding: 4px;
2092
+ .reupload-cta::part(label) {
2093
+ font-size: 14px;
2185
2094
  }
2186
2095
 
2187
- .embla__container {
2096
+ .handwritten-tutorials {
2097
+ margin-top: 25px;
2098
+ margin-bottom: 25px;
2188
2099
  display: flex;
2189
- touch-action: pan-y pinch-zoom;
2190
- margin-left: calc(var(--slide-spacing) * -1);
2100
+ flex-direction: column;
2101
+ gap: 15px;
2191
2102
  }
2192
2103
 
2193
- .embla__slide {
2194
- padding-left: calc(var(--slide-size) * 0.05);
2195
- transform: translate3d(0, 0, 0);
2196
- flex: 0 0 var(--slide-size);
2197
- min-width: 0;
2198
- position: relative;
2199
- transition: transform 0.3s ease;
2104
+ .tutorial-steps {
2105
+ list-style: none;
2106
+ padding: 0;
2107
+ margin: 0;
2108
+ display: flex;
2109
+ flex-direction: column;
2110
+ gap: 15px;
2200
2111
  }
2201
2112
 
2202
- .embla__slide:hover {
2203
- transform: scale(1.03);
2204
- z-index: 1;
2113
+ .tutorial-steps li {
2114
+ display: flex;
2115
+ flex-direction: column;
2205
2116
  }
2206
2117
 
2207
- .embla__slide__button {
2208
- background: none;
2209
- border: none;
2118
+ .visually-hidden {
2119
+ position: absolute;
2120
+ width: 1px;
2121
+ height: 1px;
2210
2122
  padding: 0;
2211
- cursor: pointer;
2212
- display: block;
2213
- width: 100%;
2123
+ margin: -1px;
2124
+ overflow: hidden;
2125
+ clip: rect(0, 0, 0, 0);
2126
+ white-space: nowrap;
2127
+ border: 0;
2214
2128
  }
2215
2129
 
2216
- .embla__slide__button:focus {
2217
- outline: none;
2130
+ .submit-error {
2131
+ color: var(--pbo-color-danger, #d93025);
2132
+ font-size: var(--pbo-font-size-small);
2133
+ text-align: center;
2134
+ display: none;
2218
2135
  }
2219
2136
 
2220
- .embla__slide__button:focus-visible {
2221
- outline: var(--pbo-focus-ring);
2222
- outline-offset: 2px;
2137
+ .submit-error:not(:empty) {
2138
+ display: block;
2223
2139
  }
2224
-
2225
- .embla__slide__img {
2226
- box-shadow:
2227
- rgba(0, 0, 0, 0) 0px 0px 0px 0px,
2228
- rgba(0, 0, 0, 0) 0px 0px 0px 0px,
2229
- rgba(0, 0, 0, 0.1) 0px 4px 6px -1px,
2230
- rgba(0, 0, 0, 0.1) 0px 2px 4px -2px;
2231
- border: 2px solid rgb(241, 245, 249);
2140
+ `,up=it`
2141
+ :host {
2142
+ display: block;
2143
+ }
2144
+ .fake-loading {
2232
2145
  display: flex;
2233
2146
  align-items: center;
2234
- justify-content: center;
2235
- width: 100%;
2236
- height: auto;
2147
+ gap: 8px;
2237
2148
  }
2238
2149
 
2239
- .embla__buttons {
2240
- display: grid;
2241
- grid-template-columns: repeat(2, 1fr);
2242
- gap: 0.6rem;
2150
+ pbo-spinner {
2151
+ font-size: 24px;
2152
+ display: flex;
2243
2153
  align-items: center;
2154
+ line-height: 1;
2244
2155
  }
2245
2156
 
2246
- .embla__button {
2247
- -webkit-tap-highlight-color: rgba(var(--text-high-contrast-rgb-value), 0.5);
2248
- -webkit-appearance: none;
2249
- appearance: none;
2250
- background-color: transparent;
2251
- touch-action: manipulation;
2252
- display: inline-flex;
2253
- text-decoration: none;
2254
- cursor: pointer;
2255
- border: 0;
2256
- padding: 0;
2257
- margin: 0;
2258
- width: 36;
2259
- height: 36;
2260
- z-index: 1;
2157
+ .fake-loading span {
2158
+ font-size: 18.75px;
2159
+ line-height: 1;
2261
2160
  display: flex;
2262
2161
  align-items: center;
2263
- justify-content: center;
2264
- color: black;
2265
2162
  }
2163
+ `;var pp=Object.defineProperty,gp=Object.getOwnPropertyDescriptor,Qs=(n,t,e,i)=>{for(var s=i>1?void 0:i?gp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&pp(t,e,s),s};let Ve=class extends vt{constructor(){super(...arguments),this.loading=!1,this.loadingTime=0,this.loadingPattern="random",this.progress=0,this.loadingInterval=null,this.startTime=0,this.PHASES={QUICK:{target:90,duration:15e3},SLOW:{target:98,duration:3e4},FINAL:{target:100,duration:1e3}}}startLoading(){this.startTime=Date.now(),this.progress=0,this.loadingInterval&&clearInterval(this.loadingInterval),this.loadingInterval=window.setInterval(()=>{const t=Date.now()-this.startTime;if(this.progress<this.PHASES.QUICK.target)this.progress=Math.min(this.PHASES.QUICK.target,t/this.PHASES.QUICK.duration*this.PHASES.QUICK.target);else if(this.progress<this.PHASES.SLOW.target){const e=(t-this.PHASES.QUICK.duration)/this.PHASES.SLOW.duration;this.progress=Math.min(this.PHASES.SLOW.target,this.PHASES.QUICK.target+e*(this.PHASES.SLOW.target-this.PHASES.QUICK.target))}this.requestUpdate()},50)}completeLoading(){this.loadingInterval&&clearInterval(this.loadingInterval);const t=this.progress,e=Date.now();this.loadingInterval=window.setInterval(()=>{const i=Date.now()-e,s=Math.min(100,t+i/this.PHASES.FINAL.duration*(100-t));this.progress=s,s>=100&&this.stopLoading(),this.requestUpdate()},16)}stopLoading(){this.loadingInterval&&(clearInterval(this.loadingInterval),this.loadingInterval=null)}updated(t){t.has("loading")&&(this.loading?this.startLoading():this.completeLoading())}disconnectedCallback(){super.disconnectedCallback(),this.stopLoading()}render(){return F`<div
2164
+ class="${fe({"fake-loading":!0,"fake-loading--linear":this.loadingPattern==="linear","fake-loading--random":this.loadingPattern==="random","fake-loading--loading":!0})}"
2165
+ >
2166
+ <pbo-spinner
2167
+ style="${ge({"--track-width":"3px","--indicator-color":"black"})}"
2168
+ ></pbo-spinner>
2169
+ <span>${Math.round(this.progress)}%</span>
2170
+ </div>`}};Ve.styles=[bt,up];Ve.dependencies={"pbo-spinner":as};Qs([C({type:Boolean,reflect:!0})],Ve.prototype,"loading",2);Qs([C({type:Number})],Ve.prototype,"loadingTime",2);Qs([C()],Ve.prototype,"loadingPattern",2);Qs([I()],Ve.prototype,"progress",2);Ve=Qs([mt("pbo-fake-loading")],Ve);var fp=Object.defineProperty,mp=Object.getOwnPropertyDescriptor,st=(n,t,e,i)=>{for(var s=i>1?void 0:i?mp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&fp(t,e,s),s};let X=class extends vt{constructor(){super(...arguments),this.card=null,this.submitHandwrittenForm=async t=>{console.warn("submitHandwrittenForm not implemented",t)},this.getProcessedImg=async t=>(console.warn("getProcessedImg not implemented",t.name),{masked_img:"",uid:""}),this.onClose=()=>{console.warn("onClose not implemented")},this.isSubmitLoading=!1,this.ctaPrimaryLabel="Add to Cart",this.isSubmitDisabled=!1,this.isProcessingError=!1,this.submitError="",this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.handwrittenDimensions={top:null,left:null,width:null,height:null,cardHeight:null,cardWidth:null}}showPicker(){this.imageInput.showPicker()}setButtonsDisabled(t){this.uploadButton&&this.saveButton&&this.reuploadButton&&(this.uploadButton.disabled=t,this.saveButton.disabled=t,this.reuploadButton.disabled=t)}setButtonsError(t){this.uploadButton&&this.saveButton&&(this.uploadButton.variant=t?"danger":"primary",this.saveButton.variant=t?"danger":"primary",this.uploadButton.value=t?"Error uploading image":"Upload Handwritten Image")}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleProcessingErrorChange(){this.setButtonsError(this.isProcessingError)}handleSourceImgChange(t,e){this.processedImg={uid:null,masked_img:null},this.emit("pbo-handwritten-form-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){this.emit("pbo-handwritten-form-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing),this.emit("pbo-image-processing",{detail:{isLoading:this.isImageProcessing}})}get formData(){var s,r,o,a,l;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={barcode:((s=this.card)==null?void 0:s.barcode)||"",pboCardId:((r=this.card)==null?void 0:r.pboId)||"Unknown",productId:(o=this.card)==null?void 0:o.productId,sku:(a=this.card)==null?void 0:a.sku,variantId:(l=this.card)==null?void 0:l.variantId,pred_image_uid:this.processedImg.uid||"",position_x:this.handwrittenDimensions.left*e,position_y:this.handwrittenDimensions.top*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return hc(i)}setDimensions(t){this.handwrittenDimensions=t}handleProcessedImgChange(){this.processedImg.masked_img&&this.emit("pbo-handwritten-form-change",{detail:{isLoading:!1,processedFileUrl:this.processedImg.masked_img}})}async handleFileChange(t){var i,s;this.sourceImg===null&&this.processedImg.masked_img===null?this.emit("pbo_edit_handwritten_form",{detail:{action:"upload"}}):this.emit("pbo_edit_handwritten_form",{detail:{action:"reupload"}}),this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.isProcessingError=!1,this.submitError="";const e=(s=(i=t.target)==null?void 0:i.files)==null?void 0:s[0];if(e!=null){this.sourceImg=e,this.isImageProcessing=!0,this.updateComplete.then(()=>{this.uploadButton.scrollIntoView(!0)});try{const r=await this.getProcessedImg(e);this.processedImg={masked_img:`data:image/png;base64,${r.masked_img}`,uid:r.uid}}catch(r){throw this.isProcessingError=!0,r}finally{this.isImageProcessing=!1}}}async handleSubmit(t){t.preventDefault(),this.isSubmitLoading=!0,this.isSubmitDisabled=!0,this.submitError="";try{await this.submitHandwrittenForm(this.formData),this.onClose(),this.emit("pbo-handwritten-form-submitted")}catch(e){throw this.submitError="Something went wrong. Please try again.",e}finally{this.isSubmitLoading=!1,this.isSubmitDisabled=!1}}render(){return F`
2171
+ <form
2172
+ name="handwritten-form"
2173
+ class="handwritten-form"
2174
+ @submit=${this.handleSubmit}
2175
+ aria-busy=${this.isImageProcessing||this.isSubmitLoading?"true":"false"}
2176
+ >
2177
+ <div role="status" aria-live="polite" aria-atomic="true" class="visually-hidden">
2178
+ ${this.isImageProcessing?"Uploading image, please wait.":""}
2179
+ ${this.isProcessingError&&!this.isImageProcessing?"Image upload failed. Please try again.":""}
2180
+ </div>
2181
+ <div class="handwritten-tutorials" aria-label="Instructions">
2182
+ <ol class="tutorial-steps">
2183
+ <li>
2184
+ <strong class="step-title">Step 1</strong>
2185
+ <span class="step-description">Write message &amp; signature on white paper</span>
2186
+ </li>
2187
+ <li>
2188
+ <strong class="step-title">Step 2</strong>
2189
+ <span class="step-description">
2190
+ Take a well-lit photo on your phone, then crop and save it
2191
+ </span>
2192
+ </li>
2193
+ <li>
2194
+ <strong class="step-title">Step 3</strong>
2195
+ <span class="step-description">Crop photo tightly around text, then upload</span>
2196
+ </li>
2197
+ <li>
2198
+ <strong class="step-title">Step 4</strong>
2199
+ <span class="step-description">Review preview &amp; adjust if needed</span>
2200
+ </li>
2201
+ </ol>
2202
+ </div>
2266
2203
 
2267
- .embla__button:disabled {
2268
- color: rgb(134, 134, 134, 0.8);
2269
- cursor: not-allowed;
2270
- }
2204
+ <label for="handwritten-file-input" class="visually-hidden">
2205
+ Handwritten image file (.png, .jpeg, .jpg)
2206
+ </label>
2207
+ <input
2208
+ id="handwritten-file-input"
2209
+ class="pixel-input"
2210
+ type="file"
2211
+ accept=".png, .jpeg, .jpg"
2212
+ @change=${this.handleFileChange}
2213
+ required
2214
+ />
2271
2215
 
2272
- .embla__button__svg {
2273
- width: 20px;
2274
- height: 20px;
2275
- }
2216
+ <!-- Fake loading -->
2217
+ ${this.isImageProcessing?F`<div class="fake-loading-container">
2218
+ <pbo-fake-loading ?loading=${this.isImageProcessing}></pbo-fake-loading>
2219
+ </div>`:Z}
2276
2220
 
2277
- .embla__button_container {
2278
- display: flex;
2279
- justify-content: center;
2280
- align-items: center;
2281
- }
2282
- `,gp=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}";/**
2283
- * @license
2284
- * Copyright 2021 Google LLC
2285
- * SPDX-License-Identifier: BSD-3-Clause
2286
- */function*uc(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}function Do(n){return typeof n=="number"}function oo(n){return typeof n=="string"}function dn(n){return typeof n=="boolean"}function Ga(n){return Object.prototype.toString.call(n)==="[object Object]"}function pt(n){return Math.abs(n)}function Ao(n){return Math.sign(n)}function js(n,t){return pt(n-t)}function fp(n,t){if(n===0||t===0||pt(n)<=pt(t))return 0;const e=js(pt(n),pt(t));return pt(e/n)}function mp(n){return Math.round(n*100)/100}function Ns(n){return Us(n).map(Number)}function Oe(n){return n[Qs(n)]}function Qs(n){return Math.max(0,n.length-1)}function Mo(n,t){return t===Qs(n)}function Ya(n,t=0){return Array.from(Array(n),(e,i)=>t+i)}function Us(n){return Object.keys(n)}function pc(n,t){return[n,t].reduce((e,i)=>(Us(i).forEach(s=>{const r=e[s],o=i[s],a=Ga(r)&&Ga(o);e[s]=a?pc(r,o):o}),e),{})}function ao(n,t){return typeof t.MouseEvent<"u"&&n instanceof t.MouseEvent}function bp(n,t){const e={start:i,center:s,end:r};function i(){return 0}function s(l){return r(l)/2}function r(l){return t-l}function o(l,c){return oo(n)?e[n](l):n(t,l,c)}return{measure:o}}function Ws(){let n=[];function t(s,r,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(r,o,a),l=()=>s.removeEventListener(r,o,a);else{const c=s;c.addListener(o),l=()=>c.removeListener(o)}return n.push(l),i}function e(){n=n.filter(s=>s())}const i={add:t,clear:e};return i}function vp(n,t,e,i){const s=Ws(),r=1e3/60;let o=null,a=0,l=0;function c(){s.add(n,"visibilitychange",()=>{n.hidden&&g()})}function h(){p(),s.clear()}function d(b){if(!l)return;o||(o=b,e(),e());const m=b-o;for(o=b,a+=m;a>=r;)e(),a-=r;const _=a/r;i(_),l&&(l=t.requestAnimationFrame(d))}function u(){l||(l=t.requestAnimationFrame(d))}function p(){t.cancelAnimationFrame(l),o=null,a=0,l=0}function g(){o=null,a=0}return{init:c,destroy:h,start:u,stop:p,update:e,render:i}}function yp(n,t){const e=t==="rtl",i=n==="y",s=i?"y":"x",r=i?"x":"y",o=!i&&e?-1:1,a=h(),l=d();function c(g){const{height:f,width:b}=g;return i?f:b}function h(){return i?"top":e?"right":"left"}function d(){return i?"bottom":e?"left":"right"}function u(g){return g*o}return{scroll:s,cross:r,startEdge:a,endEdge:l,measureSize:c,direction:u}}function zi(n=0,t=0){const e=pt(n-t);function i(c){return c<n}function s(c){return c>t}function r(c){return i(c)||s(c)}function o(c){return r(c)?i(c)?n:t:c}function a(c){return e?c-e*Math.ceil((c-t)/e):c}return{length:e,max:t,min:n,constrain:o,reachedAny:r,reachedMax:s,reachedMin:i,removeOffset:a}}function gc(n,t,e){const{constrain:i}=zi(0,n),s=n+1;let r=o(t);function o(u){return e?pt((s+u)%s):i(u)}function a(){return r}function l(u){return r=o(u),d}function c(u){return h().set(a()+u)}function h(){return gc(n,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function _p(n,t,e,i,s,r,o,a,l,c,h,d,u,p,g,f,b,m,_){const{cross:x,direction:S}=n,T=["INPUT","SELECT","TEXTAREA"],O={passive:!1},k=Ws(),E=Ws(),P=zi(50,225).constrain(p.measure(20)),R={mouse:300,touch:400},L={mouse:500,touch:600},j=g?43:25;let H=!1,M=0,U=0,q=!1,Q=!1,N=!1,kt=!1;function Gt(A){if(!_)return;function tt(Xt){(dn(_)||_(A,Xt))&&he(Xt)}const Ot=t;k.add(Ot,"dragstart",Xt=>Xt.preventDefault(),O).add(Ot,"touchmove",()=>{},O).add(Ot,"touchend",()=>{}).add(Ot,"touchstart",tt).add(Ot,"mousedown",tt).add(Ot,"touchcancel",$t).add(Ot,"contextmenu",$t).add(Ot,"click",de,!0)}function Yt(){k.clear(),E.clear()}function Ie(){const A=kt?e:t;E.add(A,"touchmove",At,O).add(A,"touchend",$t).add(A,"mousemove",At,O).add(A,"mouseup",$t)}function me(A){const tt=A.nodeName||"";return T.includes(tt)}function jt(){return(g?L:R)[kt?"mouse":"touch"]}function Le(A,tt){const Ot=d.add(Ao(A)*-1),Xt=h.byDistance(A,!g).distance;return g||pt(A)<P?Xt:b&&tt?Xt*.5:h.byIndex(Ot.get(),0).distance}function he(A){const tt=ao(A,i);kt=tt,N=g&&tt&&!A.buttons&&H,H=js(s.get(),o.get())>=2,!(tt&&A.button!==0)&&(me(A.target)||(q=!0,r.pointerDown(A),c.useFriction(0).useDuration(0),s.set(o),Ie(),M=r.readPoint(A),U=r.readPoint(A,x),u.emit("pointerDown")))}function At(A){if(!ao(A,i)&&A.touches.length>=2)return $t(A);const Ot=r.readPoint(A),Xt=r.readPoint(A,x),Fe=js(Ot,M),Ye=js(Xt,U);if(!Q&&!kt&&(!A.cancelable||(Q=Fe>Ye,!Q)))return $t(A);const ki=r.pointerMove(A);Fe>f&&(N=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(S(ki)),A.preventDefault()}function $t(A){const Ot=h.byDistance(0,!1).index!==d.get(),Xt=r.pointerUp(A)*jt(),Fe=Le(S(Xt),Ot),Ye=fp(Xt,Fe),ki=j-10*Ye,di=m+Ye/50;Q=!1,q=!1,E.clear(),c.useDuration(ki).useFriction(di),l.distance(Fe,!g),kt=!1,u.emit("pointerUp")}function de(A){N&&(A.stopPropagation(),A.preventDefault(),N=!1)}function _t(){return q}return{init:Gt,destroy:Yt,pointerDown:_t}}function xp(n,t){let i,s;function r(d){return d.timeStamp}function o(d,u){const g=`client${(u||n.scroll)==="x"?"X":"Y"}`;return(ao(d,t)?d:d.touches[0])[g]}function a(d){return i=d,s=d,o(d)}function l(d){const u=o(d)-o(s),p=r(d)-r(i)>170;return s=d,p&&(i=d),u}function c(d){if(!i||!s)return 0;const u=o(s)-o(i),p=r(d)-r(i),g=r(d)-r(s)>170,f=u/p;return p&&!g&&pt(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function wp(){function n(e){const{offsetTop:i,offsetLeft:s,offsetWidth:r,offsetHeight:o}=e;return{top:i,right:s+r,bottom:i+o,left:s,width:r,height:o}}return{measure:n}}function Cp(n){function t(i){return n*(i/100)}return{measure:t}}function Sp(n,t,e,i,s,r,o){const a=[n].concat(i);let l,c,h=[],d=!1;function u(b){return s.measureSize(o.measure(b))}function p(b){if(!r)return;c=u(n),h=i.map(u);function m(_){for(const x of _){if(d)return;const S=x.target===n,T=i.indexOf(x.target),O=S?c:h[T],k=u(S?n:i[T]);if(pt(k-O)>=.5){b.reInit(),t.emit("resize");break}}}l=new ResizeObserver(_=>{(dn(r)||r(b,_))&&m(_)}),e.requestAnimationFrame(()=>{a.forEach(_=>l.observe(_))})}function g(){d=!0,l&&l.disconnect()}return{init:p,destroy:g}}function Tp(n,t,e,i,s,r){let o=0,a=0,l=s,c=r,h=n.get(),d=0;function u(){const O=i.get()-n.get(),k=!l;let E=0;return k?(o=0,e.set(i),n.set(i),E=O):(e.set(n),o+=O/l,o*=c,h+=o,n.add(o),E=h-d),a=Ao(E),d=h,T}function p(){const O=i.get()-t.get();return pt(O)<.001}function g(){return l}function f(){return a}function b(){return o}function m(){return x(s)}function _(){return S(r)}function x(O){return l=O,T}function S(O){return c=O,T}const T={direction:f,duration:g,velocity:b,seek:u,settled:p,useBaseFriction:_,useBaseDuration:m,useFriction:S,useDuration:x};return T}function Ep(n,t,e,i,s){const r=s.measure(10),o=s.measure(50),a=zi(.1,.99);let l=!1;function c(){return!(l||!n.reachedAny(e.get())||!n.reachedAny(t.get()))}function h(p){if(!c())return;const g=n.reachedMin(t.get())?"min":"max",f=pt(n[g]-t.get()),b=e.get()-t.get(),m=a.constrain(f/o);e.subtract(b*m),!p&&pt(b)<r&&(e.set(n.constrain(e.get())),i.useDuration(25).useBaseFriction())}function d(p){l=!p}return{shouldConstrain:c,constrain:h,toggleActive:d}}function kp(n,t,e,i,s){const r=zi(-t+n,0),o=d(),a=h(),l=u();function c(g,f){return js(g,f)<=1}function h(){const g=o[0],f=Oe(o),b=o.lastIndexOf(g),m=o.indexOf(f)+1;return zi(b,m)}function d(){return e.map((g,f)=>{const{min:b,max:m}=r,_=r.constrain(g),x=!f,S=Mo(e,f);return x?m:S||c(b,_)?b:c(m,_)?m:_}).map(g=>parseFloat(g.toFixed(3)))}function u(){if(t<=n+s)return[r.max];if(i==="keepSnaps")return o;const{min:g,max:f}=a;return o.slice(g,f)}return{snapsContained:l,scrollContainLimit:a}}function Op(n,t,e){const i=t[0],s=e?i-n:Oe(t);return{limit:zi(s,i)}}function Pp(n,t,e,i){const r=t.min+.1,o=t.max+.1,{reachedMin:a,reachedMax:l}=zi(r,o);function c(u){return u===1?l(e.get()):u===-1?a(e.get()):!1}function h(u){if(!c(u))return;const p=n*(u*-1);i.forEach(g=>g.add(p))}return{loop:h}}function Dp(n){const{max:t,length:e}=n;function i(r){const o=r-t;return e?o/-e:0}return{get:i}}function Ap(n,t,e,i,s){const{startEdge:r,endEdge:o}=n,{groupSlides:a}=s,l=d().map(t.measure),c=u(),h=p();function d(){return a(i).map(f=>Oe(f)[o]-f[0][r]).map(pt)}function u(){return i.map(f=>e[r]-f[r]).map(f=>-pt(f))}function p(){return a(c).map(f=>f[0]).map((f,b)=>f+l[b])}return{snaps:c,snapsAligned:h}}function Mp(n,t,e,i,s,r){const{groupSlides:o}=s,{min:a,max:l}=i,c=h();function h(){const u=o(r),p=!n||t==="keepSnaps";return e.length===1?[r]:p?u:u.slice(a,l).map((g,f,b)=>{const m=!f,_=Mo(b,f);if(m){const x=Oe(b[0])+1;return Ya(x)}if(_){const x=Qs(r)-Oe(b)[0]+1;return Ya(x,Oe(b)[0])}return g})}return{slideRegistry:c}}function Ip(n,t,e,i,s){const{reachedAny:r,removeOffset:o,constrain:a}=i;function l(g){return g.concat().sort((f,b)=>pt(f)-pt(b))[0]}function c(g){const f=n?o(g):a(g),b=t.map((_,x)=>({diff:h(_-f,0),index:x})).sort((_,x)=>pt(_.diff)-pt(x.diff)),{index:m}=b[0];return{index:m,distance:f}}function h(g,f){const b=[g,g+e,g-e];if(!n)return g;if(!f)return l(b);const m=b.filter(_=>Ao(_)===f);return m.length?l(m):Oe(b)-e}function d(g,f){const b=t[g]-s.get(),m=h(b,f);return{index:g,distance:m}}function u(g,f){const b=s.get()+g,{index:m,distance:_}=c(b),x=!n&&r(b);if(!f||x)return{index:m,distance:g};const S=t[m]-_,T=g+h(S,0);return{index:m,distance:T}}return{byDistance:u,byIndex:d,shortcut:h}}function Lp(n,t,e,i,s,r,o){function a(d){const u=d.distance,p=d.index!==t.get();r.add(u),u&&(i.duration()?n.start():(n.update(),n.render(1),n.update())),p&&(e.set(t.get()),t.set(d.index),o.emit("select"))}function l(d,u){const p=s.byDistance(d,u);a(p)}function c(d,u){const p=t.clone().set(d),g=s.byIndex(p.get(),u);a(g)}return{distance:l,index:c}}function Fp(n,t,e,i,s,r,o,a){const l={passive:!0,capture:!0};let c=0;function h(p){if(!a)return;function g(f){if(new Date().getTime()-c>10)return;o.emit("slideFocusStart"),n.scrollLeft=0;const _=e.findIndex(x=>x.includes(f));Do(_)&&(s.useDuration(0),i.index(_,0),o.emit("slideFocus"))}r.add(document,"keydown",d,!1),t.forEach((f,b)=>{r.add(f,"focus",m=>{(dn(a)||a(p,m))&&g(b)},l)})}function d(p){p.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function As(n){let t=n;function e(){return t}function i(l){t=o(l)}function s(l){t+=o(l)}function r(l){t-=o(l)}function o(l){return Do(l)?l:l.get()}return{get:e,set:i,add:s,subtract:r}}function fc(n,t){const e=n.scroll==="x"?o:a,i=t.style;let s=null,r=!1;function o(u){return`translate3d(${u}px,0px,0px)`}function a(u){return`translate3d(0px,${u}px,0px)`}function l(u){if(r)return;const p=mp(n.direction(u));p!==s&&(i.transform=e(p),s=p)}function c(u){r=!u}function h(){r||(i.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:h,to:l,toggleActive:c}}function jp(n,t,e,i,s,r,o,a,l){const h=Ns(s),d=Ns(s).reverse(),u=m().concat(_());function p(k,E){return k.reduce((P,R)=>P-s[R],E)}function g(k,E){return k.reduce((P,R)=>p(P,E)>0?P.concat([R]):P,[])}function f(k){return r.map((E,P)=>({start:E-i[P]+.5+k,end:E+t-.5+k}))}function b(k,E,P){const R=f(E);return k.map(L=>{const j=P?0:-e,H=P?e:0,M=P?"end":"start",U=R[L][M];return{index:L,loopPoint:U,slideLocation:As(-1),translate:fc(n,l[L]),target:()=>a.get()>U?j:H}})}function m(){const k=o[0],E=g(d,k);return b(E,e,!1)}function _(){const k=t-o[0]-1,E=g(h,k);return b(E,-e,!0)}function x(){return u.every(({index:k})=>{const E=h.filter(P=>P!==k);return p(E,t)<=.1})}function S(){u.forEach(k=>{const{target:E,translate:P,slideLocation:R}=k,L=E();L!==R.get()&&(P.to(L),R.set(L))})}function T(){u.forEach(k=>k.translate.clear())}return{canLoop:x,clear:T,loop:S,loopPoints:u}}function $p(n,t,e){let i,s=!1;function r(l){if(!e)return;function c(h){for(const d of h)if(d.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}i=new MutationObserver(h=>{s||(dn(e)||e(l,h))&&c(h)}),i.observe(n,{childList:!0})}function o(){i&&i.disconnect(),s=!0}return{init:r,destroy:o}}function Rp(n,t,e,i){const s={};let r=null,o=null,a,l=!1;function c(){a=new IntersectionObserver(g=>{l||(g.forEach(f=>{const b=t.indexOf(f.target);s[b]=f}),r=null,o=null,e.emit("slidesInView"))},{root:n.parentElement,threshold:i}),t.forEach(g=>a.observe(g))}function h(){a&&a.disconnect(),l=!0}function d(g){return Us(s).reduce((f,b)=>{const m=parseInt(b),{isIntersecting:_}=s[m];return(g&&_||!g&&!_)&&f.push(m),f},[])}function u(g=!0){if(g&&r)return r;if(!g&&o)return o;const f=d(g);return g&&(r=f),g||(o=f),f}return{init:c,destroy:h,get:u}}function Bp(n,t,e,i,s,r){const{measureSize:o,startEdge:a,endEdge:l}=n,c=e[0]&&s,h=g(),d=f(),u=e.map(o),p=b();function g(){if(!c)return 0;const _=e[0];return pt(t[a]-_[a])}function f(){if(!c)return 0;const _=r.getComputedStyle(Oe(i));return parseFloat(_.getPropertyValue(`margin-${l}`))}function b(){return e.map((_,x,S)=>{const T=!x,O=Mo(S,x);return T?u[x]+h:O?u[x]+d:S[x+1][a]-_[a]}).map(pt)}return{slideSizes:u,slideSizesWithGaps:p,startGap:h,endGap:d}}function zp(n,t,e,i,s,r,o,a,l){const{startEdge:c,endEdge:h,direction:d}=n,u=Do(e);function p(m,_){return Ns(m).filter(x=>x%_===0).map(x=>m.slice(x,x+_))}function g(m){return m.length?Ns(m).reduce((_,x,S)=>{const T=Oe(_)||0,O=T===0,k=x===Qs(m),E=s[c]-r[T][c],P=s[c]-r[x][h],R=!i&&O?d(o):0,L=!i&&k?d(a):0,j=pt(P-L-(E+R));return S&&j>t+l&&_.push(x),k&&_.push(m.length),_},[]).map((_,x,S)=>{const T=Math.max(S[x-1]||0);return m.slice(T,_)}):[]}function f(m){return u?p(m,e):g(m)}return{groupSlides:f}}function Hp(n,t,e,i,s,r,o){const{align:a,axis:l,direction:c,startIndex:h,loop:d,duration:u,dragFree:p,dragThreshold:g,inViewThreshold:f,slidesToScroll:b,skipSnaps:m,containScroll:_,watchResize:x,watchSlides:S,watchDrag:T,watchFocus:O}=r,k=2,E=wp(),P=E.measure(t),R=e.map(E.measure),L=yp(l,c),j=L.measureSize(P),H=Cp(j),M=bp(a,j),U=!d&&!!_,q=d||!!_,{slideSizes:Q,slideSizesWithGaps:N,startGap:kt,endGap:Gt}=Bp(L,P,R,e,q,s),Yt=zp(L,j,b,d,P,R,kt,Gt,k),{snaps:Ie,snapsAligned:me}=Ap(L,M,P,R,Yt),jt=-Oe(Ie)+Oe(N),{snapsContained:Le,scrollContainLimit:he}=kp(j,jt,me,_,k),At=U?Le:me,{limit:$t}=Op(jt,At,d),de=gc(Qs(At),h,d),_t=de.clone(),dt=Ns(e),A=({dragHandler:Yi,scrollBody:En,scrollBounds:kn,options:{loop:rr}})=>{rr||kn.constrain(Yi.pointerDown()),En.seek()},tt=({scrollBody:Yi,translate:En,location:kn,offsetLocation:rr,previousLocation:xh,scrollLooper:wh,slideLooper:Ch,dragHandler:Sh,animation:Th,eventHandler:sa,scrollBounds:Eh,options:{loop:ra}},na)=>{const oa=Yi.settled(),kh=!Eh.shouldConstrain(),aa=ra?oa:oa&&kh,la=aa&&!Sh.pointerDown();la&&Th.stop();const Oh=kn.get()*na+xh.get()*(1-na);rr.set(Oh),ra&&(wh.loop(Yi.direction()),Ch.loop()),En.to(rr.get()),la&&sa.emit("settle"),aa||sa.emit("scroll")},Ot=vp(i,s,()=>A(Tn),Yi=>tt(Tn,Yi)),Xt=.68,Fe=At[de.get()],Ye=As(Fe),ki=As(Fe),di=As(Fe),Oi=As(Fe),vs=Tp(Ye,di,ki,Oi,u,Xt),Cn=Ip(d,At,jt,$t,Oi),Sn=Lp(Ot,de,_t,vs,Cn,Oi,o),ta=Dp($t),ea=Ws(),yh=Rp(t,e,o,f),{slideRegistry:ia}=Mp(U,_,At,he,Yt,dt),_h=Fp(n,e,ia,Sn,vs,ea,o,O),Tn={ownerDocument:i,ownerWindow:s,eventHandler:o,containerRect:P,slideRects:R,animation:Ot,axis:L,dragHandler:_p(L,n,i,s,Oi,xp(L,s),Ye,Ot,Sn,vs,Cn,de,o,H,p,g,m,Xt,T),eventStore:ea,percentOfView:H,index:de,indexPrevious:_t,limit:$t,location:Ye,offsetLocation:di,previousLocation:ki,options:r,resizeHandler:Sp(t,o,s,e,L,x,E),scrollBody:vs,scrollBounds:Ep($t,di,Oi,vs,H),scrollLooper:Pp(jt,$t,di,[Ye,di,ki,Oi]),scrollProgress:ta,scrollSnapList:At.map(ta.get),scrollSnaps:At,scrollTarget:Cn,scrollTo:Sn,slideLooper:jp(L,j,jt,Q,N,Ie,At,di,e),slideFocus:_h,slidesHandler:$p(t,o,S),slidesInView:yh,slideIndexes:dt,slideRegistry:ia,slidesToScroll:Yt,target:Oi,translate:fc(L,t)};return Tn}function Vp(){let n={},t;function e(c){t=c}function i(c){return n[c]||[]}function s(c){return i(c).forEach(h=>h(t,c)),l}function r(c,h){return n[c]=i(c).concat([h]),l}function o(c,h){return n[c]=i(c).filter(d=>d!==h),l}function a(){n={}}const l={init:e,emit:s,off:o,on:r,clear:a};return l}const Np={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function Up(n){function t(r,o){return pc(r,o||{})}function e(r){const o=r.breakpoints||{},a=Us(o).filter(l=>n.matchMedia(l).matches).map(l=>o[l]).reduce((l,c)=>t(l,c),{});return t(r,a)}function i(r){return r.map(o=>Us(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(n.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function Wp(n){let t=[];function e(r,o){return t=o.filter(({options:a})=>n.optionsAtMedia(a).active!==!1),t.forEach(a=>a.init(r,n)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function i(){t=t.filter(r=>r.destroy())}return{init:e,destroy:i}}function Io(n,t,e){const i=n.ownerDocument,s=i.defaultView,r=Up(s),o=Wp(r),a=Ws(),l=Vp(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=r,{on:u,off:p,emit:g}=l,f=L;let b=!1,m,_=c(Np,Io.globalOptions),x=c(_),S=[],T,O,k;function E(){const{container:dt,slides:A}=x;O=(oo(dt)?n.querySelector(dt):dt)||n.children[0];const Ot=oo(A)?O.querySelectorAll(A):A;k=[].slice.call(Ot||O.children)}function P(dt){const A=Hp(n,O,k,i,s,dt,l);if(dt.loop&&!A.slideLooper.canLoop()){const tt=Object.assign({},dt,{loop:!1});return P(tt)}return A}function R(dt,A){b||(_=c(_,dt),x=h(_),S=A||S,E(),m=P(x),d([_,...S.map(({options:tt})=>tt)]).forEach(tt=>a.add(tt,"change",L)),x.active&&(m.translate.to(m.location.get()),m.animation.init(),m.slidesInView.init(),m.slideFocus.init(_t),m.eventHandler.init(_t),m.resizeHandler.init(_t),m.slidesHandler.init(_t),m.options.loop&&m.slideLooper.loop(),O.offsetParent&&k.length&&m.dragHandler.init(_t),T=o.init(_t,S)))}function L(dt,A){const tt=Yt();j(),R(c({startIndex:tt},dt),A),l.emit("reInit")}function j(){m.dragHandler.destroy(),m.eventStore.clear(),m.translate.clear(),m.slideLooper.clear(),m.resizeHandler.destroy(),m.slidesHandler.destroy(),m.slidesInView.destroy(),m.animation.destroy(),o.destroy(),a.clear()}function H(){b||(b=!0,a.clear(),j(),l.emit("destroy"),l.clear())}function M(dt,A,tt){!x.active||b||(m.scrollBody.useBaseFriction().useDuration(A===!0?0:x.duration),m.scrollTo.index(dt,tt||0))}function U(dt){const A=m.index.add(1).get();M(A,dt,-1)}function q(dt){const A=m.index.add(-1).get();M(A,dt,1)}function Q(){return m.index.add(1).get()!==Yt()}function N(){return m.index.add(-1).get()!==Yt()}function kt(){return m.scrollSnapList}function Gt(){return m.scrollProgress.get(m.offsetLocation.get())}function Yt(){return m.index.get()}function Ie(){return m.indexPrevious.get()}function me(){return m.slidesInView.get()}function jt(){return m.slidesInView.get(!1)}function Le(){return T}function he(){return m}function At(){return n}function $t(){return O}function de(){return k}const _t={canScrollNext:Q,canScrollPrev:N,containerNode:$t,internalEngine:he,destroy:H,off:p,on:u,emit:g,plugins:Le,previousScrollSnap:Ie,reInit:f,rootNode:At,scrollNext:U,scrollPrev:q,scrollProgress:Gt,scrollSnapList:kt,scrollTo:M,selectedScrollSnap:Yt,slideNodes:de,slidesInView:me,slidesNotInView:jt};return R(t,e),setTimeout(()=>l.emit("init"),0),_t}Io.globalOptions=void 0;var Gp=Object.defineProperty,Yp=Object.getOwnPropertyDescriptor,Me=(n,t,e,i)=>{for(var s=i>1?void 0:i?Yp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Gp(t,e,s),s};let le=class extends vt{constructor(){super(...arguments),this.cards=[],this.skeleton=!1,this.title="",this.firstUpdated=()=>{const t={align:"start",axis:"x",loop:!1},e=Io(this.emblaViewport,t);if(this.skeleton)return;const i=this.addPrevNextBtnsClickHandlers(e,this.emblaPrevButton,this.emblaNextButton);e.on("destroy",i),e.on("reInit",()=>{!e.canScrollPrev()&&!e.canScrollNext()?(console.debug("No previous or next slides available, hiding arrows."),this.emblaPrevButton.style.visibility="hidden",this.emblaNextButton.style.visibility="hidden"):(console.debug("Previous or next slides available, showing arrows."),this.emblaPrevButton.style.visibility="visible",this.emblaNextButton.style.visibility="visible")})},this.disconnectedCallback=()=>{var t;super.disconnectedCallback(),(t=this.imageSplide)==null||t.destroy()},this.clickHandler=t=>{const e=t.target;this.emit("pbo-category-card-selected",{detail:{cardId:e.dataset.cardId||"unknown"}})},this.addTogglePrevNextBtnsActive=(t,e,i)=>{const s=()=>{t.canScrollPrev()?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled"),t.canScrollNext()?i.removeAttribute("disabled"):i.setAttribute("disabled","disabled")};return t.on("select",s).on("init",s).on("reInit",s),()=>{e.removeAttribute("disabled"),i.removeAttribute("disabled")}}}updateArrowVisibility(){const t=this.imageCarousel.querySelector(".splide__arrow--next"),e=this.imageCarousel.querySelector(".splide__arrow--prev");t.style.visibility=t.disabled?"hidden":"visible",e.style.visibility=e.disabled?"hidden":"visible"}addPrevNextBtnsClickHandlers(t,e,i){const s=()=>{t.scrollPrev()},r=()=>{t.scrollNext()};e.addEventListener("click",s,!1),i.addEventListener("click",r,!1);const o=this.addTogglePrevNextBtnsActive(t,e,i);return()=>{o(),e.removeEventListener("click",s,!1),i.removeEventListener("click",r,!1)}}render(){return this.skeleton?F`
2287
- <div class="category-container skeleton">
2288
- <div class="title"></div>
2289
- <section class="embla">
2290
- <div class="embla__viewport">
2291
- <div class="embla__container">
2292
- <div class="embla__slide">
2293
- <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2294
- </div>
2295
- <div class="embla__slide">
2296
- <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2297
- </div>
2298
- <div class="embla__slide">
2299
- <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2300
- </div>
2301
- <div class="embla__slide">
2302
- <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2303
- </div>
2304
- </div>
2305
- </div>
2306
- </section>
2307
- </div>
2308
- `:F`
2309
- <div class="category-container">
2310
- <div class="title" part="category-title">${this.title}</div>
2311
- <div class="embla__button_container embla__button_container--prev">
2312
- <button
2313
- class="embla__button embla__button--prev"
2314
- type="button"
2315
- aria-label="Previous cards"
2221
+ <div class="buttons-container">
2222
+ <!-- Upload button -->
2223
+ <pbo-button
2224
+ exportparts="base:cta-button-base, label:cta-button-label"
2225
+ name="upload"
2226
+ class="upload-button"
2227
+ size="medium"
2228
+ variant="primary"
2229
+ @click=${this.showPicker}
2230
+ style=${ge({display:this.processedImg.masked_img?"none":"block"})}
2316
2231
  >
2317
- <svg aria-hidden="true" class="embla__button__svg" viewBox="0 0 532 532">
2318
- <path
2319
- fill="currentColor"
2320
- d="M355.66 11.354c13.793-13.805 36.208-13.805 50.001 0 13.785 13.804 13.785 36.238 0 50.034L201.22 266l204.442 204.61c13.785 13.805 13.785 36.239 0 50.044-13.793 13.796-36.208 13.796-50.002 0a5994246.277 5994246.277 0 0 0-229.332-229.454 35.065 35.065 0 0 1-10.326-25.126c0-9.2 3.393-18.26 10.326-25.2C172.192 194.973 332.731 34.31 355.66 11.354Z"
2321
- ></path>
2322
- </svg>
2323
- </button>
2324
- </div>
2325
- <section class="embla">
2326
- <div class="embla__viewport">
2327
- <div class="embla__container">
2328
- ${uc(this.cards,t=>F`
2329
- <div class="embla__slide">
2330
- <button
2331
- class="embla__slide__button"
2332
- type="button"
2333
- aria-label="${t.medias.cover.alt||t.name||"Select card"}"
2334
- @click="${()=>this.emit("pbo-category-card-selected",{detail:{cardId:t.pboId}})}"
2335
- >
2336
- <img
2337
- class="embla__slide__img"
2338
- src=${t.medias.cover.url}
2339
- alt=""
2340
- aria-hidden="true"
2341
- />
2342
- </button>
2343
- </div>
2344
- `)}
2345
- </div>
2346
- </div>
2347
- </section>
2348
- <div class="embla__button_container embla__button_container--next">
2349
- <button class="embla__button embla__button--next" type="button" aria-label="Next cards">
2350
- <svg aria-hidden="true" class="embla__button__svg" viewBox="0 0 532 532">
2351
- <path
2352
- fill="currentColor"
2353
- d="M176.34 520.646c-13.793 13.805-36.208 13.805-50.001 0-13.785-13.804-13.785-36.238 0-50.034L330.78 266 126.34 61.391c-13.785-13.805-13.785-36.239 0-50.044 13.793-13.796 36.208-13.796 50.002 0 22.928 22.947 206.395 206.507 229.332 229.454a35.065 35.065 0 0 1 10.326 25.126c0 9.2-3.393 18.26-10.326 25.2-45.865 45.901-206.404 206.564-229.332 229.52Z"
2354
- ></path>
2355
- </svg>
2356
- </button>
2232
+ ${this.isProcessingError?"Please Try Again":""}
2233
+ ${this.isImageProcessing?"Uploading":""}
2234
+ ${!this.isProcessingError&&!this.isImageProcessing?"Upload Handwritten Image":""}
2235
+ </pbo-button>
2236
+
2237
+ <!-- Save button -->
2238
+ <pbo-button
2239
+ exportparts="base:cta-button-base, label:cta-button-label"
2240
+ name="save"
2241
+ type="submit"
2242
+ variant=${this.submitError?"danger":"primary"}
2243
+ class="submit-cta"
2244
+ style=${ge({display:this.sourceImg&&this.processedImg.masked_img&&!this.isImageProcessing?"block":"none"})}
2245
+ >
2246
+ ${this.ctaPrimaryLabel}
2247
+ </pbo-button>
2248
+ <div class="submit-error" role="alert" aria-live="assertive">${this.submitError}</div>
2249
+ <!-- Reupload button -->
2250
+ <pbo-button
2251
+ exportparts="base:cta-link-button-base, label:cta-link-button-label"
2252
+ name="reupload"
2253
+ variant="text"
2254
+ class="submit-cta reupload-cta"
2255
+ @click=${this.showPicker}
2256
+ size="small"
2257
+ style=${ge({display:this.sourceImg&&this.processedImg.masked_img?"block":"none","--pbo-text-color":"black"})}
2258
+ >
2259
+ reupload image
2260
+ </pbo-button>
2357
2261
  </div>
2358
- </div>
2359
- `}};le.styles=[bt,pp,en(gp)];Me([C({type:Array})],le.prototype,"cards",2);Me([C({type:Boolean,reflect:!0})],le.prototype,"skeleton",2);Me([C({type:String})],le.prototype,"title",2);Me([B("#category-carousel")],le.prototype,"imageCarousel",2);Me([B(".embla")],le.prototype,"emblaNode",2);Me([B(".embla__viewport")],le.prototype,"emblaViewport",2);Me([B(".embla__button--prev")],le.prototype,"emblaPrevButton",2);Me([B(".embla__button--next")],le.prototype,"emblaNextButton",2);Me([B(".embla__container")],le.prototype,"emblaContainerEl",2);Me([I()],le.prototype,"imageSplide",2);le=Me([mt("pbo-category")],le);const Vb=le,Xp=it`
2262
+ </form>
2263
+ `}};X.styles=[bt,dp];X.dependencies={"pbo-button":at,"pbo-fake-loading":Ve};st([C()],X.prototype,"card",2);st([C()],X.prototype,"submitHandwrittenForm",2);st([C()],X.prototype,"getProcessedImg",2);st([C({type:Function})],X.prototype,"onClose",2);st([C({type:Boolean,reflect:!0,attribute:"loading"})],X.prototype,"isSubmitLoading",2);st([C({type:String,attribute:"cta-primary-label"})],X.prototype,"ctaPrimaryLabel",2);st([C({type:Boolean,reflect:!0,attribute:"disabled"})],X.prototype,"isSubmitDisabled",2);st([B(".pixel-input")],X.prototype,"imageInput",2);st([B(".handwritten-form")],X.prototype,"handwrittenForm",2);st([B("pbo-button[name='upload']")],X.prototype,"uploadButton",2);st([B("pbo-button[name='save']")],X.prototype,"saveButton",2);st([B("pbo-button[name='reupload']")],X.prototype,"reuploadButton",2);st([I()],X.prototype,"isProcessingError",2);st([I()],X.prototype,"submitError",2);st([I()],X.prototype,"isImageProcessing",2);st([I()],X.prototype,"sourceImg",2);st([I()],X.prototype,"processedImg",2);st([I()],X.prototype,"handwrittenDimensions",2);st([G("isSubmitLoading")],X.prototype,"handleSubmitLoadingChange",1);st([G("isSubmitDisabled")],X.prototype,"handleSubmitDisabledChange",1);st([G("isProcessingError")],X.prototype,"handleProcessingErrorChange",1);st([G("sourceImg")],X.prototype,"handleSourceImgChange",1);st([G("processedFileUrl")],X.prototype,"handleProcessImageChange",1);st([G("isImageProcessing")],X.prototype,"handleImageProcessingChange",1);st([G("processedImg")],X.prototype,"handleProcessedImgChange",1);X=st([mt("pbo-handwritten-form")],X);const bp=X,vp=it`
2360
2264
  :host {
2361
- --size: 70%;
2362
- --header-spacing: var(--pbo-spacing-large);
2363
- --body-spacing: var(--pbo-spacing-large);
2364
- --footer-spacing: var(--pbo-spacing-large);
2365
- --panel-background-color: var(--pbo-panel-background-color);
2366
- --overlay-background-color: var(--pbo-overlay-background-color);
2367
- display: contents;
2265
+ display: block;
2368
2266
  }
2369
2267
 
2370
- .drawer {
2371
- top: 0;
2372
- inset-inline-start: 0;
2373
- width: 100%;
2374
- height: 100%;
2375
- pointer-events: none;
2376
- overflow: hidden;
2268
+ .label {
2269
+ line-height: normal;
2270
+ font-size: 15px;
2377
2271
  }
2378
2272
 
2379
- .drawer__overlay {
2380
- display: block;
2381
- position: fixed;
2382
- top: 0;
2383
- right: 0;
2384
- bottom: 0;
2385
- left: 0;
2386
- background-color: var(--overlay-background-color);
2387
- pointer-events: all;
2388
- backdrop-filter: blur(1px);
2389
- -webkit-backdrop-filter: blur(1px);
2273
+ .label svg {
2274
+ vertical-align: middle;
2275
+ pointer-events: none;
2276
+ color: rgb(107 114 128);
2390
2277
  }
2391
2278
 
2392
- .drawer--contained .drawer__overlay {
2393
- display: none;
2279
+ .icon {
2280
+ /* display: inline; */
2281
+ vertical-align: top;
2394
2282
  }
2395
2283
 
2396
- .drawer__panel {
2397
- position: absolute;
2398
- flex-direction: column;
2399
- z-index: 2;
2400
- max-width: 100%;
2401
- max-height: 100%;
2402
- background-color: var(--panel-background-color);
2403
- box-shadow: var(--pbo-shadow-x-large);
2404
- overflow: auto;
2405
- pointer-events: all;
2284
+ .choice-wrapper {
2285
+ display: inline-flex;
2406
2286
  }
2407
2287
 
2408
- .drawer--bottom .drawer__panel {
2409
- top: auto;
2410
- inset-inline-end: auto;
2411
- bottom: 0;
2412
- inset-inline-start: 0;
2288
+ .choices__inner .choices__item .choice-wrapper {
2413
2289
  width: 100%;
2414
- height: var(--size);
2415
- border-radius: var(--pbo-border-radius-large) var(--pbo-border-radius-large) 0 0;
2290
+ text-overflow: ellipsis;
2291
+ white-space: nowrap;
2292
+ overflow: hidden;
2416
2293
  }
2417
2294
 
2418
- .drawer--left .drawer__panel {
2419
- top: auto;
2420
- inset-inline-end: auto;
2421
- left: 0;
2422
- inset-inline-start: 0;
2423
- height: 100%;
2424
- width: var(--size);
2295
+ .choices__inner {
2296
+ height: 32px;
2297
+ background-color: rgb(255, 255, 255) !important;
2298
+ border-radius: 3.75px !important;
2425
2299
  }
2426
2300
 
2427
- .drawer--right .drawer__panel {
2428
- top: auto;
2429
- inset-inline-end: auto;
2430
- right: 0;
2431
- inset-inline-start: 0;
2432
- height: 100%;
2433
- width: var(--size);
2434
- }
2435
-
2436
- .drawer--top .drawer__panel {
2437
- top: auto;
2438
- inset-inline-end: auto;
2439
- top: 0;
2440
- inset-inline-start: 0;
2441
- width: 100%;
2442
- height: var(--size);
2301
+ .choices.is-focused .choices__inner,
2302
+ .choices.is-open .choices__inner {
2303
+ box-shadow: 0 0 0 var(--pbo-focus-ring-width, 3px) var(--pbo-focus-ring-color);
2443
2304
  }
2444
- `;var qp=Object.defineProperty,Kp=Object.getOwnPropertyDescriptor,Ti=(n,t,e,i)=>{for(var s=i>1?void 0:i?Kp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&qp(t,e,s),s};let De=class extends vt{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.radius=!0,this.contained=!1,this.label="",this.handleKeyDown=n=>{n.key==="Escape"&&this.open&&(n.stopPropagation(),this.requestClose("keyboard"))}}requestClose(n){this.hide()}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleKeyDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleKeyDown)}async hide(){this.open=!1,this.emit("pbo-after-drawer-closed")}async show(){this.open||(this.open=!0)}handleOpenChange(){this.open?this.drawer.hidden=!1:this.drawer.hidden=!0}firstUpdated(){this.drawer.hidden=!this.open}render(){return F`
2445
- <div
2446
- part="base"
2447
- class=${fe({drawer:!0,"drawer--bottom":this.placement==="bottom","drawer--top":this.placement==="top","drawer--left":this.placement==="left","drawer--right":this.placement==="right","drawer--open":this.open,"drawer--contained":this.contained})}
2305
+ `;var yp=Object.defineProperty,_p=Object.getOwnPropertyDescriptor,hs=(n,t,e,i)=>{for(var s=i>1?void 0:i?_p(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&yp(t,e,s),s};let ri=class extends vt{constructor(){super(...arguments),this.hasSlotController=new Ni(this,"help-text","label"),this.size="medium",this.label="",this.disabled=!1,this._handleDocumentClick=t=>{var i;const e=t.composedPath();this&&!e.includes(this)&&((i=this._choices)==null||i.hideDropdown())}}handleDisabledChanged(){var t;this._choices&&this.disabled?this._choices.disable():(t=this._choices)==null||t.enable()}get value(){var t;return(t=this._choices)==null?void 0:t.getValue().value}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var t;(t=this._choices)==null||t.destroy(),this._choices=new nc(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:[{value:"type",label:`
2306
+ <div class="choice-wrapper">
2307
+ <span class="label">Type message
2308
+ <svg
2309
+ stroke="currentColor"
2310
+ fill="none"
2311
+ stroke-width="0"
2312
+ viewBox="0 0 24 24"
2313
+ height="1.6em"
2314
+ width="1.6em"
2315
+ xmlns="http://www.w3.org/2000/svg"
2316
+ >
2317
+ <path d="M6.5 3H3V6.5H4V4H6.5V3Z" fill="currentColor"></path>
2318
+ <path d="M8.5 4V3H11V4H8.5Z" fill="currentColor"></path>
2319
+ <path d="M13 4H15.5V3H13V4Z" fill="currentColor"></path>
2320
+ <path d="M17.5 3V4H20V6.5H21V3H17.5Z" fill="currentColor"></path>
2321
+ <path d="M21 8.5H20V11H21V8.5Z" fill="currentColor"></path>
2322
+ <path d="M21 13H20V15.5H21V13Z" fill="currentColor"></path>
2323
+ <path d="M21 17.5H20V20H17.5V21H21V17.5Z" fill="currentColor"></path>
2324
+ <path d="M15.5 21V20H13V21H15.5Z" fill="currentColor"></path>
2325
+ <path d="M11 21V20H8.5V21H11Z" fill="currentColor"></path>
2326
+ <path d="M6.5 21V20H4V17.5H3V21H6.5Z" fill="currentColor"></path>
2327
+ <path d="M3 15.5H4V13H3V15.5Z" fill="currentColor"></path>
2328
+ <path d="M3 11H4V8.5H3V11Z" fill="currentColor"></path>
2329
+ <path d="M11 9.5H7V7.5H17V9.5H13V16.5H11V9.5Z" fill="currentColor"></path>
2330
+ </svg>
2331
+ </span>
2332
+ </div>`},{value:"handwritten",label:`
2333
+ <div class="choice-wrapper">
2334
+ <span class="label">Upload handwritten message
2335
+ <svg
2336
+ stroke="currentColor"
2337
+ fill="none"
2338
+ stroke-width="0"
2339
+ viewBox="0 0 24 24"
2340
+ height="1.6em"
2341
+ width="1.6em"
2342
+ xmlns="http://www.w3.org/2000/svg"
2343
+ >
2344
+ <path
2345
+ fill-rule="evenodd"
2346
+ clip-rule="evenodd"
2347
+ d="M21.2635 2.29289C20.873 1.90237 20.2398 1.90237 19.8493 2.29289L18.9769 3.16525C17.8618 2.63254 16.4857 2.82801 15.5621 3.75165L4.95549 14.3582L10.6123 20.0151L21.2189 9.4085C22.1426 8.48486 22.338 7.1088 21.8053 5.99367L22.6777 5.12132C23.0682 4.7308 23.0682 4.09763 22.6777 3.70711L21.2635 2.29289ZM16.9955 10.8035L10.6123 17.1867L7.78392 14.3582L14.1671 7.9751L16.9955 10.8035ZM18.8138 8.98525L19.8047 7.99429C20.1953 7.60376 20.1953 6.9706 19.8047 6.58007L18.3905 5.16586C18 4.77534 17.3668 4.77534 16.9763 5.16586L15.9853 6.15683L18.8138 8.98525Z"
2348
+ fill="currentColor"
2349
+ ></path>
2350
+ <path d="M2 22.9502L4.12171 15.1717L9.77817 20.8289L2 22.9502Z" fill="currentColor"></path>
2351
+ </svg>
2352
+ <svg
2353
+ stroke="currentColor"
2354
+ fill="currentColor"
2355
+ stroke-width="0"
2356
+ viewBox="0 0 512 512"
2357
+ height="1.6em"
2358
+ width="1.6em"
2359
+ xmlns="http://www.w3.org/2000/svg"
2360
+ >
2361
+ <circle cx="256" cy="275" r="57.5"></circle>
2362
+ <path
2363
+ d="M417.5 160H363c-4.6 0-8.9-2-12-5.4-28.4-31.8-39.1-42.6-50.7-42.6h-85.5c-11.7 0-23.2 10.8-51.7 42.7-3 3.4-7.4 5.3-11.9 5.3h-4.1v-8c0-4.4-3.6-8-8-8h-26c-4.4 0-8 3.6-8 8v8h-7.5C79.9 160 64 173.2 64 190.7v176c0 17.5 15.9 33.3 33.5 33.3h320c17.6 0 30.5-15.8 30.5-33.3v-176c0-17.5-12.9-30.7-30.5-30.7zM260 360.4c-50.3 2.3-91.7-39.1-89.4-89.4 2-43.9 37.5-79.4 81.4-81.4 50.3-2.3 91.7 39.1 89.4 89.4-2 43.9-37.5 79.4-81.4 81.4zM352 218c-7.2 0-13-5.8-13-13s5.8-13 13-13 13 5.8 13 13-5.8 13-13 13z"
2364
+ ></path>
2365
+ </svg>
2366
+ <svg
2367
+ stroke="currentColor"
2368
+ fill="currentColor"
2369
+ stroke-width="0"
2370
+ viewBox="0 0 512 512"
2371
+ height="1.6em"
2372
+ width="1.6em"
2373
+ xmlns="http://www.w3.org/2000/svg"
2374
+ >
2375
+ <path
2376
+ fill="none"
2377
+ stroke-linecap="round"
2378
+ stroke-linejoin="round"
2379
+ stroke-width="32"
2380
+ d="M336 192h40a40 40 0 0 1 40 40v192a40 40 0 0 1-40 40H136a40 40 0 0 1-40-40V232a40 40 0 0 1 40-40h40m160-64-80-80-80 80m80 193V48"
2381
+ ></path>
2382
+ </svg>
2383
+ </span>
2384
+ </div>`}],placeholder:!1,shouldSortItems:!1,itemSelectText:""}),this.choiceEl.addEventListener("change",e=>{const i=e.target;this.emit("pbo-editor-selector-change",{detail:{editor:i.value}})})}render(){const t=this.hasSlotController.test("label"),e=this.label?!0:!!t;return F` <div
2385
+ class=${fe({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":e})}
2448
2386
  >
2449
- <div
2450
- part="overlay"
2451
- class="drawer__overlay"
2452
- @click=${()=>this.requestClose("overlay")}
2453
- ></div>
2454
- <div
2455
- part="panel"
2456
- class="${fe({drawer__panel:!0})}"
2457
- role="dialog"
2458
- aria-modal="true"
2459
- aria-hidden=${this.open?"false":"true"}
2460
- aria-label=${this.label||"Drawer"}
2461
- tabindex="-1"
2387
+ <label
2388
+ part="form-control-label"
2389
+ id="label"
2390
+ class="form-control__label"
2391
+ aria-hidden=${e?"false":"true"}
2462
2392
  >
2463
- <slot part="body" class="drawer__body"></slot>
2393
+ <slot name="label">${this.label}</slot>
2394
+ </label>
2395
+ </div>
2396
+ <select part="base" class="js-choice"></select>`}};ri.styles=[bt,vp,Js,en(oc)];hs([C()],ri.prototype,"size",2);hs([C()],ri.prototype,"label",2);hs([C({type:Boolean,reflect:!0})],ri.prototype,"disabled",2);hs([G("disabled",{waitUntilFirstUpdate:!0})],ri.prototype,"handleDisabledChanged",1);hs([B(".js-choice")],ri.prototype,"choiceEl",2);ri=hs([mt("pbo-editor-selector")],ri);const xp=ri;var wp=Object.defineProperty,Cp=Object.getOwnPropertyDescriptor,Gt=(n,t,e,i)=>{for(var s=i>1?void 0:i?Cp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&wp(t,e,s),s};let St=class extends vt{constructor(){super(...arguments),this.card=null,this.onClose=()=>{},this.typeFormCtaLabel="",this.handwrittenFormCtaLabel="",this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenFormState={isLoading:!1,processedFileUrl:""},this.editorType="type",this.handleTypingFormChange=()=>{this.formData=this.typeForm.formData},this.handleHandwrittenFormChange=t=>{this.handwrittenFormState=t.detail,this.slider.focusOn(1),bi()&&t.detail.processedFileUrl!==""&&t.detail.isLoading===!1&&(this.slider.openZoomedPreview(),this.slider.scrollIntoView({behavior:"smooth",block:"start"}))},this.handleHandwrittenImageDimensionsChanged=t=>{this.handwrittenForm.setDimensions(t.detail)},this.handleEditorChange=t=>{this.emit("pbo-switch-editor",{detail:{fromEditor:this.editorType,toEditor:t.detail.editor},bubbles:!0,composed:!0}),this.editorType=t.detail.editor}}async handleCardChange(){await this.updateComplete,this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}handleEditorTypeChange(){this.updateComplete.then(()=>{var t,e;if(this.editorType==="handwritten"&&bi()&&this.handwrittenForm.scrollIntoView(!0),this.editorType==="type"){const i=(t=this.typeForm.shadowRoot)==null?void 0:t.querySelector("textarea");i==null||i.focus()}else{const i=(e=this.handwrittenForm.shadowRoot)==null?void 0:e.querySelector("pbo-button[name='upload']");i==null||i.focus()}})}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",this.handleHandwrittenImageDimensionsChanged),this.typeForm.addEventListener("pbo-type-form-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-handwritten-form-change",this.handleHandwrittenFormChange)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-type-form-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-handwritten-form-change",this.handleHandwrittenFormChange)}render(){return F`
2397
+ <div class="editor">
2398
+ <div class="editor__card" part="editor-card-slider-container">
2399
+ <pbo-editor-card-slider
2400
+ part="editor-card-slider"
2401
+ focusIndex="0"
2402
+ .livePreviewProps=${this.formData}
2403
+ .handwrittenPreviewProps=${this.handwrittenFormState}
2404
+ type=${this.editorType}
2405
+ ></pbo-editor-card-slider>
2406
+ </div>
2407
+
2408
+ <div class="editor__form" part="editor-form-container">
2409
+ <div aria-live="polite" aria-atomic="true" class="visually-hidden">
2410
+ ${this.editorType==="type"?"Text message editor active":"Handwritten image editor active"}
2411
+ </div>
2412
+ <pbo-editor-selector
2413
+ @pbo-editor-selector-change=${this.handleEditorChange}
2414
+ part="editor-selector"
2415
+ ></pbo-editor-selector>
2416
+
2417
+ <pbo-type-form
2418
+ part="type-form"
2419
+ exportparts="
2420
+ editor-textarea,
2421
+ font-selector-label,
2422
+ color-selector-label,
2423
+ alignment-selector-label,
2424
+ type-form-label,
2425
+ cta-button-base,
2426
+ cta-button-label,
2427
+ cta-link-button-label,
2428
+ cta-link-button-base
2429
+ "
2430
+ cta-primary-label=${this.typeFormCtaLabel}
2431
+ .submitTypeForm=${this.submitTypeForm}
2432
+ .onClose=${this.onClose}
2433
+ style=${ge({display:this.editorType==="type"?"block":"none"})}
2434
+ ></pbo-type-form>
2435
+ <pbo-handwritten-form
2436
+ part="handwritten-form"
2437
+ exportparts="
2438
+ cta-button-base,
2439
+ cta-button-label,
2440
+ cta-link-button-base,
2441
+ cta-link-button-label
2442
+ "
2443
+ cta-primary-label=${this.handwrittenFormCtaLabel}
2444
+ style=${ge({display:this.editorType==="handwritten"?"block":"none"})}
2445
+ .submitHandwrittenForm=${this.submitHandwrittenForm}
2446
+ .onClose=${this.onClose}
2447
+ .getProcessedImg=${this.getProcessedImg}
2448
+ ></pbo-handwritten-form>
2464
2449
  </div>
2465
2450
  </div>
2466
- `}};De.styles=[bt,Xp];Ti([B(".drawer")],De.prototype,"drawer",2);Ti([C({type:Boolean,reflect:!0})],De.prototype,"open",2);Ti([C({reflect:!0})],De.prototype,"placement",2);Ti([C({type:Boolean,reflect:!0})],De.prototype,"radius",2);Ti([C({type:Boolean,reflect:!0})],De.prototype,"contained",2);Ti([C({type:String})],De.prototype,"label",2);Ti([G("open",{waitUntilFirstUpdate:!0})],De.prototype,"handleOpenChange",1);De=Ti([mt("pbo-drawer")],De);const Nb=De,Zp=it`
2451
+ `}};St.styles=[bt,tp];St.dependencies={"pbo-editor-card-slider":ct,"pbo-type-form":J,"pbo-handwritten-form":bp,"pbo-editor-selector":xp};Gt([C({type:Object})],St.prototype,"card",2);Gt([C()],St.prototype,"submitTypeForm",2);Gt([C()],St.prototype,"submitHandwrittenForm",2);Gt([C()],St.prototype,"getProcessedImg",2);Gt([C({type:Function})],St.prototype,"onClose",2);Gt([C({type:String,attribute:"type-form-cta-primary-label"})],St.prototype,"typeFormCtaLabel",2);Gt([C({type:String,attribute:"handwritten-form-cta-primary-label"})],St.prototype,"handwrittenFormCtaLabel",2);Gt([B("pbo-type-form")],St.prototype,"typeForm",2);Gt([B("pbo-handwritten-form")],St.prototype,"handwrittenForm",2);Gt([B("pbo-editor-card-slider")],St.prototype,"slider",2);Gt([I()],St.prototype,"formData",2);Gt([I()],St.prototype,"handwrittenFormState",2);Gt([I()],St.prototype,"editorType",2);Gt([G("card")],St.prototype,"handleCardChange",1);Gt([G("editorType")],St.prototype,"handleEditorTypeChange",1);St=Gt([mt("pbo-editor")],St);const Nb=St,Ub=J,Wb=ct,Sp=it`
2467
2452
  :host {
2468
2453
  display: block;
2469
- width: 100%;
2470
- height: 100%;
2471
- --header-height: var(--pbo-drawer-header-height);
2472
- --header-padding: 0 var(--pbo-spacing-large) 0 var(--pbo-spacing-large);
2473
- --icon-button-size: 24px;
2474
2454
  --title-font-size: 18.75px;
2455
+ --title-font-weight: var(--pbo-font-weight-normal);
2456
+ --title-margin: var(--pbo-spacing-medium) 0 var(--pbo-spacing-x-small) 0;
2475
2457
  }
2476
2458
 
2477
- .body {
2478
- overflow: hidden;
2459
+ .title {
2460
+ font-size: var(--title-font-size);
2461
+ font-weight: var(--title-font-weight);
2462
+ margin: 16px 0 0 4px;
2463
+ grid-column-start: 2;
2464
+ grid-column-end: 2;
2479
2465
  }
2480
2466
 
2481
- .back-button {
2482
- display: flex;
2483
- justify-content: start;
2484
- overflow: visible;
2467
+ :host(:first-of-type) .title {
2468
+ margin-top: 4px; /* 4px more on the mobile */
2485
2469
  }
2486
2470
 
2487
- /* .icon-button svg {
2488
- height: var(--icon-button-size);
2489
- width: var(--icon-button-size);
2490
- max-height: var(--header-height);
2491
- max-width: var(--header-height);
2492
- } */
2493
-
2494
- .close-button {
2495
- display: flex;
2496
- justify-content: end;
2471
+ @media screen and (min-width: 640px) {
2472
+ :host(:first-of-type) .title {
2473
+ margin-top: 0px; /* Remove top margin for first category */
2474
+ }
2497
2475
  }
2498
2476
 
2499
- .header {
2500
- height: var(--pbo-drawer-header-height);
2501
- padding: 0 var(--pbo-spacing-large);
2502
- user-select: none;
2503
- position: sticky;
2504
- top: 0;
2505
- background-color: var(--pbo-color-gray-100);
2477
+ .category-container {
2478
+ margin-left: auto;
2479
+ margin-right: auto;
2506
2480
  display: grid;
2507
- grid-template-columns: 1fr auto 1fr;
2508
- align-items: center;
2509
- font-size: var(--pbo-font-size-2x-large);
2481
+ grid-template-columns: 30px 1fr 30px;
2482
+ grid-template-rows: auto auto;
2510
2483
  }
2511
-
2512
- .title {
2513
- font-size: var(--title-font-size);
2514
- margin: 0;
2515
- font-weight: inherit;
2484
+ /* -------------------------------- skeleton -------------------------------- */
2485
+ .skeleton .splide__slide {
2486
+ border: none;
2487
+ border-radius: var(--pbo-border-radius-large);
2516
2488
  }
2517
2489
 
2518
- .title:focus {
2519
- outline: none;
2490
+ .skeleton .title {
2491
+ border-radius: var(--pbo-border-radius-large);
2492
+ font-size: var(--pbo-font-size-x-large);
2493
+ font-weight: var(--pbo-font-weight-normal);
2494
+ margin-top: var(--pbo-spacing-medium);
2495
+ margin-bottom: var(--pbo-spacing-x-small);
2496
+ animation: pulse 1.5s infinite;
2497
+ height: var(--pbo-spacing-x-large);
2498
+ width: 100%;
2499
+ background: var(--pbo-color-gray-200);
2500
+ grid-column: 2/3;
2520
2501
  }
2521
2502
 
2522
- .icon-button {
2523
- all: unset; /* Removes default button styles (border, background, padding, etc.) */
2524
- display: flex;
2525
- align-items: center;
2526
- justify-content: center;
2527
- cursor: pointer;
2528
- color: var(--pbo-color-gray-500); /* Default icon color */
2529
- transition:
2530
- transform 0.2s ease-in-out,
2531
- color 0.2s ease-in-out;
2503
+ @keyframes pulse {
2504
+ 0% {
2505
+ background-color: #f3f3f3;
2506
+ }
2507
+ 50% {
2508
+ background-color: #e0e0e0;
2509
+ }
2510
+ 100% {
2511
+ background-color: #f3f3f3;
2512
+ }
2513
+ }
2514
+ .embla__button_container {
2515
+ grid-row: 2/3;
2516
+ justify-self: center;
2517
+ }
2518
+ .embla {
2519
+ grid-row: 2/3;
2520
+ grid-column: 2/3;
2521
+ --slide-size: 50%;
2522
+ --slide-spacing: calc(var(--slide-size) * 0.05);
2523
+ --detail-high-contrast: rgb(101, 101, 101);
2524
+ --detail-medium-contrast: rgb(25, 25, 25);
2525
+ --detail-low-contrast: rgb(21, 21, 21);
2532
2526
  }
2533
2527
 
2534
- /* Apply hover effect */
2535
- .icon-button:hover {
2536
- transform: scale(1.1); /* Slightly enlarges the icon */
2537
- color: var(--pbo-color-gray-700); /* Changes icon color on hover */
2528
+ @media screen and (min-width: 640px) {
2529
+ .embla {
2530
+ --slide-size: 33.33%;
2531
+ }
2538
2532
  }
2539
2533
 
2540
- .icon-button:focus {
2541
- outline: none;
2534
+ @media screen and (min-width: 768px) {
2535
+ .embla {
2536
+ --slide-size: 25%;
2537
+ }
2542
2538
  }
2543
2539
 
2544
- .icon-button:focus-visible {
2545
- outline: var(--pbo-focus-ring);
2546
- outline-offset: 2px;
2547
- border-radius: 2px;
2540
+ .embla__viewport {
2541
+ overflow: hidden;
2542
+ width: 100%;
2543
+ padding: 4px;
2548
2544
  }
2549
2545
 
2550
- .page-manager {
2546
+ .embla__container {
2547
+ display: flex;
2548
+ touch-action: pan-y pinch-zoom;
2549
+ margin-left: calc(var(--slide-spacing) * -1);
2550
+ }
2551
+
2552
+ .embla__slide {
2553
+ padding-left: calc(var(--slide-size) * 0.05);
2554
+ transform: translate3d(0, 0, 0);
2555
+ flex: 0 0 var(--slide-size);
2556
+ min-width: 0;
2551
2557
  position: relative;
2552
- height: 100%;
2553
- width: 100%;
2554
- display: grid;
2555
- grid-template-rows: min-content auto;
2556
- grid-gap: 0;
2558
+ transition: transform 0.3s ease;
2557
2559
  }
2558
2560
 
2559
- .category-selection {
2560
- height: 100%;
2561
+ .embla__slide:hover {
2562
+ transform: scale(1.03);
2563
+ z-index: 1;
2564
+ }
2565
+
2566
+ .embla__slide__button {
2567
+ background: none;
2568
+ border: none;
2569
+ padding: 0;
2570
+ cursor: pointer;
2571
+ display: block;
2561
2572
  width: 100%;
2562
- overflow: scroll;
2563
- display: grid;
2564
- grid-template-columns: repeat(12, 1fr);
2565
- padding: var(--pbo-spacing-small);
2566
2573
  }
2567
2574
 
2568
- @media screen and (min-width: 640px) {
2569
- .category-selection {
2570
- padding: var(--pbo-spacing-medium);
2571
- }
2575
+ .embla__slide__button:focus {
2576
+ outline: none;
2572
2577
  }
2573
2578
 
2574
- .category-selection pbo-card-selection {
2575
- grid-column: 1 / 13;
2579
+ .embla__slide__button:focus-visible {
2580
+ outline: var(--pbo-focus-ring);
2581
+ outline-offset: 2px;
2576
2582
  }
2577
2583
 
2578
- .editor {
2579
- padding: var(--pbo-spacing-small);
2580
- overflow: scroll;
2581
- height: 100%;
2584
+ .embla__slide__img {
2585
+ box-shadow:
2586
+ rgba(0, 0, 0, 0) 0px 0px 0px 0px,
2587
+ rgba(0, 0, 0, 0) 0px 0px 0px 0px,
2588
+ rgba(0, 0, 0, 0.1) 0px 4px 6px -1px,
2589
+ rgba(0, 0, 0, 0.1) 0px 2px 4px -2px;
2590
+ border: 2px solid rgb(241, 245, 249);
2591
+ display: flex;
2592
+ align-items: center;
2593
+ justify-content: center;
2582
2594
  width: 100%;
2595
+ height: auto;
2583
2596
  }
2584
2597
 
2585
- @media screen and (min-width: 640px) {
2586
- .editor {
2587
- padding: var(--pbo-spacing-medium);
2588
- }
2598
+ .embla__buttons {
2599
+ display: grid;
2600
+ grid-template-columns: repeat(2, 1fr);
2601
+ gap: 0.6rem;
2602
+ align-items: center;
2589
2603
  }
2590
2604
 
2591
- @media screen and (min-width: 768px) {
2592
- .category-selection pbo-card-selection {
2593
- grid-column: 2 / 12;
2594
- }
2605
+ .embla__button {
2606
+ -webkit-tap-highlight-color: rgba(var(--text-high-contrast-rgb-value), 0.5);
2607
+ -webkit-appearance: none;
2608
+ appearance: none;
2609
+ background-color: transparent;
2610
+ touch-action: manipulation;
2611
+ display: inline-flex;
2612
+ text-decoration: none;
2613
+ cursor: pointer;
2614
+ border: 0;
2615
+ padding: 0;
2616
+ margin: 0;
2617
+ width: 36;
2618
+ height: 36;
2619
+ z-index: 1;
2620
+ display: flex;
2621
+ align-items: center;
2622
+ justify-content: center;
2623
+ color: black;
2595
2624
  }
2596
2625
 
2597
- @media screen and (min-width: 1280px) {
2598
- .category-selection pbo-card-selection {
2599
- grid-column: 3 / 11;
2600
- }
2626
+ .embla__button:disabled {
2627
+ color: rgb(134, 134, 134, 0.8);
2628
+ cursor: not-allowed;
2601
2629
  }
2602
2630
 
2603
- /* ------------------------------ Error message ----------------------------- */
2604
- .error-container .notification {
2605
- color: oklch(70.4% 0.191 22.216);
2606
- }
2607
- .error-message {
2608
- text-align: center;
2631
+ .embla__button__svg {
2632
+ width: 20px;
2633
+ height: 20px;
2609
2634
  }
2610
- .error-container {
2635
+
2636
+ .embla__button_container {
2611
2637
  display: flex;
2612
- flex-direction: column;
2613
- align-items: center;
2614
2638
  justify-content: center;
2615
- height: 100%;
2616
- padding: var(--pbo-spacing-large);
2639
+ align-items: center;
2617
2640
  }
2618
- `,Jp=it`
2641
+ `,Tp=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}";/**
2642
+ * @license
2643
+ * Copyright 2021 Google LLC
2644
+ * SPDX-License-Identifier: BSD-3-Clause
2645
+ */function*uc(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}function Do(n){return typeof n=="number"}function oo(n){return typeof n=="string"}function dn(n){return typeof n=="boolean"}function Ga(n){return Object.prototype.toString.call(n)==="[object Object]"}function pt(n){return Math.abs(n)}function Ao(n){return Math.sign(n)}function js(n,t){return pt(n-t)}function Ep(n,t){if(n===0||t===0||pt(n)<=pt(t))return 0;const e=js(pt(n),pt(t));return pt(e/n)}function kp(n){return Math.round(n*100)/100}function Ns(n){return Us(n).map(Number)}function Oe(n){return n[tr(n)]}function tr(n){return Math.max(0,n.length-1)}function Mo(n,t){return t===tr(n)}function Ya(n,t=0){return Array.from(Array(n),(e,i)=>t+i)}function Us(n){return Object.keys(n)}function pc(n,t){return[n,t].reduce((e,i)=>(Us(i).forEach(s=>{const r=e[s],o=i[s],a=Ga(r)&&Ga(o);e[s]=a?pc(r,o):o}),e),{})}function ao(n,t){return typeof t.MouseEvent<"u"&&n instanceof t.MouseEvent}function Op(n,t){const e={start:i,center:s,end:r};function i(){return 0}function s(l){return r(l)/2}function r(l){return t-l}function o(l,c){return oo(n)?e[n](l):n(t,l,c)}return{measure:o}}function Ws(){let n=[];function t(s,r,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(r,o,a),l=()=>s.removeEventListener(r,o,a);else{const c=s;c.addListener(o),l=()=>c.removeListener(o)}return n.push(l),i}function e(){n=n.filter(s=>s())}const i={add:t,clear:e};return i}function Pp(n,t,e,i){const s=Ws(),r=1e3/60;let o=null,a=0,l=0;function c(){s.add(n,"visibilitychange",()=>{n.hidden&&g()})}function h(){p(),s.clear()}function d(b){if(!l)return;o||(o=b,e(),e());const m=b-o;for(o=b,a+=m;a>=r;)e(),a-=r;const y=a/r;i(y),l&&(l=t.requestAnimationFrame(d))}function u(){l||(l=t.requestAnimationFrame(d))}function p(){t.cancelAnimationFrame(l),o=null,a=0,l=0}function g(){o=null,a=0}return{init:c,destroy:h,start:u,stop:p,update:e,render:i}}function Dp(n,t){const e=t==="rtl",i=n==="y",s=i?"y":"x",r=i?"x":"y",o=!i&&e?-1:1,a=h(),l=d();function c(g){const{height:f,width:b}=g;return i?f:b}function h(){return i?"top":e?"right":"left"}function d(){return i?"bottom":e?"left":"right"}function u(g){return g*o}return{scroll:s,cross:r,startEdge:a,endEdge:l,measureSize:c,direction:u}}function Hi(n=0,t=0){const e=pt(n-t);function i(c){return c<n}function s(c){return c>t}function r(c){return i(c)||s(c)}function o(c){return r(c)?i(c)?n:t:c}function a(c){return e?c-e*Math.ceil((c-t)/e):c}return{length:e,max:t,min:n,constrain:o,reachedAny:r,reachedMax:s,reachedMin:i,removeOffset:a}}function gc(n,t,e){const{constrain:i}=Hi(0,n),s=n+1;let r=o(t);function o(u){return e?pt((s+u)%s):i(u)}function a(){return r}function l(u){return r=o(u),d}function c(u){return h().set(a()+u)}function h(){return gc(n,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function Ap(n,t,e,i,s,r,o,a,l,c,h,d,u,p,g,f,b,m,y){const{cross:w,direction:S}=n,T=["INPUT","SELECT","TEXTAREA"],k={passive:!1},O=Ws(),E=Ws(),P=Hi(50,225).constrain(p.measure(20)),R={mouse:300,touch:400},L={mouse:500,touch:600},j=g?43:25;let H=!1,M=0,U=0,q=!1,Q=!1,N=!1,kt=!1;function Yt(A){if(!y)return;function tt(qt){(dn(y)||y(A,qt))&&he(qt)}const Ot=t;O.add(Ot,"dragstart",qt=>qt.preventDefault(),k).add(Ot,"touchmove",()=>{},k).add(Ot,"touchend",()=>{}).add(Ot,"touchstart",tt).add(Ot,"mousedown",tt).add(Ot,"touchcancel",$t).add(Ot,"contextmenu",$t).add(Ot,"click",de,!0)}function Xt(){O.clear(),E.clear()}function Ie(){const A=kt?e:t;E.add(A,"touchmove",At,k).add(A,"touchend",$t).add(A,"mousemove",At,k).add(A,"mouseup",$t)}function me(A){const tt=A.nodeName||"";return T.includes(tt)}function jt(){return(g?L:R)[kt?"mouse":"touch"]}function Le(A,tt){const Ot=d.add(Ao(A)*-1),qt=h.byDistance(A,!g).distance;return g||pt(A)<P?qt:b&&tt?qt*.5:h.byIndex(Ot.get(),0).distance}function he(A){const tt=ao(A,i);kt=tt,N=g&&tt&&!A.buttons&&H,H=js(s.get(),o.get())>=2,!(tt&&A.button!==0)&&(me(A.target)||(q=!0,r.pointerDown(A),c.useFriction(0).useDuration(0),s.set(o),Ie(),M=r.readPoint(A),U=r.readPoint(A,w),u.emit("pointerDown")))}function At(A){if(!ao(A,i)&&A.touches.length>=2)return $t(A);const Ot=r.readPoint(A),qt=r.readPoint(A,w),Fe=js(Ot,M),Ye=js(qt,U);if(!Q&&!kt&&(!A.cancelable||(Q=Fe>Ye,!Q)))return $t(A);const Oi=r.pointerMove(A);Fe>f&&(N=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(S(Oi)),A.preventDefault()}function $t(A){const Ot=h.byDistance(0,!1).index!==d.get(),qt=r.pointerUp(A)*jt(),Fe=Le(S(qt),Ot),Ye=Ep(qt,Fe),Oi=j-10*Ye,di=m+Ye/50;Q=!1,q=!1,E.clear(),c.useDuration(Oi).useFriction(di),l.distance(Fe,!g),kt=!1,u.emit("pointerUp")}function de(A){N&&(A.stopPropagation(),A.preventDefault(),N=!1)}function _t(){return q}return{init:Yt,destroy:Xt,pointerDown:_t}}function Mp(n,t){let i,s;function r(d){return d.timeStamp}function o(d,u){const g=`client${(u||n.scroll)==="x"?"X":"Y"}`;return(ao(d,t)?d:d.touches[0])[g]}function a(d){return i=d,s=d,o(d)}function l(d){const u=o(d)-o(s),p=r(d)-r(i)>170;return s=d,p&&(i=d),u}function c(d){if(!i||!s)return 0;const u=o(s)-o(i),p=r(d)-r(i),g=r(d)-r(s)>170,f=u/p;return p&&!g&&pt(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function Ip(){function n(e){const{offsetTop:i,offsetLeft:s,offsetWidth:r,offsetHeight:o}=e;return{top:i,right:s+r,bottom:i+o,left:s,width:r,height:o}}return{measure:n}}function Lp(n){function t(i){return n*(i/100)}return{measure:t}}function Fp(n,t,e,i,s,r,o){const a=[n].concat(i);let l,c,h=[],d=!1;function u(b){return s.measureSize(o.measure(b))}function p(b){if(!r)return;c=u(n),h=i.map(u);function m(y){for(const w of y){if(d)return;const S=w.target===n,T=i.indexOf(w.target),k=S?c:h[T],O=u(S?n:i[T]);if(pt(O-k)>=.5){b.reInit(),t.emit("resize");break}}}l=new ResizeObserver(y=>{(dn(r)||r(b,y))&&m(y)}),e.requestAnimationFrame(()=>{a.forEach(y=>l.observe(y))})}function g(){d=!0,l&&l.disconnect()}return{init:p,destroy:g}}function jp(n,t,e,i,s,r){let o=0,a=0,l=s,c=r,h=n.get(),d=0;function u(){const k=i.get()-n.get(),O=!l;let E=0;return O?(o=0,e.set(i),n.set(i),E=k):(e.set(n),o+=k/l,o*=c,h+=o,n.add(o),E=h-d),a=Ao(E),d=h,T}function p(){const k=i.get()-t.get();return pt(k)<.001}function g(){return l}function f(){return a}function b(){return o}function m(){return w(s)}function y(){return S(r)}function w(k){return l=k,T}function S(k){return c=k,T}const T={direction:f,duration:g,velocity:b,seek:u,settled:p,useBaseFriction:y,useBaseDuration:m,useFriction:S,useDuration:w};return T}function $p(n,t,e,i,s){const r=s.measure(10),o=s.measure(50),a=Hi(.1,.99);let l=!1;function c(){return!(l||!n.reachedAny(e.get())||!n.reachedAny(t.get()))}function h(p){if(!c())return;const g=n.reachedMin(t.get())?"min":"max",f=pt(n[g]-t.get()),b=e.get()-t.get(),m=a.constrain(f/o);e.subtract(b*m),!p&&pt(b)<r&&(e.set(n.constrain(e.get())),i.useDuration(25).useBaseFriction())}function d(p){l=!p}return{shouldConstrain:c,constrain:h,toggleActive:d}}function Rp(n,t,e,i,s){const r=Hi(-t+n,0),o=d(),a=h(),l=u();function c(g,f){return js(g,f)<=1}function h(){const g=o[0],f=Oe(o),b=o.lastIndexOf(g),m=o.indexOf(f)+1;return Hi(b,m)}function d(){return e.map((g,f)=>{const{min:b,max:m}=r,y=r.constrain(g),w=!f,S=Mo(e,f);return w?m:S||c(b,y)?b:c(m,y)?m:y}).map(g=>parseFloat(g.toFixed(3)))}function u(){if(t<=n+s)return[r.max];if(i==="keepSnaps")return o;const{min:g,max:f}=a;return o.slice(g,f)}return{snapsContained:l,scrollContainLimit:a}}function Bp(n,t,e){const i=t[0],s=e?i-n:Oe(t);return{limit:Hi(s,i)}}function zp(n,t,e,i){const r=t.min+.1,o=t.max+.1,{reachedMin:a,reachedMax:l}=Hi(r,o);function c(u){return u===1?l(e.get()):u===-1?a(e.get()):!1}function h(u){if(!c(u))return;const p=n*(u*-1);i.forEach(g=>g.add(p))}return{loop:h}}function Hp(n){const{max:t,length:e}=n;function i(r){const o=r-t;return e?o/-e:0}return{get:i}}function Vp(n,t,e,i,s){const{startEdge:r,endEdge:o}=n,{groupSlides:a}=s,l=d().map(t.measure),c=u(),h=p();function d(){return a(i).map(f=>Oe(f)[o]-f[0][r]).map(pt)}function u(){return i.map(f=>e[r]-f[r]).map(f=>-pt(f))}function p(){return a(c).map(f=>f[0]).map((f,b)=>f+l[b])}return{snaps:c,snapsAligned:h}}function Np(n,t,e,i,s,r){const{groupSlides:o}=s,{min:a,max:l}=i,c=h();function h(){const u=o(r),p=!n||t==="keepSnaps";return e.length===1?[r]:p?u:u.slice(a,l).map((g,f,b)=>{const m=!f,y=Mo(b,f);if(m){const w=Oe(b[0])+1;return Ya(w)}if(y){const w=tr(r)-Oe(b)[0]+1;return Ya(w,Oe(b)[0])}return g})}return{slideRegistry:c}}function Up(n,t,e,i,s){const{reachedAny:r,removeOffset:o,constrain:a}=i;function l(g){return g.concat().sort((f,b)=>pt(f)-pt(b))[0]}function c(g){const f=n?o(g):a(g),b=t.map((y,w)=>({diff:h(y-f,0),index:w})).sort((y,w)=>pt(y.diff)-pt(w.diff)),{index:m}=b[0];return{index:m,distance:f}}function h(g,f){const b=[g,g+e,g-e];if(!n)return g;if(!f)return l(b);const m=b.filter(y=>Ao(y)===f);return m.length?l(m):Oe(b)-e}function d(g,f){const b=t[g]-s.get(),m=h(b,f);return{index:g,distance:m}}function u(g,f){const b=s.get()+g,{index:m,distance:y}=c(b),w=!n&&r(b);if(!f||w)return{index:m,distance:g};const S=t[m]-y,T=g+h(S,0);return{index:m,distance:T}}return{byDistance:u,byIndex:d,shortcut:h}}function Wp(n,t,e,i,s,r,o){function a(d){const u=d.distance,p=d.index!==t.get();r.add(u),u&&(i.duration()?n.start():(n.update(),n.render(1),n.update())),p&&(e.set(t.get()),t.set(d.index),o.emit("select"))}function l(d,u){const p=s.byDistance(d,u);a(p)}function c(d,u){const p=t.clone().set(d),g=s.byIndex(p.get(),u);a(g)}return{distance:l,index:c}}function Gp(n,t,e,i,s,r,o,a){const l={passive:!0,capture:!0};let c=0;function h(p){if(!a)return;function g(f){if(new Date().getTime()-c>10)return;o.emit("slideFocusStart"),n.scrollLeft=0;const y=e.findIndex(w=>w.includes(f));Do(y)&&(s.useDuration(0),i.index(y,0),o.emit("slideFocus"))}r.add(document,"keydown",d,!1),t.forEach((f,b)=>{r.add(f,"focus",m=>{(dn(a)||a(p,m))&&g(b)},l)})}function d(p){p.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function As(n){let t=n;function e(){return t}function i(l){t=o(l)}function s(l){t+=o(l)}function r(l){t-=o(l)}function o(l){return Do(l)?l:l.get()}return{get:e,set:i,add:s,subtract:r}}function fc(n,t){const e=n.scroll==="x"?o:a,i=t.style;let s=null,r=!1;function o(u){return`translate3d(${u}px,0px,0px)`}function a(u){return`translate3d(0px,${u}px,0px)`}function l(u){if(r)return;const p=kp(n.direction(u));p!==s&&(i.transform=e(p),s=p)}function c(u){r=!u}function h(){r||(i.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:h,to:l,toggleActive:c}}function Yp(n,t,e,i,s,r,o,a,l){const h=Ns(s),d=Ns(s).reverse(),u=m().concat(y());function p(O,E){return O.reduce((P,R)=>P-s[R],E)}function g(O,E){return O.reduce((P,R)=>p(P,E)>0?P.concat([R]):P,[])}function f(O){return r.map((E,P)=>({start:E-i[P]+.5+O,end:E+t-.5+O}))}function b(O,E,P){const R=f(E);return O.map(L=>{const j=P?0:-e,H=P?e:0,M=P?"end":"start",U=R[L][M];return{index:L,loopPoint:U,slideLocation:As(-1),translate:fc(n,l[L]),target:()=>a.get()>U?j:H}})}function m(){const O=o[0],E=g(d,O);return b(E,e,!1)}function y(){const O=t-o[0]-1,E=g(h,O);return b(E,-e,!0)}function w(){return u.every(({index:O})=>{const E=h.filter(P=>P!==O);return p(E,t)<=.1})}function S(){u.forEach(O=>{const{target:E,translate:P,slideLocation:R}=O,L=E();L!==R.get()&&(P.to(L),R.set(L))})}function T(){u.forEach(O=>O.translate.clear())}return{canLoop:w,clear:T,loop:S,loopPoints:u}}function Xp(n,t,e){let i,s=!1;function r(l){if(!e)return;function c(h){for(const d of h)if(d.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}i=new MutationObserver(h=>{s||(dn(e)||e(l,h))&&c(h)}),i.observe(n,{childList:!0})}function o(){i&&i.disconnect(),s=!0}return{init:r,destroy:o}}function qp(n,t,e,i){const s={};let r=null,o=null,a,l=!1;function c(){a=new IntersectionObserver(g=>{l||(g.forEach(f=>{const b=t.indexOf(f.target);s[b]=f}),r=null,o=null,e.emit("slidesInView"))},{root:n.parentElement,threshold:i}),t.forEach(g=>a.observe(g))}function h(){a&&a.disconnect(),l=!0}function d(g){return Us(s).reduce((f,b)=>{const m=parseInt(b),{isIntersecting:y}=s[m];return(g&&y||!g&&!y)&&f.push(m),f},[])}function u(g=!0){if(g&&r)return r;if(!g&&o)return o;const f=d(g);return g&&(r=f),g||(o=f),f}return{init:c,destroy:h,get:u}}function Kp(n,t,e,i,s,r){const{measureSize:o,startEdge:a,endEdge:l}=n,c=e[0]&&s,h=g(),d=f(),u=e.map(o),p=b();function g(){if(!c)return 0;const y=e[0];return pt(t[a]-y[a])}function f(){if(!c)return 0;const y=r.getComputedStyle(Oe(i));return parseFloat(y.getPropertyValue(`margin-${l}`))}function b(){return e.map((y,w,S)=>{const T=!w,k=Mo(S,w);return T?u[w]+h:k?u[w]+d:S[w+1][a]-y[a]}).map(pt)}return{slideSizes:u,slideSizesWithGaps:p,startGap:h,endGap:d}}function Zp(n,t,e,i,s,r,o,a,l){const{startEdge:c,endEdge:h,direction:d}=n,u=Do(e);function p(m,y){return Ns(m).filter(w=>w%y===0).map(w=>m.slice(w,w+y))}function g(m){return m.length?Ns(m).reduce((y,w,S)=>{const T=Oe(y)||0,k=T===0,O=w===tr(m),E=s[c]-r[T][c],P=s[c]-r[w][h],R=!i&&k?d(o):0,L=!i&&O?d(a):0,j=pt(P-L-(E+R));return S&&j>t+l&&y.push(w),O&&y.push(m.length),y},[]).map((y,w,S)=>{const T=Math.max(S[w-1]||0);return m.slice(T,y)}):[]}function f(m){return u?p(m,e):g(m)}return{groupSlides:f}}function Jp(n,t,e,i,s,r,o){const{align:a,axis:l,direction:c,startIndex:h,loop:d,duration:u,dragFree:p,dragThreshold:g,inViewThreshold:f,slidesToScroll:b,skipSnaps:m,containScroll:y,watchResize:w,watchSlides:S,watchDrag:T,watchFocus:k}=r,O=2,E=Ip(),P=E.measure(t),R=e.map(E.measure),L=Dp(l,c),j=L.measureSize(P),H=Lp(j),M=Op(a,j),U=!d&&!!y,q=d||!!y,{slideSizes:Q,slideSizesWithGaps:N,startGap:kt,endGap:Yt}=Kp(L,P,R,e,q,s),Xt=Zp(L,j,b,d,P,R,kt,Yt,O),{snaps:Ie,snapsAligned:me}=Vp(L,M,P,R,Xt),jt=-Oe(Ie)+Oe(N),{snapsContained:Le,scrollContainLimit:he}=Rp(j,jt,me,y,O),At=U?Le:me,{limit:$t}=Bp(jt,At,d),de=gc(tr(At),h,d),_t=de.clone(),dt=Ns(e),A=({dragHandler:Yi,scrollBody:En,scrollBounds:kn,options:{loop:rr}})=>{rr||kn.constrain(Yi.pointerDown()),En.seek()},tt=({scrollBody:Yi,translate:En,location:kn,offsetLocation:rr,previousLocation:xh,scrollLooper:wh,slideLooper:Ch,dragHandler:Sh,animation:Th,eventHandler:sa,scrollBounds:Eh,options:{loop:ra}},na)=>{const oa=Yi.settled(),kh=!Eh.shouldConstrain(),aa=ra?oa:oa&&kh,la=aa&&!Sh.pointerDown();la&&Th.stop();const Oh=kn.get()*na+xh.get()*(1-na);rr.set(Oh),ra&&(wh.loop(Yi.direction()),Ch.loop()),En.to(rr.get()),la&&sa.emit("settle"),aa||sa.emit("scroll")},Ot=Pp(i,s,()=>A(Tn),Yi=>tt(Tn,Yi)),qt=.68,Fe=At[de.get()],Ye=As(Fe),Oi=As(Fe),di=As(Fe),Pi=As(Fe),vs=jp(Ye,di,Oi,Pi,u,qt),Cn=Up(d,At,jt,$t,Pi),Sn=Wp(Ot,de,_t,vs,Cn,Pi,o),ta=Hp($t),ea=Ws(),yh=qp(t,e,o,f),{slideRegistry:ia}=Np(U,y,At,he,Xt,dt),_h=Gp(n,e,ia,Sn,vs,ea,o,k),Tn={ownerDocument:i,ownerWindow:s,eventHandler:o,containerRect:P,slideRects:R,animation:Ot,axis:L,dragHandler:Ap(L,n,i,s,Pi,Mp(L,s),Ye,Ot,Sn,vs,Cn,de,o,H,p,g,m,qt,T),eventStore:ea,percentOfView:H,index:de,indexPrevious:_t,limit:$t,location:Ye,offsetLocation:di,previousLocation:Oi,options:r,resizeHandler:Fp(t,o,s,e,L,w,E),scrollBody:vs,scrollBounds:$p($t,di,Pi,vs,H),scrollLooper:zp(jt,$t,di,[Ye,di,Oi,Pi]),scrollProgress:ta,scrollSnapList:At.map(ta.get),scrollSnaps:At,scrollTarget:Cn,scrollTo:Sn,slideLooper:Yp(L,j,jt,Q,N,Ie,At,di,e),slideFocus:_h,slidesHandler:Xp(t,o,S),slidesInView:yh,slideIndexes:dt,slideRegistry:ia,slidesToScroll:Xt,target:Pi,translate:fc(L,t)};return Tn}function Qp(){let n={},t;function e(c){t=c}function i(c){return n[c]||[]}function s(c){return i(c).forEach(h=>h(t,c)),l}function r(c,h){return n[c]=i(c).concat([h]),l}function o(c,h){return n[c]=i(c).filter(d=>d!==h),l}function a(){n={}}const l={init:e,emit:s,off:o,on:r,clear:a};return l}const tg={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function eg(n){function t(r,o){return pc(r,o||{})}function e(r){const o=r.breakpoints||{},a=Us(o).filter(l=>n.matchMedia(l).matches).map(l=>o[l]).reduce((l,c)=>t(l,c),{});return t(r,a)}function i(r){return r.map(o=>Us(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(n.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function ig(n){let t=[];function e(r,o){return t=o.filter(({options:a})=>n.optionsAtMedia(a).active!==!1),t.forEach(a=>a.init(r,n)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function i(){t=t.filter(r=>r.destroy())}return{init:e,destroy:i}}function Io(n,t,e){const i=n.ownerDocument,s=i.defaultView,r=eg(s),o=ig(r),a=Ws(),l=Qp(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=r,{on:u,off:p,emit:g}=l,f=L;let b=!1,m,y=c(tg,Io.globalOptions),w=c(y),S=[],T,k,O;function E(){const{container:dt,slides:A}=w;k=(oo(dt)?n.querySelector(dt):dt)||n.children[0];const Ot=oo(A)?k.querySelectorAll(A):A;O=[].slice.call(Ot||k.children)}function P(dt){const A=Jp(n,k,O,i,s,dt,l);if(dt.loop&&!A.slideLooper.canLoop()){const tt=Object.assign({},dt,{loop:!1});return P(tt)}return A}function R(dt,A){b||(y=c(y,dt),w=h(y),S=A||S,E(),m=P(w),d([y,...S.map(({options:tt})=>tt)]).forEach(tt=>a.add(tt,"change",L)),w.active&&(m.translate.to(m.location.get()),m.animation.init(),m.slidesInView.init(),m.slideFocus.init(_t),m.eventHandler.init(_t),m.resizeHandler.init(_t),m.slidesHandler.init(_t),m.options.loop&&m.slideLooper.loop(),k.offsetParent&&O.length&&m.dragHandler.init(_t),T=o.init(_t,S)))}function L(dt,A){const tt=Xt();j(),R(c({startIndex:tt},dt),A),l.emit("reInit")}function j(){m.dragHandler.destroy(),m.eventStore.clear(),m.translate.clear(),m.slideLooper.clear(),m.resizeHandler.destroy(),m.slidesHandler.destroy(),m.slidesInView.destroy(),m.animation.destroy(),o.destroy(),a.clear()}function H(){b||(b=!0,a.clear(),j(),l.emit("destroy"),l.clear())}function M(dt,A,tt){!w.active||b||(m.scrollBody.useBaseFriction().useDuration(A===!0?0:w.duration),m.scrollTo.index(dt,tt||0))}function U(dt){const A=m.index.add(1).get();M(A,dt,-1)}function q(dt){const A=m.index.add(-1).get();M(A,dt,1)}function Q(){return m.index.add(1).get()!==Xt()}function N(){return m.index.add(-1).get()!==Xt()}function kt(){return m.scrollSnapList}function Yt(){return m.scrollProgress.get(m.offsetLocation.get())}function Xt(){return m.index.get()}function Ie(){return m.indexPrevious.get()}function me(){return m.slidesInView.get()}function jt(){return m.slidesInView.get(!1)}function Le(){return T}function he(){return m}function At(){return n}function $t(){return k}function de(){return O}const _t={canScrollNext:Q,canScrollPrev:N,containerNode:$t,internalEngine:he,destroy:H,off:p,on:u,emit:g,plugins:Le,previousScrollSnap:Ie,reInit:f,rootNode:At,scrollNext:U,scrollPrev:q,scrollProgress:Yt,scrollSnapList:kt,scrollTo:M,selectedScrollSnap:Xt,slideNodes:de,slidesInView:me,slidesNotInView:jt};return R(t,e),setTimeout(()=>l.emit("init"),0),_t}Io.globalOptions=void 0;var sg=Object.defineProperty,rg=Object.getOwnPropertyDescriptor,Me=(n,t,e,i)=>{for(var s=i>1?void 0:i?rg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&sg(t,e,s),s};let Ut=class extends vt{constructor(){super(...arguments),this.cards=[],this.skeleton=!1,this.title="",this.firstUpdated=()=>{const t={align:"start",axis:"x",loop:!1},e=Io(this.emblaViewport,t);if(this.skeleton)return;const i=this.addPrevNextBtnsClickHandlers(e,this.emblaPrevButton,this.emblaNextButton);e.on("destroy",i),e.on("reInit",()=>{!e.canScrollPrev()&&!e.canScrollNext()?(console.debug("No previous or next slides available, hiding arrows."),this.emblaPrevButton.style.visibility="hidden",this.emblaNextButton.style.visibility="hidden"):(console.debug("Previous or next slides available, showing arrows."),this.emblaPrevButton.style.visibility="visible",this.emblaNextButton.style.visibility="visible")})},this.disconnectedCallback=()=>{var t;super.disconnectedCallback(),(t=this.imageSplide)==null||t.destroy()},this.clickHandler=t=>{const e=t.target;this.emit("pbo-category-card-selected",{detail:{cardId:e.dataset.cardId||"unknown"}})},this.addTogglePrevNextBtnsActive=(t,e,i)=>{const s=()=>{t.canScrollPrev()?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled"),t.canScrollNext()?i.removeAttribute("disabled"):i.setAttribute("disabled","disabled")};return t.on("select",s).on("init",s).on("reInit",s),()=>{e.removeAttribute("disabled"),i.removeAttribute("disabled")}}}updateArrowVisibility(){const t=this.imageCarousel.querySelector(".splide__arrow--next"),e=this.imageCarousel.querySelector(".splide__arrow--prev");t.style.visibility=t.disabled?"hidden":"visible",e.style.visibility=e.disabled?"hidden":"visible"}addPrevNextBtnsClickHandlers(t,e,i){const s=()=>{t.scrollPrev()},r=()=>{t.scrollNext()};e.addEventListener("click",s,!1),i.addEventListener("click",r,!1);const o=this.addTogglePrevNextBtnsActive(t,e,i);return()=>{o(),e.removeEventListener("click",s,!1),i.removeEventListener("click",r,!1)}}render(){return this.skeleton?F`
2646
+ <div class="category-container skeleton">
2647
+ <div class="title"></div>
2648
+ <section class="embla">
2649
+ <div class="embla__viewport">
2650
+ <div class="embla__container">
2651
+ <div class="embla__slide">
2652
+ <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2653
+ </div>
2654
+ <div class="embla__slide">
2655
+ <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2656
+ </div>
2657
+ <div class="embla__slide">
2658
+ <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2659
+ </div>
2660
+ <div class="embla__slide">
2661
+ <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2662
+ </div>
2663
+ </div>
2664
+ </div>
2665
+ </section>
2666
+ </div>
2667
+ `:F`
2668
+ <div class="category-container">
2669
+ <div class="title" part="category-title">${this.title}</div>
2670
+ <div class="embla__button_container embla__button_container--prev">
2671
+ <button
2672
+ class="embla__button embla__button--prev"
2673
+ type="button"
2674
+ aria-label="Previous cards"
2675
+ >
2676
+ <svg aria-hidden="true" class="embla__button__svg" viewBox="0 0 532 532">
2677
+ <path
2678
+ fill="currentColor"
2679
+ d="M355.66 11.354c13.793-13.805 36.208-13.805 50.001 0 13.785 13.804 13.785 36.238 0 50.034L201.22 266l204.442 204.61c13.785 13.805 13.785 36.239 0 50.044-13.793 13.796-36.208 13.796-50.002 0a5994246.277 5994246.277 0 0 0-229.332-229.454 35.065 35.065 0 0 1-10.326-25.126c0-9.2 3.393-18.26 10.326-25.2C172.192 194.973 332.731 34.31 355.66 11.354Z"
2680
+ ></path>
2681
+ </svg>
2682
+ </button>
2683
+ </div>
2684
+ <section class="embla">
2685
+ <div class="embla__viewport">
2686
+ <div class="embla__container">
2687
+ ${uc(this.cards,t=>F`
2688
+ <div class="embla__slide">
2689
+ <button
2690
+ class="embla__slide__button"
2691
+ type="button"
2692
+ aria-label="${t.medias.cover.alt||t.name||"Select card"}"
2693
+ @click="${()=>this.emit("pbo-category-card-selected",{detail:{cardId:t.pboId}})}"
2694
+ >
2695
+ <img
2696
+ class="embla__slide__img"
2697
+ src=${t.medias.cover.url}
2698
+ alt=""
2699
+ aria-hidden="true"
2700
+ />
2701
+ </button>
2702
+ </div>
2703
+ `)}
2704
+ </div>
2705
+ </div>
2706
+ </section>
2707
+ <div class="embla__button_container embla__button_container--next">
2708
+ <button class="embla__button embla__button--next" type="button" aria-label="Next cards">
2709
+ <svg aria-hidden="true" class="embla__button__svg" viewBox="0 0 532 532">
2710
+ <path
2711
+ fill="currentColor"
2712
+ d="M176.34 520.646c-13.793 13.805-36.208 13.805-50.001 0-13.785-13.804-13.785-36.238 0-50.034L330.78 266 126.34 61.391c-13.785-13.805-13.785-36.239 0-50.044 13.793-13.796 36.208-13.796 50.002 0 22.928 22.947 206.395 206.507 229.332 229.454a35.065 35.065 0 0 1 10.326 25.126c0 9.2-3.393 18.26-10.326 25.2-45.865 45.901-206.404 206.564-229.332 229.52Z"
2713
+ ></path>
2714
+ </svg>
2715
+ </button>
2716
+ </div>
2717
+ </div>
2718
+ `}};Ut.styles=[bt,Sp,en(Tp)];Ut.dependencies={"pbo-image":Jt};Me([C({type:Array})],Ut.prototype,"cards",2);Me([C({type:Boolean,reflect:!0})],Ut.prototype,"skeleton",2);Me([C({type:String})],Ut.prototype,"title",2);Me([B("#category-carousel")],Ut.prototype,"imageCarousel",2);Me([B(".embla")],Ut.prototype,"emblaNode",2);Me([B(".embla__viewport")],Ut.prototype,"emblaViewport",2);Me([B(".embla__button--prev")],Ut.prototype,"emblaPrevButton",2);Me([B(".embla__button--next")],Ut.prototype,"emblaNextButton",2);Me([B(".embla__container")],Ut.prototype,"emblaContainerEl",2);Me([I()],Ut.prototype,"imageSplide",2);Ut=Me([mt("pbo-category")],Ut);const Yb=Ut,ng=it`
2619
2719
  :host {
2620
- display: block;
2720
+ --size: 70%;
2721
+ --header-spacing: var(--pbo-spacing-large);
2722
+ --body-spacing: var(--pbo-spacing-large);
2723
+ --footer-spacing: var(--pbo-spacing-large);
2724
+ --panel-background-color: var(--pbo-panel-background-color);
2725
+ --overlay-background-color: var(--pbo-overlay-background-color);
2726
+ display: contents;
2621
2727
  }
2622
- `;var Qp=Object.defineProperty,tg=Object.getOwnPropertyDescriptor,Lo=(n,t,e,i)=>{for(var s=i>1?void 0:i?tg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Qp(t,e,s),s};let Hi=class extends vt{constructor(){super(...arguments),this.categories=[],this.loading=!0}render(){return this.loading?F`
2623
- <pbo-category skeleton></pbo-category>
2624
- <pbo-category skeleton></pbo-category>
2625
- `:F`
2626
- ${uc(this.categories,t=>F`<pbo-category
2627
- .cards=${t.cards}
2628
- .name=${t.name}
2629
- title=${t.name}
2630
- exportparts="category-title"
2631
- >
2632
- </pbo-category>`)}
2633
- `}};Hi.styles=[bt,Jp];Lo([C({type:Array})],Hi.prototype,"categories",2);Lo([C({type:Boolean,reflect:!0})],Hi.prototype,"loading",2);Hi=Lo([mt("pbo-card-selection")],Hi);var eg=Object.defineProperty,ig=Object.getOwnPropertyDescriptor,Et=(n,t,e,i)=>{for(var s=i>1?void 0:i?ig(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&eg(t,e,s),s};let rt=class extends vt{constructor(){super(...arguments),this.onClose=()=>{},this.currentPage="selection",this.categories=[],this.isLoadingCategories=!1,this.isError=!1,this.errorMessage="Unknown error occurred. Please try again later.",this.selectionTitle="SELECT CARD",this.editorTitle="PERSONALIZE",this.typeFormCtaLabel="Add to Cart",this.handwrittenFormCtaLabel="Add to Cart",this.selectedCard=null,this.selectedCardId=null,this.selectedCardDetails=null,this.handleCardSelected=t=>{const{cardId:e}=t.detail,i=this.findCardInCategoryById(e);this.selectedCard=i,this.goToEditor()}}get editorEl(){var t;return((t=this.shadowRoot)==null?void 0:t.querySelector("pbo-editor"))||null}handleGetProcessedImgUpdate(){this.editorEl&&(this.editorEl.getProcessedImg=this.getProcessedImg)}async goToEditor(){var t;this.currentPage="editor",await this.updateComplete,(t=this.titleEl)==null||t.focus()}async goToSelector(){var t;this.currentPage="selection",await this.updateComplete,(t=this.titleEl)==null||t.focus()}connectedCallback(){var t;super.connectedCallback(),(t=this.shadowRoot)==null||t.addEventListener("pbo-category-card-selected",this.handleCardSelected)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.shadowRoot)==null||t.removeEventListener("pbo-category-card-selected",this.handleCardSelected)}firstUpdated(){if(!this.cardSelectionEl){console.error("Card selection element not found");return}this.cardSelectionEl.categories=this.categories}handleCategoriesUpdate(){this.cardSelectionEl&&this.categories!==void 0&&this.categories.length>0&&(this.cardSelectionEl.categories=this.categories,this.requestUpdate())}setIsLoadingCategories(t){this.isLoadingCategories=t,this.cardSelectionEl&&(this.cardSelectionEl.loading=t)}findCardInCategoryById(t){for(const e of this.categories){const i=e.cards.find(s=>s.pboId===t);if(i)return i}return null}render(){return F`
2634
- <div part="base" class="page-manager">
2635
- <div class="header" part="header">
2636
- <div class="back-button" part="back-button">
2637
- ${this.currentPage!=="selection"?F`<button
2638
- @click=${this.goToSelector}
2639
- class="icon-button"
2640
- aria-label="Back to card selection"
2641
- >
2642
- <svg
2643
- part="back-icon icon"
2644
- aria-hidden="true"
2645
- width="15"
2646
- height="9"
2647
- viewBox="0 0 15 9"
2648
- fill="none"
2649
- xmlns="http://www.w3.org/2000/svg"
2650
- >
2651
- <path
2652
- d="M0.146447 4.14645C-0.0488155 4.34171 -0.0488155 4.65829 0.146447 4.85355L3.32843 8.03553C3.52369 8.2308 3.84027 8.2308 4.03553 8.03553C4.2308 7.84027 4.2308 7.52369 4.03553 7.32843L1.20711 4.5L4.03553 1.67157C4.2308 1.47631 4.2308 1.15973 4.03553 0.964466C3.84027 0.769204 3.52369 0.769204 3.32843 0.964466L0.146447 4.14645ZM14.5 4.5V4H0.5V4.5V5H14.5V4.5Z"
2653
- fill="#1F3438"
2654
- />
2655
- </svg>
2656
- </button>`:""}
2657
- </div>
2658
- <h2 class="title" part="title" tabindex="-1" aria-live="polite">
2659
- ${this.currentPage==="selection"?this.selectionTitle:this.editorTitle}
2660
- </h2>
2661
- <div class="close-button" part="close-button">
2662
- <button @click=${this.onClose} class="icon-button" aria-label="Close">
2663
- <svg
2664
- part="close-icon icon"
2665
- aria-hidden="true"
2666
- width="11.5"
2667
- height="11.5"
2668
- viewBox="0 0 13 13"
2669
- fill="none"
2670
- xmlns="http://www.w3.org/2000/svg"
2671
- >
2672
- <path d="M1 0.5L12.5 12" stroke="#1F3438" />
2673
- <path d="M12.5 0.5L1 12" stroke="#1F3438" />
2674
- </svg>
2675
- </button>
2676
- </div>
2677
- </div>
2678
- <!-- Body -->
2679
- <div class="body" part="body">
2680
- ${this.isError?F` <div class="error-container" role="alert" aria-live="assertive">
2681
- <div class="error-message">
2682
- <h4 class="notification">
2683
- An error occurred while loading the page. Please refresh the page and try again.
2684
- </h4>
2685
- ${this.errorMessage&&this.errorMessage!==""?F`<p class="error-message">${this.errorMessage}</p>`:Z}
2686
- </div>
2687
- <pbo-button
2688
- variant="primary"
2689
- size="small"
2690
- @click=${()=>{window.location.reload()}}
2691
- class="retry-button"
2692
- >
2693
- Refresh page now
2694
- </pbo-button>
2695
- </div>`:Z}
2696
- <div
2697
- class="category-selection"
2698
- ?hidden=${this.currentPage!=="selection"}
2699
- part="category-selection-container"
2700
- aria-busy=${this.isLoadingCategories?"true":"false"}
2701
- aria-label="Card categories"
2702
- >
2703
- <pbo-card-selection
2704
- part="card-selection"
2705
- .categories=${this.categories}
2706
- ?loading=${this.isLoadingCategories}
2707
- name="selection"
2708
- exportparts="category-title"
2709
- ></pbo-card-selection>
2710
- </div>
2711
- <div class="editor" ?hidden=${this.currentPage!=="editor"} part="editor-container">
2712
- <pbo-editor
2713
- part="editor"
2714
- exportparts="editor-card-slider-container,editor-form-container,type-form,handwritten-form,editor-textarea,font-selector-label,color-selector-label,alignment-selector-label,type-form-label, cta-button-base,cta-button-label,cta-link-button-base,cta-link-button-label"
2715
- .card=${this.selectedCard}
2716
- type-form-cta-primary-label=${this.typeFormCtaLabel}
2717
- handwritten-form-cta-primary-label=${this.handwrittenFormCtaLabel}
2718
- .submitTypeForm=${this.submitTypeForm}
2719
- .submitHandwrittenForm=${this.submitHandwrittenForm}
2720
- .getProcessedImg=${this.getProcessedImg}
2721
- .onClose=${this.onClose}
2722
- name="editor"
2723
- ></pbo-editor>
2724
- </div>
2725
- </div>
2726
- </div>
2727
- `}};rt.styles=[bt,Zp];rt.dependencies={"pbo-button":at,"pbo-card-selection":Hi,"pbo-editor":St};Et([B("pbo-card-selection")],rt.prototype,"cardSelectionEl",2);Et([B(".title")],rt.prototype,"titleEl",2);Et([C({type:Function})],rt.prototype,"onClose",2);Et([C({type:String,reflect:!0})],rt.prototype,"currentPage",2);Et([C()],rt.prototype,"categories",2);Et([C()],rt.prototype,"submitTypeForm",2);Et([C()],rt.prototype,"submitHandwrittenForm",2);Et([C()],rt.prototype,"getProcessedImg",2);Et([C({type:Boolean})],rt.prototype,"isLoadingCategories",2);Et([C({type:Boolean})],rt.prototype,"isError",2);Et([C({type:String})],rt.prototype,"errorMessage",2);Et([C({type:String,attribute:"selection-title"})],rt.prototype,"selectionTitle",2);Et([C({type:String,attribute:"editor-title"})],rt.prototype,"editorTitle",2);Et([C({type:String,attribute:"type-form-cta-primary-label"})],rt.prototype,"typeFormCtaLabel",2);Et([C({type:String,attribute:"handwritten-form-cta-primary-label"})],rt.prototype,"handwrittenFormCtaLabel",2);Et([I()],rt.prototype,"selectedCard",2);Et([I()],rt.prototype,"selectedCardId",2);Et([I()],rt.prototype,"selectedCardDetails",2);Et([G("getProcessedImg")],rt.prototype,"handleGetProcessedImgUpdate",1);Et([G("categories")],rt.prototype,"handleCategoriesUpdate",1);rt=Et([mt("pbo-page-manager")],rt);const Gb=rt,Yb=Hi,sg=it`
2728
- :host {
2729
- display: block;
2728
+
2729
+ .drawer {
2730
+ top: 0;
2731
+ inset-inline-start: 0;
2730
2732
  width: 100%;
2731
2733
  height: 100%;
2734
+ pointer-events: none;
2735
+ overflow: hidden;
2732
2736
  }
2733
2737
 
2734
- .fabric-container {
2735
- max-width: 100%;
2736
- max-height: 100%;
2737
- width: 100% !important;
2738
- height: 100% !important;
2739
- object-fit: contain;
2740
- display: flex;
2741
- margin-left: auto;
2742
- margin-right: auto;
2743
- flex-direction: column;
2744
- justify-content: center;
2738
+ .drawer__overlay {
2739
+ display: block;
2740
+ position: fixed;
2741
+ top: 0;
2742
+ right: 0;
2743
+ bottom: 0;
2744
+ left: 0;
2745
+ background-color: var(--overlay-background-color);
2746
+ pointer-events: all;
2747
+ backdrop-filter: blur(1px);
2748
+ -webkit-backdrop-filter: blur(1px);
2745
2749
  }
2746
2750
 
2747
- canvas {
2748
- max-width: 100% !important;
2749
- max-height: 100% !important;
2750
- width: 100% !important;
2751
- height: auto !important;
2752
- display: block;
2753
- object-fit: contain;
2751
+ .drawer--contained .drawer__overlay {
2752
+ display: none;
2754
2753
  }
2755
2754
 
2756
- .type-canvas-container {
2757
- height: 100%;
2758
- width: 100%;
2759
- object-fit: contain;
2760
- display: flex;
2761
- margin-left: auto;
2762
- margin-right: auto;
2755
+ .drawer__panel {
2756
+ position: absolute;
2763
2757
  flex-direction: column;
2764
- justify-content: center;
2758
+ z-index: 2;
2759
+ max-width: 100%;
2760
+ max-height: 100%;
2761
+ background-color: var(--panel-background-color);
2762
+ box-shadow: var(--pbo-shadow-x-large);
2763
+ overflow: auto;
2764
+ pointer-events: all;
2765
2765
  }
2766
2766
 
2767
- @media screen and (min-width: 640px) {
2768
- .type-canvas-container {
2769
- height: auto;
2770
- width: 100%;
2771
- }
2767
+ .drawer--bottom .drawer__panel {
2768
+ top: auto;
2769
+ inset-inline-end: auto;
2770
+ bottom: 0;
2771
+ inset-inline-start: 0;
2772
+ width: 100%;
2773
+ height: var(--size);
2774
+ border-radius: var(--pbo-border-radius-large) var(--pbo-border-radius-large) 0 0;
2772
2775
  }
2773
2776
 
2774
- .type-canvas-container.image-loading canvas {
2775
- display: none;
2777
+ .drawer--left .drawer__panel {
2778
+ top: auto;
2779
+ inset-inline-end: auto;
2780
+ left: 0;
2781
+ inset-inline-start: 0;
2782
+ height: 100%;
2783
+ width: var(--size);
2776
2784
  }
2777
2785
 
2778
- pbo-image {
2779
- display: none;
2786
+ .drawer--right .drawer__panel {
2787
+ top: auto;
2788
+ inset-inline-end: auto;
2789
+ right: 0;
2790
+ inset-inline-start: 0;
2791
+ height: 100%;
2792
+ width: var(--size);
2780
2793
  }
2781
2794
 
2782
- .type-canvas-container.image-loading pbo-image {
2783
- display: block;
2795
+ .drawer--top .drawer__panel {
2796
+ top: auto;
2797
+ inset-inline-end: auto;
2798
+ top: 0;
2799
+ inset-inline-start: 0;
2800
+ width: 100%;
2801
+ height: var(--size);
2784
2802
  }
2785
- `;var rg=Object.defineProperty,ng=Object.getOwnPropertyDescriptor,yt=(n,t,e,i)=>{for(var s=i>1?void 0:i?ng(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&rg(t,e,s),s};const $n=[{family:"Calibri",label:"Calibri",fontSizePt:15.9,lineHeight:1.185,maxLines:{default:12,fullSize:23}},{family:"Caveat",label:"Caveat",fontSizePt:16.5,lineHeight:1.245,maxLines:{default:11,fullSize:21}},{family:"Dancing Script",label:"Dancing Script",fontSizePt:16.4,lineHeight:1.25,maxLines:{default:11,fullSize:21}},{family:"Kalam",label:"Kalam",fontSizePt:15,lineHeight:1.25,maxLines:{default:12,fullSize:23}},{family:"Reenie Beanie",label:"Reenie Beanie",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}},{family:"Great Vibes",label:"Great Vibes",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}}],ks={width:5,displayArea:{default:{x:.42,y:3.43,width:4.16,height:3.15},fullSize:{x:.42,y:.42,width:4.16,height:6.16}}};let nt=class extends vt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.displayType="default",this.scale=1,this.logicalSize={width:0,height:0},this.areaPosition={left:0,top:0},this.areaSize={width:0,height:0},this.imgLoading=!1,this.backgroundImage=void 0,this.resizeObserver=void 0,this.dpi=0,this.fontConfig=$n.find(t=>t.family==="Arial"),this.processedMessage=""}async handleBackgroundImageUrlChange(){this.imgLoading=!0,await this.appendBackgroundImageToCanvas(this.backgroundImageUrl??"",()=>{this.imgLoading=!1}),this.updateTextAreaPosition()}handleBackgroundImageChange(){if(!this.backgroundImage)return;const t=this.canvas.getContext("2d");if(!t)throw new Error("Could not get canvas context");t.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height)}handleProcessedMessageChange(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.emit("pbo-type-canvas-processed",{detail:{message:this.processedMessage}})},300)}inchToPixel(t,e){return t*e}ptToInch(t){return t/72}firstUpdated(){this.resizeObserver=new ResizeObserver(()=>{this.updateTextAreaPosition()}),this.resizeObserver.observe(this.canvasContainer)}updated(t){var e,i,s;if(t.has("message")||t.has("font")||t.has("color")||t.has("alignment")||t.has("areaPosition")||t.has("areaSize")||t.has("displayType")){if(!this.backgroundImage||this.areaSize.width===0||this.areaSize.height===0)return;const r=this.canvas.getContext("2d");if(!r)return;r.clearRect(0,0,this.logicalSize.width,this.logicalSize.height),r.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.fontConfig=$n.find(o=>o.family===this.font)||$n[0],this.wrapText({ctx:r,message:this.message,areaPosition:this.areaPosition,areaSize:this.areaSize,maxLineSize:((e=this.fontConfig)==null?void 0:e.maxLines[this.displayType])||12,alignment:this.alignment,fontSizePt:((i=this.fontConfig)==null?void 0:i.fontSizePt)||15.9,lineHeight:((s=this.fontConfig)==null?void 0:s.lineHeight)||1.185,verticalAlignment:this.displayType==="fullSize"?"middle":"top"})}}getMaxStringLength(t,e,i){let s=0;for(let r=1;r<=e.length;r++){const o=e.substring(0,r);if(t.measureText(o).width>i)break;s=r}return s}wrapText({ctx:t,message:e,areaPosition:i,areaSize:s,maxLineSize:r,alignment:o,lineHeight:a=1.185,fontSizePt:l,verticalAlignment:c}){if(!t||!e||!i||!s)return;const d=s.height/r/1.2,u=this.inchToPixel(this.ptToInch(l),this.dpi),p=e.split(`
2786
- `);let g=[];t.font=`${d}px ${this.font}`,p.forEach(b=>{const m=b.split(" ");let _="";for(let x=0;x<m.length;x++)if(t.measureText(m[x]).width>s.width){const O=this.getMaxStringLength(t,m[x],s.width),k=m[x];x+1<m.length?(m[x]=k.substring(0,O),m[x+1]=k.substring(O,k.length)+m[x+1]):(m[x]=k.substring(0,O),m.push(k.substring(O,k.length)))}for(let x=0;x<m.length;x++){let S=_+m[x]+" ";t.measureText(S).width>s.width&&x>0?(g.push(_),_=m[x]+" "):_=S}g.push(_)}),this.processedMessage=g.slice(0,r).join(`
2787
- `);let f=this.areaPosition.left;if(o==="center"&&(f+=this.areaSize.width/2),o==="right"&&(f+=this.areaSize.width),c==="top"){t.textBaseline="top";for(let b=0;b<r&&b<g.length;b++){const m=g[b];t.fillStyle=this.color,t.textAlign=o,t.fillText(m,f,this.areaPosition.top+b*u*a)}}if(c==="middle"){t.textBaseline="middle";for(let b=0;b<r&&b<g.length;b++){const m=g[b],_=Math.min(g.length,r),x=(b+1-_/2-.5)*u*a;t.fillStyle=this.color,t.textAlign=o,t.fillText(m,f,x+this.areaPosition.top+this.areaSize.height/2)}}}updateTextAreaPosition(){if(!this.canvas||!this.backgroundImage)return;const t=window.devicePixelRatio||1,e=this.canvasContainer.clientWidth;this.scale=e/this.backgroundImage.width,this.logicalSize={width:this.canvasContainer.clientWidth,height:this.backgroundImage.height*this.scale},this.canvas.width=this.logicalSize.width*t,this.canvas.height=this.logicalSize.height*t,this.canvas.style.width=`${this.logicalSize.width}px`,this.canvas.style.height=`${this.logicalSize.height}px`;const i=this.canvas.getContext("2d");i&&(i.setTransform(1,0,0,1,0,0),i.scale(t,t),i.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.dpi=this.logicalSize.width/ks.width,this.areaPosition={left:this.inchToPixel(ks.displayArea[this.displayType].x,this.dpi),top:this.inchToPixel(ks.displayArea[this.displayType].y,this.dpi)},this.areaSize={width:this.inchToPixel(ks.displayArea[this.displayType].width,this.dpi),height:this.inchToPixel(ks.displayArea[this.displayType].height,this.dpi)})}async appendBackgroundImageToCanvas(t,e){return new Promise((i,s)=>{const r=new Image;r.onerror=()=>{s(new Error("Failed to load image"))},r.onload=()=>{this.backgroundImage=r,e&&e(),i()},t!==""&&(r.src=t)})}render(){return F`
2803
+ `;var og=Object.defineProperty,ag=Object.getOwnPropertyDescriptor,Ei=(n,t,e,i)=>{for(var s=i>1?void 0:i?ag(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&og(t,e,s),s};let De=class extends vt{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.radius=!0,this.contained=!1,this.label="",this.handleKeyDown=n=>{n.key==="Escape"&&this.open&&(n.stopPropagation(),this.requestClose("keyboard"))}}requestClose(n){this.hide()}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleKeyDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleKeyDown)}async hide(){this.open=!1,this.emit("pbo-after-drawer-closed")}async show(){this.open||(this.open=!0)}handleOpenChange(){this.open?this.drawer.hidden=!1:this.drawer.hidden=!0}firstUpdated(){this.drawer.hidden=!this.open}render(){return F`
2788
2804
  <div
2789
- class="${fe({"type-canvas-container":!0,"image-loading":this.imgLoading})}
2790
- "
2805
+ part="base"
2806
+ class=${fe({drawer:!0,"drawer--bottom":this.placement==="bottom","drawer--top":this.placement==="top","drawer--left":this.placement==="left","drawer--right":this.placement==="right","drawer--open":this.open,"drawer--contained":this.contained})}
2791
2807
  >
2792
- <canvas class="base-canvas"></canvas>
2793
- <pbo-image skeleton></pbo-image>
2808
+ <div
2809
+ part="overlay"
2810
+ class="drawer__overlay"
2811
+ @click=${()=>this.requestClose("overlay")}
2812
+ ></div>
2813
+ <div
2814
+ part="panel"
2815
+ class="${fe({drawer__panel:!0})}"
2816
+ role="dialog"
2817
+ aria-modal="true"
2818
+ aria-hidden=${this.open?"false":"true"}
2819
+ aria-label=${this.label||"Drawer"}
2820
+ tabindex="-1"
2821
+ >
2822
+ <slot part="body" class="drawer__body"></slot>
2823
+ </div>
2794
2824
  </div>
2795
- `}};nt.styles=[bt,sg];yt([C({attribute:"background-url"})],nt.prototype,"backgroundImageUrl",2);yt([C()],nt.prototype,"message",2);yt([C()],nt.prototype,"font",2);yt([C()],nt.prototype,"color",2);yt([C()],nt.prototype,"alignment",2);yt([C({attribute:"display-type"})],nt.prototype,"displayType",2);yt([B(".base-canvas")],nt.prototype,"canvas",2);yt([B(".type-canvas-container")],nt.prototype,"canvasContainer",2);yt([I()],nt.prototype,"scale",2);yt([I()],nt.prototype,"logicalSize",2);yt([I()],nt.prototype,"areaPosition",2);yt([I()],nt.prototype,"areaSize",2);yt([I()],nt.prototype,"imgLoading",2);yt([I()],nt.prototype,"backgroundImage",2);yt([I()],nt.prototype,"resizeObserver",2);yt([I()],nt.prototype,"dpi",2);yt([I()],nt.prototype,"fontConfig",2);yt([I()],nt.prototype,"processedMessage",2);yt([G("backgroundImageUrl")],nt.prototype,"handleBackgroundImageUrlChange",1);yt([G("backgroundImage")],nt.prototype,"handleBackgroundImageChange",1);yt([G("processedMessage")],nt.prototype,"handleProcessedMessageChange",1);nt=yt([mt("pbo-type-canvas")],nt);const qb=nt,og=it`
2825
+ `}};De.styles=[bt,ng];Ei([B(".drawer")],De.prototype,"drawer",2);Ei([C({type:Boolean,reflect:!0})],De.prototype,"open",2);Ei([C({reflect:!0})],De.prototype,"placement",2);Ei([C({type:Boolean,reflect:!0})],De.prototype,"radius",2);Ei([C({type:Boolean,reflect:!0})],De.prototype,"contained",2);Ei([C({type:String})],De.prototype,"label",2);Ei([G("open",{waitUntilFirstUpdate:!0})],De.prototype,"handleOpenChange",1);De=Ei([mt("pbo-drawer")],De);const lg=it`
2796
2826
  :host {
2797
2827
  display: block;
2798
- height: 100%;
2799
2828
  width: 100%;
2800
- }
2801
-
2802
- .zoomed-preview {
2803
- padding: 24px;
2804
2829
  height: 100%;
2805
- width: 100%;
2830
+ --header-height: var(--pbo-drawer-header-height);
2831
+ --header-padding: 0 var(--pbo-spacing-large) 0 var(--pbo-spacing-large);
2832
+ --icon-button-size: 24px;
2833
+ --title-font-size: 18.75px;
2806
2834
  }
2807
2835
 
2808
- .panel {
2809
- width: 100%;
2810
- height: 100%;
2836
+ .body {
2837
+ overflow: hidden;
2811
2838
  }
2812
2839
 
2813
- ::slotted(img) {
2814
- width: 100%;
2815
- max-height: 100%;
2816
- object-fit: contain;
2840
+ .back-button {
2841
+ display: flex;
2842
+ justify-content: start;
2843
+ overflow: visible;
2817
2844
  }
2818
2845
 
2846
+ /* .icon-button svg {
2847
+ height: var(--icon-button-size);
2848
+ width: var(--icon-button-size);
2849
+ max-height: var(--header-height);
2850
+ max-width: var(--header-height);
2851
+ } */
2852
+
2819
2853
  .close-button {
2820
- position: absolute;
2821
- right: 1em;
2822
- top: 1em;
2823
- cursor: pointer;
2824
- background: none;
2825
- border: none;
2826
- padding: 0;
2854
+ display: flex;
2855
+ justify-content: end;
2827
2856
  }
2828
2857
 
2829
- .close-button svg {
2830
- height: 32px;
2831
- width: 32px;
2832
- fill: #595959;
2833
- display: block;
2858
+ .header {
2859
+ height: var(--pbo-drawer-header-height);
2860
+ padding: 0 var(--pbo-spacing-large);
2861
+ user-select: none;
2862
+ position: sticky;
2863
+ top: 0;
2864
+ background-color: var(--pbo-color-gray-100);
2865
+ display: grid;
2866
+ grid-template-columns: 1fr auto 1fr;
2867
+ align-items: center;
2868
+ font-size: var(--pbo-font-size-2x-large);
2834
2869
  }
2835
2870
 
2836
- .close-button:hover svg {
2837
- scale: 1.1;
2871
+ .title {
2872
+ font-size: var(--title-font-size);
2873
+ margin: 0;
2874
+ font-weight: inherit;
2838
2875
  }
2839
2876
 
2840
- .close-button:focus {
2877
+ .title:focus {
2841
2878
  outline: none;
2842
2879
  }
2843
2880
 
2844
- .close-button:focus-visible {
2845
- outline: 2px solid #fff;
2846
- outline-offset: 2px;
2847
- border-radius: 50%;
2848
- }
2849
- `;var ag=Object.defineProperty,lg=Object.getOwnPropertyDescriptor,Wi=(n,t,e,i)=>{for(var s=i>1?void 0:i?lg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&ag(t,e,s),s};let Ve=class extends vt{constructor(){super(...arguments),this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.cardUrl="",this.handwrittenPreviewProps={isLoading:!1,url:""},this.pinchToCloseDisabled=!1,this.distance=null,this.handleTouchMove=t=>{if(this.pinchToCloseDisabled)return;t.preventDefault();const e=t.touches[0],i=t.touches[1];if(!(e&&!i)&&e&&i){const s={x:e.clientX,y:e.clientY},r={x:i.clientX,y:i.clientY},o=dc(s,r);if(this.distance===null){this.distance=o;return}this.distance-o>10&&(this.distance=null,this.close())}},this.handleTouchEnd=()=>{this.pinchToCloseDisabled||(this.distance=null)}}render(){return F`
2850
- <div class="panel" @touchmove=${this.handleTouchMove} @touchend=${this.handleTouchEnd}>
2851
- <div class="zoomed-preview">
2852
- <div
2853
- style=${ge({display:"flex","justify-content":"center",flexDirection:"column",height:"100%"})}
2854
- >
2855
- <slot part="base"></slot>
2856
- </div>
2857
- </div>
2858
-
2859
- <button class="close-button" type="button" aria-label="Close preview" @click=${this.close}>
2860
- <svg
2861
- aria-hidden="true"
2862
- xmlns="http://www.w3.org/2000/svg"
2863
- height="24px"
2864
- viewBox="0 -960 960 960"
2865
- width="24px"
2866
- fill="#F3F3F3"
2867
- >
2868
- <circle cx="480" cy="-480" r="390" fill="#FFFFFF" />
2869
- <path
2870
- d="m336-280 144-144 144 144 56-56-144-144 144-144-56-56-144 144-144-144-56 56 144 144-144 144 56 56ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"
2871
- />
2872
- </svg>
2873
- </button>
2874
- </div>
2875
- `}};Ve.styles=[bt,og];Wi([C()],Ve.prototype,"formData",2);Wi([C()],Ve.prototype,"cardUrl",2);Wi([C()],Ve.prototype,"close",2);Wi([C()],Ve.prototype,"handwrittenPreviewProps",2);Wi([C({type:Boolean,reflect:!0,attribute:"pinch-to-close-disabled"})],Ve.prototype,"pinchToCloseDisabled",2);Wi([I()],Ve.prototype,"distance",2);Ve=Wi([mt("pbo-zoomed-preview")],Ve);const Zb=Ve,cg=it`
2876
- :host {
2877
- display: block;
2881
+ .icon-button {
2882
+ all: unset; /* Removes default button styles (border, background, padding, etc.) */
2883
+ display: flex;
2884
+ align-items: center;
2885
+ justify-content: center;
2886
+ cursor: pointer;
2887
+ color: var(--pbo-color-gray-500); /* Default icon color */
2888
+ transition:
2889
+ transform 0.2s ease-in-out,
2890
+ color 0.2s ease-in-out;
2878
2891
  }
2879
2892
 
2880
- .label {
2881
- line-height: normal;
2882
- font-size: 15px;
2893
+ /* Apply hover effect */
2894
+ .icon-button:hover {
2895
+ transform: scale(1.1); /* Slightly enlarges the icon */
2896
+ color: var(--pbo-color-gray-700); /* Changes icon color on hover */
2883
2897
  }
2884
2898
 
2885
- .label svg {
2886
- vertical-align: middle;
2887
- pointer-events: none;
2888
- color: rgb(107 114 128);
2899
+ .icon-button:focus {
2900
+ outline: none;
2889
2901
  }
2890
2902
 
2891
- .icon {
2892
- /* display: inline; */
2893
- vertical-align: top;
2903
+ .icon-button:focus-visible {
2904
+ outline: var(--pbo-focus-ring);
2905
+ outline-offset: 2px;
2906
+ border-radius: 2px;
2894
2907
  }
2895
2908
 
2896
- .choice-wrapper {
2897
- display: inline-flex;
2909
+ .page-manager {
2910
+ position: relative;
2911
+ height: 100%;
2912
+ width: 100%;
2913
+ display: grid;
2914
+ grid-template-rows: min-content auto;
2915
+ grid-gap: 0;
2898
2916
  }
2899
2917
 
2900
- .choices__inner .choices__item .choice-wrapper {
2918
+ .category-selection {
2919
+ height: 100%;
2901
2920
  width: 100%;
2902
- text-overflow: ellipsis;
2903
- white-space: nowrap;
2904
- overflow: hidden;
2921
+ overflow: scroll;
2922
+ display: grid;
2923
+ grid-template-columns: repeat(12, 1fr);
2924
+ padding: var(--pbo-spacing-small);
2905
2925
  }
2906
2926
 
2907
- .choices__inner {
2908
- height: 32px;
2909
- background-color: rgb(255, 255, 255) !important;
2910
- border-radius: 3.75px !important;
2927
+ @media screen and (min-width: 640px) {
2928
+ .category-selection {
2929
+ padding: var(--pbo-spacing-medium);
2930
+ }
2911
2931
  }
2912
2932
 
2913
- .choices.is-focused .choices__inner,
2914
- .choices.is-open .choices__inner {
2915
- box-shadow: 0 0 0 var(--pbo-focus-ring-width, 3px) var(--pbo-focus-ring-color);
2916
- }
2917
- `;var hg=Object.defineProperty,dg=Object.getOwnPropertyDescriptor,hs=(n,t,e,i)=>{for(var s=i>1?void 0:i?dg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&hg(t,e,s),s};let ri=class extends vt{constructor(){super(...arguments),this.hasSlotController=new Ni(this,"help-text","label"),this.size="medium",this.label="",this.disabled=!1,this._handleDocumentClick=t=>{var i;const e=t.composedPath();this&&!e.includes(this)&&((i=this._choices)==null||i.hideDropdown())}}handleDisabledChanged(){var t;this._choices&&this.disabled?this._choices.disable():(t=this._choices)==null||t.enable()}get value(){var t;return(t=this._choices)==null?void 0:t.getValue().value}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var t;(t=this._choices)==null||t.destroy(),this._choices=new nc(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:[{value:"type",label:`
2918
- <div class="choice-wrapper">
2919
- <span class="label">Type message
2920
- <svg
2921
- stroke="currentColor"
2922
- fill="none"
2923
- stroke-width="0"
2924
- viewBox="0 0 24 24"
2925
- height="1.6em"
2926
- width="1.6em"
2927
- xmlns="http://www.w3.org/2000/svg"
2928
- >
2929
- <path d="M6.5 3H3V6.5H4V4H6.5V3Z" fill="currentColor"></path>
2930
- <path d="M8.5 4V3H11V4H8.5Z" fill="currentColor"></path>
2931
- <path d="M13 4H15.5V3H13V4Z" fill="currentColor"></path>
2932
- <path d="M17.5 3V4H20V6.5H21V3H17.5Z" fill="currentColor"></path>
2933
- <path d="M21 8.5H20V11H21V8.5Z" fill="currentColor"></path>
2934
- <path d="M21 13H20V15.5H21V13Z" fill="currentColor"></path>
2935
- <path d="M21 17.5H20V20H17.5V21H21V17.5Z" fill="currentColor"></path>
2936
- <path d="M15.5 21V20H13V21H15.5Z" fill="currentColor"></path>
2937
- <path d="M11 21V20H8.5V21H11Z" fill="currentColor"></path>
2938
- <path d="M6.5 21V20H4V17.5H3V21H6.5Z" fill="currentColor"></path>
2939
- <path d="M3 15.5H4V13H3V15.5Z" fill="currentColor"></path>
2940
- <path d="M3 11H4V8.5H3V11Z" fill="currentColor"></path>
2941
- <path d="M11 9.5H7V7.5H17V9.5H13V16.5H11V9.5Z" fill="currentColor"></path>
2942
- </svg>
2943
- </span>
2944
- </div>`},{value:"handwritten",label:`
2945
- <div class="choice-wrapper">
2946
- <span class="label">Upload handwritten message
2947
- <svg
2948
- stroke="currentColor"
2949
- fill="none"
2950
- stroke-width="0"
2951
- viewBox="0 0 24 24"
2952
- height="1.6em"
2953
- width="1.6em"
2954
- xmlns="http://www.w3.org/2000/svg"
2955
- >
2956
- <path
2957
- fill-rule="evenodd"
2958
- clip-rule="evenodd"
2959
- d="M21.2635 2.29289C20.873 1.90237 20.2398 1.90237 19.8493 2.29289L18.9769 3.16525C17.8618 2.63254 16.4857 2.82801 15.5621 3.75165L4.95549 14.3582L10.6123 20.0151L21.2189 9.4085C22.1426 8.48486 22.338 7.1088 21.8053 5.99367L22.6777 5.12132C23.0682 4.7308 23.0682 4.09763 22.6777 3.70711L21.2635 2.29289ZM16.9955 10.8035L10.6123 17.1867L7.78392 14.3582L14.1671 7.9751L16.9955 10.8035ZM18.8138 8.98525L19.8047 7.99429C20.1953 7.60376 20.1953 6.9706 19.8047 6.58007L18.3905 5.16586C18 4.77534 17.3668 4.77534 16.9763 5.16586L15.9853 6.15683L18.8138 8.98525Z"
2960
- fill="currentColor"
2961
- ></path>
2962
- <path d="M2 22.9502L4.12171 15.1717L9.77817 20.8289L2 22.9502Z" fill="currentColor"></path>
2963
- </svg>
2964
- <svg
2965
- stroke="currentColor"
2966
- fill="currentColor"
2967
- stroke-width="0"
2968
- viewBox="0 0 512 512"
2969
- height="1.6em"
2970
- width="1.6em"
2971
- xmlns="http://www.w3.org/2000/svg"
2972
- >
2973
- <circle cx="256" cy="275" r="57.5"></circle>
2974
- <path
2975
- d="M417.5 160H363c-4.6 0-8.9-2-12-5.4-28.4-31.8-39.1-42.6-50.7-42.6h-85.5c-11.7 0-23.2 10.8-51.7 42.7-3 3.4-7.4 5.3-11.9 5.3h-4.1v-8c0-4.4-3.6-8-8-8h-26c-4.4 0-8 3.6-8 8v8h-7.5C79.9 160 64 173.2 64 190.7v176c0 17.5 15.9 33.3 33.5 33.3h320c17.6 0 30.5-15.8 30.5-33.3v-176c0-17.5-12.9-30.7-30.5-30.7zM260 360.4c-50.3 2.3-91.7-39.1-89.4-89.4 2-43.9 37.5-79.4 81.4-81.4 50.3-2.3 91.7 39.1 89.4 89.4-2 43.9-37.5 79.4-81.4 81.4zM352 218c-7.2 0-13-5.8-13-13s5.8-13 13-13 13 5.8 13 13-5.8 13-13 13z"
2976
- ></path>
2977
- </svg>
2978
- <svg
2979
- stroke="currentColor"
2980
- fill="currentColor"
2981
- stroke-width="0"
2982
- viewBox="0 0 512 512"
2983
- height="1.6em"
2984
- width="1.6em"
2985
- xmlns="http://www.w3.org/2000/svg"
2986
- >
2987
- <path
2988
- fill="none"
2989
- stroke-linecap="round"
2990
- stroke-linejoin="round"
2991
- stroke-width="32"
2992
- d="M336 192h40a40 40 0 0 1 40 40v192a40 40 0 0 1-40 40H136a40 40 0 0 1-40-40V232a40 40 0 0 1 40-40h40m160-64-80-80-80 80m80 193V48"
2993
- ></path>
2994
- </svg>
2995
- </span>
2996
- </div>`}],placeholder:!1,shouldSortItems:!1,itemSelectText:""}),this.choiceEl.addEventListener("change",e=>{const i=e.target;this.emit("pbo-editor-selector-change",{detail:{editor:i.value}})})}render(){const t=this.hasSlotController.test("label"),e=this.label?!0:!!t;return F` <div
2997
- class=${fe({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":e})}
2998
- >
2999
- <label
3000
- part="form-control-label"
3001
- id="label"
3002
- class="form-control__label"
3003
- aria-hidden=${e?"false":"true"}
3004
- >
3005
- <slot name="label">${this.label}</slot>
3006
- </label>
3007
- </div>
3008
- <select part="base" class="js-choice"></select>`}};ri.styles=[bt,cg,Js,en(oc)];hs([C()],ri.prototype,"size",2);hs([C()],ri.prototype,"label",2);hs([C({type:Boolean,reflect:!0})],ri.prototype,"disabled",2);hs([G("disabled",{waitUntilFirstUpdate:!0})],ri.prototype,"handleDisabledChanged",1);hs([B(".js-choice")],ri.prototype,"choiceEl",2);ri=hs([mt("pbo-editor-selector")],ri);const Qb=ri,ug=it`
3009
- :host {
3010
- display: block;
2933
+ .category-selection pbo-card-selection {
2934
+ grid-column: 1 / 13;
3011
2935
  }
3012
2936
 
3013
- .pixel-input {
3014
- display: none;
3015
- height: 1;
3016
- width: 1;
3017
- opacity: 0;
2937
+ .editor {
2938
+ padding: var(--pbo-spacing-small);
2939
+ overflow: scroll;
2940
+ height: 100%;
2941
+ width: 100%;
3018
2942
  }
3019
2943
 
3020
- .buttons-container {
3021
- display: flex;
3022
- flex-direction: column;
2944
+ @media screen and (min-width: 640px) {
2945
+ .editor {
2946
+ padding: var(--pbo-spacing-medium);
2947
+ }
3023
2948
  }
3024
2949
 
3025
- .buttons-container pbo-button::part(base) {
3026
- font-size: var(--pbo-font-size-medium);
2950
+ @media screen and (min-width: 768px) {
2951
+ .category-selection pbo-card-selection {
2952
+ grid-column: 2 / 12;
2953
+ }
3027
2954
  }
3028
2955
 
3029
- .step-title {
3030
- margin: 0;
3031
- margin-bottom: 4.5px;
3032
- font-size: 17.5px;
3033
- font-weight: 800;
3034
- font-style: normal;
3035
- line-height: normal;
2956
+ @media screen and (min-width: 1280px) {
2957
+ .category-selection pbo-card-selection {
2958
+ grid-column: 3 / 11;
2959
+ }
3036
2960
  }
3037
2961
 
3038
- .step-description {
3039
- margin: 0;
3040
- font-size: 17.5px;
3041
- font-weight: 400;
3042
- font-style: normal;
3043
- line-height: normal;
2962
+ /* ------------------------------ Error message ----------------------------- */
2963
+ .error-container .notification {
2964
+ color: oklch(70.4% 0.191 22.216);
3044
2965
  }
3045
-
3046
- .fake-loading-container {
2966
+ .error-message {
2967
+ text-align: center;
2968
+ }
2969
+ .error-container {
3047
2970
  display: flex;
3048
- justify-content: center;
2971
+ flex-direction: column;
3049
2972
  align-items: center;
2973
+ justify-content: center;
2974
+ height: 100%;
2975
+ padding: var(--pbo-spacing-large);
2976
+ }
2977
+ `,cg=it`
2978
+ :host {
2979
+ display: block;
2980
+ }
2981
+ `;var hg=Object.defineProperty,dg=Object.getOwnPropertyDescriptor,Lo=(n,t,e,i)=>{for(var s=i>1?void 0:i?dg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&hg(t,e,s),s};let wi=class extends vt{constructor(){super(...arguments),this.categories=[],this.loading=!0}render(){return this.loading?F`
2982
+ <pbo-category skeleton></pbo-category>
2983
+ <pbo-category skeleton></pbo-category>
2984
+ `:F`
2985
+ ${uc(this.categories,t=>F`<pbo-category
2986
+ .cards=${t.cards}
2987
+ .name=${t.name}
2988
+ title=${t.name}
2989
+ exportparts="category-title"
2990
+ >
2991
+ </pbo-category>`)}
2992
+ `}};wi.styles=[bt,cg];wi.dependencies={"pbo-category":Ut};Lo([C({type:Array})],wi.prototype,"categories",2);Lo([C({type:Boolean,reflect:!0})],wi.prototype,"loading",2);wi=Lo([mt("pbo-card-selection")],wi);var ug=Object.defineProperty,pg=Object.getOwnPropertyDescriptor,Et=(n,t,e,i)=>{for(var s=i>1?void 0:i?pg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&ug(t,e,s),s};let rt=class extends vt{constructor(){super(...arguments),this.onClose=()=>{},this.currentPage="selection",this.categories=[],this.isLoadingCategories=!1,this.isError=!1,this.errorMessage="Unknown error occurred. Please try again later.",this.selectionTitle="SELECT CARD",this.editorTitle="PERSONALIZE",this.typeFormCtaLabel="Add to Cart",this.handwrittenFormCtaLabel="Add to Cart",this.selectedCard=null,this.selectedCardId=null,this.selectedCardDetails=null,this.handleCardSelected=t=>{const{cardId:e}=t.detail,i=this.findCardInCategoryById(e);this.selectedCard=i,this.goToEditor()}}get editorEl(){var t;return((t=this.shadowRoot)==null?void 0:t.querySelector("pbo-editor"))||null}handleGetProcessedImgUpdate(){this.editorEl&&(this.editorEl.getProcessedImg=this.getProcessedImg)}async goToEditor(){var t;this.currentPage="editor",await this.updateComplete,(t=this.titleEl)==null||t.focus()}async goToSelector(){var t;this.currentPage="selection",await this.updateComplete,(t=this.titleEl)==null||t.focus()}connectedCallback(){var t;super.connectedCallback(),(t=this.shadowRoot)==null||t.addEventListener("pbo-category-card-selected",this.handleCardSelected)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.shadowRoot)==null||t.removeEventListener("pbo-category-card-selected",this.handleCardSelected)}firstUpdated(){if(!this.cardSelectionEl){console.error("Card selection element not found");return}this.cardSelectionEl.categories=this.categories}handleCategoriesUpdate(){this.cardSelectionEl&&this.categories!==void 0&&this.categories.length>0&&(this.cardSelectionEl.categories=this.categories,this.requestUpdate())}setIsLoadingCategories(t){this.isLoadingCategories=t,this.cardSelectionEl&&(this.cardSelectionEl.loading=t)}findCardInCategoryById(t){for(const e of this.categories){const i=e.cards.find(s=>s.pboId===t);if(i)return i}return null}render(){return F`
2993
+ <div part="base" class="page-manager">
2994
+ <div class="header" part="header">
2995
+ <div class="back-button" part="back-button">
2996
+ ${this.currentPage!=="selection"?F`<button
2997
+ @click=${this.goToSelector}
2998
+ class="icon-button"
2999
+ aria-label="Back to card selection"
3000
+ >
3001
+ <svg
3002
+ part="back-icon icon"
3003
+ aria-hidden="true"
3004
+ width="15"
3005
+ height="9"
3006
+ viewBox="0 0 15 9"
3007
+ fill="none"
3008
+ xmlns="http://www.w3.org/2000/svg"
3009
+ >
3010
+ <path
3011
+ d="M0.146447 4.14645C-0.0488155 4.34171 -0.0488155 4.65829 0.146447 4.85355L3.32843 8.03553C3.52369 8.2308 3.84027 8.2308 4.03553 8.03553C4.2308 7.84027 4.2308 7.52369 4.03553 7.32843L1.20711 4.5L4.03553 1.67157C4.2308 1.47631 4.2308 1.15973 4.03553 0.964466C3.84027 0.769204 3.52369 0.769204 3.32843 0.964466L0.146447 4.14645ZM14.5 4.5V4H0.5V4.5V5H14.5V4.5Z"
3012
+ fill="#1F3438"
3013
+ />
3014
+ </svg>
3015
+ </button>`:""}
3016
+ </div>
3017
+ <h2 class="title" part="title" tabindex="-1" aria-live="polite">
3018
+ ${this.currentPage==="selection"?this.selectionTitle:this.editorTitle}
3019
+ </h2>
3020
+ <div class="close-button" part="close-button">
3021
+ <button @click=${this.onClose} class="icon-button" aria-label="Close">
3022
+ <svg
3023
+ part="close-icon icon"
3024
+ aria-hidden="true"
3025
+ width="11.5"
3026
+ height="11.5"
3027
+ viewBox="0 0 13 13"
3028
+ fill="none"
3029
+ xmlns="http://www.w3.org/2000/svg"
3030
+ >
3031
+ <path d="M1 0.5L12.5 12" stroke="#1F3438" />
3032
+ <path d="M12.5 0.5L1 12" stroke="#1F3438" />
3033
+ </svg>
3034
+ </button>
3035
+ </div>
3036
+ </div>
3037
+ <!-- Body -->
3038
+ <div class="body" part="body">
3039
+ ${this.isError?F` <div class="error-container" role="alert" aria-live="assertive">
3040
+ <div class="error-message">
3041
+ <h4 class="notification">
3042
+ An error occurred while loading the page. Please refresh the page and try again.
3043
+ </h4>
3044
+ ${this.errorMessage&&this.errorMessage!==""?F`<p class="error-message">${this.errorMessage}</p>`:Z}
3045
+ </div>
3046
+ <pbo-button
3047
+ variant="primary"
3048
+ size="small"
3049
+ @click=${()=>{window.location.reload()}}
3050
+ class="retry-button"
3051
+ >
3052
+ Refresh page now
3053
+ </pbo-button>
3054
+ </div>`:Z}
3055
+ <div
3056
+ class="category-selection"
3057
+ ?hidden=${this.currentPage!=="selection"}
3058
+ part="category-selection-container"
3059
+ aria-busy=${this.isLoadingCategories?"true":"false"}
3060
+ aria-label="Card categories"
3061
+ >
3062
+ <pbo-card-selection
3063
+ part="card-selection"
3064
+ .categories=${this.categories}
3065
+ ?loading=${this.isLoadingCategories}
3066
+ name="selection"
3067
+ exportparts="category-title"
3068
+ ></pbo-card-selection>
3069
+ </div>
3070
+ <div class="editor" ?hidden=${this.currentPage!=="editor"} part="editor-container">
3071
+ <pbo-editor
3072
+ part="editor"
3073
+ exportparts="editor-card-slider-container,editor-form-container,type-form,handwritten-form,editor-textarea,font-selector-label,color-selector-label,alignment-selector-label,type-form-label, cta-button-base,cta-button-label,cta-link-button-base,cta-link-button-label"
3074
+ .card=${this.selectedCard}
3075
+ type-form-cta-primary-label=${this.typeFormCtaLabel}
3076
+ handwritten-form-cta-primary-label=${this.handwrittenFormCtaLabel}
3077
+ .submitTypeForm=${this.submitTypeForm}
3078
+ .submitHandwrittenForm=${this.submitHandwrittenForm}
3079
+ .getProcessedImg=${this.getProcessedImg}
3080
+ .onClose=${this.onClose}
3081
+ name="editor"
3082
+ ></pbo-editor>
3083
+ </div>
3084
+ </div>
3085
+ </div>
3086
+ `}};rt.styles=[bt,lg];rt.dependencies={"pbo-button":at,"pbo-card-selection":wi,"pbo-editor":St};Et([B("pbo-card-selection")],rt.prototype,"cardSelectionEl",2);Et([B(".title")],rt.prototype,"titleEl",2);Et([C({type:Function})],rt.prototype,"onClose",2);Et([C({type:String,reflect:!0})],rt.prototype,"currentPage",2);Et([C()],rt.prototype,"categories",2);Et([C()],rt.prototype,"submitTypeForm",2);Et([C()],rt.prototype,"submitHandwrittenForm",2);Et([C()],rt.prototype,"getProcessedImg",2);Et([C({type:Boolean})],rt.prototype,"isLoadingCategories",2);Et([C({type:Boolean})],rt.prototype,"isError",2);Et([C({type:String})],rt.prototype,"errorMessage",2);Et([C({type:String,attribute:"selection-title"})],rt.prototype,"selectionTitle",2);Et([C({type:String,attribute:"editor-title"})],rt.prototype,"editorTitle",2);Et([C({type:String,attribute:"type-form-cta-primary-label"})],rt.prototype,"typeFormCtaLabel",2);Et([C({type:String,attribute:"handwritten-form-cta-primary-label"})],rt.prototype,"handwrittenFormCtaLabel",2);Et([I()],rt.prototype,"selectedCard",2);Et([I()],rt.prototype,"selectedCardId",2);Et([I()],rt.prototype,"selectedCardDetails",2);Et([G("getProcessedImg")],rt.prototype,"handleGetProcessedImgUpdate",1);Et([G("categories")],rt.prototype,"handleCategoriesUpdate",1);rt=Et([mt("pbo-page-manager")],rt);const Kb=rt,Zb=wi,gg=it`
3087
+ :host {
3088
+ display: block;
3089
+ width: 100%;
3090
+ height: 100%;
3050
3091
  }
3051
3092
 
3052
- .handwritten-form {
3093
+ .fabric-container {
3094
+ max-width: 100%;
3095
+ max-height: 100%;
3096
+ width: 100% !important;
3097
+ height: 100% !important;
3098
+ object-fit: contain;
3053
3099
  display: flex;
3100
+ margin-left: auto;
3101
+ margin-right: auto;
3054
3102
  flex-direction: column;
3055
- gap: var(--pbo-spacing-medium);
3056
- padding: 0;
3057
- }
3058
-
3059
- .reupload-cta::part(base) {
3060
- color: black;
3061
- }
3062
-
3063
- .reupload-cta::part(label) {
3064
- font-size: 14px;
3103
+ justify-content: center;
3065
3104
  }
3066
3105
 
3067
- .handwritten-tutorials {
3068
- margin-top: 25px;
3069
- margin-bottom: 25px;
3070
- display: flex;
3071
- flex-direction: column;
3072
- gap: 15px;
3106
+ canvas {
3107
+ max-width: 100% !important;
3108
+ max-height: 100% !important;
3109
+ width: 100% !important;
3110
+ height: auto !important;
3111
+ display: block;
3112
+ object-fit: contain;
3073
3113
  }
3074
3114
 
3075
- .tutorial-steps {
3076
- list-style: none;
3077
- padding: 0;
3078
- margin: 0;
3115
+ .type-canvas-container {
3116
+ height: 100%;
3117
+ width: 100%;
3118
+ object-fit: contain;
3079
3119
  display: flex;
3120
+ margin-left: auto;
3121
+ margin-right: auto;
3080
3122
  flex-direction: column;
3081
- gap: 15px;
3123
+ justify-content: center;
3082
3124
  }
3083
3125
 
3084
- .tutorial-steps li {
3085
- display: flex;
3086
- flex-direction: column;
3126
+ @media screen and (min-width: 640px) {
3127
+ .type-canvas-container {
3128
+ height: auto;
3129
+ width: 100%;
3130
+ }
3087
3131
  }
3088
3132
 
3089
- .visually-hidden {
3090
- position: absolute;
3091
- width: 1px;
3092
- height: 1px;
3093
- padding: 0;
3094
- margin: -1px;
3095
- overflow: hidden;
3096
- clip: rect(0, 0, 0, 0);
3097
- white-space: nowrap;
3098
- border: 0;
3133
+ .type-canvas-container.image-loading canvas {
3134
+ display: none;
3099
3135
  }
3100
3136
 
3101
- .submit-error {
3102
- color: var(--pbo-color-danger, #d93025);
3103
- font-size: var(--pbo-font-size-small);
3104
- text-align: center;
3137
+ pbo-image {
3105
3138
  display: none;
3106
3139
  }
3107
3140
 
3108
- .submit-error:not(:empty) {
3141
+ .type-canvas-container.image-loading pbo-image {
3109
3142
  display: block;
3110
3143
  }
3111
- `,pg=it`
3144
+ `;var fg=Object.defineProperty,mg=Object.getOwnPropertyDescriptor,yt=(n,t,e,i)=>{for(var s=i>1?void 0:i?mg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&fg(t,e,s),s};const $n=[{family:"Calibri",label:"Calibri",fontSizePt:15.9,lineHeight:1.185,maxLines:{default:12,fullSize:23}},{family:"Caveat",label:"Caveat",fontSizePt:16.5,lineHeight:1.245,maxLines:{default:11,fullSize:21}},{family:"Dancing Script",label:"Dancing Script",fontSizePt:16.4,lineHeight:1.25,maxLines:{default:11,fullSize:21}},{family:"Kalam",label:"Kalam",fontSizePt:15,lineHeight:1.25,maxLines:{default:12,fullSize:23}},{family:"Reenie Beanie",label:"Reenie Beanie",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}},{family:"Great Vibes",label:"Great Vibes",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}}],ks={width:5,displayArea:{default:{x:.42,y:3.43,width:4.16,height:3.15},fullSize:{x:.42,y:.42,width:4.16,height:6.16}}};let nt=class extends vt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.displayType="default",this.scale=1,this.logicalSize={width:0,height:0},this.areaPosition={left:0,top:0},this.areaSize={width:0,height:0},this.imgLoading=!1,this.backgroundImage=void 0,this.resizeObserver=void 0,this.dpi=0,this.fontConfig=$n.find(n=>n.family==="Arial"),this.processedMessage=""}async handleBackgroundImageUrlChange(){this.imgLoading=!0,await this.appendBackgroundImageToCanvas(this.backgroundImageUrl??"",()=>{this.imgLoading=!1}),this.updateTextAreaPosition()}handleBackgroundImageChange(){if(!this.backgroundImage)return;const n=this.canvas.getContext("2d");if(!n)throw new Error("Could not get canvas context");n.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height)}handleProcessedMessageChange(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.emit("pbo-type-canvas-processed",{detail:{message:this.processedMessage}})},300)}inchToPixel(n,t){return n*t}ptToInch(n){return n/72}firstUpdated(){this.resizeObserver=new ResizeObserver(()=>{this.updateTextAreaPosition()}),this.resizeObserver.observe(this.canvasContainer)}updated(n){var t,e,i;if(n.has("message")||n.has("font")||n.has("color")||n.has("alignment")||n.has("areaPosition")||n.has("areaSize")||n.has("displayType")){if(!this.backgroundImage||this.areaSize.width===0||this.areaSize.height===0)return;const s=this.canvas.getContext("2d");if(!s)return;s.clearRect(0,0,this.logicalSize.width,this.logicalSize.height),s.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.fontConfig=$n.find(r=>r.family===this.font)||$n[0],this.wrapText({ctx:s,message:this.message,areaPosition:this.areaPosition,areaSize:this.areaSize,maxLineSize:((t=this.fontConfig)==null?void 0:t.maxLines[this.displayType])||12,alignment:this.alignment,fontSizePt:((e=this.fontConfig)==null?void 0:e.fontSizePt)||15.9,lineHeight:((i=this.fontConfig)==null?void 0:i.lineHeight)||1.185,verticalAlignment:this.displayType==="fullSize"?"middle":"top"})}}getMaxStringLength(n,t,e){let i=0;for(let s=1;s<=t.length;s++){const r=t.substring(0,s);if(n.measureText(r).width>e)break;i=s}return i}wrapText({ctx:n,message:t,areaPosition:e,areaSize:i,maxLineSize:s,alignment:r,lineHeight:o=1.185,fontSizePt:a,verticalAlignment:l}){if(!n||!t||!e||!i)return;const h=i.height/s/1.2,d=this.inchToPixel(this.ptToInch(a),this.dpi),u=t.split(`
3145
+ `);let p=[];n.font=`${h}px ${this.font}`,u.forEach(f=>{const b=f.split(" ");let m="";for(let y=0;y<b.length;y++)if(n.measureText(b[y]).width>i.width){const T=this.getMaxStringLength(n,b[y],i.width),k=b[y];y+1<b.length?(b[y]=k.substring(0,T),b[y+1]=k.substring(T,k.length)+b[y+1]):(b[y]=k.substring(0,T),b.push(k.substring(T,k.length)))}for(let y=0;y<b.length;y++){let w=m+b[y]+" ";n.measureText(w).width>i.width&&y>0?(p.push(m),m=b[y]+" "):m=w}p.push(m)}),this.processedMessage=p.slice(0,s).join(`
3146
+ `);let g=this.areaPosition.left;if(r==="center"&&(g+=this.areaSize.width/2),r==="right"&&(g+=this.areaSize.width),l==="top"){n.textBaseline="top";for(let f=0;f<s&&f<p.length;f++){const b=p[f];n.fillStyle=this.color,n.textAlign=r,n.fillText(b,g,this.areaPosition.top+f*d*o)}}if(l==="middle"){n.textBaseline="middle";for(let f=0;f<s&&f<p.length;f++){const b=p[f],m=Math.min(p.length,s),y=(f+1-m/2-.5)*d*o;n.fillStyle=this.color,n.textAlign=r,n.fillText(b,g,y+this.areaPosition.top+this.areaSize.height/2)}}}updateTextAreaPosition(){if(!this.canvas||!this.backgroundImage)return;const n=window.devicePixelRatio||1,t=this.canvasContainer.clientWidth;this.scale=t/this.backgroundImage.width,this.logicalSize={width:this.canvasContainer.clientWidth,height:this.backgroundImage.height*this.scale},this.canvas.width=this.logicalSize.width*n,this.canvas.height=this.logicalSize.height*n,this.canvas.style.width=`${this.logicalSize.width}px`,this.canvas.style.height=`${this.logicalSize.height}px`;const e=this.canvas.getContext("2d");e&&(e.setTransform(1,0,0,1,0,0),e.scale(n,n),e.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.dpi=this.logicalSize.width/ks.width,this.areaPosition={left:this.inchToPixel(ks.displayArea[this.displayType].x,this.dpi),top:this.inchToPixel(ks.displayArea[this.displayType].y,this.dpi)},this.areaSize={width:this.inchToPixel(ks.displayArea[this.displayType].width,this.dpi),height:this.inchToPixel(ks.displayArea[this.displayType].height,this.dpi)})}async appendBackgroundImageToCanvas(n,t){return new Promise((e,i)=>{const s=new Image;s.onerror=()=>{i(new Error("Failed to load image"))},s.onload=()=>{this.backgroundImage=s,t&&t(),e()},n!==""&&(s.src=n)})}render(){return F`
3147
+ <div
3148
+ class="${fe({"type-canvas-container":!0,"image-loading":this.imgLoading})}
3149
+ "
3150
+ >
3151
+ <canvas class="base-canvas"></canvas>
3152
+ <pbo-image skeleton></pbo-image>
3153
+ </div>
3154
+ `}};nt.styles=[bt,gg];yt([C({attribute:"background-url"})],nt.prototype,"backgroundImageUrl",2);yt([C()],nt.prototype,"message",2);yt([C()],nt.prototype,"font",2);yt([C()],nt.prototype,"color",2);yt([C()],nt.prototype,"alignment",2);yt([C({attribute:"display-type"})],nt.prototype,"displayType",2);yt([B(".base-canvas")],nt.prototype,"canvas",2);yt([B(".type-canvas-container")],nt.prototype,"canvasContainer",2);yt([I()],nt.prototype,"scale",2);yt([I()],nt.prototype,"logicalSize",2);yt([I()],nt.prototype,"areaPosition",2);yt([I()],nt.prototype,"areaSize",2);yt([I()],nt.prototype,"imgLoading",2);yt([I()],nt.prototype,"backgroundImage",2);yt([I()],nt.prototype,"resizeObserver",2);yt([I()],nt.prototype,"dpi",2);yt([I()],nt.prototype,"fontConfig",2);yt([I()],nt.prototype,"processedMessage",2);yt([G("backgroundImageUrl")],nt.prototype,"handleBackgroundImageUrlChange",1);yt([G("backgroundImage")],nt.prototype,"handleBackgroundImageChange",1);yt([G("processedMessage")],nt.prototype,"handleProcessedMessageChange",1);nt=yt([mt("pbo-type-canvas")],nt);const bg=it`
3112
3155
  :host {
3113
3156
  display: block;
3157
+ height: 100%;
3158
+ width: 100%;
3114
3159
  }
3115
- .fake-loading {
3116
- display: flex;
3117
- align-items: center;
3118
- gap: 8px;
3160
+
3161
+ .zoomed-preview {
3162
+ padding: 24px;
3163
+ height: 100%;
3164
+ width: 100%;
3119
3165
  }
3120
3166
 
3121
- pbo-spinner {
3122
- font-size: 24px;
3123
- display: flex;
3124
- align-items: center;
3125
- line-height: 1;
3167
+ .panel {
3168
+ width: 100%;
3169
+ height: 100%;
3126
3170
  }
3127
3171
 
3128
- .fake-loading span {
3129
- font-size: 18.75px;
3130
- line-height: 1;
3131
- display: flex;
3132
- align-items: center;
3172
+ ::slotted(img) {
3173
+ width: 100%;
3174
+ max-height: 100%;
3175
+ object-fit: contain;
3133
3176
  }
3134
- `;var gg=Object.defineProperty,fg=Object.getOwnPropertyDescriptor,tr=(n,t,e,i)=>{for(var s=i>1?void 0:i?fg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&gg(t,e,s),s};let Ne=class extends vt{constructor(){super(...arguments),this.loading=!1,this.loadingTime=0,this.loadingPattern="random",this.progress=0,this.loadingInterval=null,this.startTime=0,this.PHASES={QUICK:{target:90,duration:15e3},SLOW:{target:98,duration:3e4},FINAL:{target:100,duration:1e3}}}startLoading(){this.startTime=Date.now(),this.progress=0,this.loadingInterval&&clearInterval(this.loadingInterval),this.loadingInterval=window.setInterval(()=>{const t=Date.now()-this.startTime;if(this.progress<this.PHASES.QUICK.target)this.progress=Math.min(this.PHASES.QUICK.target,t/this.PHASES.QUICK.duration*this.PHASES.QUICK.target);else if(this.progress<this.PHASES.SLOW.target){const e=(t-this.PHASES.QUICK.duration)/this.PHASES.SLOW.duration;this.progress=Math.min(this.PHASES.SLOW.target,this.PHASES.QUICK.target+e*(this.PHASES.SLOW.target-this.PHASES.QUICK.target))}this.requestUpdate()},50)}completeLoading(){this.loadingInterval&&clearInterval(this.loadingInterval);const t=this.progress,e=Date.now();this.loadingInterval=window.setInterval(()=>{const i=Date.now()-e,s=Math.min(100,t+i/this.PHASES.FINAL.duration*(100-t));this.progress=s,s>=100&&this.stopLoading(),this.requestUpdate()},16)}stopLoading(){this.loadingInterval&&(clearInterval(this.loadingInterval),this.loadingInterval=null)}updated(t){t.has("loading")&&(this.loading?this.startLoading():this.completeLoading())}disconnectedCallback(){super.disconnectedCallback(),this.stopLoading()}render(){return F`<div
3135
- class="${fe({"fake-loading":!0,"fake-loading--linear":this.loadingPattern==="linear","fake-loading--random":this.loadingPattern==="random","fake-loading--loading":!0})}"
3136
- >
3137
- <pbo-spinner
3138
- style="${ge({"--track-width":"3px","--indicator-color":"black"})}"
3139
- ></pbo-spinner>
3140
- <span>${Math.round(this.progress)}%</span>
3141
- </div>`}};Ne.styles=[bt,pg];Ne.dependencies={"pbo-spinner":as};tr([C({type:Boolean,reflect:!0})],Ne.prototype,"loading",2);tr([C({type:Number})],Ne.prototype,"loadingTime",2);tr([C()],Ne.prototype,"loadingPattern",2);tr([I()],Ne.prototype,"progress",2);Ne=tr([mt("pbo-fake-loading")],Ne);var mg=Object.defineProperty,bg=Object.getOwnPropertyDescriptor,st=(n,t,e,i)=>{for(var s=i>1?void 0:i?bg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&mg(t,e,s),s};let X=class extends vt{constructor(){super(...arguments),this.card=null,this.submitHandwrittenForm=async t=>{console.warn("submitHandwrittenForm not implemented",t)},this.getProcessedImg=async t=>(console.warn("getProcessedImg not implemented",t.name),{masked_img:"",uid:""}),this.onClose=()=>{console.warn("onClose not implemented")},this.isSubmitLoading=!1,this.ctaPrimaryLabel="Add to Cart",this.isSubmitDisabled=!1,this.isProcessingError=!1,this.submitError="",this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.handwrittenDimensions={top:null,left:null,width:null,height:null,cardHeight:null,cardWidth:null}}showPicker(){this.imageInput.showPicker()}setButtonsDisabled(t){this.uploadButton&&this.saveButton&&this.reuploadButton&&(this.uploadButton.disabled=t,this.saveButton.disabled=t,this.reuploadButton.disabled=t)}setButtonsError(t){this.uploadButton&&this.saveButton&&(this.uploadButton.variant=t?"danger":"primary",this.saveButton.variant=t?"danger":"primary",this.uploadButton.value=t?"Error uploading image":"Upload Handwritten Image")}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleProcessingErrorChange(){this.setButtonsError(this.isProcessingError)}handleSourceImgChange(t,e){this.processedImg={uid:null,masked_img:null},this.emit("pbo-handwritten-form-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){this.emit("pbo-handwritten-form-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing),this.emit("pbo-image-processing",{detail:{isLoading:this.isImageProcessing}})}get formData(){var s,r,o,a,l;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={barcode:((s=this.card)==null?void 0:s.barcode)||"",pboCardId:((r=this.card)==null?void 0:r.pboId)||"Unknown",productId:(o=this.card)==null?void 0:o.productId,sku:(a=this.card)==null?void 0:a.sku,variantId:(l=this.card)==null?void 0:l.variantId,pred_image_uid:this.processedImg.uid||"",position_x:this.handwrittenDimensions.left*e,position_y:this.handwrittenDimensions.top*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return hc(i)}setDimensions(t){this.handwrittenDimensions=t}handleProcessedImgChange(){this.processedImg.masked_img&&this.emit("pbo-handwritten-form-change",{detail:{isLoading:!1,processedFileUrl:this.processedImg.masked_img}})}async handleFileChange(t){var i,s;this.sourceImg===null&&this.processedImg.masked_img===null?this.emit("pbo_edit_handwritten_form",{detail:{action:"upload"}}):this.emit("pbo_edit_handwritten_form",{detail:{action:"reupload"}}),this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.isProcessingError=!1,this.submitError="";const e=(s=(i=t.target)==null?void 0:i.files)==null?void 0:s[0];if(e!=null){this.sourceImg=e,this.isImageProcessing=!0,this.updateComplete.then(()=>{this.uploadButton.scrollIntoView(!0)});try{const r=await this.getProcessedImg(e);this.processedImg={masked_img:`data:image/png;base64,${r.masked_img}`,uid:r.uid}}catch(r){throw this.isProcessingError=!0,r}finally{this.isImageProcessing=!1}}}async handleSubmit(t){t.preventDefault(),this.isSubmitLoading=!0,this.isSubmitDisabled=!0,this.submitError="";try{await this.submitHandwrittenForm(this.formData),this.onClose(),this.emit("pbo-handwritten-form-submitted")}catch(e){throw this.submitError="Something went wrong. Please try again.",e}finally{this.isSubmitLoading=!1,this.isSubmitDisabled=!1}}render(){return F`
3142
- <form
3143
- name="handwritten-form"
3144
- class="handwritten-form"
3145
- @submit=${this.handleSubmit}
3146
- aria-busy=${this.isImageProcessing||this.isSubmitLoading?"true":"false"}
3147
- >
3148
- <div role="status" aria-live="polite" aria-atomic="true" class="visually-hidden">
3149
- ${this.isImageProcessing?"Uploading image, please wait.":""}
3150
- ${this.isProcessingError&&!this.isImageProcessing?"Image upload failed. Please try again.":""}
3151
- </div>
3152
- <div class="handwritten-tutorials" aria-label="Instructions">
3153
- <ol class="tutorial-steps">
3154
- <li>
3155
- <strong class="step-title">Step 1</strong>
3156
- <span class="step-description">Write message &amp; signature on white paper</span>
3157
- </li>
3158
- <li>
3159
- <strong class="step-title">Step 2</strong>
3160
- <span class="step-description">
3161
- Take a well-lit photo on your phone, then crop and save it
3162
- </span>
3163
- </li>
3164
- <li>
3165
- <strong class="step-title">Step 3</strong>
3166
- <span class="step-description">Crop photo tightly around text, then upload</span>
3167
- </li>
3168
- <li>
3169
- <strong class="step-title">Step 4</strong>
3170
- <span class="step-description">Review preview &amp; adjust if needed</span>
3171
- </li>
3172
- </ol>
3173
- </div>
3174
3177
 
3175
- <label for="handwritten-file-input" class="visually-hidden">
3176
- Handwritten image file (.png, .jpeg, .jpg)
3177
- </label>
3178
- <input
3179
- id="handwritten-file-input"
3180
- class="pixel-input"
3181
- type="file"
3182
- accept=".png, .jpeg, .jpg"
3183
- @change=${this.handleFileChange}
3184
- required
3185
- />
3178
+ .close-button {
3179
+ position: absolute;
3180
+ right: 1em;
3181
+ top: 1em;
3182
+ cursor: pointer;
3183
+ background: none;
3184
+ border: none;
3185
+ padding: 0;
3186
+ }
3186
3187
 
3187
- <!-- Fake loading -->
3188
- ${this.isImageProcessing?F`<div class="fake-loading-container">
3189
- <pbo-fake-loading ?loading=${this.isImageProcessing}></pbo-fake-loading>
3190
- </div>`:Z}
3188
+ .close-button svg {
3189
+ height: 32px;
3190
+ width: 32px;
3191
+ fill: #595959;
3192
+ display: block;
3193
+ }
3191
3194
 
3192
- <div class="buttons-container">
3193
- <!-- Upload button -->
3194
- <pbo-button
3195
- exportparts="base:cta-button-base, label:cta-button-label"
3196
- name="upload"
3197
- class="upload-button"
3198
- size="medium"
3199
- variant="primary"
3200
- @click=${this.showPicker}
3201
- style=${ge({display:this.processedImg.masked_img?"none":"block"})}
3202
- >
3203
- ${this.isProcessingError?"Please Try Again":""}
3204
- ${this.isImageProcessing?"Uploading":""}
3205
- ${!this.isProcessingError&&!this.isImageProcessing?"Upload Handwritten Image":""}
3206
- </pbo-button>
3195
+ .close-button:hover svg {
3196
+ scale: 1.1;
3197
+ }
3207
3198
 
3208
- <!-- Save button -->
3209
- <pbo-button
3210
- exportparts="base:cta-button-base, label:cta-button-label"
3211
- name="save"
3212
- type="submit"
3213
- variant=${this.submitError?"danger":"primary"}
3214
- class="submit-cta"
3215
- style=${ge({display:this.sourceImg&&this.processedImg.masked_img&&!this.isImageProcessing?"block":"none"})}
3216
- >
3217
- ${this.ctaPrimaryLabel}
3218
- </pbo-button>
3219
- <div class="submit-error" role="alert" aria-live="assertive">${this.submitError}</div>
3220
- <!-- Reupload button -->
3221
- <pbo-button
3222
- exportparts="base:cta-link-button-base, label:cta-link-button-label"
3223
- name="reupload"
3224
- variant="text"
3225
- class="submit-cta reupload-cta"
3226
- @click=${this.showPicker}
3227
- size="small"
3228
- style=${ge({display:this.sourceImg&&this.processedImg.masked_img?"block":"none","--pbo-text-color":"black"})}
3199
+ .close-button:focus {
3200
+ outline: none;
3201
+ }
3202
+
3203
+ .close-button:focus-visible {
3204
+ outline: 2px solid #fff;
3205
+ outline-offset: 2px;
3206
+ border-radius: 50%;
3207
+ }
3208
+ `;var vg=Object.defineProperty,yg=Object.getOwnPropertyDescriptor,Wi=(n,t,e,i)=>{for(var s=i>1?void 0:i?yg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&vg(t,e,s),s};let Ne=class extends vt{constructor(){super(...arguments),this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.cardUrl="",this.handwrittenPreviewProps={isLoading:!1,url:""},this.pinchToCloseDisabled=!1,this.distance=null,this.handleTouchMove=n=>{if(this.pinchToCloseDisabled)return;n.preventDefault();const t=n.touches[0],e=n.touches[1];if(!(t&&!e)&&t&&e){const i={x:t.clientX,y:t.clientY},s={x:e.clientX,y:e.clientY},r=dc(i,s);if(this.distance===null){this.distance=r;return}this.distance-r>10&&(this.distance=null,this.close())}},this.handleTouchEnd=()=>{this.pinchToCloseDisabled||(this.distance=null)}}render(){return F`
3209
+ <div class="panel" @touchmove=${this.handleTouchMove} @touchend=${this.handleTouchEnd}>
3210
+ <div class="zoomed-preview">
3211
+ <div
3212
+ style=${ge({display:"flex","justify-content":"center",flexDirection:"column",height:"100%"})}
3229
3213
  >
3230
- reupload image
3231
- </pbo-button>
3214
+ <slot part="base"></slot>
3215
+ </div>
3232
3216
  </div>
3233
- </form>
3234
- `}};X.styles=[bt,ug];X.dependencies={"pbo-button":at,"pbo-fake-loading":Ne};st([C()],X.prototype,"card",2);st([C()],X.prototype,"submitHandwrittenForm",2);st([C()],X.prototype,"getProcessedImg",2);st([C({type:Function})],X.prototype,"onClose",2);st([C({type:Boolean,reflect:!0,attribute:"loading"})],X.prototype,"isSubmitLoading",2);st([C({type:String,attribute:"cta-primary-label"})],X.prototype,"ctaPrimaryLabel",2);st([C({type:Boolean,reflect:!0,attribute:"disabled"})],X.prototype,"isSubmitDisabled",2);st([B(".pixel-input")],X.prototype,"imageInput",2);st([B(".handwritten-form")],X.prototype,"handwrittenForm",2);st([B("pbo-button[name='upload']")],X.prototype,"uploadButton",2);st([B("pbo-button[name='save']")],X.prototype,"saveButton",2);st([B("pbo-button[name='reupload']")],X.prototype,"reuploadButton",2);st([I()],X.prototype,"isProcessingError",2);st([I()],X.prototype,"submitError",2);st([I()],X.prototype,"isImageProcessing",2);st([I()],X.prototype,"sourceImg",2);st([I()],X.prototype,"processedImg",2);st([I()],X.prototype,"handwrittenDimensions",2);st([G("isSubmitLoading")],X.prototype,"handleSubmitLoadingChange",1);st([G("isSubmitDisabled")],X.prototype,"handleSubmitDisabledChange",1);st([G("isProcessingError")],X.prototype,"handleProcessingErrorChange",1);st([G("sourceImg")],X.prototype,"handleSourceImgChange",1);st([G("processedFileUrl")],X.prototype,"handleProcessImageChange",1);st([G("isImageProcessing")],X.prototype,"handleImageProcessingChange",1);st([G("processedImg")],X.prototype,"handleProcessedImgChange",1);X=st([mt("pbo-handwritten-form")],X);const iv=X,vg=it`
3217
+
3218
+ <button class="close-button" type="button" aria-label="Close preview" @click=${this.close}>
3219
+ <svg
3220
+ aria-hidden="true"
3221
+ xmlns="http://www.w3.org/2000/svg"
3222
+ height="24px"
3223
+ viewBox="0 -960 960 960"
3224
+ width="24px"
3225
+ fill="#F3F3F3"
3226
+ >
3227
+ <circle cx="480" cy="-480" r="390" fill="#FFFFFF" />
3228
+ <path
3229
+ d="m336-280 144-144 144 144 56-56-144-144 144-144-56-56-144 144-144-144-56 56 144 144-144 144 56 56ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"
3230
+ />
3231
+ </svg>
3232
+ </button>
3233
+ </div>
3234
+ `}};Ne.styles=[bt,bg];Wi([C()],Ne.prototype,"formData",2);Wi([C()],Ne.prototype,"cardUrl",2);Wi([C()],Ne.prototype,"close",2);Wi([C()],Ne.prototype,"handwrittenPreviewProps",2);Wi([C({type:Boolean,reflect:!0,attribute:"pinch-to-close-disabled"})],Ne.prototype,"pinchToCloseDisabled",2);Wi([I()],Ne.prototype,"distance",2);Ne=Wi([mt("pbo-zoomed-preview")],Ne);const _g=it`
3235
3235
  :host {
3236
3236
  display: block;
3237
3237
  width: 100%;
@@ -3259,9 +3259,9 @@
3259
3259
  display: block;
3260
3260
  object-fit: contain;
3261
3261
  }
3262
- `;function v(n,t,e){return(t=(function(i){var s=(function(r,o){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var l=a.call(r,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(r)})(i,"string");return typeof s=="symbol"?s:s+""})(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Xa(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter((function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable}))),e.push.apply(e,i)}return e}function y(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Xa(Object(e),!0).forEach((function(i){v(n,i,e[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Xa(Object(e)).forEach((function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))}))}return n}function ot(n,t){if(n==null)return{};var e,i,s=(function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l})(n,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);for(i=0;i<r.length;i++)e=r[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(n,e)&&(s[e]=n[e])}return s}function Ge(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}class qa{constructor(){v(this,"browserShadowBlurConstant",1),v(this,"DPI",96),v(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),v(this,"perfLimitSizeTotal",2097152),v(this,"maxCacheSideLimit",4096),v(this,"minCacheSideLimit",256),v(this,"disableStyleCopyPaste",!1),v(this,"enableGLFiltering",!0),v(this,"textureSize",4096),v(this,"forceGLPutImageData",!1),v(this,"cachesBoundsOfCurve",!1),v(this,"fontPaths",{}),v(this,"NUM_FRACTION_DIGITS",4)}}const W=new class extends qa{constructor(n){super(),this.configure(n)}configure(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,n)}addFonts(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=y(y({},this.fontPaths),n)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach((n=>{delete this.fontPaths[n]}))}clearFonts(){this.fontPaths={}}restoreDefaults(n){const t=new qa,e=(n==null?void 0:n.reduce(((i,s)=>(i[s]=t[s],i)),{}))||t;this.configure(e)}},wi=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return console[n]("fabric",...e)};class ze extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class yg extends ze{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class _g{}class xg extends _g{testPrecision(t,e){const i="precision ".concat(e,` float;
3263
- void main(){}`),s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,i),t.compileShader(s),!!t.getShaderParameter(s,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find((i=>this.testPrecision(e,i))),e.getExtension("WEBGL_lose_context").loseContext(),wi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const wg={};let Ka;const Ue=()=>Ka||(Ka={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new xg,dispose(){},copyPasteData:wg}),ds=()=>Ue().document,un=()=>Ue().window,mc=()=>{var n;return Math.max((n=W.devicePixelRatio)!==null&&n!==void 0?n:un().devicePixelRatio,1)},$s=new class{constructor(){v(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(n){let{fontFamily:t,fontStyle:e,fontWeight:i}=n;t=t.toLowerCase();const s=this.charWidthsCache;s.has(t)||s.set(t,new Map);const r=s.get(t),o="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return r.has(o)||r.set(o,new Map),r.get(o)}clearFontCache(n){n?this.charWidthsCache.delete((n||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(n){const{perfLimitSizeTotal:t}=W,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},lo="6.9.1";function Lr(){}const er=Math.PI/2,Nr=2*Math.PI,Fo=Math.PI/180,Zt=Object.freeze([1,0,0,1,0,0]),jo=16,ui=.4477152502,V="center",Y="left",se="top",co="bottom",wt="right",re="none",$o=/\r?\n/,bc="moving",pn="scaling",vc="rotating",Ro="rotate",yc="skewing",Gs="resizing",Cg="modifyPoly",Sg="modifyPath",Ur="changed",gn="scale",ce="scaleX",_e="scaleY",us="skewX",ps="skewY",Mt="fill",ne="stroke",Wr="modified",Xi="json",Rn="svg",D=new class{constructor(){this[Xi]=new Map,this[Rn]=new Map}has(n){return this[Xi].has(n)}getClass(n){const t=this[Xi].get(n);if(!t)throw new ze("No class registered for ".concat(n));return t}setClass(n,t){t?this[Xi].set(t,n):(this[Xi].set(n.type,n),this[Xi].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[Rn].get(n)}setSVGClass(n,t){this[Rn].set(t??n.type.toLowerCase(),n)}},Gr=new class extends Array{remove(n){const t=this.indexOf(n);t>-1&&this.splice(t,1)}cancelAll(){const n=this.splice(0);return n.forEach((t=>t.abort())),n}cancelByCanvas(n){if(!n)return[];const t=this.filter((e=>{var i;return e.target===n||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===n}));return t.forEach((e=>e.abort())),t}cancelByTarget(n){if(!n)return[];const t=this.filter((e=>e.target===n));return t.forEach((e=>e.abort())),t}};class Tg{constructor(){v(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach((i=>{let[s,r]=i;this.on(s,r)})),()=>this.off(t);if(e){const i=t;return this.__eventListeners[i]||(this.__eventListeners[i]=[]),this.__eventListeners[i].push(e),()=>this.off(i,e)}return()=>!1}once(t,e){if(typeof t=="object"){const i=[];return Object.entries(t).forEach((s=>{let[r,o]=s;i.push(this.once(r,o))})),()=>i.forEach((s=>s()))}if(e){const i=this.on(t,(function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];e.call(this,...r),i()}));return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],s=i.indexOf(e);s>-1&&i.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const i in this.__eventListeners)this._removeEventListener(i);else typeof t=="object"?Object.entries(t).forEach((i=>{let[s,r]=i;this._removeEventListener(s,r)})):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(s)for(let r=0;r<s.length;r++)s[r].call(this,e||{})}}const Zi=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},ni=n=>{if(n===0)return 1;switch(Math.abs(n)/er){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},oi=n=>{if(n===0)return 0;const t=n/er,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class w{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new w(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new w(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new w(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new w(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new w(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new w(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new w(this.x/t.x,this.y/t.y)}scalarDivide(t){return new w(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new w(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new w(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new w(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new w(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bo;const i=oi(t),s=ni(t),r=this.subtract(e);return new w(r.x*s-r.y*i,r.x*i+r.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new w(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Bo=new w(0,0),Fr=n=>!!n&&Array.isArray(n._objects);function _c(n){class t extends n{constructor(){super(...arguments),v(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];const o=this._objects.push(...s);return s.forEach((a=>this._onObjectAdded(a))),o}insertAt(i){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return this._objects.splice(i,0,...r),r.forEach((a=>this._onObjectAdded(a))),this._objects.length}remove(){const i=this._objects,s=[];for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return o.forEach((l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),s.push(l),this._onObjectRemoved(l))})),s}forEachObject(i){this.getObjects().forEach(((s,r,o)=>i(s,r,o)))}getObjects(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];return s.length===0?[...this._objects]:this._objects.filter((o=>o.isType(...s)))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,s){return!!this._objects.includes(i)||!!s&&this._objects.some((r=>r instanceof t&&r.contains(i,!0)))}complexity(){return this._objects.reduce(((i,s)=>i+=s.complexity?s.complexity():0),0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(Zi(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(Zi(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==0){const o=this.findNewLowerIndex(i,r,s);return Zi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==this._objects.length-1){const o=this.findNewUpperIndex(i,r,s);return Zi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(Zi(this._objects,i),this._objects.splice(s,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,s,r){let o;if(r){o=s;for(let a=s-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(i,s,r){let o;if(r){o=s;for(let a=s+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(i){let{left:s,top:r,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new w(s,r),d=h.add(new w(o,a));for(let u=this._objects.length-1;u>=0;u--){const p=this._objects[u];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,d)||p.isContainedWithinRect(h,d)||l&&p.containsPoint(h)||l&&p.containsPoint(d))&&c.push(p)}return c}}return t}class xc extends Tg{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function jr(n){return un().requestAnimationFrame(n)}function Eg(n){return un().cancelAnimationFrame(n)}let kg=0;const Ci=()=>kg++,ai=()=>{const n=ds().createElement("canvas");if(!n||n.getContext===void 0)throw new ze("Failed to create `canvas` element");return n},Og=()=>ds().createElement("img"),xe=n=>{const t=ai();return t.width=n.width,t.height=n.height,t},wc=(n,t,e)=>n.toDataURL("image/".concat(t),e),Cc=(n,t,e)=>new Promise(((i,s)=>{n.toBlob(i,"image/".concat(t),e)})),Ct=n=>n*Fo,li=n=>n/Fo,Pg=n=>n.every(((t,e)=>t===Zt[e])),te=(n,t,e)=>new w(n).transform(t,e),Ee=n=>{const t=1/(n[0]*n[3]-n[1]*n[2]),e=[t*n[3],-t*n[1],-t*n[2],t*n[0],0,0],{x:i,y:s}=new w(n[4],n[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},Bt=(n,t,e)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],e?0:n[0]*t[4]+n[2]*t[5]+n[4],e?0:n[1]*t[4]+n[3]*t[5]+n[5]],zo=(n,t)=>n.reduceRight(((e,i)=>i&&e?Bt(i,e,t):i||e),void 0)||Zt.concat(),Sc=n=>{let[t,e]=n;return Math.atan2(e,t)},Yr=n=>{const t=Sc(n),e=Math.pow(n[0],2)+Math.pow(n[1],2),i=Math.sqrt(e),s=(n[0]*n[3]-n[2]*n[1])/i,r=Math.atan2(n[0]*n[2]+n[1]*n[3],e);return{angle:li(t),scaleX:i,scaleY:s,skewX:li(r),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},ir=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function gs(){let{angle:n=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=Ct(n),s=ni(i),r=oi(i);return[s,r,-r,s,t?t-(s*t-r*e):0,e?e-(r*t+s*e):0]}const Ho=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},Tc=n=>Math.tan(Ct(n)),Ec=n=>[1,0,Tc(n),1,0,0],kc=n=>[1,Tc(n),0,1,0,0],fn=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:r=0,skewY:o=0}=n,a=Ho(i?-t:t,s?-e:e);return r&&(a=Bt(a,Ec(r),!0)),o&&(a=Bt(a,kc(o),!0)),a},Dg=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let s=ir(t,e);i&&(s=Bt(s,gs({angle:i})));const r=fn(n);return Pg(r)||(s=Bt(s,r)),s},$r=function(n){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((function(i,s){if(t&&t.aborted)return s(new yg("loadImage"));const r=Og();let o;t&&(o=function(l){r.src="",s(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){r.onload=r.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(r)};n?(r.onload=a,r.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new ze("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=n):a()}))},Ys=function(n){let{signal:t,reviver:e=Lr}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((i,s)=>{const r=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(n.map((o=>D.getClass(o.type).fromObject(o,{signal:t}).then((a=>(e(o,a),r.push(a),a)))))).then(i).catch((o=>{r.forEach((a=>{a.dispose&&a.dispose()})),s(o)})).finally((()=>{t&&t.removeEventListener("abort",s)}))}))},mn=function(n){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((e,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0});const r=Object.values(n).map((a=>a&&a.type&&D.has(a.type)?Ys([a],{signal:t}).then((l=>{let[c]=l;return s.push(c),c})):a)),o=Object.keys(n);Promise.all(r).then((a=>a.reduce(((l,c,h)=>(l[o[h]]=c,l)),{}))).then(e).catch((a=>{s.forEach((l=>{l.dispose&&l.dispose()})),i(a)})).finally((()=>{t&&t.removeEventListener("abort",i)}))}))},fs=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce(((t,e)=>(e in n&&(t[e]=n[e]),t)),{})},Vo=(n,t)=>Object.keys(n).reduce(((e,i)=>(t(n[i],i,n)&&(e[i]=n[i]),e)),{}),et=(n,t)=>parseFloat(Number(n).toFixed(t)),Xs=n=>"matrix("+n.map((t=>et(t,W.NUM_FRACTION_DIGITS))).join(" ")+")",ve=n=>!!n&&n.toLive!==void 0,Za=n=>!!n&&typeof n.toObject=="function",Ja=n=>!!n&&n.offsetX!==void 0&&"source"in n,Ai=n=>!!n&&"multiSelectionStacking"in n;function Oc(n){const t=n&&Te(n);let e=0,i=0;if(!n||!t)return{left:e,top:i};let s=n;const r=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===t?(e=o.scrollLeft||r.scrollLeft||0,i=o.scrollTop||r.scrollTop||0):(e+=s.scrollLeft||0,i+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:i}}const Te=n=>n.ownerDocument||null,Pc=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Dc=function(n,t,e){let{width:i,height:s}=e,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;n.width=i,n.height=s,r>1&&(n.setAttribute("width",(i*r).toString()),n.setAttribute("height",(s*r).toString()),t.scale(r,r))},ho=(n,t)=>{let{width:e,height:i}=t;e&&(n.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(n.style.height=typeof i=="number"?"".concat(i,"px"):i)};function Qa(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=re,n}class Ac{constructor(t){v(this,"_originalCanvasStyle",void 0),v(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&i.getContext!==void 0?t:t&&ds().getElementById(t)||ai();var i;if(e.hasAttribute("data-fabric"))throw new ze("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:i}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(i)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:s}=this.lower;Dc(i,s,t,e)}setCSSDimensions(t){ho(this.lower.el,t)}calcOffset(){return(function(t){var e;const i=t&&Te(t),s={left:0,top:0};if(!i)return s;const r=((e=Pc(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(r.borderLeftWidth,10)||0,s.top+=parseInt(r.borderTopWidth,10)||0,s.left+=parseInt(r.paddingLeft,10)||0,s.top+=parseInt(r.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=Oc(t);return{left:o.left+l.left-(a.clientLeft||0)+s.left,top:o.top+l.top-(a.clientTop||0)+s.top}})(this.lower.el)}dispose(){Ue().dispose(this.lower.el),delete this.lower}}const Ag={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Zt]},Mg=["objects"];class sr extends _c(xc){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return sr.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new Ac(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),r}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(wi("warn",`Canvas is trying to add an object that belongs to a different canvas.
3264
- Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?mc():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:i=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const s=y({width:this.width,height:this.height},t);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}i||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const i=t,s=[...this.viewportTransform],r=te(t,Ee(s));s[0]=e,s[3]=e;const o=te(r,s);s[4]+=i.x-o.x,s[5]+=i.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new w(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new w(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=jr((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Ee(this.viewportTransform),s=te({x:0,y:0},i),r=te({x:t,y:e},i),o=s.min(r),a=s.max(r);return this.vptCoords={tl:o,tr:new w(a.x,o.y),bl:new w(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Eg(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,s)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const i=this.viewportTransform;t.save(),t.transform(...i),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let i=0,s=e.length;i<s;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],s=this["".concat(e,"Image")],r=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!s)return;const a=ve(i);if(i){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=a?i.toLive(t):i,o&&t.transform(...r),a){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const l=i.gradientTransform||i.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...r),s.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new w(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new w(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new w(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new w(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new w(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return te(this.getCenterPoint(),Ee(this.viewportTransform))}_centerObject(t,e){t.setXY(e,V,V),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const i=this.clipPath,s=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return y(y(y({version:lo},fs(this,e)),{},{objects:this._objects.filter((r=>!r.excludeFromExport)).map((r=>this._toObject(r,t,e)))},this.__serializeBgOverlay(t,e)),s?{clipPath:s}:null)}_toObject(t,e,i){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const r=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!s),r}__serializeBgOverlay(t,e){const i={},s=this.backgroundImage,r=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return ve(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),ve(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),s&&!s.excludeFromExport&&(i.backgroundImage=this._toObject(s,t,e)),r&&!r.excludeFromExport&&(i.overlayImage=this._toObject(r,t,e)),i}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
3262
+ `;function v(n,t,e){return(t=(function(i){var s=(function(r,o){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var l=a.call(r,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(r)})(i,"string");return typeof s=="symbol"?s:s+""})(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Xa(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter((function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable}))),e.push.apply(e,i)}return e}function _(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Xa(Object(e),!0).forEach((function(i){v(n,i,e[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Xa(Object(e)).forEach((function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))}))}return n}function ot(n,t){if(n==null)return{};var e,i,s=(function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l})(n,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);for(i=0;i<r.length;i++)e=r[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(n,e)&&(s[e]=n[e])}return s}function Ge(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}class qa{constructor(){v(this,"browserShadowBlurConstant",1),v(this,"DPI",96),v(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),v(this,"perfLimitSizeTotal",2097152),v(this,"maxCacheSideLimit",4096),v(this,"minCacheSideLimit",256),v(this,"disableStyleCopyPaste",!1),v(this,"enableGLFiltering",!0),v(this,"textureSize",4096),v(this,"forceGLPutImageData",!1),v(this,"cachesBoundsOfCurve",!1),v(this,"fontPaths",{}),v(this,"NUM_FRACTION_DIGITS",4)}}const W=new class extends qa{constructor(n){super(),this.configure(n)}configure(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,n)}addFonts(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=_(_({},this.fontPaths),n)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach((n=>{delete this.fontPaths[n]}))}clearFonts(){this.fontPaths={}}restoreDefaults(n){const t=new qa,e=(n==null?void 0:n.reduce(((i,s)=>(i[s]=t[s],i)),{}))||t;this.configure(e)}},Ci=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return console[n]("fabric",...e)};class ze extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class xg extends ze{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class wg{}class Cg extends wg{testPrecision(t,e){const i="precision ".concat(e,` float;
3263
+ void main(){}`),s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,i),t.compileShader(s),!!t.getShaderParameter(s,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find((i=>this.testPrecision(e,i))),e.getExtension("WEBGL_lose_context").loseContext(),Ci("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Sg={};let Ka;const Ue=()=>Ka||(Ka={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Cg,dispose(){},copyPasteData:Sg}),ds=()=>Ue().document,un=()=>Ue().window,mc=()=>{var n;return Math.max((n=W.devicePixelRatio)!==null&&n!==void 0?n:un().devicePixelRatio,1)},$s=new class{constructor(){v(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(n){let{fontFamily:t,fontStyle:e,fontWeight:i}=n;t=t.toLowerCase();const s=this.charWidthsCache;s.has(t)||s.set(t,new Map);const r=s.get(t),o="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return r.has(o)||r.set(o,new Map),r.get(o)}clearFontCache(n){n?this.charWidthsCache.delete((n||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(n){const{perfLimitSizeTotal:t}=W,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},lo="6.9.1";function Lr(){}const er=Math.PI/2,Nr=2*Math.PI,Fo=Math.PI/180,Qt=Object.freeze([1,0,0,1,0,0]),jo=16,ui=.4477152502,V="center",Y="left",ne="top",co="bottom",wt="right",oe="none",$o=/\r?\n/,bc="moving",pn="scaling",vc="rotating",Ro="rotate",yc="skewing",Gs="resizing",Tg="modifyPoly",Eg="modifyPath",Ur="changed",gn="scale",ce="scaleX",_e="scaleY",us="skewX",ps="skewY",Mt="fill",ae="stroke",Wr="modified",Xi="json",Rn="svg",D=new class{constructor(){this[Xi]=new Map,this[Rn]=new Map}has(n){return this[Xi].has(n)}getClass(n){const t=this[Xi].get(n);if(!t)throw new ze("No class registered for ".concat(n));return t}setClass(n,t){t?this[Xi].set(t,n):(this[Xi].set(n.type,n),this[Xi].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[Rn].get(n)}setSVGClass(n,t){this[Rn].set(t??n.type.toLowerCase(),n)}},Gr=new class extends Array{remove(n){const t=this.indexOf(n);t>-1&&this.splice(t,1)}cancelAll(){const n=this.splice(0);return n.forEach((t=>t.abort())),n}cancelByCanvas(n){if(!n)return[];const t=this.filter((e=>{var i;return e.target===n||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===n}));return t.forEach((e=>e.abort())),t}cancelByTarget(n){if(!n)return[];const t=this.filter((e=>e.target===n));return t.forEach((e=>e.abort())),t}};class kg{constructor(){v(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach((i=>{let[s,r]=i;this.on(s,r)})),()=>this.off(t);if(e){const i=t;return this.__eventListeners[i]||(this.__eventListeners[i]=[]),this.__eventListeners[i].push(e),()=>this.off(i,e)}return()=>!1}once(t,e){if(typeof t=="object"){const i=[];return Object.entries(t).forEach((s=>{let[r,o]=s;i.push(this.once(r,o))})),()=>i.forEach((s=>s()))}if(e){const i=this.on(t,(function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];e.call(this,...r),i()}));return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],s=i.indexOf(e);s>-1&&i.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const i in this.__eventListeners)this._removeEventListener(i);else typeof t=="object"?Object.entries(t).forEach((i=>{let[s,r]=i;this._removeEventListener(s,r)})):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(s)for(let r=0;r<s.length;r++)s[r].call(this,e||{})}}const Zi=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},ni=n=>{if(n===0)return 1;switch(Math.abs(n)/er){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},oi=n=>{if(n===0)return 0;const t=n/er,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class x{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new x(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new x(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new x(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new x(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new x(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new x(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new x(this.x/t.x,this.y/t.y)}scalarDivide(t){return new x(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new x(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new x(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new x(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bo;const i=oi(t),s=ni(t),r=this.subtract(e);return new x(r.x*s-r.y*i,r.x*i+r.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new x(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Bo=new x(0,0),Fr=n=>!!n&&Array.isArray(n._objects);function _c(n){class t extends n{constructor(){super(...arguments),v(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];const o=this._objects.push(...s);return s.forEach((a=>this._onObjectAdded(a))),o}insertAt(i){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return this._objects.splice(i,0,...r),r.forEach((a=>this._onObjectAdded(a))),this._objects.length}remove(){const i=this._objects,s=[];for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return o.forEach((l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),s.push(l),this._onObjectRemoved(l))})),s}forEachObject(i){this.getObjects().forEach(((s,r,o)=>i(s,r,o)))}getObjects(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];return s.length===0?[...this._objects]:this._objects.filter((o=>o.isType(...s)))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,s){return!!this._objects.includes(i)||!!s&&this._objects.some((r=>r instanceof t&&r.contains(i,!0)))}complexity(){return this._objects.reduce(((i,s)=>i+=s.complexity?s.complexity():0),0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(Zi(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(Zi(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==0){const o=this.findNewLowerIndex(i,r,s);return Zi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==this._objects.length-1){const o=this.findNewUpperIndex(i,r,s);return Zi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(Zi(this._objects,i),this._objects.splice(s,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,s,r){let o;if(r){o=s;for(let a=s-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(i,s,r){let o;if(r){o=s;for(let a=s+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(i){let{left:s,top:r,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new x(s,r),d=h.add(new x(o,a));for(let u=this._objects.length-1;u>=0;u--){const p=this._objects[u];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,d)||p.isContainedWithinRect(h,d)||l&&p.containsPoint(h)||l&&p.containsPoint(d))&&c.push(p)}return c}}return t}class xc extends kg{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function jr(n){return un().requestAnimationFrame(n)}function Og(n){return un().cancelAnimationFrame(n)}let Pg=0;const Si=()=>Pg++,ai=()=>{const n=ds().createElement("canvas");if(!n||n.getContext===void 0)throw new ze("Failed to create `canvas` element");return n},Dg=()=>ds().createElement("img"),xe=n=>{const t=ai();return t.width=n.width,t.height=n.height,t},wc=(n,t,e)=>n.toDataURL("image/".concat(t),e),Cc=(n,t,e)=>new Promise(((i,s)=>{n.toBlob(i,"image/".concat(t),e)})),Ct=n=>n*Fo,li=n=>n/Fo,Ag=n=>n.every(((t,e)=>t===Qt[e])),ie=(n,t,e)=>new x(n).transform(t,e),Ee=n=>{const t=1/(n[0]*n[3]-n[1]*n[2]),e=[t*n[3],-t*n[1],-t*n[2],t*n[0],0,0],{x:i,y:s}=new x(n[4],n[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},Bt=(n,t,e)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],e?0:n[0]*t[4]+n[2]*t[5]+n[4],e?0:n[1]*t[4]+n[3]*t[5]+n[5]],zo=(n,t)=>n.reduceRight(((e,i)=>i&&e?Bt(i,e,t):i||e),void 0)||Qt.concat(),Sc=n=>{let[t,e]=n;return Math.atan2(e,t)},Yr=n=>{const t=Sc(n),e=Math.pow(n[0],2)+Math.pow(n[1],2),i=Math.sqrt(e),s=(n[0]*n[3]-n[2]*n[1])/i,r=Math.atan2(n[0]*n[2]+n[1]*n[3],e);return{angle:li(t),scaleX:i,scaleY:s,skewX:li(r),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},ir=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function gs(){let{angle:n=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=Ct(n),s=ni(i),r=oi(i);return[s,r,-r,s,t?t-(s*t-r*e):0,e?e-(r*t+s*e):0]}const Ho=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},Tc=n=>Math.tan(Ct(n)),Ec=n=>[1,0,Tc(n),1,0,0],kc=n=>[1,Tc(n),0,1,0,0],fn=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:r=0,skewY:o=0}=n,a=Ho(i?-t:t,s?-e:e);return r&&(a=Bt(a,Ec(r),!0)),o&&(a=Bt(a,kc(o),!0)),a},Mg=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let s=ir(t,e);i&&(s=Bt(s,gs({angle:i})));const r=fn(n);return Ag(r)||(s=Bt(s,r)),s},$r=function(n){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((function(i,s){if(t&&t.aborted)return s(new xg("loadImage"));const r=Dg();let o;t&&(o=function(l){r.src="",s(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){r.onload=r.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(r)};n?(r.onload=a,r.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new ze("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=n):a()}))},Ys=function(n){let{signal:t,reviver:e=Lr}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((i,s)=>{const r=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(n.map((o=>D.getClass(o.type).fromObject(o,{signal:t}).then((a=>(e(o,a),r.push(a),a)))))).then(i).catch((o=>{r.forEach((a=>{a.dispose&&a.dispose()})),s(o)})).finally((()=>{t&&t.removeEventListener("abort",s)}))}))},mn=function(n){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((e,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0});const r=Object.values(n).map((a=>a&&a.type&&D.has(a.type)?Ys([a],{signal:t}).then((l=>{let[c]=l;return s.push(c),c})):a)),o=Object.keys(n);Promise.all(r).then((a=>a.reduce(((l,c,h)=>(l[o[h]]=c,l)),{}))).then(e).catch((a=>{s.forEach((l=>{l.dispose&&l.dispose()})),i(a)})).finally((()=>{t&&t.removeEventListener("abort",i)}))}))},fs=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce(((t,e)=>(e in n&&(t[e]=n[e]),t)),{})},Vo=(n,t)=>Object.keys(n).reduce(((e,i)=>(t(n[i],i,n)&&(e[i]=n[i]),e)),{}),et=(n,t)=>parseFloat(Number(n).toFixed(t)),Xs=n=>"matrix("+n.map((t=>et(t,W.NUM_FRACTION_DIGITS))).join(" ")+")",ve=n=>!!n&&n.toLive!==void 0,Za=n=>!!n&&typeof n.toObject=="function",Ja=n=>!!n&&n.offsetX!==void 0&&"source"in n,Mi=n=>!!n&&"multiSelectionStacking"in n;function Oc(n){const t=n&&Te(n);let e=0,i=0;if(!n||!t)return{left:e,top:i};let s=n;const r=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===t?(e=o.scrollLeft||r.scrollLeft||0,i=o.scrollTop||r.scrollTop||0):(e+=s.scrollLeft||0,i+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:i}}const Te=n=>n.ownerDocument||null,Pc=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Dc=function(n,t,e){let{width:i,height:s}=e,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;n.width=i,n.height=s,r>1&&(n.setAttribute("width",(i*r).toString()),n.setAttribute("height",(s*r).toString()),t.scale(r,r))},ho=(n,t)=>{let{width:e,height:i}=t;e&&(n.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(n.style.height=typeof i=="number"?"".concat(i,"px"):i)};function Qa(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=oe,n}class Ac{constructor(t){v(this,"_originalCanvasStyle",void 0),v(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&i.getContext!==void 0?t:t&&ds().getElementById(t)||ai();var i;if(e.hasAttribute("data-fabric"))throw new ze("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:i}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(i)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:s}=this.lower;Dc(i,s,t,e)}setCSSDimensions(t){ho(this.lower.el,t)}calcOffset(){return(function(t){var e;const i=t&&Te(t),s={left:0,top:0};if(!i)return s;const r=((e=Pc(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(r.borderLeftWidth,10)||0,s.top+=parseInt(r.borderTopWidth,10)||0,s.left+=parseInt(r.paddingLeft,10)||0,s.top+=parseInt(r.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=Oc(t);return{left:o.left+l.left-(a.clientLeft||0)+s.left,top:o.top+l.top-(a.clientTop||0)+s.top}})(this.lower.el)}dispose(){Ue().dispose(this.lower.el),delete this.lower}}const Ig={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Qt]},Lg=["objects"];class sr extends _c(xc){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return sr.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new Ac(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),r}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(Ci("warn",`Canvas is trying to add an object that belongs to a different canvas.
3264
+ Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?mc():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:i=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const s=_({width:this.width,height:this.height},t);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}i||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const i=t,s=[...this.viewportTransform],r=ie(t,Ee(s));s[0]=e,s[3]=e;const o=ie(r,s);s[4]+=i.x-o.x,s[5]+=i.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new x(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new x(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=jr((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Ee(this.viewportTransform),s=ie({x:0,y:0},i),r=ie({x:t,y:e},i),o=s.min(r),a=s.max(r);return this.vptCoords={tl:o,tr:new x(a.x,o.y),bl:new x(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Og(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,s)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const i=this.viewportTransform;t.save(),t.transform(...i),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let i=0,s=e.length;i<s;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],s=this["".concat(e,"Image")],r=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!s)return;const a=ve(i);if(i){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=a?i.toLive(t):i,o&&t.transform(...r),a){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const l=i.gradientTransform||i.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...r),s.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new x(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new x(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new x(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return ie(this.getCenterPoint(),Ee(this.viewportTransform))}_centerObject(t,e){t.setXY(e,V,V),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const i=this.clipPath,s=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return _(_(_({version:lo},fs(this,e)),{},{objects:this._objects.filter((r=>!r.excludeFromExport)).map((r=>this._toObject(r,t,e)))},this.__serializeBgOverlay(t,e)),s?{clipPath:s}:null)}_toObject(t,e,i){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const r=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!s),r}__serializeBgOverlay(t,e){const i={},s=this.backgroundImage,r=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return ve(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),ve(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),s&&!s.excludeFromExport&&(i.backgroundImage=this._toObject(s,t,e)),r&&!r.excludeFromExport&&(i.overlayImage=this._toObject(r,t,e)),i}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
3265
3265
  `)),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push(`</g>
3266
3266
  `),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",`" standalone="no" ?>
3267
3267
  `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
@@ -3269,7 +3269,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3269
3269
  `,"<desc>Created with Fabric.js ",lo,`</desc>
3270
3270
  `,`<defs>
3271
3271
  `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
3272
- `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(Ci()),'<clipPath id="'.concat(e.clipPathId,`" >
3272
+ `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(Si()),'<clipPath id="'.concat(e.clipPathId,`" >
3273
3273
  `).concat(e.toClipPathSVG(t.reviver),`</clipPath>
3274
3274
  `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map((t=>{const e=this["".concat(t,"Color")];if(ve(e)){const i=this["".concat(t,"Vpt")],s=this.viewportTransform,r={isType:()=>!1,width:this.width/(i?s[0]:1),height:this.height/(i?s[3]:1)};return e.toSVG(r,{additionalTransform:i?Xs(s):""})}})).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=W.fontPaths;this._objects.forEach((function r(o){t.push(o),Fr(o)&&o._objects.forEach(r)})),t.forEach((r=>{if(!(o=r)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=r;!e[l]&&i[l]&&(e[l]=!0,a&&Object.values(a).forEach((c=>{Object.values(c).forEach((h=>{let{fontFamily:d=""}=h;!e[d]&&i[d]&&(e[d]=!0)}))})))}));const s=Object.keys(e).map((r=>` @font-face {
3275
3275
  font-family: '`.concat(r,`';
@@ -3279,13 +3279,13 @@ Resulting to default behavior: removing object from previous canvas and adding t
3279
3279
  `.concat(s,`]]></style>
3280
3280
  `):""}_setSVGObjects(t,e){this.forEachObject((i=>{i.excludeFromExport||this._setSVGObject(t,i,e)}))}_setSVGObject(t,e,i){t.push(e.toSVG(i))}_setSVGBgOverlayImage(t,e,i){const s=this[e];s&&!s.excludeFromExport&&s.toSVG&&t.push(s.toSVG(i))}_setSVGBgOverlayColor(t,e){const i=this["".concat(e,"Color")];if(i)if(ve(i)){const s=i.repeat||"",r=this.width,o=this.height,a=this["".concat(e,"Vpt")]?Xs(Ee(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(r/2,",").concat(o/2,')" x="').concat(i.offsetX-r/2,'" y="').concat(i.offsetY-o/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!Ja(i)?r:i.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!Ja(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
3281
3281
  `))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
3282
- `)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new ze("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:r=[]}=s,o=ot(s,Mg),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:d}=o,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Ys(r,{reviver:e,signal:i}),mn({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:d},{signal:i})]).then((p=>{let[g,f]=p;return this.clear(),this.add(...g),this.set(o),this.set(f),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=xe(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:r=!1}=t,o=s*(r?this.getRetinaScaling():1);return wc(this.toCanvasElement(o,t),e,i)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:r=!1}=t,o=s*(r?this.getRetinaScaling():1);return Cc(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:s,top:r,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(i||this.height)*t,c=this.getZoom(),h=this.width,d=this.height,u=this.skipControlsDrawing,p=c*t,g=this.viewportTransform,f=[p,0,0,p,(g[4]-(s||0))*t,(g[5]-(r||0))*t],b=this.enableRetinaScaling,m=xe({width:a,height:l}),_=o?this._objects.filter((x=>o(x))):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),_),this.viewportTransform=g,this.width=h,this.height=d,this.calcViewportBoundaries(),this.enableRetinaScaling=b,this.skipControlsDrawing=u,m}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Gr.cancelByCanvas(this),this.disposed=!0,new Promise(((t,e)=>{const i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()}))}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject((t=>t.dispose())),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}v(sr,"ownDefaults",Ag);const Ig=["touchstart","touchmove","touchend"],Lg=n=>{const t=Oc(n.target),e=(function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i})(n);return new w(e.clientX+t.left,e.clientY+t.top)},uo=n=>Ig.includes(n.type)||n.pointerType==="touch",tl=n=>{n.preventDefault(),n.stopPropagation()},ei=n=>{let t=0,e=0,i=0,s=0;for(let r=0,o=n.length;r<o;r++){const{x:a,y:l}=n[r];(a>i||!r)&&(i=a),(a<t||!r)&&(t=a),(l>s||!r)&&(s=l),(l<e||!r)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},Fg=["translateX","translateY","scaleX","scaleY"],jg=(n,t)=>Xr(n,Bt(t,n.calcOwnMatrix())),Xr=(n,t)=>{const e=Yr(t),{translateX:i,translateY:s,scaleX:r,scaleY:o}=e,a=ot(e,Fg),l=new w(i,s);n.flipX=!1,n.flipY=!1,Object.assign(n,a),n.set({scaleX:r,scaleY:o}),n.setPositionByOrigin(l,V,V)},$g=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},Mc=n=>({scaleX:n.scaleX,scaleY:n.scaleY,skewX:n.skewX,skewY:n.skewY,angle:n.angle,left:n.left,flipX:n.flipX,flipY:n.flipY,top:n.top}),No=(n,t,e)=>{const i=n/2,s=t/2,r=[new w(-i,-s),new w(i,-s),new w(-i,s),new w(i,s)].map((a=>a.transform(e))),o=ei(r);return new w(o.width,o.height)},bn=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zt;return Bt(Ee(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Zt),n)},ss=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Zt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Zt;return n.transform(bn(t,e))},Rg=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Zt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Zt;return n.transform(bn(t,e),!0)},Bg=(n,t,e)=>{const i=bn(t,e);return Xr(n,Bt(i,n.calcOwnMatrix())),i},Ic=(n,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(n),y(y({},t),{},{target:i})),i.fire(n,t)},zg={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Pt=n=>typeof n=="string"?zg[n]:n-.5,qr="not-allowed";function Lc(n){return Pt(n.originX)===Pt(V)&&Pt(n.originY)===Pt(V)}function el(n){return .5-Pt(n)}const Pe=(n,t)=>n[t],Fc=(n,t,e,i)=>({e:n,transform:t,pointer:new w(e,i)});function jc(n,t){const e=n.getTotalAngle()+li(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Uo(n,t,e,i,s){var r;let{target:o,corner:a}=n;const l=o.controls[a],c=((r=o.canvas)===null||r===void 0?void 0:r.getZoom())||1,h=o.padding/c,d=(function(u,p,g,f){const b=u.getRelativeCenterPoint(),m=g!==void 0&&f!==void 0?u.translateToGivenOrigin(b,V,V,g,f):new w(u.left,u.top);return(u.angle?p.rotate(-Ct(u.angle),b):p).subtract(m)})(o,new w(i,s),t,e);return d.x>=h&&(d.x-=h),d.x<=-h&&(d.x+=h),d.y>=h&&(d.y-=h),d.y<=h&&(d.y+=h),d.x-=l.offsetX,d.y-=l.offsetY,d}const Hg=(n,t,e,i)=>{const{target:s,offsetX:r,offsetY:o}=t,a=e-r,l=i-o,c=!Pe(s,"lockMovementX")&&s.left!==a,h=!Pe(s,"lockMovementY")&&s.top!==l;return c&&s.set(Y,a),h&&s.set(se,l),(c||h)&&Ic(bc,Fc(n,t,e,i)),c||h},Kr=n=>n.replace(/\s+/g," "),il={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},Bn=(n,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+6*(t-n)*e:e<.5?t:e<2/3?n+(t-n)*(2/3-e)*6:n),sl=(n,t,e,i)=>{n/=255,t/=255,e/=255;const s=Math.max(n,t,e),r=Math.min(n,t,e);let o,a;const l=(s+r)/2;if(s===r)o=a=0;else{const c=s-r;switch(a=l>.5?c/(2-s-r):c/(s+r),s){case n:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-n)/c+2;break;case e:o=(n-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},rl=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},lr=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),nl=n=>{let[t,e,i,s=1]=n;const r=Math.round(.3*t+.59*e+.11*i);return[r,r,r,s]};class K{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof K)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,r=1]=t;this.setSource([e,i,s,r])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in il&&(t=il[t]),t==="transparent"?[255,255,255,0]:K.sourceFromHex(t)||K.sourceFromRgb(t)||K.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=sl(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=sl(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,s]=this.getSource();return"".concat(lr(t)).concat(lr(e)).concat(lr(i)).concat(lr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(nl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=nl(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof K||(t=new K(t));const e=this.getSource(),i=t.getSource(),[s,r,o]=e.map(((a,l)=>Math.round(.5*a+.5*i[l])));return this.setSource([s,r,o,e[3]]),this}static fromRgb(t){return K.fromRgba(t)}static fromRgba(t){return new K(K.sourceFromRgb(t))}static sourceFromRgb(t){const e=Kr(t).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(e){const[i,s,r]=e.slice(1,4).map((o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a}));return[i,s,r,rl(e[4])]}}static fromHsl(t){return K.fromHsla(t)}static fromHsla(t){return new K(K.sourceFromHsl(t))}static sourceFromHsl(t){const e=Kr(t).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!e)return;const i=(K.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let o,a,l;if(s===0)o=a=l=r;else{const c=r<=.5?r*(s+1):r+s-r*s,h=2*r-c;o=Bn(h,c,i+1/3),a=Bn(h,c,i),l=Bn(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),rl(e[4])]}static fromHex(t){return new K(K.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let i;i=e.length<=4?e.split("").map((l=>l+l)):e.match(/.{2}/g);const[s,r,o,a=255]=i.map((l=>parseInt(l,16)));return[s,r,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?li(i):e.includes("turn")?360*i:i}}const rs=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jo;const e=/\D{0,2}$/.exec(n),i=parseFloat(n),s=W.DPI;switch(e==null?void 0:e[0]){case"mm":return i*s/25.4;case"cm":return i*s/2.54;case"in":return i*s;case"pt":return i*s/72;case"pc":return i*s/72*12;case"em":return i*t;default:return i}},Vg=n=>{const[t,e]=n.trim().split(" "),[i,s]=(r=t)&&r!==re?[r.slice(1,4),r.slice(5,8)]:r===re?[r,r]:["Mid","Mid"];var r;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},qs=function(n,t){let e,i,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const r=new K(t),o=r.getAlpha();e=r.toRgb(),o!==1&&(i=o.toString())}else e="none";return s?"".concat(n,": ").concat(e,"; ").concat(i?"".concat(n,"-opacity: ").concat(i,"; "):""):"".concat(n,'="').concat(e,'" ').concat(i?"".concat(n,'-opacity="').concat(i,'" '):"")};class $c{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):re,r=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",d=t?"":this.getSvgFilter(),u=qs(Mt,this.fill);return[qs(ne,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",u,"fill-rule: ",e,"; ","opacity: ",c,";",d,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Xs(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),r=t.indexOf("COMMON_PARTS");return t[r]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,d=this.stroke,u=this.fill,p=this.shadow,g=[],f=t.indexOf("COMMON_PARTS");let b;l&&(l.clipPathId="CLIPPATH_".concat(Ci()),b='<clipPath id="'.concat(l.clipPathId,`" >
3282
+ `)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new ze("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:r=[]}=s,o=ot(s,Lg),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:d}=o,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Ys(r,{reviver:e,signal:i}),mn({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:d},{signal:i})]).then((p=>{let[g,f]=p;return this.clear(),this.add(...g),this.set(o),this.set(f),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=xe(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:r=!1}=t,o=s*(r?this.getRetinaScaling():1);return wc(this.toCanvasElement(o,t),e,i)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:r=!1}=t,o=s*(r?this.getRetinaScaling():1);return Cc(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:s,top:r,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(i||this.height)*t,c=this.getZoom(),h=this.width,d=this.height,u=this.skipControlsDrawing,p=c*t,g=this.viewportTransform,f=[p,0,0,p,(g[4]-(s||0))*t,(g[5]-(r||0))*t],b=this.enableRetinaScaling,m=xe({width:a,height:l}),y=o?this._objects.filter((w=>o(w))):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),y),this.viewportTransform=g,this.width=h,this.height=d,this.calcViewportBoundaries(),this.enableRetinaScaling=b,this.skipControlsDrawing=u,m}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Gr.cancelByCanvas(this),this.disposed=!0,new Promise(((t,e)=>{const i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()}))}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject((t=>t.dispose())),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}v(sr,"ownDefaults",Ig);const Fg=["touchstart","touchmove","touchend"],jg=n=>{const t=Oc(n.target),e=(function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i})(n);return new x(e.clientX+t.left,e.clientY+t.top)},uo=n=>Fg.includes(n.type)||n.pointerType==="touch",tl=n=>{n.preventDefault(),n.stopPropagation()},ei=n=>{let t=0,e=0,i=0,s=0;for(let r=0,o=n.length;r<o;r++){const{x:a,y:l}=n[r];(a>i||!r)&&(i=a),(a<t||!r)&&(t=a),(l>s||!r)&&(s=l),(l<e||!r)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},$g=["translateX","translateY","scaleX","scaleY"],Rg=(n,t)=>Xr(n,Bt(t,n.calcOwnMatrix())),Xr=(n,t)=>{const e=Yr(t),{translateX:i,translateY:s,scaleX:r,scaleY:o}=e,a=ot(e,$g),l=new x(i,s);n.flipX=!1,n.flipY=!1,Object.assign(n,a),n.set({scaleX:r,scaleY:o}),n.setPositionByOrigin(l,V,V)},Bg=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},Mc=n=>({scaleX:n.scaleX,scaleY:n.scaleY,skewX:n.skewX,skewY:n.skewY,angle:n.angle,left:n.left,flipX:n.flipX,flipY:n.flipY,top:n.top}),No=(n,t,e)=>{const i=n/2,s=t/2,r=[new x(-i,-s),new x(i,-s),new x(-i,s),new x(i,s)].map((a=>a.transform(e))),o=ei(r);return new x(o.width,o.height)},bn=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qt;return Bt(Ee(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt),n)},ss=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qt;return n.transform(bn(t,e))},zg=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qt;return n.transform(bn(t,e),!0)},Hg=(n,t,e)=>{const i=bn(t,e);return Xr(n,Bt(i,n.calcOwnMatrix())),i},Ic=(n,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(n),_(_({},t),{},{target:i})),i.fire(n,t)},Vg={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Pt=n=>typeof n=="string"?Vg[n]:n-.5,qr="not-allowed";function Lc(n){return Pt(n.originX)===Pt(V)&&Pt(n.originY)===Pt(V)}function el(n){return .5-Pt(n)}const Pe=(n,t)=>n[t],Fc=(n,t,e,i)=>({e:n,transform:t,pointer:new x(e,i)});function jc(n,t){const e=n.getTotalAngle()+li(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Uo(n,t,e,i,s){var r;let{target:o,corner:a}=n;const l=o.controls[a],c=((r=o.canvas)===null||r===void 0?void 0:r.getZoom())||1,h=o.padding/c,d=(function(u,p,g,f){const b=u.getRelativeCenterPoint(),m=g!==void 0&&f!==void 0?u.translateToGivenOrigin(b,V,V,g,f):new x(u.left,u.top);return(u.angle?p.rotate(-Ct(u.angle),b):p).subtract(m)})(o,new x(i,s),t,e);return d.x>=h&&(d.x-=h),d.x<=-h&&(d.x+=h),d.y>=h&&(d.y-=h),d.y<=h&&(d.y+=h),d.x-=l.offsetX,d.y-=l.offsetY,d}const Ng=(n,t,e,i)=>{const{target:s,offsetX:r,offsetY:o}=t,a=e-r,l=i-o,c=!Pe(s,"lockMovementX")&&s.left!==a,h=!Pe(s,"lockMovementY")&&s.top!==l;return c&&s.set(Y,a),h&&s.set(ne,l),(c||h)&&Ic(bc,Fc(n,t,e,i)),c||h},Kr=n=>n.replace(/\s+/g," "),il={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},Bn=(n,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+6*(t-n)*e:e<.5?t:e<2/3?n+(t-n)*(2/3-e)*6:n),sl=(n,t,e,i)=>{n/=255,t/=255,e/=255;const s=Math.max(n,t,e),r=Math.min(n,t,e);let o,a;const l=(s+r)/2;if(s===r)o=a=0;else{const c=s-r;switch(a=l>.5?c/(2-s-r):c/(s+r),s){case n:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-n)/c+2;break;case e:o=(n-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},rl=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},lr=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),nl=n=>{let[t,e,i,s=1]=n;const r=Math.round(.3*t+.59*e+.11*i);return[r,r,r,s]};class K{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof K)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,r=1]=t;this.setSource([e,i,s,r])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in il&&(t=il[t]),t==="transparent"?[255,255,255,0]:K.sourceFromHex(t)||K.sourceFromRgb(t)||K.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=sl(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=sl(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,s]=this.getSource();return"".concat(lr(t)).concat(lr(e)).concat(lr(i)).concat(lr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(nl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=nl(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof K||(t=new K(t));const e=this.getSource(),i=t.getSource(),[s,r,o]=e.map(((a,l)=>Math.round(.5*a+.5*i[l])));return this.setSource([s,r,o,e[3]]),this}static fromRgb(t){return K.fromRgba(t)}static fromRgba(t){return new K(K.sourceFromRgb(t))}static sourceFromRgb(t){const e=Kr(t).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(e){const[i,s,r]=e.slice(1,4).map((o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a}));return[i,s,r,rl(e[4])]}}static fromHsl(t){return K.fromHsla(t)}static fromHsla(t){return new K(K.sourceFromHsl(t))}static sourceFromHsl(t){const e=Kr(t).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!e)return;const i=(K.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let o,a,l;if(s===0)o=a=l=r;else{const c=r<=.5?r*(s+1):r+s-r*s,h=2*r-c;o=Bn(h,c,i+1/3),a=Bn(h,c,i),l=Bn(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),rl(e[4])]}static fromHex(t){return new K(K.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let i;i=e.length<=4?e.split("").map((l=>l+l)):e.match(/.{2}/g);const[s,r,o,a=255]=i.map((l=>parseInt(l,16)));return[s,r,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?li(i):e.includes("turn")?360*i:i}}const rs=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jo;const e=/\D{0,2}$/.exec(n),i=parseFloat(n),s=W.DPI;switch(e==null?void 0:e[0]){case"mm":return i*s/25.4;case"cm":return i*s/2.54;case"in":return i*s;case"pt":return i*s/72;case"pc":return i*s/72*12;case"em":return i*t;default:return i}},Ug=n=>{const[t,e]=n.trim().split(" "),[i,s]=(r=t)&&r!==oe?[r.slice(1,4),r.slice(5,8)]:r===oe?[r,r]:["Mid","Mid"];var r;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},qs=function(n,t){let e,i,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const r=new K(t),o=r.getAlpha();e=r.toRgb(),o!==1&&(i=o.toString())}else e="none";return s?"".concat(n,": ").concat(e,"; ").concat(i?"".concat(n,"-opacity: ").concat(i,"; "):""):"".concat(n,'="').concat(e,'" ').concat(i?"".concat(n,'-opacity="').concat(i,'" '):"")};class $c{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):oe,r=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",d=t?"":this.getSvgFilter(),u=qs(Mt,this.fill);return[qs(ae,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",u,"fill-rule: ",e,"; ","opacity: ",c,";",d,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Xs(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),r=t.indexOf("COMMON_PARTS");return t[r]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,d=this.stroke,u=this.fill,p=this.shadow,g=[],f=t.indexOf("COMMON_PARTS");let b;l&&(l.clipPathId="CLIPPATH_".concat(Si()),b='<clipPath id="'.concat(l.clipPathId,`" >
3283
3283
  `).concat(l.toClipPathSVG(i),`</clipPath>
3284
3284
  `)),h&&g.push("<g ",a,this.getSvgCommons(),` >
3285
3285
  `),g.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
3286
3286
  `);const m=[o,c,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[f]=m,ve(u)&&g.push(u.toSVG(this)),ve(d)&&g.push(d.toSVG(this)),p&&g.push(p.toSVG(this)),l&&g.push(b),g.push(t.join("")),g.push(`</g>
3287
3287
  `),h&&g.push(`</g>
3288
- `),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==Mt?' paint-order="'.concat(this.paintFirst,'" '):""}}function vn(n){return new RegExp("^("+n.join("|")+")\\b","i")}const Vi="textDecorationThickness",Rc=["fontSize","fontWeight","fontFamily","fontStyle"],Bc=["underline","overline","linethrough"],zc=[...Rc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Hc=[...zc,...Bc,"textBackgroundColor","direction",Vi],Ng=[...Rc,...Bc,ne,"strokeWidth",Mt,"deltaY","textBackgroundColor",Vi],Ug={_reNewline:$o,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Y,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Y,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[Vi]:66.667},Re="justify",Zr="justify-left",Rs="justify-right",Bs="justify-center";var ol,al,ll;const ke=String.raw(ol||(ol=Ge(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),zn=String.raw(al||(al=Ge(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),Wg=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+ke+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+ke+"))?\\s+(.*)"),Gg={cx:Y,x:Y,r:"radius",cy:se,y:se,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":Vi},Hn="font-size",Vn="clip-path";vn(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);vn(["symbol","image","marker","pattern","view","svg"]);const cl=vn(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(ll||(ll=Ge(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),ke,zn,ke,zn,ke,zn,ke));const Yg=new w(1,0),Vc=new w,Nc=(n,t)=>n.rotate(t),po=(n,t)=>new w(t).subtract(n),go=n=>n.distanceFrom(Vc),fo=(n,t)=>Math.atan2(zs(n,t),qg(n,t)),Xg=n=>fo(Yg,n),Wo=n=>n.eq(Vc)?n:n.scalarDivide(go(n)),Uc=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return Wo(new w(-n.y,n.x).scalarMultiply(t?1:-1))},zs=(n,t)=>n.x*t.y-n.y*t.x,qg=(n,t)=>n.x*t.x+n.y*t.y,hl=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const i=zs(t,e),s=zs(t,n),r=zs(e,n);return i>=0?s>=0&&r<=0:!(s<=0&&r>=0)},dl="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",ul=new RegExp("(?:\\s|^)"+dl+dl+"("+ke+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ii{constructor(t){const e=typeof t=="string"?ii.parseShadow(t):t;Object.assign(this,ii.ownDefaults,e),this.id=Ci()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,r=0]=(ul.exec(e)||[]).map((o=>parseFloat(o)||0));return{color:(e.replace(ul,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:s,blur:r}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=Nc(new w(this.offsetX,this.offsetY),Ct(-t.angle)),i=new K(this.color);let s=40,r=40;return t.width&&t.height&&(s=100*et((Math.abs(e.x)+this.blur)/t.width,W.NUM_FRACTION_DIGITS)+20,r=100*et((Math.abs(e.y)+this.blur)/t.height,W.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(r,'%" height="').concat(100+2*r,'%" x="-').concat(s,'%" width="').concat(100+2*s,`%" >
3288
+ `),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==Mt?' paint-order="'.concat(this.paintFirst,'" '):""}}function vn(n){return new RegExp("^("+n.join("|")+")\\b","i")}const Vi="textDecorationThickness",Rc=["fontSize","fontWeight","fontFamily","fontStyle"],Bc=["underline","overline","linethrough"],zc=[...Rc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Hc=[...zc,...Bc,"textBackgroundColor","direction",Vi],Wg=[...Rc,...Bc,ae,"strokeWidth",Mt,"deltaY","textBackgroundColor",Vi],Gg={_reNewline:$o,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Y,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Y,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[Vi]:66.667},Re="justify",Zr="justify-left",Rs="justify-right",Bs="justify-center";var ol,al,ll;const ke=String.raw(ol||(ol=Ge(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),zn=String.raw(al||(al=Ge(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),Yg=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+ke+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+ke+"))?\\s+(.*)"),Xg={cx:Y,x:Y,r:"radius",cy:ne,y:ne,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":Vi},Hn="font-size",Vn="clip-path";vn(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);vn(["symbol","image","marker","pattern","view","svg"]);const cl=vn(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(ll||(ll=Ge(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),ke,zn,ke,zn,ke,zn,ke));const qg=new x(1,0),Vc=new x,Nc=(n,t)=>n.rotate(t),po=(n,t)=>new x(t).subtract(n),go=n=>n.distanceFrom(Vc),fo=(n,t)=>Math.atan2(zs(n,t),Zg(n,t)),Kg=n=>fo(qg,n),Wo=n=>n.eq(Vc)?n:n.scalarDivide(go(n)),Uc=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return Wo(new x(-n.y,n.x).scalarMultiply(t?1:-1))},zs=(n,t)=>n.x*t.y-n.y*t.x,Zg=(n,t)=>n.x*t.x+n.y*t.y,hl=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const i=zs(t,e),s=zs(t,n),r=zs(e,n);return i>=0?s>=0&&r<=0:!(s<=0&&r>=0)},dl="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",ul=new RegExp("(?:\\s|^)"+dl+dl+"("+ke+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ii{constructor(t){const e=typeof t=="string"?ii.parseShadow(t):t;Object.assign(this,ii.ownDefaults,e),this.id=Si()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,r=0]=(ul.exec(e)||[]).map((o=>parseFloat(o)||0));return{color:(e.replace(ul,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:s,blur:r}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=Nc(new x(this.offsetX,this.offsetY),Ct(-t.angle)),i=new K(this.color);let s=40,r=40;return t.width&&t.height&&(s=100*et((Math.abs(e.x)+this.blur)/t.width,W.NUM_FRACTION_DIGITS)+20,r=100*et((Math.abs(e.y)+this.blur)/t.height,W.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(r,'%" height="').concat(100+2*r,'%" x="-').concat(s,'%" width="').concat(100+2*s,`%" >
3289
3289
  <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(et(this.blur?this.blur/2:0,W.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
3290
3290
  <feOffset dx="`).concat(et(e.x,W.NUM_FRACTION_DIGITS),'" dy="').concat(et(e.y,W.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
3291
3291
  <feFlood flood-color="`).concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),`"/>
@@ -3295,44 +3295,44 @@ Resulting to default behavior: removing object from previous canvas and adding t
3295
3295
  <feMergeNode in="SourceGraphic"></feMergeNode>
3296
3296
  </feMerge>
3297
3297
  </filter>
3298
- `)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=ii.ownDefaults;return this.includeDefaultValues?t:Vo(t,((i,s)=>i!==e[s]))}static async fromObject(t){return new this(t)}}v(ii,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(ii,"type","shadow"),D.setClass(ii,"shadow");const ls=(n,t,e)=>Math.max(n,Math.min(t,e)),Kg=[se,Y,ce,_e,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",us,ps],ci=[Mt,ne,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Zg={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:Y,originY:se,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Mt,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},Jg=(n,t,e,i)=>-e*Math.cos(n/i*er)+e+t,Qg=()=>!1;class Go{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:o=Jg,onStart:a=Lr,onChange:l=Lr,onComplete:c=Lr,abort:h=Qg,target:d}=t;v(this,"_state","pending"),v(this,"durationProgress",0),v(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=r,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=d,this.startValue=e,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout((()=>jr(t)),this.delay):jr(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:s,valueProgress:r}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=r,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),jr(this.tick)))}register(){Gr.push(this)}unregister(){Gr.remove(this)}abort(){this._state="aborted",this.unregister()}}const tf=["startValue","endValue"];class ef extends Go{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(y(y({},ot(t,tf)),{},{startValue:e,byValue:i-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const sf=["startValue","endValue"];class rf extends Go{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(y(y({},ot(t,sf)),{},{startValue:e,byValue:i.map(((s,r)=>s-e[r]))}))}calculate(t){const e=this.startValue.map(((i,s)=>this.easing(t,i,this.byValue[s],this.duration,s)));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const nf=["startValue","endValue","easing","onChange","onComplete","abort"],of=(n,t,e,i)=>t+e*(1-Math.cos(n/i*er)),Nn=n=>n&&((t,e,i)=>n(new K(t).toRgba(),e,i));class af extends Go{constructor(t){let{startValue:e,endValue:i,easing:s=of,onChange:r,onComplete:o,abort:a}=t,l=ot(t,nf);const c=new K(e).getSource(),h=new K(i).getSource();super(y(y({},l),{},{startValue:c,byValue:h.map(((d,u)=>d-c[u])),easing:s,onChange:Nn(r),onComplete:Nn(o),abort:Nn(a)}))}calculate(t){const[e,i,s,r]=this.startValue.map(((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l))),o=[...[e,i,s].map(Math.round),ls(0,r,1)];return{value:o,valueProgress:o.map(((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0)).find((a=>a!==0))||0}}}function Wc(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new rf(n):new ef(n);return t.start(),t}function lf(n){const t=new af(n);return t.start(),t}class ut{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some((e=>e.eq(t)))}append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.points=this.points.concat(e.filter((s=>!this.includes(s)))),this}static isPointContained(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(i))return t.eq(e);if(e.x===i.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const r=po(e,i),o=po(e,t).divide(r);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const i=new w(t).setX(Math.min(t.x-1,...e.map((r=>r.x))));let s=0;for(let r=0;r<e.length;r++){const o=this.intersectSegmentSegment(e[r],e[(r+1)%e.length],t,i);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,i,s){let r=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-i.x,h=s.y-i.y,d=t.x-i.x,u=t.y-i.y,p=c*u-h*d,g=a*u-l*d,f=h*a-c*l;if(f!==0){const b=p/f,m=g/f;return(r||0<=b&&b<=1)&&(o||0<=m&&m<=1)?new ut("Intersection").append(new w(t.x+b*a,t.y+b*l)):new ut}if(p===0||g===0){const b=r||o||ut.isPointContained(t,i,s)||ut.isPointContained(e,i,s)||ut.isPointContained(i,t,e)||ut.isPointContained(s,t,e);return new ut(b?"Coincident":void 0)}return new ut("Parallel")}static intersectSegmentLine(t,e,i,s){return ut.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return ut.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const r=new ut,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=ut.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;r.append(...c.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,i){return ut.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new ut,s=t.length,r=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=ut.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(r.push(c),i.append(a,l)):i.append(...c.points)}return r.length>0&&r.length===t.length?new ut("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),r=e.max(i),o=new w(r.x,s.y),a=new w(s.x,r.y);return ut.intersectPolygonPolygon(t,[s,o,r,a])}}class cf extends xc{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?te(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=te(t,Ee(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new w(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:i,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),r=[t,e,i,s];if(this.group){const o=this.group.calcTransformMatrix();return r.map((a=>te(a,o)))}return r}intersectsWithRect(t,e){return ut.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ut.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every((e=>t.containsPoint(e)))}isContainedWithinRect(t,e){const{left:i,top:s,width:r,height:o}=this.getBoundingRect();return i>=t.x&&i+r<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return ut.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some((i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.y>=t.y))||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every((i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y)))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return ei(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(ce,t),this._set(_e,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?li(Sc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Zt.concat()}calcACoords(){const t=gs({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=ir(e,i),r=Bt(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:te({x:-a,y:-l},r),tr:te({x:a,y:-l},r),bl:te({x:-a,y:l},r),br:te({x:a,y:l},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Pt(this.originX),Pt(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every(((r,o)=>r===i[o]))?s.value:(this.group&&(e=Bt(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const i=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},r=Dg(s);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new w(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=y({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,r=0;this.strokeUniform&&(s=0,r=i);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new w(o*e.scaleX,a*e.scaleY):No(o,a,fn(e)),l.scalarAdd(r)}translateToGivenOrigin(t,e,i,s,r){let o=t.x,a=t.y;const l=Pt(s)-Pt(e),c=Pt(r)-Pt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new w(o,a)}translateToCenterPoint(t,e,i){if(e===V&&i===V)return t;const s=this.translateToGivenOrigin(t,e,i,V,V);return this.angle?s.rotate(Ct(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,V,V,e,i);return this.angle?s.rotate(Ct(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?te(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new w(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const s=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:r.x,top:r.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Y,se)}}const hf=["type"],df=["extraParam"];let qe=class Rr extends cf{static getDefaults(){return Rr.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){wi("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,Rr.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ai(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=W.maxCacheSideLimit,r=W.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=W.perfLimitSizeTotal)return e<r&&(t.width=r),i<r&&(t.height=r),t;const o=e/i,[a,l]=$s.limitDimsByArea(o),c=ls(r,a,s),h=ls(r,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),i>h&&(t.zoomY/=i/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:i,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:s,zoomX:r,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==r||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||s!==t.height?(t.width=i,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const d=a/2,u=l/2;return this.cacheTranslationX=Math.round(t.width/2-d)+d,this.cacheTranslationY=Math.round(t.height/2-u)+u,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,o),this.zoomX=r,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new w(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Yr(this.calcTransformMatrix());return new w(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==ce&&t!==_e||(e=this._constrainScale(e)),t===ce&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ii||(e=new ii(e));const i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===ne&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){const s=this.fill,r=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=s,this.stroke=r}createClipPathLayer(t,e){const i=xe(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach((r=>{r.transform(s)})),e.parentClipPaths.push(t),t.absolutePositioned){const r=Ee(this.calcTransformMatrix());s.transform(r[0],r[1],r[2],r[3],r[4],r[5])}return t.transform(s),t.drawObject(s,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,s)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,ve(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:i}=e;i&&(ve(i)?(t.fillStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.fillStyle=i)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[r,,,o]=(i==null?void 0:i.viewportTransform)||Zt,a=r*s,l=o*s,c=e.nonScaling?new w(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*W.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!ve(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,s,r):t.transform(1,0,0,1,s,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:r}}_renderPaintInOrder(t){this.paintFirst===ne?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/r,a=s.y/this.scaleY/r,l=xe({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(s.zoomX/this.scaleX/r,s.zoomY/this.scaleY/r),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(r*this.scaleX/s.zoomX,r*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new w(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(D.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Mc(this),i=this.group,s=this.shadow,r=Math.abs,o=t.enableRetinaScaling?mc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(_=>new sr(_,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&$g(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Bg(this,this.getViewportTransform()),this.setCoords();const c=ai(),h=this.getBoundingRect(),d=this.shadow,u=new w;if(d){const _=d.blur,x=d.nonScaling?new w(1,1):this.getObjectScaling();u.x=2*Math.round(r(d.offsetX)+_)*r(x.x),u.y=2*Math.round(r(d.offsetY)+_)*r(x.y)}const p=h.width+u.x,g=h.height+u.y;c.width=Math.ceil(p),c.height=Math.ceil(g);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new w(f.width/2,f.height/2),V,V);const b=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const m=f.toCanvasElement(a||1,t);return this.set("canvas",b),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),m}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return wc(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Cc(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:i,originY:s}=this;if(e){const{x:r,y:o}=this.getRelativeCenterPoint();this.originX=V,this.originY=V,this.left=r,this.top=o}if(this.set("angle",t),e){const{x:r,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=r,this.top=o,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Gr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Ue().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce(((i,s)=>{let[r,o]=s;return i[r]=this._animate(r,o,e),i}),{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),r=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=y(y({},i),{},{target:this,startValue:a??s.reduce(((d,u)=>d[u]),this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(d,u,p)=>{s.reduce(((g,f,b)=>(b===s.length-1&&(g[f]=d),g[f])),this),l&&l(d,u,p)},onComplete:(d,u,p)=>{this.setCoords(),c&&c(d,u,p)}});return r?lf(h):Wc(h)}isDescendantOf(t){const{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),i=t.getAncestors();if(e.length===0&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let s,r=0;r<e.length;r++){if(s=e[r],s===t)return{fork:[this,...e.slice(0,r)],otherFork:[],common:e.slice(r)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(s===i[o])return{fork:[this,...e.slice(0,r)],otherFork:[t,...i.slice(0,o)],common:e.slice(r)}}}return{fork:[this,...e],otherFork:[t,...i],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const i=e.common[0]||this.canvas;if(!i)return;const s=e.fork.pop(),r=e.otherFork.pop(),o=i._objects.indexOf(s),a=i._objects.indexOf(r);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Rr.customProperties,this.constructor.customProperties||[]);let e;const i=W.NUM_FRACTION_DIGITS,{clipPath:s,fill:r,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:p,height:g,strokeWidth:f,strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:_,strokeUniform:x,strokeMiterLimit:S,scaleX:T,scaleY:O,angle:k,flipX:E,flipY:P,opacity:R,visible:L,backgroundColor:j,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:q,skewY:Q}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const N=Gt=>et(Gt,i),kt=y(y({},fs(this,t)),{},{type:this.constructor.type,version:lo,originX:d,originY:u,left:N(c),top:N(h),width:N(p),height:N(g),fill:Za(r)?r.toObject():r,stroke:Za(o)?o.toObject():o,strokeWidth:N(f),strokeDashArray:l&&l.concat(),strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:_,strokeUniform:x,strokeMiterLimit:N(S),scaleX:N(T),scaleY:N(O),angle:N(k),flipX:E,flipY:P,opacity:N(R),shadow:a&&a.toObject(),visible:L,backgroundColor:j,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:N(q),skewY:N(Q)},e?{clipPath:e}:null);return this.includeDefaultValues?kt:this._removeDefaultValues(kt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Vo(t,((s,r)=>{if(r===Y||r===se||r==="type")return!0;const o=i[r];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)}))}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=ot(t,hf),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,r=ot(i,df);return mn(e,r).then((o=>s?(delete o[s],new this(e[s],o)):new this(o)))}static fromObject(t,e){return this._fromObject(t,e)}};v(qe,"stateProperties",Kg),v(qe,"cacheProperties",ci),v(qe,"ownDefaults",Zg),v(qe,"type","FabricObject"),v(qe,"colorProperties",[Mt,ne,"backgroundColor"]),v(qe,"customProperties",[]),D.setClass(qe),D.setClass(qe,"object");const ms=(n,t,e)=>(i,s,r,o)=>{const a=t(i,s,r,o);return a&&Ic(n,y(y({},Fc(i,s,r,o)),e)),a};function bs(n){return(t,e,i,s)=>{const{target:r,originX:o,originY:a}=e,l=r.getRelativeCenterPoint(),c=r.translateToOriginPoint(l,o,a),h=n(t,e,i,s);return r.setPositionByOrigin(c,e.originX,e.originY),h}}const pl=ms(Gs,bs(((n,t,e,i)=>{const s=Uo(t,t.originX,t.originY,e,i);if(Pt(t.originX)===Pt(V)||Pt(t.originX)===Pt(wt)&&s.x<0||Pt(t.originX)===Pt(Y)&&s.x>0){const{target:r}=t,o=r.strokeWidth/(r.strokeUniform?r.scaleX:1),a=Lc(t)?2:1,l=r.width,c=Math.abs(s.x*a/r.scaleX)-o;return r.set("width",Math.max(c,1)),l!==r.width}return!1})));function uf(n,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?ne:Mt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,d=t,u=e;n.save(),n.fillStyle=i.cornerColor||s.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r>o?(h=r,n.scale(1,o/r),u=e*r/o):o>r?(h=o,n.scale(r/o,1),d=t*o/r):h=r,n.beginPath(),n.arc(d,u,h/2,0,Nr,!1),n[l](),c&&n.stroke(),n.restore()}function pf(n,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?ne:Mt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=r/2,d=o/2;n.save(),n.fillStyle=i.cornerColor||s.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",n.translate(t,e);const u=s.getTotalAngle();n.rotate(Ct(u)),n["".concat(l,"Rect")](-h,-d,r,o),c&&n.strokeRect(-h,-d,r,o),n.restore()}class Ce{constructor(t){v(this,"visible",!0),v(this,"actionName",gn),v(this,"angle",0),v(this,"x",0),v(this,"y",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"sizeX",0),v(this,"sizeY",0),v(this,"touchSizeX",0),v(this,"touchSizeY",0),v(this,"cursorStyle","crosshair"),v(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var r;let{tl:o,tr:a,br:l,bl:c}=s;return((r=e.canvas)===null||r===void 0?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&ut.isPointInPolygon(i,[o,a,l,c])}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,s;return(i=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new w(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,r,o){const a=zo([ir(i,s),gs({angle:t}),Ho((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new w(-.5,-.5).transform(a),tr:new w(.5,-.5).transform(a),br:new w(.5,.5).transform(a),bl:new w(-.5,.5).transform(a)}}render(t,e,i,s,r){((s=s||{}).cornerStyle||r.cornerStyle)==="circle"?uf.call(this,t,e,i,s,r):pf.call(this,t,e,i,s,r)}}const gf=(n,t,e)=>e.lockRotation?qr:t.cursorStyle,ff=ms(vc,bs(((n,t,e,i)=>{let{target:s,ex:r,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(Pe(s,"lockRotation"))return!1;const d=Math.atan2(o-h.y,r-h.x),u=Math.atan2(i-h.y,e-h.x);let p=li(u-d+a);if(s.snapAngle&&s.snapAngle>0){const f=s.snapAngle,b=s.snapThreshold||f,m=Math.ceil(p/f)*f,_=Math.floor(p/f)*f;Math.abs(p-_)<b?p=_:Math.abs(p-m)<b&&(p=m)}p<0&&(p=360+p),p%=360;const g=s.angle!==p;return s.angle=p,g})));function Gc(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Yc(n,t,e){const i=Pe(n,"lockScalingX"),s=Pe(n,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:r,height:o,strokeWidth:a}=n;return r===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const mf=["e","se","s","sw","w","nw","n","ne","e"],Ms=(n,t,e)=>{const i=Gc(n,e);if(Yc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return qr;const s=jc(e,t);return"".concat(mf[s],"-resize")};function Yo(n,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,o=s.by,a=Gc(n,r);let l,c,h,d,u,p;if(Yc(r,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Uo(t,t.originX,t.originY,e,i),u=o!=="y"?Math.sign(l.x||t.signX||1):1,p=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=u),t.signY||(t.signY=p),Pe(r,"lockScalingFlip")&&(t.signX!==u||t.signY!==p))return!1;if(d=r._getTransformedDimensions(),a&&!o){const b=Math.abs(l.x)+Math.abs(l.y),{original:m}=t,_=b/(Math.abs(d.x*m.scaleX/r.scaleX)+Math.abs(d.y*m.scaleY/r.scaleY));c=m.scaleX*_,h=m.scaleY*_}else c=Math.abs(l.x*r.scaleX/d.x),h=Math.abs(l.y*r.scaleY/d.y);Lc(t)&&(c*=2,h*=2),t.signX!==u&&o!=="y"&&(t.originX=el(t.originX),c*=-1,t.signX=u),t.signY!==p&&o!=="x"&&(t.originY=el(t.originY),h*=-1,t.signY=p)}const g=r.scaleX,f=r.scaleY;return o?(o==="x"&&r.set(ce,c),o==="y"&&r.set(_e,h)):(!Pe(r,"lockScalingX")&&r.set(ce,c),!Pe(r,"lockScalingY")&&r.set(_e,h)),g!==r.scaleX||f!==r.scaleY}const cr=ms(pn,bs(((n,t,e,i)=>Yo(n,t,e,i)))),bf=ms(pn,bs(((n,t,e,i)=>Yo(n,t,e,i,{by:"x"})))),vf=ms(pn,bs(((n,t,e,i)=>Yo(n,t,e,i,{by:"y"})))),yf=["target","ex","ey","skewingSide"],Un={x:{counterAxis:"y",scale:ce,skew:us,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:_e,skew:ps,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},_f=["ns","nesw","ew","nwse"],xf=(n,t,e)=>{if(t.x!==0&&Pe(e,"lockSkewingY")||t.y!==0&&Pe(e,"lockSkewingX"))return qr;const i=jc(e,t)%4;return"".concat(_f[i],"-resize")};function Xc(n,t,e,i,s){const{target:r}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Un[n];if(Pe(r,l))return!1;const{origin:d,flip:u}=Un[o],p=Pt(e[d])*(r[u]?-1:1),g=-Math.sign(p)*(r[h]?-1:1),f=.5*-((r[c]===0&&Uo(e,V,V,i,s)[n]>0||r[c]>0?1:-1)*g)+.5;return ms(yc,bs(((m,_,x,S)=>(function(T,O,k){let{target:E,ex:P,ey:R,skewingSide:L}=O,j=ot(O,yf);const{skew:H}=Un[T],M=k.subtract(new w(P,R)).divide(new w(E.scaleX,E.scaleY))[T],U=E[H],q=j[H],Q=Math.tan(Ct(q)),N=T==="y"?E._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:E._getTransformedDimensions({scaleX:1,scaleY:1}).y,kt=2*M*L/Math.max(N,1)+Q,Gt=li(Math.atan(kt));E.set(H,Gt);const Yt=U!==E[H];if(Yt&&T==="y"){const{skewX:Ie,scaleX:me}=E,jt=E._getTransformedDimensions({skewY:U}),Le=E._getTransformedDimensions(),he=Ie!==0?jt.x/Le.x:1;he!==1&&E.set(ce,he*me)}return Yt})(n,_,new w(x,S)))))(t,y(y({},e),{},{[a]:f,skewingSide:g}),i,s)}const wf=(n,t,e,i)=>Xc("x",n,t,e,i),Cf=(n,t,e,i)=>Xc("y",n,t,e,i);function yn(n,t){return n[t.canvas.altActionKey]}const hr=(n,t,e)=>{const i=yn(n,e);return t.x===0?i?us:_e:t.y===0?i?ps:ce:""},Qi=(n,t,e)=>yn(n,e)?xf(0,t,e):Ms(n,t,e),gl=(n,t,e,i)=>yn(n,t.target)?Cf(n,t,e,i):bf(n,t,e,i),fl=(n,t,e,i)=>yn(n,t.target)?wf(n,t,e,i):vf(n,t,e,i),qc=()=>({ml:new Ce({x:-.5,y:0,cursorStyleHandler:Qi,actionHandler:gl,getActionName:hr}),mr:new Ce({x:.5,y:0,cursorStyleHandler:Qi,actionHandler:gl,getActionName:hr}),mb:new Ce({x:0,y:.5,cursorStyleHandler:Qi,actionHandler:fl,getActionName:hr}),mt:new Ce({x:0,y:-.5,cursorStyleHandler:Qi,actionHandler:fl,getActionName:hr}),tl:new Ce({x:-.5,y:-.5,cursorStyleHandler:Ms,actionHandler:cr}),tr:new Ce({x:.5,y:-.5,cursorStyleHandler:Ms,actionHandler:cr}),bl:new Ce({x:-.5,y:.5,cursorStyleHandler:Ms,actionHandler:cr}),br:new Ce({x:.5,y:.5,cursorStyleHandler:Ms,actionHandler:cr}),mtr:new Ce({x:0,y:-.5,actionHandler:ff,cursorStyleHandler:gf,offsetY:-40,withConnection:!0,actionName:Ro})}),Sf=()=>({mr:new Ce({x:.5,y:0,actionHandler:pl,cursorStyleHandler:Qi,actionName:Gs}),ml:new Ce({x:-.5,y:0,actionHandler:pl,cursorStyleHandler:Qi,actionName:Gs})}),Tf=()=>y(y({},qc()),Sf());class Ks extends qe{static getDefaults(){return y(y({},super.getDefaults()),Ks.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ks.ownDefaults),this.setOptions(t)}static createControls(){return{controls:qc()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,s=e.action;if(this===i&&s&&s.startsWith(gn))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[r,o]=i[s],a=this.controls[r];if(a.shouldActivate(r,this,t,e?o.touchCorner:o.corner))return this.__corner=r,{key:r,control:a,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=ir(e.x,e.y),s=gs({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=Bt(i,s),o=Bt(t,r),a=Bt(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Yr(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl(((d,u)=>{const p=d.positionHandler(c,a,this,d);h[u]=Object.assign(p,this._calcCornerCoords(d,p))})),h}_calcCornerCoords(t,e){const i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(Ct(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=y({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=s.borderColor,this._setLineDash(t,s.borderDashArray),this.strokeBorders(t,e),s.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,r=y({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),a=r.hasBorders,l=r.hasControls,c=Bt(o,this.calcTransformMatrix()),h=Yr(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(Ct(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const r=No(this.width,this.height,fn(e)),o=this.isStrokeAccountedForInDimensions()?Bo:(this.strokeUniform?new w().scalarAdd(this.canvas?this.canvas.getZoom():1):new w(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=r.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl(((s,r)=>{s.withConnection&&s.getVisibility(this,r)&&(i=!0,t.moveTo(s.x*e.x,s.y*e.y),t.lineTo(s.x*e.x+s.offsetX,s.y*e.y+s.offsetY))})),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:r,cornerColor:o}=this,a=y({cornerStrokeColor:s,cornerDashArray:r,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}})),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach((e=>{let[i,s]=e;return this.setControlVisible(i,s)}))}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);const s=this.width+4,r=this.height+4;return e.clearRect(-s/2,-r/2,s,r),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function Kc(n,t){return t.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((i=>{i!=="constructor"&&Object.defineProperty(n.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}))})),n}v(Ks,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Nt extends Ks{}Kc(Nt,[$c]),D.setClass(Nt),D.setClass(Nt,"object");const Ef=(n,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:r}=n.getImageData(t-i,e-i,s,s);for(let o=3;o<r.length;o+=4)if(r[o]>0)return!1;return!0};class Zc{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new w(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new w(1/this.options.scaleX,1/this.options.scaleY):new w(1,1)}createSideVector(t,e){const i=po(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new w(t);return e.y+=e.x*Math.tan(Ct(this.options.skewY)),e.x+=e.y*Math.tan(Ct(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const kf=new w;class ns extends Zc{static getOrthogonalRotationFactor(t,e){const i=e?fo(t,e):Xg(t);return Math.abs(i)<er?-1:1}constructor(t,e,i,s){super(s),v(this,"AB",void 0),v(this,"AC",void 0),v(this,"alpha",void 0),v(this,"bisector",void 0),this.A=new w(t),this.B=new w(e),this.C=new w(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=fo(this.AB,this.AC),this.bisector=Wo(Nc(this.AB.eq(kf)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),r=Uc(s),o=ns.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,i*o)}projectBevel(){const t=[];return(this.alpha%Nr==0?[this.B]:[this.B,this.C]).forEach((e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))})),t}projectMiter(){const t=[],e=Math.abs(this.alpha),i=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),r=this.options.strokeUniform?go(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return go(s)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new w(ns.getOrthogonalRotationFactor(this.bisector),ns.getOrthogonalRotationFactor(new w(this.bisector.y,this.bisector.x)));return[new w(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new w(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach((r=>{hl(r,t,e)&&i.push(this.A.add(r))})),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:r,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new w(Math.tan(Ct(s)),Math.tan(Ct(r))),h=this.strokeProjectionMagnitude,d=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),u=new w(Math.sqrt(Math.max(h**2-d**2,0)),d),p=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),g=new w(p,Math.sqrt(Math.max(h**2-p**2,0)));return[g,g.scalarMultiply(-1),u,u.scalarMultiply(-1)].map((f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f))).forEach((f=>{hl(f,t,e)&&i.push(this.applySkew(this.A).add(f))})),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Nr==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),r=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=zs(s,o)>0,l=a?s:r,c=a?r:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector})))}}class ml extends Zc{constructor(t,e,i){super(i),this.A=new w(t),this.T=new w(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(Uc(s),i)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new w(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new ns(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new w(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(Wo(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map((e=>this.applySkew(e)))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t})))}}const Of=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(n.length===0)return i;const s=n.reduce(((r,o)=>(r[r.length-1].eq(o)||r.push(new w(o)),r)),[new w(n[0])]);if(s.length===1)e=!0;else if(!e){const r=s[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,(a=>!a.eq(r)));s.splice(o+1)}return s.forEach(((r,o,a)=>{let l,c;o===0?(c=a[1],l=e?r:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?r:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new ml(r,r,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new ns(r,l,c,t).project()):i.push(...new ml(r,o===0?c:l,t).project())})),i},Xo=n=>{const t={};return Object.keys(n).forEach((e=>{t[e]={},Object.keys(n[e]).forEach((i=>{t[e][i]=y({},n[e][i])}))})),t},Pf=n=>n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let Os;const qo=n=>{if(Os||Os||(Os="Intl"in un()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),Os){const t=Os.segment(n);return Array.from(t).map((e=>{let{segment:i}=e;return i}))}return Df(n)},Df=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=Af(n,i))!==!1&&t.push(e);return t},Af=(n,t)=>{const e=n.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return n.charAt(t);if(55296<=e&&e<=56319){if(n.length<=t+1)throw"High surrogate without following low surrogate";const s=n.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return n.charAt(t)+n.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=n.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},Ko=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return n.fill!==t.fill||n.stroke!==t.stroke||n.strokeWidth!==t.strokeWidth||n.fontSize!==t.fontSize||n.fontFamily!==t.fontFamily||n.fontWeight!==t.fontWeight||n.fontStyle!==t.fontStyle||n.textDecorationThickness!==t.textDecorationThickness||n.textBackgroundColor!==t.textBackgroundColor||n.deltaY!==t.deltaY||e&&(n.overline!==t.overline||n.underline!==t.underline||n.linethrough!==t.linethrough)},Mf=(n,t)=>{const e=t.split(`
3299
- `),i=[];let s=-1,r={};n=Xo(n);for(let o=0;o<e.length;o++){const a=qo(e[o]);if(n[o])for(let l=0;l<a.length;l++){s++;const c=n[o][l];c&&Object.keys(c).length>0&&(Ko(r,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),r=c||{}}else s+=a.length,r={}}return i},If=(n,t)=>{if(!Array.isArray(n))return Xo(n);const e=t.split($o),i={};let s=-1,r=0;for(let o=0;o<e.length;o++){const a=qo(e[o]);for(let l=0;l<a.length;l++)s++,n[r]&&n[r].start<=s&&s<n[r].end&&(i[o]=i[o]||{},i[o][l]=y({},n[r].style),s===n[r].end-1&&r++)}return i},Ei=["display","transform",Mt,"fill-opacity","fill-rule","opacity",ne,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function bl(n,t){const e=n.nodeName,i=n.getAttribute("class"),s=n.getAttribute("id"),r="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),s&&t.length&&(o=new RegExp("#"+s+r,"i"),t=t.replace(o,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+r,"i"),t=t.replace(o,"")}return t.length===0}function Lf(n,t){let e=!0;const i=bl(n,t.pop());return i&&t.length&&(e=(function(s,r){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&r.length;)a&&(o=r.pop()),a=bl(s=s.parentElement,o);return r.length===0})(n,t)),i&&e&&t.length===0}const Ff=n=>{var t;return(t=Gg[n])!==null&&t!==void 0?t:n},jf=new RegExp("(".concat(ke,")"),"gi"),$f=n=>Kr(n.replace(jf," $1 ").replace(/,/gi," "));var vl,yl,_l,xl,wl,Cl,Sl;const Kt="(".concat(ke,")"),Rf=String.raw(vl||(vl=Ge(["(skewX)(",")"],["(skewX)\\(","\\)"])),Kt),Bf=String.raw(yl||(yl=Ge(["(skewY)(",")"],["(skewY)\\(","\\)"])),Kt),zf=String.raw(_l||(_l=Ge(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Kt,Kt,Kt),Hf=String.raw(xl||(xl=Ge(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Kt,Kt),Vf=String.raw(wl||(wl=Ge(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Kt,Kt),Nf=String.raw(Cl||(Cl=Ge(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Kt,Kt,Kt,Kt,Kt,Kt),Zo="(?:".concat(Nf,"|").concat(Vf,"|").concat(zf,"|").concat(Hf,"|").concat(Rf,"|").concat(Bf,")"),Uf="(?:".concat(Zo,"*)"),Wf=String.raw(Sl||(Sl=Ge(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Uf),Gf=new RegExp(Wf),Yf=new RegExp(Zo),Xf=new RegExp(Zo,"g");function mo(n){const t=[];if(!(n=$f(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!Gf.test(n))return[...Zt];for(const e of n.matchAll(Xf)){const i=Yf.exec(e[0]);if(!i)continue;let s=Zt;const r=i.filter((g=>!!g)),[,o,...a]=r,[l,c,h,d,u,p]=a.map((g=>parseFloat(g)));switch(o){case"translate":s=ir(l,c);break;case Ro:s=gs({angle:l},{x:c,y:h});break;case gn:s=Ho(l,c);break;case us:s=Ec(l);break;case ps:s=kc(l);break;case"matrix":s=[l,c,h,d,u,p]}t.push(s)}return zo(t)}function qf(n,t,e,i){const s=Array.isArray(t);let r,o=t;if(n!==Mt&&n!==ne||t!==re){if(n==="strokeUniform")return t==="non-scaling-stroke";if(n==="strokeDashArray")o=t===re?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(n==="transformMatrix")o=e&&e.transformMatrix?Bt(e.transformMatrix,mo(t)):mo(t);else if(n==="visible")o=t!==re&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(n==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(n==="textAnchor")o=t==="start"?Y:t==="end"?wt:V;else if(n==="charSpacing"||n===Vi)r=rs(t,i)/i*1e3;else if(n==="paintFirst"){const a=t.indexOf(Mt),l=t.indexOf(ne);o=Mt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=ne)}else{if(n==="href"||n==="xlink:href"||n==="font"||n==="id")return t;if(n==="imageSmoothing")return t==="optimizeQuality";r=s?t.map(rs):rs(t,i)}}else o="";return!s&&isNaN(r)?o:r}function Kf(n,t){const e=n.match(Wg);if(!e)return;const i=e[1],s=e[3],r=e[4],o=e[5],a=e[6];i&&(t.fontStyle=i),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),r&&(t.fontSize=rs(r)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function Zf(n,t){n.replace(/;\s*$/,"").split(";").forEach((e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()}))}function Jf(n){const t={},e=n.getAttribute("style");return e&&(typeof e=="string"?Zf(e,t):(function(i,s){Object.entries(i).forEach((r=>{let[o,a]=r;a!==void 0&&(s[o.toLowerCase()]=a)}))})(e,t)),t}const Qf={stroke:"strokeOpacity",fill:"fillOpacity"};function hi(n,t,e){if(!n)return{};let i,s={},r=jo;n.parentNode&&cl.test(n.parentNode.nodeName)&&(s=hi(n.parentElement,t,e),s.fontSize&&(i=r=rs(s.fontSize)));const o=y(y(y({},t.reduce(((c,h)=>{const d=n.getAttribute(h);return d&&(c[h]=d),c}),{})),(function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d={};for(const u in h)Lf(c,u.split(" "))&&(d=y(y({},d),h[u]));return d})(n,e)),Jf(n));o[Vn]&&n.setAttribute(Vn,o[Vn]),o[Hn]&&(i=rs(o[Hn],r),o[Hn]="".concat(i));const a={};for(const c in o){const h=Ff(c),d=qf(h,o[c],s,i);a[h]=d}a&&a.font&&Kf(a.font,a);const l=y(y({},s),a);return cl.test(n.nodeName)?l:(function(c){const h=Nt.getDefaults();return Object.entries(Qf).forEach((d=>{let[u,p]=d;if(c[p]===void 0||c[u]==="")return;if(c[u]===void 0){if(!h[u])return;c[u]=h[u]}if(c[u].indexOf("url(")===0)return;const g=new K(c[u]);c[u]=g.setAlpha(et(g.getAlpha()*c[p],2)).toRgba()})),c})(l)}const tm=["left","top","width","height","visible"],Jc=["rx","ry"];class ie extends Nt{static getDefaults(){return y(y({},super.getDefaults()),ie.ownDefaults)}constructor(t){super(),Object.assign(this,ie.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:i}=this,s=-e/2,r=-i/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,i/2):0,l=o!==0||a!==0;t.beginPath(),t.moveTo(s+o,r),t.lineTo(s+e-o,r),l&&t.bezierCurveTo(s+e-ui*o,r,s+e,r+ui*a,s+e,r+a),t.lineTo(s+e,r+i-a),l&&t.bezierCurveTo(s+e,r+i-ui*a,s+e-ui*o,r+i,s+e-o,r+i),t.lineTo(s+o,r+i),l&&t.bezierCurveTo(s+ui*o,r+i,s,r+i-ui*a,s,r+i-a),t.lineTo(s,r+a),l&&t.bezierCurveTo(s,r+ui*a,s+ui*o,r,s+o,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Jc,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,`" />
3300
- `)]}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=ot(s,tm);return new this(y(y(y({},e),h),{},{left:r,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}v(ie,"type","Rect"),v(ie,"cacheProperties",[...ci,...Jc]),v(ie,"ownDefaults",{rx:0,ry:0}),v(ie,"ATTRIBUTE_NAMES",[...Ei,"x","y","rx","ry","width","height"]),D.setClass(ie),D.setSVGClass(ie);const Qe="initialization",Jr="added",Jo="removed",Qr="imperative",Qc=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:r,group:o}=t,a=o&&o!==n?bn(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?Rg(new w(i,i),void 0,n.calcTransformMatrix()):Bo,d=!e&&c?i:0,u=No(s+d,r+d,zo([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class _n{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===Qe||e===Qr||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Qe&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Qr&&e.overrides)return e.overrides;if(t.length===0)return;const{left:r,top:o,width:a,height:l}=ei(t.map((d=>Qc(s,d))).reduce(((d,u)=>d.concat(u)),[])),c=new w(a,l),h=new w(r,o).add(c.scalarDivide(2));if(i===Qe){const d=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new w(0,0),size:d}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(_n,"type","strategy");class bo extends _n{shouldPerformLayout(t){return!0}}v(bo,"type","fit-content"),D.setClass(bo);const em=["strategy"],im=["target","strategy","bubbles","prevStrategy"],th="layoutManager";class Zs{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new bo;v(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=y(y({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:i}=e;return[Wr,bc,Gs,vc,pn,yc,Ur,Cg,Sg].map((s=>t.on(s,(r=>this.performLayout(s===Wr?{type:"object_modified",trigger:s,e:r,target:i}:{type:"object_modifying",trigger:s,e:r,target:i})))))}subscribe(t,e){this.unsubscribe(t,e);const i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach((i=>i())),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach((e=>this.unsubscribe(e,t)))}subscribeTargets(t){t.targets.forEach((e=>this.subscribe(e,t)))}onBeforeLayout(t){const{target:e,type:i}=t,{canvas:s}=e;if(i===Qe||i===Jr?this.subscribeTargets(t):i===Jo&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Qr&&t.deep){const r=ot(t,em);e.forEachObject((o=>o.layoutManager&&o.layoutManager.performLayout(y(y({},r),{},{bubbles:!1,target:o}))))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,r=i.calcLayoutResult(t,e.getObjects());if(!r)return;const o=s===Qe?new w:e.getRelativeCenterPoint(),{center:a,correction:l=new w,relativeCorrection:c=new w}=r,h=o.subtract(a).add(l).transform(s===Qe?Zt:Ee(e.calcOwnMatrix()),!0).add(c);return{result:r,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:r}=e;var o,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===Qe?i.set({left:(o=t.x)!==null&&o!==void 0?o:r.x+s.x*Pt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:r.y+s.y*Pt(i.originY)}):(i.setPositionByOrigin(r,V,V),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject((s=>{s.group===i&&this.layoutObject(t,e,s)})),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:s}=e;i.set({left:i.left+s.x,top:i.top+s.y})}onAfterLayout(t,e){const{target:i,strategy:s,bubbles:r,prevStrategy:o}=t,a=ot(t,im),{canvas:l}=i;i.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:i});const c=i.parent;r&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(y(y({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((e=>e.forEach((i=>i())))),t.clear()}toObject(){return{type:th,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}D.setClass(Zs,th);const sm=["type","objects","layoutManager"];class rm extends Zs{performLayout(){}}class _i extends _c(Nt){static getDefaults(){return y(y({},super.getDefaults()),_i.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"_activeObjects",[]),v(this,"__objectSelectionTracker",void 0),v(this,"__objectSelectionDisposer",void 0),Object.assign(this,_i.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject((s=>{this.enterGroup(s,!1)})),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Zs,this.layoutManager.performLayout({type:Qe,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(wi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(wi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter(((e,i,s)=>this.canEnterGroup(e)&&s.indexOf(e)===i))}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(e),r=super.add(...s);return this._onAfterObjectsChange(Jr,s),r}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...r);return this._onAfterObjectsChange(Jr,r),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Jo,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const i=this[t];return super._set(t,e),t==="canvas"&&i!==e&&(this._objects||[]).forEach((s=>{s._set(t,e)})),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const r=s.indexOf(i);r>-1&&(s.splice(r,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Xr(t,Bt(Ee(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Xr(t,Bt(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){const t=Nt.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let r=0;r<this._objects.length;r++){var s;const o=this._objects[r];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Ee(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject((t=>t.setCoords()))}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(y({target:this,type:Qr},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter((function(s){return!s.excludeFromExport})).map((function(s){const r=s.includeDefaultValues;s.includeDefaultValues=i;const o=s[t||"toObject"](e);return s.includeDefaultValues=r,o}))}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return y(y(y({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject((t=>{this._watchObject(!1,t),t.dispose()})),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=ie.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
3298
+ `)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=ii.ownDefaults;return this.includeDefaultValues?t:Vo(t,((i,s)=>i!==e[s]))}static async fromObject(t){return new this(t)}}v(ii,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(ii,"type","shadow"),D.setClass(ii,"shadow");const ls=(n,t,e)=>Math.max(n,Math.min(t,e)),Jg=[ne,Y,ce,_e,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",us,ps],ci=[Mt,ae,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Qg={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:Y,originY:ne,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Mt,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},tf=(n,t,e,i)=>-e*Math.cos(n/i*er)+e+t,ef=()=>!1;class Go{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:o=tf,onStart:a=Lr,onChange:l=Lr,onComplete:c=Lr,abort:h=ef,target:d}=t;v(this,"_state","pending"),v(this,"durationProgress",0),v(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=r,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=d,this.startValue=e,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout((()=>jr(t)),this.delay):jr(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:s,valueProgress:r}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=r,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),jr(this.tick)))}register(){Gr.push(this)}unregister(){Gr.remove(this)}abort(){this._state="aborted",this.unregister()}}const sf=["startValue","endValue"];class rf extends Go{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(_(_({},ot(t,sf)),{},{startValue:e,byValue:i-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const nf=["startValue","endValue"];class of extends Go{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(_(_({},ot(t,nf)),{},{startValue:e,byValue:i.map(((s,r)=>s-e[r]))}))}calculate(t){const e=this.startValue.map(((i,s)=>this.easing(t,i,this.byValue[s],this.duration,s)));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const af=["startValue","endValue","easing","onChange","onComplete","abort"],lf=(n,t,e,i)=>t+e*(1-Math.cos(n/i*er)),Nn=n=>n&&((t,e,i)=>n(new K(t).toRgba(),e,i));class cf extends Go{constructor(t){let{startValue:e,endValue:i,easing:s=lf,onChange:r,onComplete:o,abort:a}=t,l=ot(t,af);const c=new K(e).getSource(),h=new K(i).getSource();super(_(_({},l),{},{startValue:c,byValue:h.map(((d,u)=>d-c[u])),easing:s,onChange:Nn(r),onComplete:Nn(o),abort:Nn(a)}))}calculate(t){const[e,i,s,r]=this.startValue.map(((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l))),o=[...[e,i,s].map(Math.round),ls(0,r,1)];return{value:o,valueProgress:o.map(((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0)).find((a=>a!==0))||0}}}function Wc(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new of(n):new rf(n);return t.start(),t}function hf(n){const t=new cf(n);return t.start(),t}class ut{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some((e=>e.eq(t)))}append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.points=this.points.concat(e.filter((s=>!this.includes(s)))),this}static isPointContained(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(i))return t.eq(e);if(e.x===i.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const r=po(e,i),o=po(e,t).divide(r);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const i=new x(t).setX(Math.min(t.x-1,...e.map((r=>r.x))));let s=0;for(let r=0;r<e.length;r++){const o=this.intersectSegmentSegment(e[r],e[(r+1)%e.length],t,i);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,i,s){let r=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-i.x,h=s.y-i.y,d=t.x-i.x,u=t.y-i.y,p=c*u-h*d,g=a*u-l*d,f=h*a-c*l;if(f!==0){const b=p/f,m=g/f;return(r||0<=b&&b<=1)&&(o||0<=m&&m<=1)?new ut("Intersection").append(new x(t.x+b*a,t.y+b*l)):new ut}if(p===0||g===0){const b=r||o||ut.isPointContained(t,i,s)||ut.isPointContained(e,i,s)||ut.isPointContained(i,t,e)||ut.isPointContained(s,t,e);return new ut(b?"Coincident":void 0)}return new ut("Parallel")}static intersectSegmentLine(t,e,i,s){return ut.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return ut.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const r=new ut,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=ut.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;r.append(...c.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,i){return ut.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new ut,s=t.length,r=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=ut.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(r.push(c),i.append(a,l)):i.append(...c.points)}return r.length>0&&r.length===t.length?new ut("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),r=e.max(i),o=new x(r.x,s.y),a=new x(s.x,r.y);return ut.intersectPolygonPolygon(t,[s,o,r,a])}}class df extends xc{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?ie(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=ie(t,Ee(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:i,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),r=[t,e,i,s];if(this.group){const o=this.group.calcTransformMatrix();return r.map((a=>ie(a,o)))}return r}intersectsWithRect(t,e){return ut.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ut.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every((e=>t.containsPoint(e)))}isContainedWithinRect(t,e){const{left:i,top:s,width:r,height:o}=this.getBoundingRect();return i>=t.x&&i+r<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return ut.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some((i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.y>=t.y))||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every((i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y)))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return ei(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(ce,t),this._set(_e,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?li(Sc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Qt.concat()}calcACoords(){const t=gs({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=ir(e,i),r=Bt(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:ie({x:-a,y:-l},r),tr:ie({x:a,y:-l},r),bl:ie({x:-a,y:l},r),br:ie({x:a,y:l},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Pt(this.originX),Pt(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every(((r,o)=>r===i[o]))?s.value:(this.group&&(e=Bt(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const i=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},r=Mg(s);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,r=0;this.strokeUniform&&(s=0,r=i);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new x(o*e.scaleX,a*e.scaleY):No(o,a,fn(e)),l.scalarAdd(r)}translateToGivenOrigin(t,e,i,s,r){let o=t.x,a=t.y;const l=Pt(s)-Pt(e),c=Pt(r)-Pt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new x(o,a)}translateToCenterPoint(t,e,i){if(e===V&&i===V)return t;const s=this.translateToGivenOrigin(t,e,i,V,V);return this.angle?s.rotate(Ct(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,V,V,e,i);return this.angle?s.rotate(Ct(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?ie(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const s=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:r.x,top:r.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Y,ne)}}const uf=["type"],pf=["extraParam"];let qe=class Rr extends df{static getDefaults(){return Rr.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){Ci("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,Rr.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ai(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=W.maxCacheSideLimit,r=W.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=W.perfLimitSizeTotal)return e<r&&(t.width=r),i<r&&(t.height=r),t;const o=e/i,[a,l]=$s.limitDimsByArea(o),c=ls(r,a,s),h=ls(r,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),i>h&&(t.zoomY/=i/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:i,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:s,zoomX:r,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==r||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||s!==t.height?(t.width=i,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const d=a/2,u=l/2;return this.cacheTranslationX=Math.round(t.width/2-d)+d,this.cacheTranslationY=Math.round(t.height/2-u)+u,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,o),this.zoomX=r,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Yr(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==ce&&t!==_e||(e=this._constrainScale(e)),t===ce&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ii||(e=new ii(e));const i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===ae&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){const s=this.fill,r=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=s,this.stroke=r}createClipPathLayer(t,e){const i=xe(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach((r=>{r.transform(s)})),e.parentClipPaths.push(t),t.absolutePositioned){const r=Ee(this.calcTransformMatrix());s.transform(r[0],r[1],r[2],r[3],r[4],r[5])}return t.transform(s),t.drawObject(s,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,s)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,ve(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:i}=e;i&&(ve(i)?(t.fillStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.fillStyle=i)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[r,,,o]=(i==null?void 0:i.viewportTransform)||Qt,a=r*s,l=o*s,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*W.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!ve(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,s,r):t.transform(1,0,0,1,s,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:r}}_renderPaintInOrder(t){this.paintFirst===ae?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/r,a=s.y/this.scaleY/r,l=xe({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(s.zoomX/this.scaleX/r,s.zoomY/this.scaleY/r),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(r*this.scaleX/s.zoomX,r*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(D.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Mc(this),i=this.group,s=this.shadow,r=Math.abs,o=t.enableRetinaScaling?mc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(y=>new sr(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Bg(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Hg(this,this.getViewportTransform()),this.setCoords();const c=ai(),h=this.getBoundingRect(),d=this.shadow,u=new x;if(d){const y=d.blur,w=d.nonScaling?new x(1,1):this.getObjectScaling();u.x=2*Math.round(r(d.offsetX)+y)*r(w.x),u.y=2*Math.round(r(d.offsetY)+y)*r(w.y)}const p=h.width+u.x,g=h.height+u.y;c.width=Math.ceil(p),c.height=Math.ceil(g);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new x(f.width/2,f.height/2),V,V);const b=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const m=f.toCanvasElement(a||1,t);return this.set("canvas",b),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),m}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return wc(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Cc(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:i,originY:s}=this;if(e){const{x:r,y:o}=this.getRelativeCenterPoint();this.originX=V,this.originY=V,this.left=r,this.top=o}if(this.set("angle",t),e){const{x:r,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=r,this.top=o,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Gr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Ue().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce(((i,s)=>{let[r,o]=s;return i[r]=this._animate(r,o,e),i}),{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),r=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=_(_({},i),{},{target:this,startValue:a??s.reduce(((d,u)=>d[u]),this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(d,u,p)=>{s.reduce(((g,f,b)=>(b===s.length-1&&(g[f]=d),g[f])),this),l&&l(d,u,p)},onComplete:(d,u,p)=>{this.setCoords(),c&&c(d,u,p)}});return r?hf(h):Wc(h)}isDescendantOf(t){const{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),i=t.getAncestors();if(e.length===0&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let s,r=0;r<e.length;r++){if(s=e[r],s===t)return{fork:[this,...e.slice(0,r)],otherFork:[],common:e.slice(r)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(s===i[o])return{fork:[this,...e.slice(0,r)],otherFork:[t,...i.slice(0,o)],common:e.slice(r)}}}return{fork:[this,...e],otherFork:[t,...i],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const i=e.common[0]||this.canvas;if(!i)return;const s=e.fork.pop(),r=e.otherFork.pop(),o=i._objects.indexOf(s),a=i._objects.indexOf(r);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Rr.customProperties,this.constructor.customProperties||[]);let e;const i=W.NUM_FRACTION_DIGITS,{clipPath:s,fill:r,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:p,height:g,strokeWidth:f,strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:y,strokeUniform:w,strokeMiterLimit:S,scaleX:T,scaleY:k,angle:O,flipX:E,flipY:P,opacity:R,visible:L,backgroundColor:j,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:q,skewY:Q}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const N=Yt=>et(Yt,i),kt=_(_({},fs(this,t)),{},{type:this.constructor.type,version:lo,originX:d,originY:u,left:N(c),top:N(h),width:N(p),height:N(g),fill:Za(r)?r.toObject():r,stroke:Za(o)?o.toObject():o,strokeWidth:N(f),strokeDashArray:l&&l.concat(),strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:y,strokeUniform:w,strokeMiterLimit:N(S),scaleX:N(T),scaleY:N(k),angle:N(O),flipX:E,flipY:P,opacity:N(R),shadow:a&&a.toObject(),visible:L,backgroundColor:j,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:N(q),skewY:N(Q)},e?{clipPath:e}:null);return this.includeDefaultValues?kt:this._removeDefaultValues(kt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Vo(t,((s,r)=>{if(r===Y||r===ne||r==="type")return!0;const o=i[r];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)}))}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=ot(t,uf),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,r=ot(i,pf);return mn(e,r).then((o=>s?(delete o[s],new this(e[s],o)):new this(o)))}static fromObject(t,e){return this._fromObject(t,e)}};v(qe,"stateProperties",Jg),v(qe,"cacheProperties",ci),v(qe,"ownDefaults",Qg),v(qe,"type","FabricObject"),v(qe,"colorProperties",[Mt,ae,"backgroundColor"]),v(qe,"customProperties",[]),D.setClass(qe),D.setClass(qe,"object");const ms=(n,t,e)=>(i,s,r,o)=>{const a=t(i,s,r,o);return a&&Ic(n,_(_({},Fc(i,s,r,o)),e)),a};function bs(n){return(t,e,i,s)=>{const{target:r,originX:o,originY:a}=e,l=r.getRelativeCenterPoint(),c=r.translateToOriginPoint(l,o,a),h=n(t,e,i,s);return r.setPositionByOrigin(c,e.originX,e.originY),h}}const pl=ms(Gs,bs(((n,t,e,i)=>{const s=Uo(t,t.originX,t.originY,e,i);if(Pt(t.originX)===Pt(V)||Pt(t.originX)===Pt(wt)&&s.x<0||Pt(t.originX)===Pt(Y)&&s.x>0){const{target:r}=t,o=r.strokeWidth/(r.strokeUniform?r.scaleX:1),a=Lc(t)?2:1,l=r.width,c=Math.abs(s.x*a/r.scaleX)-o;return r.set("width",Math.max(c,1)),l!==r.width}return!1})));function gf(n,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?ae:Mt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,d=t,u=e;n.save(),n.fillStyle=i.cornerColor||s.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r>o?(h=r,n.scale(1,o/r),u=e*r/o):o>r?(h=o,n.scale(r/o,1),d=t*o/r):h=r,n.beginPath(),n.arc(d,u,h/2,0,Nr,!1),n[l](),c&&n.stroke(),n.restore()}function ff(n,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?ae:Mt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=r/2,d=o/2;n.save(),n.fillStyle=i.cornerColor||s.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",n.translate(t,e);const u=s.getTotalAngle();n.rotate(Ct(u)),n["".concat(l,"Rect")](-h,-d,r,o),c&&n.strokeRect(-h,-d,r,o),n.restore()}class Ce{constructor(t){v(this,"visible",!0),v(this,"actionName",gn),v(this,"angle",0),v(this,"x",0),v(this,"y",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"sizeX",0),v(this,"sizeY",0),v(this,"touchSizeX",0),v(this,"touchSizeY",0),v(this,"cursorStyle","crosshair"),v(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var r;let{tl:o,tr:a,br:l,bl:c}=s;return((r=e.canvas)===null||r===void 0?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&ut.isPointInPolygon(i,[o,a,l,c])}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,s;return(i=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,r,o){const a=zo([ir(i,s),gs({angle:t}),Ho((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}render(t,e,i,s,r){((s=s||{}).cornerStyle||r.cornerStyle)==="circle"?gf.call(this,t,e,i,s,r):ff.call(this,t,e,i,s,r)}}const mf=(n,t,e)=>e.lockRotation?qr:t.cursorStyle,bf=ms(vc,bs(((n,t,e,i)=>{let{target:s,ex:r,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(Pe(s,"lockRotation"))return!1;const d=Math.atan2(o-h.y,r-h.x),u=Math.atan2(i-h.y,e-h.x);let p=li(u-d+a);if(s.snapAngle&&s.snapAngle>0){const f=s.snapAngle,b=s.snapThreshold||f,m=Math.ceil(p/f)*f,y=Math.floor(p/f)*f;Math.abs(p-y)<b?p=y:Math.abs(p-m)<b&&(p=m)}p<0&&(p=360+p),p%=360;const g=s.angle!==p;return s.angle=p,g})));function Gc(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Yc(n,t,e){const i=Pe(n,"lockScalingX"),s=Pe(n,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:r,height:o,strokeWidth:a}=n;return r===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const vf=["e","se","s","sw","w","nw","n","ne","e"],Ms=(n,t,e)=>{const i=Gc(n,e);if(Yc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return qr;const s=jc(e,t);return"".concat(vf[s],"-resize")};function Yo(n,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,o=s.by,a=Gc(n,r);let l,c,h,d,u,p;if(Yc(r,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Uo(t,t.originX,t.originY,e,i),u=o!=="y"?Math.sign(l.x||t.signX||1):1,p=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=u),t.signY||(t.signY=p),Pe(r,"lockScalingFlip")&&(t.signX!==u||t.signY!==p))return!1;if(d=r._getTransformedDimensions(),a&&!o){const b=Math.abs(l.x)+Math.abs(l.y),{original:m}=t,y=b/(Math.abs(d.x*m.scaleX/r.scaleX)+Math.abs(d.y*m.scaleY/r.scaleY));c=m.scaleX*y,h=m.scaleY*y}else c=Math.abs(l.x*r.scaleX/d.x),h=Math.abs(l.y*r.scaleY/d.y);Lc(t)&&(c*=2,h*=2),t.signX!==u&&o!=="y"&&(t.originX=el(t.originX),c*=-1,t.signX=u),t.signY!==p&&o!=="x"&&(t.originY=el(t.originY),h*=-1,t.signY=p)}const g=r.scaleX,f=r.scaleY;return o?(o==="x"&&r.set(ce,c),o==="y"&&r.set(_e,h)):(!Pe(r,"lockScalingX")&&r.set(ce,c),!Pe(r,"lockScalingY")&&r.set(_e,h)),g!==r.scaleX||f!==r.scaleY}const cr=ms(pn,bs(((n,t,e,i)=>Yo(n,t,e,i)))),yf=ms(pn,bs(((n,t,e,i)=>Yo(n,t,e,i,{by:"x"})))),_f=ms(pn,bs(((n,t,e,i)=>Yo(n,t,e,i,{by:"y"})))),xf=["target","ex","ey","skewingSide"],Un={x:{counterAxis:"y",scale:ce,skew:us,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:_e,skew:ps,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},wf=["ns","nesw","ew","nwse"],Cf=(n,t,e)=>{if(t.x!==0&&Pe(e,"lockSkewingY")||t.y!==0&&Pe(e,"lockSkewingX"))return qr;const i=jc(e,t)%4;return"".concat(wf[i],"-resize")};function Xc(n,t,e,i,s){const{target:r}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Un[n];if(Pe(r,l))return!1;const{origin:d,flip:u}=Un[o],p=Pt(e[d])*(r[u]?-1:1),g=-Math.sign(p)*(r[h]?-1:1),f=.5*-((r[c]===0&&Uo(e,V,V,i,s)[n]>0||r[c]>0?1:-1)*g)+.5;return ms(yc,bs(((m,y,w,S)=>(function(T,k,O){let{target:E,ex:P,ey:R,skewingSide:L}=k,j=ot(k,xf);const{skew:H}=Un[T],M=O.subtract(new x(P,R)).divide(new x(E.scaleX,E.scaleY))[T],U=E[H],q=j[H],Q=Math.tan(Ct(q)),N=T==="y"?E._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:E._getTransformedDimensions({scaleX:1,scaleY:1}).y,kt=2*M*L/Math.max(N,1)+Q,Yt=li(Math.atan(kt));E.set(H,Yt);const Xt=U!==E[H];if(Xt&&T==="y"){const{skewX:Ie,scaleX:me}=E,jt=E._getTransformedDimensions({skewY:U}),Le=E._getTransformedDimensions(),he=Ie!==0?jt.x/Le.x:1;he!==1&&E.set(ce,he*me)}return Xt})(n,y,new x(w,S)))))(t,_(_({},e),{},{[a]:f,skewingSide:g}),i,s)}const Sf=(n,t,e,i)=>Xc("x",n,t,e,i),Tf=(n,t,e,i)=>Xc("y",n,t,e,i);function yn(n,t){return n[t.canvas.altActionKey]}const hr=(n,t,e)=>{const i=yn(n,e);return t.x===0?i?us:_e:t.y===0?i?ps:ce:""},Qi=(n,t,e)=>yn(n,e)?Cf(0,t,e):Ms(n,t,e),gl=(n,t,e,i)=>yn(n,t.target)?Tf(n,t,e,i):yf(n,t,e,i),fl=(n,t,e,i)=>yn(n,t.target)?Sf(n,t,e,i):_f(n,t,e,i),qc=()=>({ml:new Ce({x:-.5,y:0,cursorStyleHandler:Qi,actionHandler:gl,getActionName:hr}),mr:new Ce({x:.5,y:0,cursorStyleHandler:Qi,actionHandler:gl,getActionName:hr}),mb:new Ce({x:0,y:.5,cursorStyleHandler:Qi,actionHandler:fl,getActionName:hr}),mt:new Ce({x:0,y:-.5,cursorStyleHandler:Qi,actionHandler:fl,getActionName:hr}),tl:new Ce({x:-.5,y:-.5,cursorStyleHandler:Ms,actionHandler:cr}),tr:new Ce({x:.5,y:-.5,cursorStyleHandler:Ms,actionHandler:cr}),bl:new Ce({x:-.5,y:.5,cursorStyleHandler:Ms,actionHandler:cr}),br:new Ce({x:.5,y:.5,cursorStyleHandler:Ms,actionHandler:cr}),mtr:new Ce({x:0,y:-.5,actionHandler:bf,cursorStyleHandler:mf,offsetY:-40,withConnection:!0,actionName:Ro})}),Ef=()=>({mr:new Ce({x:.5,y:0,actionHandler:pl,cursorStyleHandler:Qi,actionName:Gs}),ml:new Ce({x:-.5,y:0,actionHandler:pl,cursorStyleHandler:Qi,actionName:Gs})}),kf=()=>_(_({},qc()),Ef());class Ks extends qe{static getDefaults(){return _(_({},super.getDefaults()),Ks.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ks.ownDefaults),this.setOptions(t)}static createControls(){return{controls:qc()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,s=e.action;if(this===i&&s&&s.startsWith(gn))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[r,o]=i[s],a=this.controls[r];if(a.shouldActivate(r,this,t,e?o.touchCorner:o.corner))return this.__corner=r,{key:r,control:a,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=ir(e.x,e.y),s=gs({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=Bt(i,s),o=Bt(t,r),a=Bt(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Yr(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl(((d,u)=>{const p=d.positionHandler(c,a,this,d);h[u]=Object.assign(p,this._calcCornerCoords(d,p))})),h}_calcCornerCoords(t,e){const i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(Ct(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=_({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=s.borderColor,this._setLineDash(t,s.borderDashArray),this.strokeBorders(t,e),s.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,r=_({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),a=r.hasBorders,l=r.hasControls,c=Bt(o,this.calcTransformMatrix()),h=Yr(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(Ct(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const r=No(this.width,this.height,fn(e)),o=this.isStrokeAccountedForInDimensions()?Bo:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=r.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl(((s,r)=>{s.withConnection&&s.getVisibility(this,r)&&(i=!0,t.moveTo(s.x*e.x,s.y*e.y),t.lineTo(s.x*e.x+s.offsetX,s.y*e.y+s.offsetY))})),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:r,cornerColor:o}=this,a=_({cornerStrokeColor:s,cornerDashArray:r,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}})),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach((e=>{let[i,s]=e;return this.setControlVisible(i,s)}))}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);const s=this.width+4,r=this.height+4;return e.clearRect(-s/2,-r/2,s,r),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function Kc(n,t){return t.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((i=>{i!=="constructor"&&Object.defineProperty(n.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}))})),n}v(Ks,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Nt extends Ks{}Kc(Nt,[$c]),D.setClass(Nt),D.setClass(Nt,"object");const Of=(n,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:r}=n.getImageData(t-i,e-i,s,s);for(let o=3;o<r.length;o+=4)if(r[o]>0)return!1;return!0};class Zc{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const i=po(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(Ct(this.options.skewY)),e.x+=e.y*Math.tan(Ct(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Pf=new x;class ns extends Zc{static getOrthogonalRotationFactor(t,e){const i=e?fo(t,e):Kg(t);return Math.abs(i)<er?-1:1}constructor(t,e,i,s){super(s),v(this,"AB",void 0),v(this,"AC",void 0),v(this,"alpha",void 0),v(this,"bisector",void 0),this.A=new x(t),this.B=new x(e),this.C=new x(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=fo(this.AB,this.AC),this.bisector=Wo(Nc(this.AB.eq(Pf)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),r=Uc(s),o=ns.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,i*o)}projectBevel(){const t=[];return(this.alpha%Nr==0?[this.B]:[this.B,this.C]).forEach((e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))})),t}projectMiter(){const t=[],e=Math.abs(this.alpha),i=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),r=this.options.strokeUniform?go(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return go(s)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new x(ns.getOrthogonalRotationFactor(this.bisector),ns.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach((r=>{hl(r,t,e)&&i.push(this.A.add(r))})),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:r,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(Ct(s)),Math.tan(Ct(r))),h=this.strokeProjectionMagnitude,d=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),u=new x(Math.sqrt(Math.max(h**2-d**2,0)),d),p=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),g=new x(p,Math.sqrt(Math.max(h**2-p**2,0)));return[g,g.scalarMultiply(-1),u,u.scalarMultiply(-1)].map((f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f))).forEach((f=>{hl(f,t,e)&&i.push(this.applySkew(this.A).add(f))})),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Nr==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),r=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=zs(s,o)>0,l=a?s:r,c=a?r:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector})))}}class ml extends Zc{constructor(t,e,i){super(i),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(Uc(s),i)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new ns(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(Wo(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map((e=>this.applySkew(e)))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t})))}}const Df=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(n.length===0)return i;const s=n.reduce(((r,o)=>(r[r.length-1].eq(o)||r.push(new x(o)),r)),[new x(n[0])]);if(s.length===1)e=!0;else if(!e){const r=s[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,(a=>!a.eq(r)));s.splice(o+1)}return s.forEach(((r,o,a)=>{let l,c;o===0?(c=a[1],l=e?r:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?r:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new ml(r,r,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new ns(r,l,c,t).project()):i.push(...new ml(r,o===0?c:l,t).project())})),i},Xo=n=>{const t={};return Object.keys(n).forEach((e=>{t[e]={},Object.keys(n[e]).forEach((i=>{t[e][i]=_({},n[e][i])}))})),t},Af=n=>n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let Os;const qo=n=>{if(Os||Os||(Os="Intl"in un()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),Os){const t=Os.segment(n);return Array.from(t).map((e=>{let{segment:i}=e;return i}))}return Mf(n)},Mf=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=If(n,i))!==!1&&t.push(e);return t},If=(n,t)=>{const e=n.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return n.charAt(t);if(55296<=e&&e<=56319){if(n.length<=t+1)throw"High surrogate without following low surrogate";const s=n.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return n.charAt(t)+n.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=n.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},Ko=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return n.fill!==t.fill||n.stroke!==t.stroke||n.strokeWidth!==t.strokeWidth||n.fontSize!==t.fontSize||n.fontFamily!==t.fontFamily||n.fontWeight!==t.fontWeight||n.fontStyle!==t.fontStyle||n.textDecorationThickness!==t.textDecorationThickness||n.textBackgroundColor!==t.textBackgroundColor||n.deltaY!==t.deltaY||e&&(n.overline!==t.overline||n.underline!==t.underline||n.linethrough!==t.linethrough)},Lf=(n,t)=>{const e=t.split(`
3299
+ `),i=[];let s=-1,r={};n=Xo(n);for(let o=0;o<e.length;o++){const a=qo(e[o]);if(n[o])for(let l=0;l<a.length;l++){s++;const c=n[o][l];c&&Object.keys(c).length>0&&(Ko(r,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),r=c||{}}else s+=a.length,r={}}return i},Ff=(n,t)=>{if(!Array.isArray(n))return Xo(n);const e=t.split($o),i={};let s=-1,r=0;for(let o=0;o<e.length;o++){const a=qo(e[o]);for(let l=0;l<a.length;l++)s++,n[r]&&n[r].start<=s&&s<n[r].end&&(i[o]=i[o]||{},i[o][l]=_({},n[r].style),s===n[r].end-1&&r++)}return i},ki=["display","transform",Mt,"fill-opacity","fill-rule","opacity",ae,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function bl(n,t){const e=n.nodeName,i=n.getAttribute("class"),s=n.getAttribute("id"),r="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),s&&t.length&&(o=new RegExp("#"+s+r,"i"),t=t.replace(o,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+r,"i"),t=t.replace(o,"")}return t.length===0}function jf(n,t){let e=!0;const i=bl(n,t.pop());return i&&t.length&&(e=(function(s,r){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&r.length;)a&&(o=r.pop()),a=bl(s=s.parentElement,o);return r.length===0})(n,t)),i&&e&&t.length===0}const $f=n=>{var t;return(t=Xg[n])!==null&&t!==void 0?t:n},Rf=new RegExp("(".concat(ke,")"),"gi"),Bf=n=>Kr(n.replace(Rf," $1 ").replace(/,/gi," "));var vl,yl,_l,xl,wl,Cl,Sl;const Zt="(".concat(ke,")"),zf=String.raw(vl||(vl=Ge(["(skewX)(",")"],["(skewX)\\(","\\)"])),Zt),Hf=String.raw(yl||(yl=Ge(["(skewY)(",")"],["(skewY)\\(","\\)"])),Zt),Vf=String.raw(_l||(_l=Ge(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Zt,Zt,Zt),Nf=String.raw(xl||(xl=Ge(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Zt,Zt),Uf=String.raw(wl||(wl=Ge(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Zt,Zt),Wf=String.raw(Cl||(Cl=Ge(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Zt,Zt,Zt,Zt,Zt,Zt),Zo="(?:".concat(Wf,"|").concat(Uf,"|").concat(Vf,"|").concat(Nf,"|").concat(zf,"|").concat(Hf,")"),Gf="(?:".concat(Zo,"*)"),Yf=String.raw(Sl||(Sl=Ge(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Gf),Xf=new RegExp(Yf),qf=new RegExp(Zo),Kf=new RegExp(Zo,"g");function mo(n){const t=[];if(!(n=Bf(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!Xf.test(n))return[...Qt];for(const e of n.matchAll(Kf)){const i=qf.exec(e[0]);if(!i)continue;let s=Qt;const r=i.filter((g=>!!g)),[,o,...a]=r,[l,c,h,d,u,p]=a.map((g=>parseFloat(g)));switch(o){case"translate":s=ir(l,c);break;case Ro:s=gs({angle:l},{x:c,y:h});break;case gn:s=Ho(l,c);break;case us:s=Ec(l);break;case ps:s=kc(l);break;case"matrix":s=[l,c,h,d,u,p]}t.push(s)}return zo(t)}function Zf(n,t,e,i){const s=Array.isArray(t);let r,o=t;if(n!==Mt&&n!==ae||t!==oe){if(n==="strokeUniform")return t==="non-scaling-stroke";if(n==="strokeDashArray")o=t===oe?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(n==="transformMatrix")o=e&&e.transformMatrix?Bt(e.transformMatrix,mo(t)):mo(t);else if(n==="visible")o=t!==oe&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(n==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(n==="textAnchor")o=t==="start"?Y:t==="end"?wt:V;else if(n==="charSpacing"||n===Vi)r=rs(t,i)/i*1e3;else if(n==="paintFirst"){const a=t.indexOf(Mt),l=t.indexOf(ae);o=Mt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=ae)}else{if(n==="href"||n==="xlink:href"||n==="font"||n==="id")return t;if(n==="imageSmoothing")return t==="optimizeQuality";r=s?t.map(rs):rs(t,i)}}else o="";return!s&&isNaN(r)?o:r}function Jf(n,t){const e=n.match(Yg);if(!e)return;const i=e[1],s=e[3],r=e[4],o=e[5],a=e[6];i&&(t.fontStyle=i),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),r&&(t.fontSize=rs(r)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function Qf(n,t){n.replace(/;\s*$/,"").split(";").forEach((e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()}))}function tm(n){const t={},e=n.getAttribute("style");return e&&(typeof e=="string"?Qf(e,t):(function(i,s){Object.entries(i).forEach((r=>{let[o,a]=r;a!==void 0&&(s[o.toLowerCase()]=a)}))})(e,t)),t}const em={stroke:"strokeOpacity",fill:"fillOpacity"};function hi(n,t,e){if(!n)return{};let i,s={},r=jo;n.parentNode&&cl.test(n.parentNode.nodeName)&&(s=hi(n.parentElement,t,e),s.fontSize&&(i=r=rs(s.fontSize)));const o=_(_(_({},t.reduce(((c,h)=>{const d=n.getAttribute(h);return d&&(c[h]=d),c}),{})),(function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d={};for(const u in h)jf(c,u.split(" "))&&(d=_(_({},d),h[u]));return d})(n,e)),tm(n));o[Vn]&&n.setAttribute(Vn,o[Vn]),o[Hn]&&(i=rs(o[Hn],r),o[Hn]="".concat(i));const a={};for(const c in o){const h=$f(c),d=Zf(h,o[c],s,i);a[h]=d}a&&a.font&&Jf(a.font,a);const l=_(_({},s),a);return cl.test(n.nodeName)?l:(function(c){const h=Nt.getDefaults();return Object.entries(em).forEach((d=>{let[u,p]=d;if(c[p]===void 0||c[u]==="")return;if(c[u]===void 0){if(!h[u])return;c[u]=h[u]}if(c[u].indexOf("url(")===0)return;const g=new K(c[u]);c[u]=g.setAlpha(et(g.getAlpha()*c[p],2)).toRgba()})),c})(l)}const im=["left","top","width","height","visible"],Jc=["rx","ry"];class re extends Nt{static getDefaults(){return _(_({},super.getDefaults()),re.ownDefaults)}constructor(t){super(),Object.assign(this,re.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:i}=this,s=-e/2,r=-i/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,i/2):0,l=o!==0||a!==0;t.beginPath(),t.moveTo(s+o,r),t.lineTo(s+e-o,r),l&&t.bezierCurveTo(s+e-ui*o,r,s+e,r+ui*a,s+e,r+a),t.lineTo(s+e,r+i-a),l&&t.bezierCurveTo(s+e,r+i-ui*a,s+e-ui*o,r+i,s+e-o,r+i),t.lineTo(s+o,r+i),l&&t.bezierCurveTo(s+ui*o,r+i,s,r+i-ui*a,s,r+i-a),t.lineTo(s,r+a),l&&t.bezierCurveTo(s,r+ui*a,s+ui*o,r,s+o,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Jc,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,`" />
3300
+ `)]}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=ot(s,im);return new this(_(_(_({},e),h),{},{left:r,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}v(re,"type","Rect"),v(re,"cacheProperties",[...ci,...Jc]),v(re,"ownDefaults",{rx:0,ry:0}),v(re,"ATTRIBUTE_NAMES",[...ki,"x","y","rx","ry","width","height"]),D.setClass(re),D.setSVGClass(re);const Qe="initialization",Jr="added",Jo="removed",Qr="imperative",Qc=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:r,group:o}=t,a=o&&o!==n?bn(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?zg(new x(i,i),void 0,n.calcTransformMatrix()):Bo,d=!e&&c?i:0,u=No(s+d,r+d,zo([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class _n{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===Qe||e===Qr||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Qe&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Qr&&e.overrides)return e.overrides;if(t.length===0)return;const{left:r,top:o,width:a,height:l}=ei(t.map((d=>Qc(s,d))).reduce(((d,u)=>d.concat(u)),[])),c=new x(a,l),h=new x(r,o).add(c.scalarDivide(2));if(i===Qe){const d=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:d}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(_n,"type","strategy");class bo extends _n{shouldPerformLayout(t){return!0}}v(bo,"type","fit-content"),D.setClass(bo);const sm=["strategy"],rm=["target","strategy","bubbles","prevStrategy"],th="layoutManager";class Zs{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new bo;v(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=_(_({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:i}=e;return[Wr,bc,Gs,vc,pn,yc,Ur,Tg,Eg].map((s=>t.on(s,(r=>this.performLayout(s===Wr?{type:"object_modified",trigger:s,e:r,target:i}:{type:"object_modifying",trigger:s,e:r,target:i})))))}subscribe(t,e){this.unsubscribe(t,e);const i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach((i=>i())),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach((e=>this.unsubscribe(e,t)))}subscribeTargets(t){t.targets.forEach((e=>this.subscribe(e,t)))}onBeforeLayout(t){const{target:e,type:i}=t,{canvas:s}=e;if(i===Qe||i===Jr?this.subscribeTargets(t):i===Jo&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Qr&&t.deep){const r=ot(t,sm);e.forEachObject((o=>o.layoutManager&&o.layoutManager.performLayout(_(_({},r),{},{bubbles:!1,target:o}))))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,r=i.calcLayoutResult(t,e.getObjects());if(!r)return;const o=s===Qe?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=r,h=o.subtract(a).add(l).transform(s===Qe?Qt:Ee(e.calcOwnMatrix()),!0).add(c);return{result:r,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:r}=e;var o,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===Qe?i.set({left:(o=t.x)!==null&&o!==void 0?o:r.x+s.x*Pt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:r.y+s.y*Pt(i.originY)}):(i.setPositionByOrigin(r,V,V),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject((s=>{s.group===i&&this.layoutObject(t,e,s)})),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:s}=e;i.set({left:i.left+s.x,top:i.top+s.y})}onAfterLayout(t,e){const{target:i,strategy:s,bubbles:r,prevStrategy:o}=t,a=ot(t,rm),{canvas:l}=i;i.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:i});const c=i.parent;r&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(_(_({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((e=>e.forEach((i=>i())))),t.clear()}toObject(){return{type:th,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}D.setClass(Zs,th);const nm=["type","objects","layoutManager"];class om extends Zs{performLayout(){}}class _i extends _c(Nt){static getDefaults(){return _(_({},super.getDefaults()),_i.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"_activeObjects",[]),v(this,"__objectSelectionTracker",void 0),v(this,"__objectSelectionDisposer",void 0),Object.assign(this,_i.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject((s=>{this.enterGroup(s,!1)})),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Zs,this.layoutManager.performLayout({type:Qe,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Ci("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(Ci("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter(((e,i,s)=>this.canEnterGroup(e)&&s.indexOf(e)===i))}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(e),r=super.add(...s);return this._onAfterObjectsChange(Jr,s),r}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const r=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...r);return this._onAfterObjectsChange(Jr,r),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Jo,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const i=this[t];return super._set(t,e),t==="canvas"&&i!==e&&(this._objects||[]).forEach((s=>{s._set(t,e)})),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const r=s.indexOf(i);r>-1&&(s.splice(r,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Xr(t,Bt(Ee(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Xr(t,Bt(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){const t=Nt.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let r=0;r<this._objects.length;r++){var s;const o=this._objects[r];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Ee(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject((t=>t.setCoords()))}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(_({target:this,type:Qr},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter((function(s){return!s.excludeFromExport})).map((function(s){const r=s.includeDefaultValues;s.includeDefaultValues=i;const o=s[t||"toObject"](e);return s.includeDefaultValues=r,o}))}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return _(_(_({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject((t=>{this._watchObject(!1,t),t.dispose()})),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=re.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
3301
3301
  `],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toSVG(t));return e.push(`</g>
3302
- `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:r}=t,o=ot(t,sm);return Promise.all([Ys(s,e),mn(o,e)]).then((a=>{let[l,c]=a;const h=new this(l,y(y(y({},o),c),{},{layoutManager:new rm}));if(r){const d=D.getClass(r.type),u=D.getClass(r.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Zs;return h.layoutManager.subscribeTargets({type:Qe,target:h,targets:h.getObjects()}),h.setCoords(),h}))}}v(_i,"type","Group"),v(_i,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),D.setClass(_i);const nm=(n,t)=>Math.min(t.width/n.width,t.height/n.height),om=(n,t)=>Math.max(t.width/n.width,t.height/n.height),vo="\\s*,?\\s*",Ps="".concat(vo,"(").concat(ke,")"),am="".concat(Ps).concat(Ps).concat(Ps).concat(vo,"([01])").concat(vo,"([01])").concat(Ps).concat(Ps),lm={m:"l",M:"L"},cm=(n,t,e,i,s,r,o,a,l,c,h)=>{const d=ni(n),u=oi(n),p=ni(t),g=oi(t),f=e*s*p-i*r*g+o,b=i*s*p+e*r*g+a;return["C",c+l*(-e*s*u-i*r*d),h+l*(-i*s*u+e*r*d),f+l*(e*s*g+i*r*p),b+l*(i*s*g-e*r*p),f,b]},Tl=(n,t,e,i)=>{const s=Math.atan2(t,n),r=Math.atan2(i,e);return r>=s?r-s:2*Math.PI-(s-r)};function El(n,t,e,i,s,r,o,a){let l;if(W.cachesBoundsOfCurve&&(l=[...arguments].join(),$s.boundsOfCurveCache[l]))return $s.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let p=6*n-12*e+6*s,g=-3*n+9*e-9*s+3*o,f=3*e-3*n;for(let S=0;S<2;++S){if(S>0&&(p=6*t-12*i+6*r,g=-3*t+9*i-9*r+3*a,f=3*i-3*t),h(g)<1e-12){if(h(p)<1e-12)continue;const P=-f/p;0<P&&P<1&&d.push(P);continue}const T=p*p-4*f*g;if(T<0)continue;const O=c(T),k=(-p+O)/(2*g);0<k&&k<1&&d.push(k);const E=(-p-O)/(2*g);0<E&&E<1&&d.push(E)}let b=d.length;const m=b,_=eh(n,t,e,i,s,r,o,a);for(;b--;){const{x:S,y:T}=_(d[b]);u[0][b]=S,u[1][b]=T}u[0][m]=n,u[1][m]=t,u[0][m+1]=o,u[1][m+1]=a;const x=[new w(Math.min(...u[0]),Math.min(...u[1])),new w(Math.max(...u[0]),Math.max(...u[1]))];return W.cachesBoundsOfCurve&&($s.boundsOfCurveCache[l]=x),x}const hm=(n,t,e)=>{let[i,s,r,o,a,l,c,h]=e;const d=((u,p,g,f,b,m,_)=>{if(g===0||f===0)return[];let x=0,S=0,T=0;const O=Math.PI,k=_*Fo,E=oi(k),P=ni(k),R=.5*(-P*u-E*p),L=.5*(-P*p+E*u),j=g**2,H=f**2,M=L**2,U=R**2,q=j*H-j*M-H*U;let Q=Math.abs(g),N=Math.abs(f);if(q<0){const _t=Math.sqrt(1-q/(j*H));Q*=_t,N*=_t}else T=(b===m?-1:1)*Math.sqrt(q/(j*M+H*U));const kt=T*Q*L/N,Gt=-T*N*R/Q,Yt=P*kt-E*Gt+.5*u,Ie=E*kt+P*Gt+.5*p;let me=Tl(1,0,(R-kt)/Q,(L-Gt)/N),jt=Tl((R-kt)/Q,(L-Gt)/N,(-R-kt)/Q,(-L-Gt)/N);m===0&&jt>0?jt-=2*O:m===1&&jt<0&&(jt+=2*O);const Le=Math.ceil(Math.abs(jt/O*2)),he=[],At=jt/Le,$t=8/3*Math.sin(At/4)*Math.sin(At/4)/Math.sin(At/2);let de=me+At;for(let _t=0;_t<Le;_t++)he[_t]=cm(me,de,P,E,Q,N,Yt,Ie,$t,x,S),x=he[_t][5],S=he[_t][6],me=de,de+=At;return he})(c-n,h-t,s,r,a,l,o);for(let u=0,p=d.length;u<p;u++)d[u][1]+=n,d[u][2]+=t,d[u][3]+=n,d[u][4]+=t,d[u][5]+=n,d[u][6]+=t;return d},dm=n=>{let t=0,e=0,i=0,s=0;const r=[];let o,a=0,l=0;for(const c of n){const h=[...c];let d;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],d=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],d=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],d=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],s=h[2],d=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],d=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],d=["C",a,l,h[1],h[2],t,e],a=d[3],l=d[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],d=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],d=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":hm(t,e,h).forEach((u=>r.push(u))),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,d=["Z"]}d?(r.push(d),o=d[0]):o=""}return r},tn=(n,t,e,i)=>Math.sqrt((e-n)**2+(i-t)**2),eh=(n,t,e,i,s,r,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),d=(p=>3*p*(1-p)**2)(l),u=(p=>(1-p)**3)(l);return new w(o*c+s*h+e*d+n*u,a*c+r*h+i*d+t*u)},ih=n=>n**2,sh=n=>2*n*(1-n),rh=n=>(1-n)**2,um=(n,t,e,i,s,r,o,a)=>l=>{const c=ih(l),h=sh(l),d=rh(l),u=3*(d*(e-n)+h*(s-e)+c*(o-s)),p=3*(d*(i-t)+h*(r-i)+c*(a-r));return Math.atan2(p,u)},pm=(n,t,e,i,s,r)=>o=>{const a=ih(o),l=sh(o),c=rh(o);return new w(s*a+e*l+n*c,r*a+i*l+t*c)},gm=(n,t,e,i,s,r)=>o=>{const a=1-o,l=2*(a*(e-n)+o*(s-e)),c=2*(a*(i-t)+o*(r-i));return Math.atan2(c,l)},kl=(n,t,e)=>{let i=new w(t,e),s=0;for(let r=1;r<=100;r+=1){const o=n(r/100);s+=tn(i.x,i.y,o.x,o.y),i=o}return s},fm=(n,t)=>{let e,i=0,s=0,r={x:n.x,y:n.y},o=y({},r),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;s<t&&a>1e-4;)o=c(i),l=i,e=tn(r.x,r.y,o.x,o.y),e+s>t?(i-=a,a/=2):(r=o,i+=a,s+=e);return y(y({},o),{},{angle:h(l)})},nh=n=>{let t,e,i=0,s=0,r=0,o=0,a=0;const l=[];for(const c of n){const h={x:s,y:r,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=s=c[1],e.y=a=r=c[2];break;case"L":e=h,e.length=tn(s,r,c[1],c[2]),s=c[1],r=c[2];break;case"C":t=eh(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=um(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=kl(t,s,r),s=c[5],r=c[6];break;case"Q":t=pm(s,r,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=gm(s,r,c[1],c[2],c[3],c[4]),e.length=kl(t,s,r),s=c[3],r=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=tn(s,r,o,a),s=o,r=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:r}),l},mm=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:nh(n),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],r=t/s.length,o=n[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return y(y({},new w(s.x,s.y).lerp(new w(s.destX,s.destY),r)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return y(y({},new w(s.x,s.y).lerp(new w(o[1],o[2]),r)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return fm(s,t)}},bm=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Ol=new RegExp(am,"g"),vm=new RegExp(ke,"gi"),ym={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},_m=n=>{var t;const e=[],i=(t=n.match(bm))!==null&&t!==void 0?t:[];for(const s of i){const r=s[0];if(r==="z"||r==="Z"){e.push([r]);continue}const o=ym[r.toLowerCase()];let a=[];if(r==="a"||r==="A"){Ol.lastIndex=0;for(let l=null;l=Ol.exec(s);)a.push(...l.slice(1))}else a=s.match(vm)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=lm[r];c[0]=l>0&&h?h:r;for(let d=0;d<o;d++)c[d+1]=parseFloat(a[l+d]);e.push(c)}}return e},xm=(n,t)=>n.map((e=>e.map(((i,s)=>s===0||t===void 0?i:et(i,t))).join(" "))).join(" ");function yo(n,t){const e=n.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach((i=>{let[s,r]=i;return e.setProperty(s,r)})))}class wm extends Ac{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),v(this,"upper",void 0),v(this,"container",void 0);const{el:s}=this.lower,r=this.createUpperCanvas();this.upper={el:r,ctx:r.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(r,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,r),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=ai();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=ds().createElement("div");return t.setAttribute("data-fabric","wrapper"),yo(t,{position:"relative"}),Qa(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;yo(t,y(y({},i),{},{"touch-action":s?"manipulation":re})),Qa(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;Dc(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),ho(this.upper.el,t),ho(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),Ue().dispose(this.upper.el),delete this.upper,delete this.container}}class xn extends sr{constructor(){super(...arguments),v(this,"targets",[]),v(this,"_hoveredTargets",[]),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return y(y({},super.getDefaults()),xn.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new wm(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter((e=>!e.group&&e!==t)).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,i){const s=this.targetFindTolerance,r=this.pixelFindContext;this.clearContext(r),r.save(),r.translate(-e+s,-i+s),r.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=o,r.restore();const a=Math.round(s*this.getRetinaScaling());return Ef(r,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find((i=>!!i&&t[i]===!0)):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&i.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let s;return e===gn||e===ce||e===_e||e===Gs?s=this.centeredScaling||t.centeredScaling:e===Ro&&(s=this.centeredRotation||t.centeredRotation),s?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=wt:["mr","tr","br"].includes(e)&&(i.x=Y),["tl","mt","tr"].includes(e)?i.y=co:["bl","mb","br"].includes(e)&&(i.y=se)),i}_setupCurrentTransform(t,e,i){var s;const r=e.group?ss(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):Hg,c=((p,g,f,b)=>{if(!g||!p)return"drag";const m=b.controls[g];return m.getActionName(f,m,b)})(i,o,t,e),h=t[this.centeredKey],d=this._shouldCenterTransform(e,c,h)?{x:V,y:V}:this._getOriginFromCorner(e,o),u={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:d.x,originY:d.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:Ct(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:y(y({},Mc(e)),{},{originX:d.x,originY:d.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,o=new w(e,i).transform(this.viewportTransform),a=new w(e+s,i+r).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),d=Math.max(o.x,a.x),u=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,d-c,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,d-=l,u-=l,Nt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,d-c,u-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,s=this.getActiveObjects();if(this.targets=[],i&&s.length>=1){if(i.findControl(e,uo(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const r=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=r,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),r=t.padding/s;if(r){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),d=ni(h)*r,u=oi(h)*r,p=d+u,g=d-u;i=[new w(o.x-g,o.y-p),new w(a.x+p,a.y-g),new w(l.x+g,l.y+p),new w(c.x-p,c.y+g)]}return ut.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,ss(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(Fr(s)&&s.subTargetCheck){const r=this._searchPossibleTargets(s._objects,e);r&&this.targets.push(r)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Fr(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let r=s.length-1;r>0;r--){const o=s[r];if(!Fr(o)||!o.interactive)return o}return s[0]}return i}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let r=Lg(t),o=s.width||0,a=s.height||0;o&&a||(se in s&&co in s&&(a=Math.abs(s.top-s.bottom)),wt in s&&Y in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=ss(r,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(r.x/=l,r.y/=l);const c=o===0||a===0?new w(1,1):new w(i.width/o,i.height/a);return r.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ai(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return Ai(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const r=this.getActiveObjects(),o=[],a=[];t.forEach((l=>{r.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))})),r.forEach((l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))})),t.length>0&&r.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):r.length>0?(s=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),s}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Ai(t)&&i!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),Ai(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});const s=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),s}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,i=e.target,s={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),i.fire(Wr,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ai(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,i){const s=this._realizeGroupTransformOnObject(t),r=super._toObject(t,e,i);return t.set(s),r}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ai(e)&&this._activeObject===e){const i=fs(t,["angle","flipX","flipY",Y,ce,_e,us,ps,se]);return jg(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(xn,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class Cm{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),Zi(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Sm=["target","oldTarget","fireCanvas","e"],ue={passive:!1},qi=(n,t)=>{const e=n.getViewportPoint(t),i=n.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},pi=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.addEventListener(...e)},be=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.removeEventListener(...e)},Tm={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class _o extends xn{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Cm(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((e=>{this[e]=this[e].bind(this)})),this.addOrRemove(pi,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(Pc(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,ue),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel,{passive:!1}),t(i,"contextmenu",this._onContextMenu),t(i,"click",this._onClick),t(i,"dblclick",this._onClick),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,ue)}removeListeners(){this.addOrRemove(be,"remove");const t=this._getEventPrefix(),e=Te(this.upperCanvasEl);be(e,"".concat(t,"up"),this._onMouseUp),be(e,"touchend",this._onTouchEnd,ue),be(e,"".concat(t,"move"),this._onMouseMove,ue),be(e,"touchmove",this._onMouseMove,ue),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=y({e:t},qi(this,t));this.fire("mouse:out",y(y({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",y({},i)),this._hoveredTargets.forEach((s=>{this.fire("mouse:out",y(y({},i),{},{target:s})),s&&s.fire("mouseout",y({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",y({e:t},qi(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const i={e:t,target:e};return this.fire("dragstart",i),e.fire("dragstart",i),void pi(this.upperCanvasEl,"drag",this._onDragProgress)}tl(t)}_renderDragEffects(t,e,i){let s=!1;const r=this._dropTarget;r&&r!==e&&r!==i&&(r.clearContextTop(),s=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==re,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};be(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:i,targets:s}=this.findDragTargets(t),r=this._dragSource,o={e:t,target:i,subTargets:s,dragSource:r,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(a=i),i.fire(e,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,r,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),s={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:i}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",y({e:t,target:e,subTargets:i,dragSource:this._dragSource},qi(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&tl(t),this._basicEventHandler("contextmenu",s),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||i&&this._target===i)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,r=this._getEventPrefix(),o=Te(s);pi(o,"touchend",this._onTouchEnd,ue),e&&pi(o,"touchmove",this._onMouseMove,ue),be(s,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();be(e,"".concat(i,"move"),this._onMouseMove,ue);const s=Te(e);pi(s,"".concat(i,"up"),this._onMouseUp),pi(s,"".concat(i,"move"),this._onMouseMove,ue)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=Te(this.upperCanvasEl);be(i,"touchend",this._onTouchEnd,ue),be(i,"touchmove",this._onMouseMove,ue),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{pi(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0}),400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){const s=Te(this.upperCanvasEl);be(s,"".concat(i,"up"),this._onMouseUp),be(s,"".concat(i,"move"),this._onMouseMove,ue),pi(e,"".concat(i,"move"),this._onMouseMove,ue)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const i=this._currentTransform,s=this._isClick,r=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!s){const h=r===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(r)||!h&&r===this._activeObject)}if(r){const h=r.findControl(this.getViewportPoint(t),uo(t)),{key:d,control:u}=h||{};if(l=d,r.selectable&&r!==this._activeObject&&r.activeOn==="up")this.setActiveObject(r,t),c=!0;else if(u){const p=u.getMouseUpHandler(t,r,u);p&&(a=this.getScenePoint(t),p.call(u,t,i,a.x,a.y))}r.isMoving=!1}if(i&&(i.target!==r||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],d=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),d&&d.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:s=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let r=0;r<s.length;r++)s[r]!==i&&s[r].fire(t,e);return e}_handleEvent(t,e,i){const s=this._target,r=this.targets||[],o=y(y(y({e:t,target:s,subTargets:r},qi(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),e==="down:before"||e==="down"?i:{});this.fire("mouse:".concat(e),o),s&&s.fire("mouse".concat(e),o);for(let a=0;a<r.length;a++)r[a]!==s&&r[a].fire("mouse".concat(e),o)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,i=!!e&&e===this._activeObject;const{button:s}=t;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(t,"down",{alreadySelected:i}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let r=this._shouldRender(e),o=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,o=!0,r=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const a=this.getScenePoint(t);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(i=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),uo(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,i);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}r&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:i}),r&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=ss(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const i=this.findTarget(t);this._setCursorFromEvent(t,i),this._fireOverOutEvents(t,i)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)r[a]===e||s[a]&&s[a]===i||this.fireSyntheticInOutEvents("mouse",{e:t,target:r[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:r[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:r,e:o}=e,a=ot(e,Sm);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=Tm[t],u=s!==i;if(s&&u){const p=y(y({},a),{},{e:o,target:s,nextTarget:i},qi(this,o));r&&this.fire(d,p),s.fire(c,p)}if(i&&u){const p=y(y({},a),{},{e:o,target:i,previousTarget:s},qi(this,o));r&&this.fire(h,p),i.fire(l,p)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,s=i.target,r=s.group?ss(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,r),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:r,target:o}=e,a=!!r&&r(t,e,i.x,i.y);a&&o.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=Ai(this._activeObject)?this._activeObject:null,r=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(r){const o=r.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map((o=>{i=o.hoverCursor||i})),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=Ai(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||s)&&(s||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(s){const r=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(r,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],i.size()===1&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(r,t)}else{i.isEditing&&i.exitEditing();const r=new(D.getClass("ActiveSelection"))([],{canvas:this});r.multiSelectAdd(i,e),this._hoveredTarget=r,this._setActiveObject(r,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,o=new w(e,i),a=o.add(new w(s,r)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),d=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter((u=>!u.onSelect({e:t}))).reverse():h;if(d.length===1)this.setActiveObject(d[0],t);else if(d.length>1){const u=D.getClass("ActiveSelection");this.setActiveObject(new u(d,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:i}=this.elements;i.ctx=void 0;const s=super.toCanvasElement(t,e);return i.ctx=i.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const oh={x1:0,y1:0,x2:0,y2:0},Em=y(y({},oh),{},{r1:0,r2:0}),ts=(n,t)=>isNaN(n)&&typeof t=="number"?t:n;function ah(n){return n&&/%$/.test(n)&&Number.isFinite(parseFloat(n))}function lh(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(ah(n)?100:1):NaN;return ls(0,ts(e,t),1)}const km=/\s*;\s*/,Om=/\s*:\s*/;function Pm(n,t){let e,i;const s=n.getAttribute("style");if(s){const o=s.split(km);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Om).map((h=>h.trim()));l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const r=new K(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:lh(n.getAttribute("offset"),0),color:r.toRgb(),opacity:ts(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function Dm(n,t){const e=[],i=n.getElementsByTagName("stop"),s=lh(t,1);for(let r=i.length;r--;)e.push(Pm(i[r],s));return e}function ch(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function hh(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function we(n,t){return n.getAttribute(t)}function Am(n,t){return(function(e,i){let s,{width:r,height:o,gradientUnits:a}=i;return Object.entries(e).reduce(((l,c)=>{let[h,d]=c;if(d==="Infinity")s=1;else if(d==="-Infinity")s=0;else{const u=typeof d=="string";s=u?parseFloat(d):d,u&&ah(d)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=r),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l}),{})})(ch(n)==="linear"?(function(e){return{x1:we(e,"x1")||0,y1:we(e,"y1")||0,x2:we(e,"x2")||"100%",y2:we(e,"y2")||0}})(n):(function(e){return{x1:we(e,"fx")||we(e,"cx")||"50%",y1:we(e,"fy")||we(e,"cy")||"50%",r1:0,x2:we(e,"cx")||"50%",y2:we(e,"cy")||"50%",r2:we(e,"r")||"50%"}})(n),y(y({},t),{},{gradientUnits:hh(n)}))}class dr{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:r=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:y(y({},e==="radial"?Em:oh),s),colorStops:r,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(Ci()):Ci()})}addColorStop(t){for(const e in t){const i=new K(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return y(y({},fs(this,t)),{},{type:this.type,coords:y({},this.coords),colorStops:this.colorStops.map((e=>y({},e))),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():Zt.concat(),r=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((d=>y({},d))).sort(((d,u)=>d.offset-u.offset));let a=-this.offsetX,l=-this.offsetY;var c;r==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Xs(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:d,y1:u,x2:p,y2:g}=this.coords;i.push("<linearGradient ",h,' x1="',d,'" y1="',u,'" x2="',p,'" y2="',g,`">
3302
+ `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:r}=t,o=ot(t,nm);return Promise.all([Ys(s,e),mn(o,e)]).then((a=>{let[l,c]=a;const h=new this(l,_(_(_({},o),c),{},{layoutManager:new om}));if(r){const d=D.getClass(r.type),u=D.getClass(r.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Zs;return h.layoutManager.subscribeTargets({type:Qe,target:h,targets:h.getObjects()}),h.setCoords(),h}))}}v(_i,"type","Group"),v(_i,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),D.setClass(_i);const am=(n,t)=>Math.min(t.width/n.width,t.height/n.height),lm=(n,t)=>Math.max(t.width/n.width,t.height/n.height),vo="\\s*,?\\s*",Ps="".concat(vo,"(").concat(ke,")"),cm="".concat(Ps).concat(Ps).concat(Ps).concat(vo,"([01])").concat(vo,"([01])").concat(Ps).concat(Ps),hm={m:"l",M:"L"},dm=(n,t,e,i,s,r,o,a,l,c,h)=>{const d=ni(n),u=oi(n),p=ni(t),g=oi(t),f=e*s*p-i*r*g+o,b=i*s*p+e*r*g+a;return["C",c+l*(-e*s*u-i*r*d),h+l*(-i*s*u+e*r*d),f+l*(e*s*g+i*r*p),b+l*(i*s*g-e*r*p),f,b]},Tl=(n,t,e,i)=>{const s=Math.atan2(t,n),r=Math.atan2(i,e);return r>=s?r-s:2*Math.PI-(s-r)};function El(n,t,e,i,s,r,o,a){let l;if(W.cachesBoundsOfCurve&&(l=[...arguments].join(),$s.boundsOfCurveCache[l]))return $s.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let p=6*n-12*e+6*s,g=-3*n+9*e-9*s+3*o,f=3*e-3*n;for(let S=0;S<2;++S){if(S>0&&(p=6*t-12*i+6*r,g=-3*t+9*i-9*r+3*a,f=3*i-3*t),h(g)<1e-12){if(h(p)<1e-12)continue;const P=-f/p;0<P&&P<1&&d.push(P);continue}const T=p*p-4*f*g;if(T<0)continue;const k=c(T),O=(-p+k)/(2*g);0<O&&O<1&&d.push(O);const E=(-p-k)/(2*g);0<E&&E<1&&d.push(E)}let b=d.length;const m=b,y=eh(n,t,e,i,s,r,o,a);for(;b--;){const{x:S,y:T}=y(d[b]);u[0][b]=S,u[1][b]=T}u[0][m]=n,u[1][m]=t,u[0][m+1]=o,u[1][m+1]=a;const w=[new x(Math.min(...u[0]),Math.min(...u[1])),new x(Math.max(...u[0]),Math.max(...u[1]))];return W.cachesBoundsOfCurve&&($s.boundsOfCurveCache[l]=w),w}const um=(n,t,e)=>{let[i,s,r,o,a,l,c,h]=e;const d=((u,p,g,f,b,m,y)=>{if(g===0||f===0)return[];let w=0,S=0,T=0;const k=Math.PI,O=y*Fo,E=oi(O),P=ni(O),R=.5*(-P*u-E*p),L=.5*(-P*p+E*u),j=g**2,H=f**2,M=L**2,U=R**2,q=j*H-j*M-H*U;let Q=Math.abs(g),N=Math.abs(f);if(q<0){const _t=Math.sqrt(1-q/(j*H));Q*=_t,N*=_t}else T=(b===m?-1:1)*Math.sqrt(q/(j*M+H*U));const kt=T*Q*L/N,Yt=-T*N*R/Q,Xt=P*kt-E*Yt+.5*u,Ie=E*kt+P*Yt+.5*p;let me=Tl(1,0,(R-kt)/Q,(L-Yt)/N),jt=Tl((R-kt)/Q,(L-Yt)/N,(-R-kt)/Q,(-L-Yt)/N);m===0&&jt>0?jt-=2*k:m===1&&jt<0&&(jt+=2*k);const Le=Math.ceil(Math.abs(jt/k*2)),he=[],At=jt/Le,$t=8/3*Math.sin(At/4)*Math.sin(At/4)/Math.sin(At/2);let de=me+At;for(let _t=0;_t<Le;_t++)he[_t]=dm(me,de,P,E,Q,N,Xt,Ie,$t,w,S),w=he[_t][5],S=he[_t][6],me=de,de+=At;return he})(c-n,h-t,s,r,a,l,o);for(let u=0,p=d.length;u<p;u++)d[u][1]+=n,d[u][2]+=t,d[u][3]+=n,d[u][4]+=t,d[u][5]+=n,d[u][6]+=t;return d},pm=n=>{let t=0,e=0,i=0,s=0;const r=[];let o,a=0,l=0;for(const c of n){const h=[...c];let d;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],d=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],d=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],d=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],s=h[2],d=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],d=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],d=["C",a,l,h[1],h[2],t,e],a=d[3],l=d[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],d=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],d=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":um(t,e,h).forEach((u=>r.push(u))),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,d=["Z"]}d?(r.push(d),o=d[0]):o=""}return r},tn=(n,t,e,i)=>Math.sqrt((e-n)**2+(i-t)**2),eh=(n,t,e,i,s,r,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),d=(p=>3*p*(1-p)**2)(l),u=(p=>(1-p)**3)(l);return new x(o*c+s*h+e*d+n*u,a*c+r*h+i*d+t*u)},ih=n=>n**2,sh=n=>2*n*(1-n),rh=n=>(1-n)**2,gm=(n,t,e,i,s,r,o,a)=>l=>{const c=ih(l),h=sh(l),d=rh(l),u=3*(d*(e-n)+h*(s-e)+c*(o-s)),p=3*(d*(i-t)+h*(r-i)+c*(a-r));return Math.atan2(p,u)},fm=(n,t,e,i,s,r)=>o=>{const a=ih(o),l=sh(o),c=rh(o);return new x(s*a+e*l+n*c,r*a+i*l+t*c)},mm=(n,t,e,i,s,r)=>o=>{const a=1-o,l=2*(a*(e-n)+o*(s-e)),c=2*(a*(i-t)+o*(r-i));return Math.atan2(c,l)},kl=(n,t,e)=>{let i=new x(t,e),s=0;for(let r=1;r<=100;r+=1){const o=n(r/100);s+=tn(i.x,i.y,o.x,o.y),i=o}return s},bm=(n,t)=>{let e,i=0,s=0,r={x:n.x,y:n.y},o=_({},r),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;s<t&&a>1e-4;)o=c(i),l=i,e=tn(r.x,r.y,o.x,o.y),e+s>t?(i-=a,a/=2):(r=o,i+=a,s+=e);return _(_({},o),{},{angle:h(l)})},nh=n=>{let t,e,i=0,s=0,r=0,o=0,a=0;const l=[];for(const c of n){const h={x:s,y:r,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=s=c[1],e.y=a=r=c[2];break;case"L":e=h,e.length=tn(s,r,c[1],c[2]),s=c[1],r=c[2];break;case"C":t=eh(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=gm(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=kl(t,s,r),s=c[5],r=c[6];break;case"Q":t=fm(s,r,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=mm(s,r,c[1],c[2],c[3],c[4]),e.length=kl(t,s,r),s=c[3],r=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=tn(s,r,o,a),s=o,r=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:r}),l},vm=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:nh(n),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],r=t/s.length,o=n[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return _(_({},new x(s.x,s.y).lerp(new x(s.destX,s.destY),r)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return _(_({},new x(s.x,s.y).lerp(new x(o[1],o[2]),r)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return bm(s,t)}},ym=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Ol=new RegExp(cm,"g"),_m=new RegExp(ke,"gi"),xm={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},wm=n=>{var t;const e=[],i=(t=n.match(ym))!==null&&t!==void 0?t:[];for(const s of i){const r=s[0];if(r==="z"||r==="Z"){e.push([r]);continue}const o=xm[r.toLowerCase()];let a=[];if(r==="a"||r==="A"){Ol.lastIndex=0;for(let l=null;l=Ol.exec(s);)a.push(...l.slice(1))}else a=s.match(_m)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=hm[r];c[0]=l>0&&h?h:r;for(let d=0;d<o;d++)c[d+1]=parseFloat(a[l+d]);e.push(c)}}return e},Cm=(n,t)=>n.map((e=>e.map(((i,s)=>s===0||t===void 0?i:et(i,t))).join(" "))).join(" ");function yo(n,t){const e=n.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach((i=>{let[s,r]=i;return e.setProperty(s,r)})))}class Sm extends Ac{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),v(this,"upper",void 0),v(this,"container",void 0);const{el:s}=this.lower,r=this.createUpperCanvas();this.upper={el:r,ctx:r.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(r,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,r),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=ai();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=ds().createElement("div");return t.setAttribute("data-fabric","wrapper"),yo(t,{position:"relative"}),Qa(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;yo(t,_(_({},i),{},{"touch-action":s?"manipulation":oe})),Qa(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;Dc(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),ho(this.upper.el,t),ho(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),Ue().dispose(this.upper.el),delete this.upper,delete this.container}}class xn extends sr{constructor(){super(...arguments),v(this,"targets",[]),v(this,"_hoveredTargets",[]),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return _(_({},super.getDefaults()),xn.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Sm(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter((e=>!e.group&&e!==t)).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,i){const s=this.targetFindTolerance,r=this.pixelFindContext;this.clearContext(r),r.save(),r.translate(-e+s,-i+s),r.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=o,r.restore();const a=Math.round(s*this.getRetinaScaling());return Of(r,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find((i=>!!i&&t[i]===!0)):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&i.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let s;return e===gn||e===ce||e===_e||e===Gs?s=this.centeredScaling||t.centeredScaling:e===Ro&&(s=this.centeredRotation||t.centeredRotation),s?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=wt:["mr","tr","br"].includes(e)&&(i.x=Y),["tl","mt","tr"].includes(e)?i.y=co:["bl","mb","br"].includes(e)&&(i.y=ne)),i}_setupCurrentTransform(t,e,i){var s;const r=e.group?ss(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):Ng,c=((p,g,f,b)=>{if(!g||!p)return"drag";const m=b.controls[g];return m.getActionName(f,m,b)})(i,o,t,e),h=t[this.centeredKey],d=this._shouldCenterTransform(e,c,h)?{x:V,y:V}:this._getOriginFromCorner(e,o),u={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:d.x,originY:d.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:Ct(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:_(_({},Mc(e)),{},{originX:d.x,originY:d.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,o=new x(e,i).transform(this.viewportTransform),a=new x(e+s,i+r).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),d=Math.max(o.x,a.x),u=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,d-c,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,d-=l,u-=l,Nt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,d-c,u-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,s=this.getActiveObjects();if(this.targets=[],i&&s.length>=1){if(i.findControl(e,uo(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const r=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=r,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),r=t.padding/s;if(r){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),d=ni(h)*r,u=oi(h)*r,p=d+u,g=d-u;i=[new x(o.x-g,o.y-p),new x(a.x+p,a.y-g),new x(l.x+g,l.y+p),new x(c.x-p,c.y+g)]}return ut.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,ss(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(Fr(s)&&s.subTargetCheck){const r=this._searchPossibleTargets(s._objects,e);r&&this.targets.push(r)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Fr(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let r=s.length-1;r>0;r--){const o=s[r];if(!Fr(o)||!o.interactive)return o}return s[0]}return i}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let r=jg(t),o=s.width||0,a=s.height||0;o&&a||(ne in s&&co in s&&(a=Math.abs(s.top-s.bottom)),wt in s&&Y in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=ss(r,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(r.x/=l,r.y/=l);const c=o===0||a===0?new x(1,1):new x(i.width/o,i.height/a);return r.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ai(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return Mi(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const r=this.getActiveObjects(),o=[],a=[];t.forEach((l=>{r.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))})),r.forEach((l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))})),t.length>0&&r.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):r.length>0?(s=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),s}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Mi(t)&&i!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),Mi(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});const s=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),s}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,i=e.target,s={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),i.fire(Wr,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Mi(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,i){const s=this._realizeGroupTransformOnObject(t),r=super._toObject(t,e,i);return t.set(s),r}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Mi(e)&&this._activeObject===e){const i=fs(t,["angle","flipX","flipY",Y,ce,_e,us,ps,ne]);return Rg(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(xn,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class Tm{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),Zi(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Em=["target","oldTarget","fireCanvas","e"],ue={passive:!1},qi=(n,t)=>{const e=n.getViewportPoint(t),i=n.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},pi=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.addEventListener(...e)},be=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.removeEventListener(...e)},km={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class _o extends xn{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Tm(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((e=>{this[e]=this[e].bind(this)})),this.addOrRemove(pi,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(Pc(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,ue),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel,{passive:!1}),t(i,"contextmenu",this._onContextMenu),t(i,"click",this._onClick),t(i,"dblclick",this._onClick),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,ue)}removeListeners(){this.addOrRemove(be,"remove");const t=this._getEventPrefix(),e=Te(this.upperCanvasEl);be(e,"".concat(t,"up"),this._onMouseUp),be(e,"touchend",this._onTouchEnd,ue),be(e,"".concat(t,"move"),this._onMouseMove,ue),be(e,"touchmove",this._onMouseMove,ue),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=_({e:t},qi(this,t));this.fire("mouse:out",_(_({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",_({},i)),this._hoveredTargets.forEach((s=>{this.fire("mouse:out",_(_({},i),{},{target:s})),s&&s.fire("mouseout",_({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",_({e:t},qi(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const i={e:t,target:e};return this.fire("dragstart",i),e.fire("dragstart",i),void pi(this.upperCanvasEl,"drag",this._onDragProgress)}tl(t)}_renderDragEffects(t,e,i){let s=!1;const r=this._dropTarget;r&&r!==e&&r!==i&&(r.clearContextTop(),s=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==oe,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};be(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:i,targets:s}=this.findDragTargets(t),r=this._dragSource,o={e:t,target:i,subTargets:s,dragSource:r,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(a=i),i.fire(e,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,r,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),s={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:i}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",_({e:t,target:e,subTargets:i,dragSource:this._dragSource},qi(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&tl(t),this._basicEventHandler("contextmenu",s),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||i&&this._target===i)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,r=this._getEventPrefix(),o=Te(s);pi(o,"touchend",this._onTouchEnd,ue),e&&pi(o,"touchmove",this._onMouseMove,ue),be(s,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();be(e,"".concat(i,"move"),this._onMouseMove,ue);const s=Te(e);pi(s,"".concat(i,"up"),this._onMouseUp),pi(s,"".concat(i,"move"),this._onMouseMove,ue)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=Te(this.upperCanvasEl);be(i,"touchend",this._onTouchEnd,ue),be(i,"touchmove",this._onMouseMove,ue),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{pi(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0}),400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){const s=Te(this.upperCanvasEl);be(s,"".concat(i,"up"),this._onMouseUp),be(s,"".concat(i,"move"),this._onMouseMove,ue),pi(e,"".concat(i,"move"),this._onMouseMove,ue)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const i=this._currentTransform,s=this._isClick,r=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!s){const h=r===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(r)||!h&&r===this._activeObject)}if(r){const h=r.findControl(this.getViewportPoint(t),uo(t)),{key:d,control:u}=h||{};if(l=d,r.selectable&&r!==this._activeObject&&r.activeOn==="up")this.setActiveObject(r,t),c=!0;else if(u){const p=u.getMouseUpHandler(t,r,u);p&&(a=this.getScenePoint(t),p.call(u,t,i,a.x,a.y))}r.isMoving=!1}if(i&&(i.target!==r||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],d=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),d&&d.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:s=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let r=0;r<s.length;r++)s[r]!==i&&s[r].fire(t,e);return e}_handleEvent(t,e,i){const s=this._target,r=this.targets||[],o=_(_(_({e:t,target:s,subTargets:r},qi(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),e==="down:before"||e==="down"?i:{});this.fire("mouse:".concat(e),o),s&&s.fire("mouse".concat(e),o);for(let a=0;a<r.length;a++)r[a]!==s&&r[a].fire("mouse".concat(e),o)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,i=!!e&&e===this._activeObject;const{button:s}=t;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(t,"down",{alreadySelected:i}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let r=this._shouldRender(e),o=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,o=!0,r=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const a=this.getScenePoint(t);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(i=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),uo(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,i);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}r&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:i}),r&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=ss(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const i=this.findTarget(t);this._setCursorFromEvent(t,i),this._fireOverOutEvents(t,i)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)r[a]===e||s[a]&&s[a]===i||this.fireSyntheticInOutEvents("mouse",{e:t,target:r[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:r[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:r,e:o}=e,a=ot(e,Em);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=km[t],u=s!==i;if(s&&u){const p=_(_({},a),{},{e:o,target:s,nextTarget:i},qi(this,o));r&&this.fire(d,p),s.fire(c,p)}if(i&&u){const p=_(_({},a),{},{e:o,target:i,previousTarget:s},qi(this,o));r&&this.fire(h,p),i.fire(l,p)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,s=i.target,r=s.group?ss(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,r),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:r,target:o}=e,a=!!r&&r(t,e,i.x,i.y);a&&o.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=Mi(this._activeObject)?this._activeObject:null,r=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(r){const o=r.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map((o=>{i=o.hoverCursor||i})),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=Mi(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||s)&&(s||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(s){const r=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(r,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],i.size()===1&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(r,t)}else{i.isEditing&&i.exitEditing();const r=new(D.getClass("ActiveSelection"))([],{canvas:this});r.multiSelectAdd(i,e),this._hoveredTarget=r,this._setActiveObject(r,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,o=new x(e,i),a=o.add(new x(s,r)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),d=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter((u=>!u.onSelect({e:t}))).reverse():h;if(d.length===1)this.setActiveObject(d[0],t);else if(d.length>1){const u=D.getClass("ActiveSelection");this.setActiveObject(new u(d,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:i}=this.elements;i.ctx=void 0;const s=super.toCanvasElement(t,e);return i.ctx=i.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const oh={x1:0,y1:0,x2:0,y2:0},Om=_(_({},oh),{},{r1:0,r2:0}),ts=(n,t)=>isNaN(n)&&typeof t=="number"?t:n;function ah(n){return n&&/%$/.test(n)&&Number.isFinite(parseFloat(n))}function lh(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(ah(n)?100:1):NaN;return ls(0,ts(e,t),1)}const Pm=/\s*;\s*/,Dm=/\s*:\s*/;function Am(n,t){let e,i;const s=n.getAttribute("style");if(s){const o=s.split(Pm);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Dm).map((h=>h.trim()));l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const r=new K(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:lh(n.getAttribute("offset"),0),color:r.toRgb(),opacity:ts(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function Mm(n,t){const e=[],i=n.getElementsByTagName("stop"),s=lh(t,1);for(let r=i.length;r--;)e.push(Am(i[r],s));return e}function ch(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function hh(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function we(n,t){return n.getAttribute(t)}function Im(n,t){return(function(e,i){let s,{width:r,height:o,gradientUnits:a}=i;return Object.entries(e).reduce(((l,c)=>{let[h,d]=c;if(d==="Infinity")s=1;else if(d==="-Infinity")s=0;else{const u=typeof d=="string";s=u?parseFloat(d):d,u&&ah(d)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=r),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l}),{})})(ch(n)==="linear"?(function(e){return{x1:we(e,"x1")||0,y1:we(e,"y1")||0,x2:we(e,"x2")||"100%",y2:we(e,"y2")||0}})(n):(function(e){return{x1:we(e,"fx")||we(e,"cx")||"50%",y1:we(e,"fy")||we(e,"cy")||"50%",r1:0,x2:we(e,"cx")||"50%",y2:we(e,"cy")||"50%",r2:we(e,"r")||"50%"}})(n),_(_({},t),{},{gradientUnits:hh(n)}))}class dr{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:r=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:_(_({},e==="radial"?Om:oh),s),colorStops:r,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(Si()):Si()})}addColorStop(t){for(const e in t){const i=new K(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return _(_({},fs(this,t)),{},{type:this.type,coords:_({},this.coords),colorStops:this.colorStops.map((e=>_({},e))),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():Qt.concat(),r=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((d=>_({},d))).sort(((d,u)=>d.offset-u.offset));let a=-this.offsetX,l=-this.offsetY;var c;r==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Xs(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:d,y1:u,x2:p,y2:g}=this.coords;i.push("<linearGradient ",h,' x1="',d,'" y1="',u,'" x2="',p,'" y2="',g,`">
3303
3303
  `)}else if(this.type==="radial"){const{x1:d,y1:u,x2:p,y2:g,r1:f,r2:b}=this.coords,m=f>b;i.push("<radialGradient ",h,' cx="',m?d:p,'" cy="',m?u:g,'" r="',m?f:b,'" fx="',m?p:d,'" fy="',m?g:u,`">
3304
- `),m&&(o.reverse(),o.forEach((x=>{x.offset=1-x.offset})));const _=Math.min(f,b);if(_>0){const x=_/Math.max(f,b);o.forEach((S=>{S.offset+=x*(1-S.offset)}))}}return o.forEach((d=>{let{color:u,offset:p,opacity:g}=d;i.push("<stop ",'offset="',100*p+"%",'" style="stop-color:',u,g!==void 0?";stop-opacity: "+g:";",`"/>
3304
+ `),m&&(o.reverse(),o.forEach((w=>{w.offset=1-w.offset})));const y=Math.min(f,b);if(y>0){const w=y/Math.max(f,b);o.forEach((S=>{S.offset+=w*(1-S.offset)}))}}return o.forEach((d=>{let{color:u,offset:p,opacity:g}=d;i.push("<stop ",'offset="',100*p+"%",'" style="stop-color:',u,g!==void 0?";stop-opacity: "+g:";",`"/>
3305
3305
  `)})),i.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
3306
- `),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:r,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,r):t.createRadialGradient(e,i,o,s,r,a);return this.colorStops.forEach((c=>{let{color:h,opacity:d,offset:u}=c;l.addColorStop(u,d!==void 0?new K(h).setAlpha(d).toRgba():h)})),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(y(y({},t),{},{colorStops:e?e.map((s=>y({},s))):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=hh(t),r=e._findCenterFromElement();return new this(y({id:t.getAttribute("id")||void 0,type:ch(t),coords:Am(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Dm(t,i.opacity),gradientUnits:s,gradientTransform:mo(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}v(dr,"type","Gradient"),D.setClass(dr,"gradient"),D.setClass(dr,"linear"),D.setClass(dr,"radial");const Mm=["type","source","patternTransform"];class Wn{get type(){return"pattern"}set type(t){wi("warn","Setting type has no effect",t)}constructor(t){v(this,"repeat","repeat"),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"crossOrigin",""),this.id=Ci(),Object.assign(this,t)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return y(y({},fs(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:et(this.offsetX,W.NUM_FRACTION_DIGITS),offsetY:et(this.offsetY,W.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:r,id:o}=this,a=ts(this.offsetX/e,0),l=ts(this.offsetY/i,0),c=r==="repeat-y"||r==="no-repeat"?1+Math.abs(a||0):ts(s.width/e,0),h=r==="repeat-x"||r==="no-repeat"?1+Math.abs(l||0):ts(s.height/i,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
3307
- `)}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,o=ot(t,Mm);const a=await $r(s,y(y({},e),{},{crossOrigin:o.crossOrigin}));return new this(y(y({},o),{},{patternTransform:r&&r.slice(0),source:a}))}}v(Wn,"type","Pattern"),D.setClass(Wn),D.setClass(Wn,"pattern");const Im=["path","left","top"],Lm=["d"];class Mi extends Nt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:r}=e,o=ot(e,Im);super(),Object.assign(this,Mi.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(Y,s),typeof r=="number"&&this.set(se,r)}_setPath(t,e){this.path=dm(Array.isArray(t)?t:_m(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new w(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,i=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+i);break;case"M":t.moveTo(s[1]+e,s[2]+i);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i,s[5]+e,s[6]+i);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject(t)),{},{path:this.path.map((e=>e.slice()))})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=xm(this.path,W.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
3308
- `)]}_getOffsetTransform(){const t=W.NUM_FRACTION_DIGITS;return" translate(".concat(et(-this.pathOffset.x,t),", ").concat(et(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,V,V)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,r=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],r=o[2],t.push({x:e,y:i},{x:s,y:r});break;case"M":s=o[1],r=o[2],e=s,i=r;break;case"C":t.push(...El(s,r,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],r=o[6];break;case"Q":t.push(...El(s,r,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],r=o[4];break;case"Z":s=e,r=i}return ei(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return y(y({},t),{},{pathOffset:new w(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i),{d:r}=s;return new this(r,y(y(y({},ot(s,Lm)),e),{},{left:void 0,top:void 0}))}}v(Mi,"type","Path"),v(Mi,"cacheProperties",[...ci,"path","fillRule"]),v(Mi,"ATTRIBUTE_NAMES",[...Ei,"d"]),D.setClass(Mi),D.setSVGClass(Mi);const Fm=["left","top","radius"],dh=["radius","startAngle","endAngle","counterClockwise"];class Ke extends Nt{static getDefaults(){return y(y({},super.getDefaults()),Ke.ownDefaults)}constructor(t){super(),Object.assign(this,Ke.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,Ct(this.startAngle),Ct(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(ce)}getRadiusY(){return this.get("radius")*this.get(_e)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...dh,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
3306
+ `),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:r,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,r):t.createRadialGradient(e,i,o,s,r,a);return this.colorStops.forEach((c=>{let{color:h,opacity:d,offset:u}=c;l.addColorStop(u,d!==void 0?new K(h).setAlpha(d).toRgba():h)})),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(_(_({},t),{},{colorStops:e?e.map((s=>_({},s))):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=hh(t),r=e._findCenterFromElement();return new this(_({id:t.getAttribute("id")||void 0,type:ch(t),coords:Im(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Mm(t,i.opacity),gradientUnits:s,gradientTransform:mo(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}v(dr,"type","Gradient"),D.setClass(dr,"gradient"),D.setClass(dr,"linear"),D.setClass(dr,"radial");const Lm=["type","source","patternTransform"];class Wn{get type(){return"pattern"}set type(t){Ci("warn","Setting type has no effect",t)}constructor(t){v(this,"repeat","repeat"),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"crossOrigin",""),this.id=Si(),Object.assign(this,t)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return _(_({},fs(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:et(this.offsetX,W.NUM_FRACTION_DIGITS),offsetY:et(this.offsetY,W.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:r,id:o}=this,a=ts(this.offsetX/e,0),l=ts(this.offsetY/i,0),c=r==="repeat-y"||r==="no-repeat"?1+Math.abs(a||0):ts(s.width/e,0),h=r==="repeat-x"||r==="no-repeat"?1+Math.abs(l||0):ts(s.height/i,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
3307
+ `)}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,o=ot(t,Lm);const a=await $r(s,_(_({},e),{},{crossOrigin:o.crossOrigin}));return new this(_(_({},o),{},{patternTransform:r&&r.slice(0),source:a}))}}v(Wn,"type","Pattern"),D.setClass(Wn),D.setClass(Wn,"pattern");const Fm=["path","left","top"],jm=["d"];class Ii extends Nt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:r}=e,o=ot(e,Fm);super(),Object.assign(this,Ii.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(Y,s),typeof r=="number"&&this.set(ne,r)}_setPath(t,e){this.path=pm(Array.isArray(t)?t:wm(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new x(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,i=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+i);break;case"M":t.moveTo(s[1]+e,s[2]+i);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i,s[5]+e,s[6]+i);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),{},{path:this.path.map((e=>e.slice()))})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=Cm(this.path,W.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
3308
+ `)]}_getOffsetTransform(){const t=W.NUM_FRACTION_DIGITS;return" translate(".concat(et(-this.pathOffset.x,t),", ").concat(et(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,V,V)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,r=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],r=o[2],t.push({x:e,y:i},{x:s,y:r});break;case"M":s=o[1],r=o[2],e=s,i=r;break;case"C":t.push(...El(s,r,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],r=o[6];break;case"Q":t.push(...El(s,r,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],r=o[4];break;case"Z":s=e,r=i}return ei(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return _(_({},t),{},{pathOffset:new x(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i),{d:r}=s;return new this(r,_(_(_({},ot(s,jm)),e),{},{left:void 0,top:void 0}))}}v(Ii,"type","Path"),v(Ii,"cacheProperties",[...ci,"path","fillRule"]),v(Ii,"ATTRIBUTE_NAMES",[...ki,"d"]),D.setClass(Ii),D.setSVGClass(Ii);const $m=["left","top","radius"],dh=["radius","startAngle","endAngle","counterClockwise"];class Ke extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Ke.ownDefaults)}constructor(t){super(),Object.assign(this,Ke.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,Ct(this.startAngle),Ct(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(ce)}getRadiusY(){return this.get("radius")*this.get(_e)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...dh,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
3309
3309
  `];{const{radius:e}=this,i=Ct(this.startAngle),s=Ct(this.endAngle),r=ni(i)*e,o=oi(i)*e,a=ni(s)*e,l=oi(s)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(r," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
3310
- `]}}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,radius:a=0}=s;return new this(y(y({},ot(s,Fm)),{},{radius:a,left:r-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}v(Ke,"type","Circle"),v(Ke,"cacheProperties",[...ci,...dh]),v(Ke,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(Ke,"ATTRIBUTE_NAMES",["cx","cy","r",...Ei]),D.setClass(Ke),D.setSVGClass(Ke);const jm=["x1","y1","x2","y2"],$m=["x1","y1","x2","y2"],xo=["x1","x2","y1","y2"];class Ii extends Nt{constructor(){let[t,e,i,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Ii.ownDefaults),this.setOptions(r),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=r;typeof o=="number"&&this.set(Y,o),typeof a=="number"&&this.set(se,a)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:s}=this;this.width=Math.abs(i-t),this.height=Math.abs(s-e);const{left:r,top:o,width:a,height:l}=ei([{x:t,y:e},{x:i,y:s}]),c=new w(r+a/2,o+l/2);this.setPositionByOrigin(c,V,V)}_set(t,e){return super._set(t,e),xo.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const i=t.strokeStyle;var s;ve(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new w((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:r,height:o}=this,a=t<=e?-1:1,l=i<=s?-1:1;return{x1:a*r/2,x2:a*-r/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(s,`" />
3311
- `)]}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i),{x1:r=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([r,o,a,l],ot(s,jm))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,o=ot(t,$m);return this._fromObject(y(y({},o),{},{points:[e,i,s,r]}),{extraParam:"points"})}}v(Ii,"type","Line"),v(Ii,"cacheProperties",[...ci,...xo]),v(Ii,"ATTRIBUTE_NAMES",Ei.concat(xo)),D.setClass(Ii),D.setSVGClass(Ii);class ji extends Nt{static getDefaults(){return y(y({},super.getDefaults()),ji.ownDefaults)}constructor(t){super(),Object.assign(this,ji.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}v(ji,"type","Triangle"),v(ji,"ownDefaults",{width:100,height:100}),D.setClass(ji),D.setSVGClass(ji);const uh=["rx","ry"];class Ze extends Nt{static getDefaults(){return y(y({},super.getDefaults()),Ze.ownDefaults)}constructor(t){super(),Object.assign(this,Ze.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(ce)}getRy(){return this.get("ry")*this.get(_e)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...uh,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
3312
- `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Nr,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function Rm(n){if(!n)return[];const t=n.replace(/,/g," ").trim().split(/\s+/),e=[];for(let i=0;i<t.length;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e}v(Ze,"type","Ellipse"),v(Ze,"cacheProperties",[...ci,...uh]),v(Ze,"ownDefaults",{rx:0,ry:0}),v(Ze,"ATTRIBUTE_NAMES",[...Ei,"cx","cy","rx","ry"]),D.setClass(Ze),D.setSVGClass(Ze);const Bm=["left","top"],ph={exactBoundingBox:!1};class Se extends Nt{static getDefaults(){return y(y({},super.getDefaults()),Se.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"strokeDiff",void 0),Object.assign(this,Se.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(Y,i),typeof s=="number"&&this.set(se,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Of(this.points,t,this.isOpen())}_calcDimensions(t){t=y({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map((c=>c.projectedPoint)):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new w,strokeOffset:new w,strokeDiff:new w};const i=ei(e),s=fn(y(y({},t),{},{scaleX:1,scaleY:1})),r=ei(this.points.map((c=>te(c,s,!0)))),o=new w(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(Ct(this.skewX)),l-=a*Math.tan(Ct(this.skewY))),y(y({},i),{},{pathOffset:new w(a,l),strokeOffset:new w(r.left,r.top).subtract(new w(i.left,i.top)).multiply(o),strokeDiff:new w(i.width,i.height).subtract(new w(r.width,r.height)).multiply(o)})}_findCenterFromElement(){const t=ei(this.points);return new w(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:s,height:r,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:r,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new w(e+s/2,i+r/2),V,V)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new w(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some((a=>this.strokeUniform||this.constructor.layoutProperties.includes(a)))){var e,i;const{width:a,height:l}=this._calcDimensions(t);o=new w((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,r;o=new w((s=t.width)!==null&&s!==void 0?s:this.width,(r=t.height)!==null&&r!==void 0?r:this.height)}return o.multiply(new w(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&i&&((t===ce||t===_e)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject(t)),{},{points:this.points.map((e=>{let{x:i,y:s}=e;return{x:i,y:s}}))})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=W.NUM_FRACTION_DIGITS;for(let r=0,o=this.points.length;r<o;r++)t.push(et(this.points[r].x-e,s),",",et(this.points[r].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
3313
- `)]}_render(t){const e=this.points.length,i=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-s);for(let r=0;r<e;r++){const o=this.points[r];t.lineTo(o.x-i,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(Rm(t.getAttribute("points")),y(y({},ot(hi(t,this.ATTRIBUTE_NAMES,i),Bm)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(Se,"ownDefaults",ph),v(Se,"type","Polyline"),v(Se,"layoutProperties",[us,ps,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(Se,"cacheProperties",[...ci,"points"]),v(Se,"ATTRIBUTE_NAMES",[...Ei]),D.setClass(Se),D.setSVGClass(Se);class ur extends Se{isOpen(){return!1}}v(ur,"ownDefaults",ph),v(ur,"type","Polygon"),D.setClass(ur),D.setSVGClass(ur);class gh extends Nt{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const i in e)for(const s in e[i])for(const r in e[i][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const i=e===void 0?this.styles:{0:this.styles[e]};for(const s in i)for(const r in i[s])if(i[s][r][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,r=0,o=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};r++,h[t]!==void 0?(s?h[t]!==s&&(o=!1):s=h[t],h[t]===this[t]&&delete h[t]):o=!1,Object.keys(h).length!==0?i++:delete e[l][c]}i===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&r===a&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,s,r;for(s in e){for(r in i=e[s],i)delete i[r][t],Object.keys(i[r]).length===0&&delete i[r];Object.keys(i).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const r=Vo(y(y({},this._getStyleDeclaration(i,s)),e),(o=>o!==void 0));this._setStyleDeclaration(i,s,r)}getSelectionStyles(t,e,i){const s=[];for(let r=t;r<(e||t);r++)s.push(this.getStyleAtPosition(r,i));return s}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,s):this._getStyleDeclaration(i,s)}setSelectionStyles(t,e,i){for(let s=e;s<(i||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const s=this.styles&&this.styles[t];return s&&(i=s[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return y(y({},fs(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,i){this.styles[t][e]=i}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}v(gh,"_styleProperties",Ng);const zm=/ +/g,Hm=/"/g;function Gn(n,t,e,i,s){return" ".concat((function(r,o){let{left:a,top:l,width:c,height:h}=o,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:W.NUM_FRACTION_DIGITS;const u=qs(Mt,r,!1),[p,g,f,b]=[a,l,c,h].map((m=>et(m,d)));return"<rect ".concat(u,' x="').concat(p,'" y="').concat(g,'" width="').concat(f,'" height="').concat(b,'"></rect>')})(n,{left:t,top:e,width:i,height:s}),`
3314
- `)}const Vm=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Yn;class qt extends gh{static getDefaults(){return y(y({},super.getDefaults()),qt.ownDefaults)}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,qt.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=nh(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Re)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,r,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Re||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,r=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){i=a.length,t=(this.width-e)/i;for(let h=0;h<=r.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(r[h])?(o.width+=t,o.kernedWidth+=t,o.left+=s,s+=t):o.left+=s}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<i.length;s++){if(t<=i[s].length)return{lineIndex:s,charIndex:t};t-=i[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:i[s-1].length<t?i[s-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===ne?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case V:t.textBaseline="middle";break;case"ascender":t.textBaseline=se;break;case"descender":t.textBaseline=co}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,i,s,r,o){this._renderChars(t,e,i,s,r,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let r=0,o=this._textLines.length;r<o;r++){const a=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){s+=a;continue}const l=this._textLines[r].length,c=this._getLineLeftOffset(r);let h,d,u=0,p=0,g=this.getValueOfPropertyAt(r,0,"textBackgroundColor");const f=this.getHeightOfLineImpl(r);for(let b=0;b<l;b++){const m=this.__charBounds[r][b];d=this.getValueOfPropertyAt(r,b,"textBackgroundColor"),this.path?(t.save(),t.translate(m.renderLeft,m.renderTop),t.rotate(m.angle),t.fillStyle=d,d&&t.fillRect(-m.width/2,-f*(1-this._fontSizeFraction),m.width,f),t.restore()):d!==g?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=g,g&&t.fillRect(h,s,u,f),p=m.left,u=m.width,g=d):u+=m.kernedWidth}d&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=d,t.fillRect(h,s,u,f)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const r=$s.getFontCache(e),o=this._getFontDeclaration(e),a=i?i+t:t,l=i&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,d,u,p;if(i&&r.has(i)&&(u=r.get(i)),r.has(t)&&(p=h=r.get(t)),l&&r.has(a)&&(d=r.get(a),p=d-u),h===void 0||u===void 0||d===void 0){const g=(function(){return Yn||(Yn=xe({width:0,height:0}).getContext("2d")),Yn})();this._setTextStyles(g,e,!0),h===void 0&&(p=h=g.measureText(t).width,r.set(t,h)),u===void 0&&l&&i&&(u=g.measureText(i).width,r.set(i,u)),l&&d===void 0&&(d=g.measureText(a).width,r.set(a,d),p=d-u)}return{width:h*c,kernedWidth:p*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const r=this.pathSide===wt,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const d=a[h];i=this._getGraphemeBox(d,t,h,e),c[h]=i,s+=i.kernedWidth,e=d}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const d=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Y:h=r?d-s:0;break;case V:h=(d-s)/2;break;case wt:h=r?0:d-s}h+=this.pathStartOffset*(r?-1:1);for(let u=r?l-1:0;r?u>=0:u<l;r?u--:u++)i=c[u],h>d?h%=d:h<0&&(h+=d),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,r=mm(s.path,i,s.segmentsInfo);e.renderLeft=r.x-s.pathOffset.x,e.renderTop=r.y-s.pathOffset.y,e.angle=r.angle+(this.pathSide===wt?Math.PI:0)}_getGraphemeBox(t,e,i,s,r){const o=this.getCompleteStyleDeclaration(e,i),a=s?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,d=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),d+=c,h+=c);const u={width:d,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!r){const p=this.__charBounds[e][i-1];u.left=p.left+p.width+l.kernedWidth-l.width}return u}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let i=this.getHeightOfChar(t,0);for(let s=1,r=this._textLines[t].length;s<r;s++)i=Math.max(this.getHeightOfChar(t,s),i);return e[t]=i*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,i=this._textLines.length;e<i;e++)t+=e===i-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0;const s=this._getLeftOffset(),r=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(e,t,this._textLines[o],s+this._getLineLeftOffset(o),r+i+this.getHeightOfLineImpl(o),o),i+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Mt))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,r,o){const a=this.textAlign.includes(Re),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction==="ltr",d=this.direction==="ltr"?1:-1,u=e.direction;let p,g,f,b,m,_="",x=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?Y:wt),r-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,i.join(""),s,r),void e.restore();for(let S=0,T=i.length-1;S<=T;S++)b=S===T||this.charSpacing||l,_+=i[S],f=this.__charBounds[o][S],x===0?(s+=d*(f.kernedWidth-f.width),x+=f.width):x+=f.kernedWidth,a&&!b&&this._reSpaceAndTab.test(i[S])&&(b=!0),b||(p=p||this.getCompleteStyleDeclaration(o,S),g=this.getCompleteStyleDeclaration(o,S+1),b=Ko(p,g,!1)),b&&(l?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,o,S,_,-x/2,0),e.restore()):(m=s,this._renderChar(t,e,o,S,_,m,r)),_="",p=g,s+=d*x,x=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=xe({width:e,height:i}),r=s.getContext("2d");return s.width=e,s.height=i,r.beginPath(),r.moveTo(0,0),r.lineTo(e,0),r.lineTo(e,i),r.lineTo(0,i),r.closePath(),r.translate(e/2,i/2),r.fillStyle=t.toLive(r),this._applyPatternGradientTransform(r,t),r.fill(),r.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,r;return ve(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(s=-this.width/2,r=-this.height/2,t.translate(s,r),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:r}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:s}=e;return t.lineWidth=s,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",i)}_setFillStyles(t,e){let{fill:i}=e;return this.handleFiller(t,"fillStyle",i)}_renderChar(t,e,i,s,r,o,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,d=t==="strokeText"&&c.stroke&&c.strokeWidth;if(d||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const u=this._setFillStyles(e,c);e.fillText(r,o-u.offsetX,a-u.offsetY)}if(d){const u=this._setStrokeStyles(e,c);e.strokeText(r,o-u.offsetX,a-u.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const s=this.get2DCursorLocation(t,!0),r=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:r*i.size,deltaY:o+r*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,r=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===Re||s===Bs&&!o||s===Rs&&!o||s===Zr&&!o?0:(s===V&&(a=i/2),s===wt&&(a=i),s===Bs&&(a=i/2),s===Rs&&(a=i),r==="rtl"&&(s===wt||s===Re||s===Rs?a=0:s===Y||s===Zr?a=-i:s!==V&&s!==Bs||(a=-i/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return(s=this._getStyleDeclaration(t,e)[i])!==null&&s!==void 0?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),r=this.path,o=this._getWidthOfCharSpacing(),a=e==="linethrough"?.5:e==="overline"?1:0,l=this.offsets[e];for(let c=0,h=this._textLines.length;c<h;c++){const d=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){i+=d;continue}const u=this._textLines[c],p=d/this.lineHeight,g=this._getLineLeftOffset(c);let f=0,b=0,m=this.getValueOfPropertyAt(c,0,e),_=this.getValueOfPropertyAt(c,0,Mt),x=this.getValueOfPropertyAt(c,0,Vi),S=m,T=_,O=x;const k=i+p*(1-this._fontSizeFraction);let E=this.getHeightOfChar(c,0),P=this.getValueOfPropertyAt(c,0,"deltaY");for(let j=0,H=u.length;j<H;j++){const M=this.__charBounds[c][j];S=this.getValueOfPropertyAt(c,j,e),T=this.getValueOfPropertyAt(c,j,Mt),O=this.getValueOfPropertyAt(c,j,Vi);const U=this.getHeightOfChar(c,j),q=this.getValueOfPropertyAt(c,j,"deltaY");if(r&&S&&T){const Q=this.fontSize*O/1e3;t.save(),t.fillStyle=_,t.translate(M.renderLeft,M.renderTop),t.rotate(M.angle),t.fillRect(-M.kernedWidth/2,l*U+q-a*Q,M.kernedWidth,Q),t.restore()}else if((S!==m||T!==_||U!==E||O!==x||q!==P)&&b>0){const Q=this.fontSize*x/1e3;let N=s+g+f;this.direction==="rtl"&&(N=this.width-N-b),m&&_&&x&&(t.fillStyle=_,t.fillRect(N,k+l*E+P-a*Q,b,Q)),f=M.left,b=M.width,m=S,x=O,_=T,E=U,P=q}else b+=M.kernedWidth}let R=s+g+f;this.direction==="rtl"&&(R=this.width-R-b),t.fillStyle=T;const L=this.fontSize*O/1e3;S&&T&&O&&t.fillRect(R,k+l*E+P-a*L,b-o,L),i+=d}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||qt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(r?this.CACHE_FONT_SIZE:s,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return qo(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
3315
- `];let r=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),r=r.concat(i[o],s);return r.pop(),{_unwrappedLines:i,lines:e,graphemeText:r,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject([...Hc,...t])),{},{styles:Mf(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let s=!1,r=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),s=s||i.includes(o),r=r||o==="path";else s=i.includes(t),r=t==="path";return r&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=hi(t,qt.ATTRIBUTE_NAMES,i),r=y(y({},e),s),{textAnchor:o=Y,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:d=0,fontSize:u=jo,strokeWidth:p=1}=r,g=ot(r,Vm),f=new this(Kr(t.textContent||"").trim(),y({left:d+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:u},g)),b=f.getScaledHeight()/f.height,m=((f.height+f.strokeWidth)*f.lineHeight-f.height)*b,_=f.getScaledHeight()+m;let x=0;return o===V&&(x=f.getScaledWidth()/2),o===wt&&(x=f.getScaledWidth()),f.set({left:f.left-x,top:f.top-(_-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:p}),f}static fromObject(t){return this._fromObject(y(y({},t),{},{styles:If(t.styles||{},t.text)}),{extraParam:"text"})}}v(qt,"textLayoutProperties",zc),v(qt,"cacheProperties",[...ci,...Hc]),v(qt,"ownDefaults",Ug),v(qt,"type","Text"),v(qt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(qt,"ATTRIBUTE_NAMES",Ei.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Kc(qt,[class extends $c{_toSVG(){const n=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(n.textTop,n.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(n){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:n,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:n,withShadow:!0,additionalTransform:Xs(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(n){let{textBgRects:t,textSpans:e}=n;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(Hm,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
3316
- `]}_getSVGTextAndBg(n,t){const e=[],i=[];let s,r=n;this.backgroundColor&&i.push(...Gn(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)s=this._getLineLeftOffset(o),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+s,r),this._setSVGTextLineText(e,o,t+s,r),r+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(n,t,e,i,s){const r=W.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,n!==n.trim()||!!n.match(zm)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(et(l,r),'" '):"",{angle:h,renderLeft:d,renderTop:u,width:p}=s;let g="";if(d!==void 0){const f=p/2;h&&(g=' rotate="'.concat(et(li(h),r),'"'));const b=gs({angle:li(h)});b[4]=d,b[5]=u;const m=new w(-f,0).transform(b);e=m.x,i=m.y}return'<tspan x="'.concat(et(e,r),'" y="').concat(et(i,r),'" ').concat(c).concat(g).concat(a,">").concat(Pf(n),"</tspan>")}_setSVGTextLineText(n,t,e,i){const s=this.getHeightOfLine(t),r=this.textAlign.includes(Re),o=this._textLines[t];let a,l,c,h,d,u="",p=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=o.length-1;g<=f;g++)d=g===f||this.charSpacing||this.path,u+=o[g],c=this.__charBounds[t][g],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,r&&!d&&this._reSpaceAndTab.test(o[g])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(t,g),l=this.getCompleteStyleDeclaration(t,g+1),d=Ko(a,l,!0)),d&&(h=this._getStyleDeclaration(t,g),n.push(this._createTextCharSpan(u,h,e,i,c)),u="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(n,t,e,i){const s=this._textLines[t],r=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:d,width:u,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...Gn(c,e+l,i,a,r)),l=d,a=u,c=o):a+=p}o&&n.push(...Gn(c,e+l,i,a,r))}_getSVGLineTopOffset(n){let t,e=0;for(t=0;t<n;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(n){return"".concat(super.getSvgStyles(n)," text-decoration-thickness: ").concat(et(this.textDecorationThickness*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(n,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:r,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:d,overline:u,underline:p}=n,g=this.getSvgTextDecoration({underline:p??this.underline,overline:u??this.overline,linethrough:d??this.linethrough}),f=h||this.textDecorationThickness;return[s?qs(ne,s):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",g?"text-decoration: ".concat(g,"; text-decoration-thickness: ").concat(et(f*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; "):"",r?qs(Mt,r):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter((t=>n[t.replace("-","")])).join(" ")}}]),D.setClass(qt),D.setSVGClass(qt);class Nm{constructor(t){v(this,"target",void 0),v(this,"__mouseDownInPlace",!1),v(this,"__dragStartFired",!1),v(this,"__isDraggingOver",!1),v(this,"__dragStartSelection",void 0),v(this,"__dragImageDisposer",void 0),v(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach((i=>i())),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var i;let{selectionStart:s,selectionEnd:r}=e;const o=this.target,a=o.canvas,l=new w(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new w(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),d=a.getScenePoint(t).subtract(h),u=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),g=h.subtract(new w(p.left,p.top)),f=a.viewportTransform,b=g.add(d).transform(f,!0),m=o.backgroundColor,_=Xo(o.styles);o.backgroundColor="";const x={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(x,0,s),o.setSelectionStyles(x,r,o.text.length),o.dirty=!0;const S=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=m,o.styles=_,o.dirty=!0,yo(S,{position:"fixed",left:"".concat(-S.width,"px"),border:re,width:"".concat(S.width/u,"px"),height:"".concat(S.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{S.remove()},Te(t.target||this.target.hiddenTextarea).body.appendChild(S),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(S,b.x,b.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},r=e._text.slice(s.selectionStart,s.selectionEnd).join(""),o=y({text:e.text,value:r},s);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:i}=t,s=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let r=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(r&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=r[Math.max(0,r.length-1)],d=0;if(this.__dragStartSelection){const u=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>u&&l<=p?l=u:l>p&&(l-=p-u),o.removeChars(u,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(r,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+d,o._text.length),o.selectionEnd=Math.min(o.selectionStart+r.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Ur,{index:l+d,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const s=this.target,r=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||re;l===re?(s.selectionStart=o,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(o,a),s.selectionStart=s.selectionEnd=o,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Ur,{index:o,action:"dragend"}),r.fire("text:changed",{target:s}),r.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Pl=/[ \n\.,;!\?\-]/;class Um extends qt{constructor(){super(...arguments),v(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:r}=t;return Wc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach((e=>{e&&!e.isDone()&&(t=!0,e.abort())})),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some((t=>!t||t.isDone()))&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){const i=this._text;let s=t>0&&this._reSpace.test(i[t])&&(e===-1||!$o.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!Pl.test(r);)s+=e,r=i[s];return e===-1&&Pl.test(r)&&s++,s}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.searchWordBoundary(t,-1),s=Math.max(i,this.searchWordBoundary(t,1));this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.findLineBoundaryLeft(t),s=this.findLineBoundaryRight(t);this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;Te(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,r=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==r||s!==i&&r!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===r||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,i){const s=i.slice(0,t),r=this.graphemeSplit(s).length;if(t===e)return{selectionStart:r,selectionEnd:r};const o=i.slice(t,e);return{selectionStart:r,selectionEnd:r+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const s=i.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+i.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex,o=this.getValueOfPropertyAt(s,r,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,d=c.height/l,u=h-o,p=d-o,g=new w(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new w(c.clientWidth/h,c.clientHeight/d));return g.x<0&&(g.x=0),g.x>u&&(g.x=u),g.y<0&&(g.y=0),g.y>p&&(g.y=p),g.x+=this.canvas._offset.left,g.y+=this.canvas._offset.top,{left:"".concat(g.x,"px"),top:"".concat(g.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(Wr),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:r,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==r){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[r])for(let a=o;a<this._unwrappedTextLines[r].length;a++){const l=this.styles[r][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-o]=l)}for(let a=i+1;a<=r;a++)delete this.styles[a];this.shiftLineStyles(r,i-r)}else if(this.styles[i]){const a=this.styles[i],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const s in this.styles){const r=parseInt(s,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}}insertNewlineStyleObject(t,e,i,s){const r={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const d in this.styles[t]){const u=parseInt(d,10);u>=e&&(l=!0,r[u-e]=this.styles[t][d],a&&e===0||delete this.styles[t][d])}let h=!1;for(l&&!a&&(this.styles[t+i]=r,h=!0),(h||o>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:y({},s[i-1])}:c?this.styles[t+i]={0:y({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const r=this.styles[t],o=r?y({},r):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(r[c+i]=o[c],o[c-i]||delete r[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=y({},s[i]));return}if(!r)return;const a=r[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=y({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),r=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
3317
- `?(a++,r[a]=0):r[a]++;for(r[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+r[0],a),o=1;o<a;o++)r[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,r[o],i):i&&this.styles[s.lineIndex+o]&&i[0]&&(this.styles[s.lineIndex+o][0]=i[0]),i=i&&i.slice(r[o]+1);r[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,r[o],i)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;s>i&&this.removeStyleFromTo(i,s);const r=this.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[...this._text.slice(0,i),...r,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=Y:this._selectionDirection===wt&&(this._selectionDirection=Y,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===wt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=wt:this._selectionDirection===Y&&(this._selectionDirection=wt,this.selectionStart=e),this.selectionEnd=i)}}class Wm extends Um{initHiddenTextarea(){const t=this.canvas&&Te(this.canvas.getElement())||ds(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map((o=>{let[a,l]=o;return e.setAttribute(a,l)}));const{top:i,left:s,fontSize:r}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(r,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map((o=>{let[a,l]=o;return e.addEventListener(a,this[l].bind(this))})),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:i,selectionStart:s,selectionEnd:r}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Ur),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void o();const a=this._splitTextIntoLines(i).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,d=this.selectionEnd,u=h!==d;let p,g,f,b,m=c-l;const _=this.fromStringToGraphemeSelection(s,r,i),x=h>_.selectionStart;u?(g=this._text.slice(h,d),m+=d-h):c<l&&(g=x?this._text.slice(d+m,d):this._text.slice(h,h-m));const S=a.slice(_.selectionEnd-m,_.selectionEnd);if(g&&g.length&&(S.length&&(p=this.getSelectionStyles(h,h+1,!1),p=S.map((()=>p[0]))),u?(f=h,b=d):x?(f=d-g.length,b=d):(f=d,b=d+g.length),this.removeStyleFromTo(f,b)),S.length){const{copyPasteData:T}=Ue();e&&S.join("")===T.copiedText&&!W.disableStyleCopyPaste&&(p=T.copiedTextStyle),this.insertNewStyleBlock(S,h,p)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:s}=e;this.compositionStart=i,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Ue();t.copiedText=this.getSelectedText(),W.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,s=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],s+=i.left+i.width),s}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(r===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=s.charIndex,a=this._getWidthBeforeCursor(r,o),l=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(o).length+l+1+this.missingNewlineOffset(r)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(r===0||t.metaKey||t.keyCode===33)return-i;const o=s.charIndex,a=this._getWidthBeforeCursor(r,o),l=this._getIndexOnLine(r-1,a),c=this._textLines[r].slice(0,o),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,r,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){r=!0;const h=o-s,d=o,u=Math.abs(h-e);a=Math.abs(d-e)<u?l:l-1;break}return r||(a=i.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===wt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=ls(0,this.selectionStart,s),this.selectionEnd=ls(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Y?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Y,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===wt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=Y,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const i="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Y&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=wt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=wt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Dl=n=>!!n.button;class Gm extends Wm{constructor(){super(...arguments),v(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new Nm(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:i}=t;this.canvas&&this.editable&&!Dl(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),i&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=i||this.isEditing)))}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const r=this.canvas._activeObject;if(r&&r!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Dl(e)||s||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Ee(this.calcTransformMatrix())).add(new w(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,r=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),r=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(r));const a=this._textLines[r].length,l=this.__charBounds[r];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&s++;break}o=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const pr="moveCursorUp",gr="moveCursorDown",fr="moveCursorLeft",mr="moveCursorRight",br="exitEditing",Al=(n,t)=>{const e=t.getRetinaScaling();n.setTransform(e,0,0,e,0,0);const i=t.viewportTransform;n.transform(i[0],i[1],i[2],i[3],i[4],i[5])},Ym=y({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:br,27:br,33:pr,34:gr,35:mr,36:fr,37:fr,38:pr,39:mr,40:gr},keysMapRtl:{9:br,27:br,33:pr,34:gr,35:fr,36:mr,37:mr,38:pr,39:fr,40:gr},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class ti extends Gm{static getDefaults(){return y(y({},super.getDefaults()),ti.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,y(y({},ti.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof _o&&this.canvas.textEditingManager.remove(this),e instanceof _o&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),i=this.findAncestorsWithClipPath(),s=i.length>0;let r,o=t;if(s){r=xe(t.canvas),o=r.getContext("2d"),Al(o,this.canvas);const a=this.calcTransformMatrix();o.transform(a[0],a[1],a[2],a[3],a[4],a[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(o,e):this.renderCursor(o,e),s)for(const a of i){const l=a.clipPath,c=xe(t.canvas),h=c.getContext("2d");if(Al(h,this.canvas),!l.absolutePositioned){const d=a.calcTransformMatrix();h.transform(d[0],d[1],d[2],d[3],d[4],d[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(o,l,c)}s&&(t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const i=this._getLeftOffset(),s=this._getTopOffset(),r=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:r.left,topOffset:r.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0;const{charIndex:s,lineIndex:r}=this.get2DCursorLocation(t);for(let c=0;c<r;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(r),a=this.__charBounds[r][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[r].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===wt||this.textAlign===Re||this.textAlign===Rs?l.left*=-1:this.textAlign===Y||this.textAlign===Zr?l.left=o-(i>0?i:0):this.textAlign!==V&&this.textAlign!==Bs||(l.left=o-(i>0?i:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(s,r,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,r,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,r,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,i){const{color:s,opacity:r,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=r,t.fillRect(o,a,l,c)}renderSelection(t,e){const i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,i){const s=e.selectionStart,r=e.selectionEnd,o=this.textAlign.includes(Re),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(r),c=a.lineIndex,h=l.lineIndex,d=a.charIndex<0?0:a.charIndex,u=l.charIndex<0?0:l.charIndex;for(let p=c;p<=h;p++){const g=this._getLineLeftOffset(p)||0;let f=this.getHeightOfLine(p),b=0,m=0,_=0;if(p===c&&(m=this.__charBounds[c][d].left),p>=c&&p<h)_=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(u===0)_=this.__charBounds[h][u].left;else{const k=this._getWidthOfCharSpacing();_=this.__charBounds[h][u-1].left+this.__charBounds[h][u-1].width-k}b=f,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(f/=this.lineHeight);let x=i.left+g+m,S=f,T=0;const O=_-m;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",S=1,T=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===wt||this.textAlign===Re||this.textAlign===Rs?x=this.width-x-O:this.textAlign===Y||this.textAlign===Zr?x=i.left+g-_:this.textAlign!==V&&this.textAlign!==Bs||(x=i.left+g-_)),t.fillRect(x,i.top+i.topOffset+T,O,S),i.topOffset+=b}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Mt)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}v(ti,"ownDefaults",Ym),v(ti,"type","IText"),D.setClass(ti),D.setClass(ti,"i-text");class vi extends ti{static getDefaults(){return y(y({},super.getDefaults()),vi.ownDefaults)}constructor(t,e){super(t,y(y({},vi.ownDefaults),e))}static createControls(){return{controls:Tf()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Re)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const r={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
3318
- `&&o>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(i++,s++),r[o]={line:e,offset:i},s+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return r}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[e];i&&(e=i.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,r=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(s=a.line,r=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const d=parseInt(h,10);if(d>=i&&(!r||d<e))for(const u in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,i){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,i)}_deleteStyleDeclaration(t,e){const i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const i=this.getGraphemeDataForRender(t),s=[];for(let r=0;r<i.wordsData.length;r++)s.push(...this._wrapLine(r,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map(((r,o)=>{let a=0;const l=e?this.graphemeSplit(r):this.wordSplit(r);return l.length===0?[{word:[],width:0}]:l.map((c=>{const h=e?[c]:this.graphemeSplit(c),d=this._measureWord(h,o,a);return s=Math.max(d,s),a+=h.length+i.length,{word:h,width:d}}))})),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=0;for(let o=0,a=t.length;o<a;o++)r+=this._getGraphemeBox(t[o],e,o+s,i,!0).kernedWidth,i=t[o];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:r}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let d=0,u=[],p=0,g=0,f=!0;e-=o;const b=Math.max(e,s,this.dynamicMinWidth),m=r[t];let _;for(p=0,_=0;_<m.length;_++){const{word:x,width:S}=m[_];p+=x.length,d+=g+S-a,d>b&&!f?(c.push(u),u=[],d=S,f=!0):d+=a,f||l||u.push(h),u=u.concat(x),g=l?0:this._measureWord([h],t,p),p++,f=!1}return _&&c.push(u),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),s=new Array(i.length);for(let r=0;r<i.length;r++)s[r]=i[r].join("");return e.lines=s,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const i=parseInt(e,10);if(this._textLines[i]){const s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}v(vi,"type","Textbox"),v(vi,"textLayoutProperties",[...ti.textLayoutProperties,"width"]),v(vi,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),D.setClass(vi);class Ml extends _n{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:r}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=ei(Qc(i,s)),l=new w(o,a);if(s.absolutePositioned)return{center:ss(s.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new w,correction:d=new w}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:d.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}v(Ml,"type","clip-path"),D.setClass(Ml);class Il extends _n{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new w(i.width||s.x,i.height||s.y)}}v(Il,"type","fixed"),D.setClass(Il);class Xm extends Zs{subscribeTargets(t){const e=t.target;t.targets.reduce(((i,s)=>(s.parent&&i.add(s.parent),i)),new Set).forEach((i=>{i.layoutManager.subscribeTargets({target:i,targets:[e]})}))}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce(((s,r)=>(r.parent&&s.add(r.parent),s)),new Set).forEach((s=>{!i.some((r=>r.parent===s))&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})}))}}class $i extends _i{static getDefaults(){return y(y({},super.getDefaults()),$i.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,$i.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:r}=e;this.groupInit(t,{left:i,top:s,layoutManager:r??new Xm})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach((s=>{const r=this._objects.findIndex((a=>a.isInFrontOf(s))),o=r===-1?this.size():r;this.insertAt(o,s)}))}canEnterGroup(t){return this.getObjects().some((e=>e.isDescendantOf(t)||t.isDescendantOf(e)))?(wi("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const i=new Set;e.forEach((s=>{const{parent:r}=s;r&&i.add(r)})),t===Jo?i.forEach((s=>{s._onAfterObjectsChange(Jr,e)})):i.forEach((s=>{s._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=y(y({hasControls:!1},i),{},{forActiveSelection:!0});for(let r=0;r<this._objects.length;r++)this._objects[r]._renderControls(t,s);super._renderControls(t,e),t.restore()}}v($i,"type","ActiveSelection"),v($i,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),D.setClass($i),D.setClass($i,"activeSelection");class qm{constructor(){v(this,"resources",{})}applyFilters(t,e,i,s,r){const o=r.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,s);const a={sourceWidth:i,sourceHeight:s,imageData:o.getImageData(0,0,i,s),originalEl:e,originalImageData:o.getImageData(0,0,i,s),canvasEl:r,ctx:o,filterBackend:this};t.forEach((c=>{c.applyTo(a)}));const{imageData:l}=a;return l.width===i&&l.height===s||(r.width=l.width,r.height=l.height),o.putImageData(l,0,0),a}}class fh{constructor(){let{tileSize:t=W.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};v(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),v(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=xe({width:t,height:e}),s=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)}applyFilters(t,e,i,s,r,o){const a=this.gl,l=r.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,i,s,c?void 0:e),targetTexture:this.createTexture(a,i,s),originalTexture:c||this.createTexture(a,i,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},d=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,d),t.forEach((u=>{u&&u.applyTo(h)})),(function(u){const p=u.targetCanvas,g=p.width,f=p.height,b=u.destinationWidth,m=u.destinationHeight;g===b&&f===m||(p.width=b,p.height=m)})(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(d),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,r){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:d,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:p,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,d,r||o),t.texParameteri(a,u,r||o),t.texParameteri(a,p,h),t.texParameteri(a,g,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,null),f}getCachedTexture(t,e,i){const{textureCache:s}=this;if(s[t])return s[t];{const r=this.createTexture(this.gl,e.width,e.height,e,i);return r&&(s[t]=r),r}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,s=e.targetCanvas,r=s.getContext("2d");if(!r)return;r.translate(0,s.height),r.scale(1,-1);const o=i.height-s.height;r.drawImage(i,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),s=e.destinationWidth,r=e.destinationHeight,o=s*r*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,r,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,r);i.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}let Xn;function Km(){const{WebGLProbe:n}=Ue();return n.queryWebGL(ai()),W.enableGLFiltering&&n.isSupported(W.textureSize)?new fh({tileSize:W.textureSize}):new qm}function qn(){return!Xn&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Xn=Km()),Xn}const Zm=["filters","resizeFilter","src","crossOrigin","type"],mh=["cropX","cropY"];class ee extends Nt{static getDefaults(){return y(y({},super.getDefaults()),ee.ownDefaults)}constructor(t,e){super(),v(this,"_lastScaleX",1),v(this,"_lastScaleY",1),v(this,"_filterScalingX",1),v(this,"_filterScalingY",1),this.filters=[],Object.assign(this,ee.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Ci()),this.setElement(typeof t=="string"?(this.canvas&&Te(this.canvas.getElement())||ds()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){var e;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(i),(e=t.classList)===null||e===void 0||e.add(ee.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=qn(!1);e instanceof fh&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((t=>{const e=this[t];e&&Ue().dispose(e),this[t]=void 0}))}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach((i=>{i&&e.push(i.toObject())})),y(y({},super.toObject([...mh,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,i=-this.width/2,s=-this.height/2;let r=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=Ci();r.push('<clipPath id="imageCrop_'+c+`">
3310
+ `]}}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,radius:a=0}=s;return new this(_(_({},ot(s,$m)),{},{radius:a,left:r-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}v(Ke,"type","Circle"),v(Ke,"cacheProperties",[...ci,...dh]),v(Ke,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(Ke,"ATTRIBUTE_NAMES",["cx","cy","r",...ki]),D.setClass(Ke),D.setSVGClass(Ke);const Rm=["x1","y1","x2","y2"],Bm=["x1","y1","x2","y2"],xo=["x1","x2","y1","y2"];class Li extends Nt{constructor(){let[t,e,i,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Li.ownDefaults),this.setOptions(r),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=r;typeof o=="number"&&this.set(Y,o),typeof a=="number"&&this.set(ne,a)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:s}=this;this.width=Math.abs(i-t),this.height=Math.abs(s-e);const{left:r,top:o,width:a,height:l}=ei([{x:t,y:e},{x:i,y:s}]),c=new x(r+a/2,o+l/2);this.setPositionByOrigin(c,V,V)}_set(t,e){return super._set(t,e),xo.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const i=t.strokeStyle;var s;ve(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new x((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:r,height:o}=this,a=t<=e?-1:1,l=i<=s?-1:1;return{x1:a*r/2,x2:a*-r/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(s,`" />
3311
+ `)]}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i),{x1:r=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([r,o,a,l],ot(s,Rm))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,o=ot(t,Bm);return this._fromObject(_(_({},o),{},{points:[e,i,s,r]}),{extraParam:"points"})}}v(Li,"type","Line"),v(Li,"cacheProperties",[...ci,...xo]),v(Li,"ATTRIBUTE_NAMES",ki.concat(xo)),D.setClass(Li),D.setSVGClass(Li);class $i extends Nt{static getDefaults(){return _(_({},super.getDefaults()),$i.ownDefaults)}constructor(t){super(),Object.assign(this,$i.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}v($i,"type","Triangle"),v($i,"ownDefaults",{width:100,height:100}),D.setClass($i),D.setSVGClass($i);const uh=["rx","ry"];class Ze extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Ze.ownDefaults)}constructor(t){super(),Object.assign(this,Ze.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(ce)}getRy(){return this.get("ry")*this.get(_e)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...uh,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
3312
+ `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Nr,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=hi(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function zm(n){if(!n)return[];const t=n.replace(/,/g," ").trim().split(/\s+/),e=[];for(let i=0;i<t.length;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e}v(Ze,"type","Ellipse"),v(Ze,"cacheProperties",[...ci,...uh]),v(Ze,"ownDefaults",{rx:0,ry:0}),v(Ze,"ATTRIBUTE_NAMES",[...ki,"cx","cy","rx","ry"]),D.setClass(Ze),D.setSVGClass(Ze);const Hm=["left","top"],ph={exactBoundingBox:!1};class Se extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Se.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"strokeDiff",void 0),Object.assign(this,Se.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(Y,i),typeof s=="number"&&this.set(ne,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Df(this.points,t,this.isOpen())}_calcDimensions(t){t=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map((c=>c.projectedPoint)):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new x,strokeOffset:new x,strokeDiff:new x};const i=ei(e),s=fn(_(_({},t),{},{scaleX:1,scaleY:1})),r=ei(this.points.map((c=>ie(c,s,!0)))),o=new x(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(Ct(this.skewX)),l-=a*Math.tan(Ct(this.skewY))),_(_({},i),{},{pathOffset:new x(a,l),strokeOffset:new x(r.left,r.top).subtract(new x(i.left,i.top)).multiply(o),strokeDiff:new x(i.width,i.height).subtract(new x(r.width,r.height)).multiply(o)})}_findCenterFromElement(){const t=ei(this.points);return new x(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:s,height:r,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:r,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new x(e+s/2,i+r/2),V,V)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new x(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some((a=>this.strokeUniform||this.constructor.layoutProperties.includes(a)))){var e,i;const{width:a,height:l}=this._calcDimensions(t);o=new x((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,r;o=new x((s=t.width)!==null&&s!==void 0?s:this.width,(r=t.height)!==null&&r!==void 0?r:this.height)}return o.multiply(new x(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&i&&((t===ce||t===_e)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),{},{points:this.points.map((e=>{let{x:i,y:s}=e;return{x:i,y:s}}))})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=W.NUM_FRACTION_DIGITS;for(let r=0,o=this.points.length;r<o;r++)t.push(et(this.points[r].x-e,s),",",et(this.points[r].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
3313
+ `)]}_render(t){const e=this.points.length,i=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-s);for(let r=0;r<e;r++){const o=this.points[r];t.lineTo(o.x-i,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(zm(t.getAttribute("points")),_(_({},ot(hi(t,this.ATTRIBUTE_NAMES,i),Hm)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(Se,"ownDefaults",ph),v(Se,"type","Polyline"),v(Se,"layoutProperties",[us,ps,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(Se,"cacheProperties",[...ci,"points"]),v(Se,"ATTRIBUTE_NAMES",[...ki]),D.setClass(Se),D.setSVGClass(Se);class ur extends Se{isOpen(){return!1}}v(ur,"ownDefaults",ph),v(ur,"type","Polygon"),D.setClass(ur),D.setSVGClass(ur);class gh extends Nt{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const i in e)for(const s in e[i])for(const r in e[i][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const i=e===void 0?this.styles:{0:this.styles[e]};for(const s in i)for(const r in i[s])if(i[s][r][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,r=0,o=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};r++,h[t]!==void 0?(s?h[t]!==s&&(o=!1):s=h[t],h[t]===this[t]&&delete h[t]):o=!1,Object.keys(h).length!==0?i++:delete e[l][c]}i===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&r===a&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,s,r;for(s in e){for(r in i=e[s],i)delete i[r][t],Object.keys(i[r]).length===0&&delete i[r];Object.keys(i).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const r=Vo(_(_({},this._getStyleDeclaration(i,s)),e),(o=>o!==void 0));this._setStyleDeclaration(i,s,r)}getSelectionStyles(t,e,i){const s=[];for(let r=t;r<(e||t);r++)s.push(this.getStyleAtPosition(r,i));return s}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,s):this._getStyleDeclaration(i,s)}setSelectionStyles(t,e,i){for(let s=e;s<(i||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const s=this.styles&&this.styles[t];return s&&(i=s[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return _(_({},fs(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,i){this.styles[t][e]=i}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}v(gh,"_styleProperties",Wg);const Vm=/ +/g,Nm=/"/g;function Gn(n,t,e,i,s){return" ".concat((function(r,o){let{left:a,top:l,width:c,height:h}=o,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:W.NUM_FRACTION_DIGITS;const u=qs(Mt,r,!1),[p,g,f,b]=[a,l,c,h].map((m=>et(m,d)));return"<rect ".concat(u,' x="').concat(p,'" y="').concat(g,'" width="').concat(f,'" height="').concat(b,'"></rect>')})(n,{left:t,top:e,width:i,height:s}),`
3314
+ `)}const Um=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Yn;class Kt extends gh{static getDefaults(){return _(_({},super.getDefaults()),Kt.ownDefaults)}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,Kt.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=nh(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Re)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,r,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Re||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,r=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){i=a.length,t=(this.width-e)/i;for(let h=0;h<=r.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(r[h])?(o.width+=t,o.kernedWidth+=t,o.left+=s,s+=t):o.left+=s}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<i.length;s++){if(t<=i[s].length)return{lineIndex:s,charIndex:t};t-=i[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:i[s-1].length<t?i[s-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===ae?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case V:t.textBaseline="middle";break;case"ascender":t.textBaseline=ne;break;case"descender":t.textBaseline=co}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,i,s,r,o){this._renderChars(t,e,i,s,r,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let r=0,o=this._textLines.length;r<o;r++){const a=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){s+=a;continue}const l=this._textLines[r].length,c=this._getLineLeftOffset(r);let h,d,u=0,p=0,g=this.getValueOfPropertyAt(r,0,"textBackgroundColor");const f=this.getHeightOfLineImpl(r);for(let b=0;b<l;b++){const m=this.__charBounds[r][b];d=this.getValueOfPropertyAt(r,b,"textBackgroundColor"),this.path?(t.save(),t.translate(m.renderLeft,m.renderTop),t.rotate(m.angle),t.fillStyle=d,d&&t.fillRect(-m.width/2,-f*(1-this._fontSizeFraction),m.width,f),t.restore()):d!==g?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=g,g&&t.fillRect(h,s,u,f),p=m.left,u=m.width,g=d):u+=m.kernedWidth}d&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=d,t.fillRect(h,s,u,f)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const r=$s.getFontCache(e),o=this._getFontDeclaration(e),a=i?i+t:t,l=i&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,d,u,p;if(i&&r.has(i)&&(u=r.get(i)),r.has(t)&&(p=h=r.get(t)),l&&r.has(a)&&(d=r.get(a),p=d-u),h===void 0||u===void 0||d===void 0){const g=(function(){return Yn||(Yn=xe({width:0,height:0}).getContext("2d")),Yn})();this._setTextStyles(g,e,!0),h===void 0&&(p=h=g.measureText(t).width,r.set(t,h)),u===void 0&&l&&i&&(u=g.measureText(i).width,r.set(i,u)),l&&d===void 0&&(d=g.measureText(a).width,r.set(a,d),p=d-u)}return{width:h*c,kernedWidth:p*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const r=this.pathSide===wt,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const d=a[h];i=this._getGraphemeBox(d,t,h,e),c[h]=i,s+=i.kernedWidth,e=d}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const d=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Y:h=r?d-s:0;break;case V:h=(d-s)/2;break;case wt:h=r?0:d-s}h+=this.pathStartOffset*(r?-1:1);for(let u=r?l-1:0;r?u>=0:u<l;r?u--:u++)i=c[u],h>d?h%=d:h<0&&(h+=d),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,r=vm(s.path,i,s.segmentsInfo);e.renderLeft=r.x-s.pathOffset.x,e.renderTop=r.y-s.pathOffset.y,e.angle=r.angle+(this.pathSide===wt?Math.PI:0)}_getGraphemeBox(t,e,i,s,r){const o=this.getCompleteStyleDeclaration(e,i),a=s?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,d=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),d+=c,h+=c);const u={width:d,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!r){const p=this.__charBounds[e][i-1];u.left=p.left+p.width+l.kernedWidth-l.width}return u}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let i=this.getHeightOfChar(t,0);for(let s=1,r=this._textLines[t].length;s<r;s++)i=Math.max(this.getHeightOfChar(t,s),i);return e[t]=i*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,i=this._textLines.length;e<i;e++)t+=e===i-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0;const s=this._getLeftOffset(),r=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(e,t,this._textLines[o],s+this._getLineLeftOffset(o),r+i+this.getHeightOfLineImpl(o),o),i+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Mt))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,r,o){const a=this.textAlign.includes(Re),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction==="ltr",d=this.direction==="ltr"?1:-1,u=e.direction;let p,g,f,b,m,y="",w=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?Y:wt),r-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,i.join(""),s,r),void e.restore();for(let S=0,T=i.length-1;S<=T;S++)b=S===T||this.charSpacing||l,y+=i[S],f=this.__charBounds[o][S],w===0?(s+=d*(f.kernedWidth-f.width),w+=f.width):w+=f.kernedWidth,a&&!b&&this._reSpaceAndTab.test(i[S])&&(b=!0),b||(p=p||this.getCompleteStyleDeclaration(o,S),g=this.getCompleteStyleDeclaration(o,S+1),b=Ko(p,g,!1)),b&&(l?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,o,S,y,-w/2,0),e.restore()):(m=s,this._renderChar(t,e,o,S,y,m,r)),y="",p=g,s+=d*w,w=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=xe({width:e,height:i}),r=s.getContext("2d");return s.width=e,s.height=i,r.beginPath(),r.moveTo(0,0),r.lineTo(e,0),r.lineTo(e,i),r.lineTo(0,i),r.closePath(),r.translate(e/2,i/2),r.fillStyle=t.toLive(r),this._applyPatternGradientTransform(r,t),r.fill(),r.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,r;return ve(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(s=-this.width/2,r=-this.height/2,t.translate(s,r),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:r}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:s}=e;return t.lineWidth=s,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",i)}_setFillStyles(t,e){let{fill:i}=e;return this.handleFiller(t,"fillStyle",i)}_renderChar(t,e,i,s,r,o,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,d=t==="strokeText"&&c.stroke&&c.strokeWidth;if(d||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const u=this._setFillStyles(e,c);e.fillText(r,o-u.offsetX,a-u.offsetY)}if(d){const u=this._setStrokeStyles(e,c);e.strokeText(r,o-u.offsetX,a-u.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const s=this.get2DCursorLocation(t,!0),r=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:r*i.size,deltaY:o+r*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,r=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===Re||s===Bs&&!o||s===Rs&&!o||s===Zr&&!o?0:(s===V&&(a=i/2),s===wt&&(a=i),s===Bs&&(a=i/2),s===Rs&&(a=i),r==="rtl"&&(s===wt||s===Re||s===Rs?a=0:s===Y||s===Zr?a=-i:s!==V&&s!==Bs||(a=-i/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return(s=this._getStyleDeclaration(t,e)[i])!==null&&s!==void 0?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),r=this.path,o=this._getWidthOfCharSpacing(),a=e==="linethrough"?.5:e==="overline"?1:0,l=this.offsets[e];for(let c=0,h=this._textLines.length;c<h;c++){const d=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){i+=d;continue}const u=this._textLines[c],p=d/this.lineHeight,g=this._getLineLeftOffset(c);let f=0,b=0,m=this.getValueOfPropertyAt(c,0,e),y=this.getValueOfPropertyAt(c,0,Mt),w=this.getValueOfPropertyAt(c,0,Vi),S=m,T=y,k=w;const O=i+p*(1-this._fontSizeFraction);let E=this.getHeightOfChar(c,0),P=this.getValueOfPropertyAt(c,0,"deltaY");for(let j=0,H=u.length;j<H;j++){const M=this.__charBounds[c][j];S=this.getValueOfPropertyAt(c,j,e),T=this.getValueOfPropertyAt(c,j,Mt),k=this.getValueOfPropertyAt(c,j,Vi);const U=this.getHeightOfChar(c,j),q=this.getValueOfPropertyAt(c,j,"deltaY");if(r&&S&&T){const Q=this.fontSize*k/1e3;t.save(),t.fillStyle=y,t.translate(M.renderLeft,M.renderTop),t.rotate(M.angle),t.fillRect(-M.kernedWidth/2,l*U+q-a*Q,M.kernedWidth,Q),t.restore()}else if((S!==m||T!==y||U!==E||k!==w||q!==P)&&b>0){const Q=this.fontSize*w/1e3;let N=s+g+f;this.direction==="rtl"&&(N=this.width-N-b),m&&y&&w&&(t.fillStyle=y,t.fillRect(N,O+l*E+P-a*Q,b,Q)),f=M.left,b=M.width,m=S,w=k,y=T,E=U,P=q}else b+=M.kernedWidth}let R=s+g+f;this.direction==="rtl"&&(R=this.width-R-b),t.fillStyle=T;const L=this.fontSize*k/1e3;S&&T&&k&&t.fillRect(R,O+l*E+P-a*L,b-o,L),i+=d}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Kt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(r?this.CACHE_FONT_SIZE:s,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return qo(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
3315
+ `];let r=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),r=r.concat(i[o],s);return r.pop(),{_unwrappedLines:i,lines:e,graphemeText:r,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject([...Hc,...t])),{},{styles:Lf(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let s=!1,r=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),s=s||i.includes(o),r=r||o==="path";else s=i.includes(t),r=t==="path";return r&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=hi(t,Kt.ATTRIBUTE_NAMES,i),r=_(_({},e),s),{textAnchor:o=Y,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:d=0,fontSize:u=jo,strokeWidth:p=1}=r,g=ot(r,Um),f=new this(Kr(t.textContent||"").trim(),_({left:d+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:u},g)),b=f.getScaledHeight()/f.height,m=((f.height+f.strokeWidth)*f.lineHeight-f.height)*b,y=f.getScaledHeight()+m;let w=0;return o===V&&(w=f.getScaledWidth()/2),o===wt&&(w=f.getScaledWidth()),f.set({left:f.left-w,top:f.top-(y-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:p}),f}static fromObject(t){return this._fromObject(_(_({},t),{},{styles:Ff(t.styles||{},t.text)}),{extraParam:"text"})}}v(Kt,"textLayoutProperties",zc),v(Kt,"cacheProperties",[...ci,...Hc]),v(Kt,"ownDefaults",Gg),v(Kt,"type","Text"),v(Kt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(Kt,"ATTRIBUTE_NAMES",ki.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Kc(Kt,[class extends $c{_toSVG(){const n=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(n.textTop,n.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(n){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:n,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:n,withShadow:!0,additionalTransform:Xs(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(n){let{textBgRects:t,textSpans:e}=n;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(Nm,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
3316
+ `]}_getSVGTextAndBg(n,t){const e=[],i=[];let s,r=n;this.backgroundColor&&i.push(...Gn(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)s=this._getLineLeftOffset(o),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+s,r),this._setSVGTextLineText(e,o,t+s,r),r+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(n,t,e,i,s){const r=W.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,n!==n.trim()||!!n.match(Vm)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(et(l,r),'" '):"",{angle:h,renderLeft:d,renderTop:u,width:p}=s;let g="";if(d!==void 0){const f=p/2;h&&(g=' rotate="'.concat(et(li(h),r),'"'));const b=gs({angle:li(h)});b[4]=d,b[5]=u;const m=new x(-f,0).transform(b);e=m.x,i=m.y}return'<tspan x="'.concat(et(e,r),'" y="').concat(et(i,r),'" ').concat(c).concat(g).concat(a,">").concat(Af(n),"</tspan>")}_setSVGTextLineText(n,t,e,i){const s=this.getHeightOfLine(t),r=this.textAlign.includes(Re),o=this._textLines[t];let a,l,c,h,d,u="",p=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=o.length-1;g<=f;g++)d=g===f||this.charSpacing||this.path,u+=o[g],c=this.__charBounds[t][g],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,r&&!d&&this._reSpaceAndTab.test(o[g])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(t,g),l=this.getCompleteStyleDeclaration(t,g+1),d=Ko(a,l,!0)),d&&(h=this._getStyleDeclaration(t,g),n.push(this._createTextCharSpan(u,h,e,i,c)),u="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(n,t,e,i){const s=this._textLines[t],r=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:d,width:u,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...Gn(c,e+l,i,a,r)),l=d,a=u,c=o):a+=p}o&&n.push(...Gn(c,e+l,i,a,r))}_getSVGLineTopOffset(n){let t,e=0;for(t=0;t<n;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(n){return"".concat(super.getSvgStyles(n)," text-decoration-thickness: ").concat(et(this.textDecorationThickness*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(n,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:r,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:d,overline:u,underline:p}=n,g=this.getSvgTextDecoration({underline:p??this.underline,overline:u??this.overline,linethrough:d??this.linethrough}),f=h||this.textDecorationThickness;return[s?qs(ae,s):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",g?"text-decoration: ".concat(g,"; text-decoration-thickness: ").concat(et(f*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; "):"",r?qs(Mt,r):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter((t=>n[t.replace("-","")])).join(" ")}}]),D.setClass(Kt),D.setSVGClass(Kt);class Wm{constructor(t){v(this,"target",void 0),v(this,"__mouseDownInPlace",!1),v(this,"__dragStartFired",!1),v(this,"__isDraggingOver",!1),v(this,"__dragStartSelection",void 0),v(this,"__dragImageDisposer",void 0),v(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach((i=>i())),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var i;let{selectionStart:s,selectionEnd:r}=e;const o=this.target,a=o.canvas,l=new x(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),d=a.getScenePoint(t).subtract(h),u=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),g=h.subtract(new x(p.left,p.top)),f=a.viewportTransform,b=g.add(d).transform(f,!0),m=o.backgroundColor,y=Xo(o.styles);o.backgroundColor="";const w={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(w,0,s),o.setSelectionStyles(w,r,o.text.length),o.dirty=!0;const S=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=m,o.styles=y,o.dirty=!0,yo(S,{position:"fixed",left:"".concat(-S.width,"px"),border:oe,width:"".concat(S.width/u,"px"),height:"".concat(S.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{S.remove()},Te(t.target||this.target.hiddenTextarea).body.appendChild(S),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(S,b.x,b.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},r=e._text.slice(s.selectionStart,s.selectionEnd).join(""),o=_({text:e.text,value:r},s);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:i}=t,s=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let r=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(r&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=r[Math.max(0,r.length-1)],d=0;if(this.__dragStartSelection){const u=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>u&&l<=p?l=u:l>p&&(l-=p-u),o.removeChars(u,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(r,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+d,o._text.length),o.selectionEnd=Math.min(o.selectionStart+r.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Ur,{index:l+d,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const s=this.target,r=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||oe;l===oe?(s.selectionStart=o,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(o,a),s.selectionStart=s.selectionEnd=o,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Ur,{index:o,action:"dragend"}),r.fire("text:changed",{target:s}),r.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Pl=/[ \n\.,;!\?\-]/;class Gm extends Kt{constructor(){super(...arguments),v(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:r}=t;return Wc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach((e=>{e&&!e.isDone()&&(t=!0,e.abort())})),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some((t=>!t||t.isDone()))&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){const i=this._text;let s=t>0&&this._reSpace.test(i[t])&&(e===-1||!$o.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!Pl.test(r);)s+=e,r=i[s];return e===-1&&Pl.test(r)&&s++,s}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.searchWordBoundary(t,-1),s=Math.max(i,this.searchWordBoundary(t,1));this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.findLineBoundaryLeft(t),s=this.findLineBoundaryRight(t);this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;Te(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,r=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==r||s!==i&&r!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===r||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,i){const s=i.slice(0,t),r=this.graphemeSplit(s).length;if(t===e)return{selectionStart:r,selectionEnd:r};const o=i.slice(t,e);return{selectionStart:r,selectionEnd:r+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const s=i.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+i.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex,o=this.getValueOfPropertyAt(s,r,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,d=c.height/l,u=h-o,p=d-o,g=new x(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/d));return g.x<0&&(g.x=0),g.x>u&&(g.x=u),g.y<0&&(g.y=0),g.y>p&&(g.y=p),g.x+=this.canvas._offset.left,g.y+=this.canvas._offset.top,{left:"".concat(g.x,"px"),top:"".concat(g.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(Wr),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:r,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==r){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[r])for(let a=o;a<this._unwrappedTextLines[r].length;a++){const l=this.styles[r][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-o]=l)}for(let a=i+1;a<=r;a++)delete this.styles[a];this.shiftLineStyles(r,i-r)}else if(this.styles[i]){const a=this.styles[i],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const s in this.styles){const r=parseInt(s,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}}insertNewlineStyleObject(t,e,i,s){const r={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const d in this.styles[t]){const u=parseInt(d,10);u>=e&&(l=!0,r[u-e]=this.styles[t][d],a&&e===0||delete this.styles[t][d])}let h=!1;for(l&&!a&&(this.styles[t+i]=r,h=!0),(h||o>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:_({},s[i-1])}:c?this.styles[t+i]={0:_({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const r=this.styles[t],o=r?_({},r):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(r[c+i]=o[c],o[c-i]||delete r[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=_({},s[i]));return}if(!r)return;const a=r[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=_({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),r=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
3317
+ `?(a++,r[a]=0):r[a]++;for(r[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+r[0],a),o=1;o<a;o++)r[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,r[o],i):i&&this.styles[s.lineIndex+o]&&i[0]&&(this.styles[s.lineIndex+o][0]=i[0]),i=i&&i.slice(r[o]+1);r[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,r[o],i)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;s>i&&this.removeStyleFromTo(i,s);const r=this.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[...this._text.slice(0,i),...r,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=Y:this._selectionDirection===wt&&(this._selectionDirection=Y,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===wt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=wt:this._selectionDirection===Y&&(this._selectionDirection=wt,this.selectionStart=e),this.selectionEnd=i)}}class Ym extends Gm{initHiddenTextarea(){const t=this.canvas&&Te(this.canvas.getElement())||ds(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map((o=>{let[a,l]=o;return e.setAttribute(a,l)}));const{top:i,left:s,fontSize:r}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(r,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map((o=>{let[a,l]=o;return e.addEventListener(a,this[l].bind(this))})),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:i,selectionStart:s,selectionEnd:r}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Ur),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void o();const a=this._splitTextIntoLines(i).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,d=this.selectionEnd,u=h!==d;let p,g,f,b,m=c-l;const y=this.fromStringToGraphemeSelection(s,r,i),w=h>y.selectionStart;u?(g=this._text.slice(h,d),m+=d-h):c<l&&(g=w?this._text.slice(d+m,d):this._text.slice(h,h-m));const S=a.slice(y.selectionEnd-m,y.selectionEnd);if(g&&g.length&&(S.length&&(p=this.getSelectionStyles(h,h+1,!1),p=S.map((()=>p[0]))),u?(f=h,b=d):w?(f=d-g.length,b=d):(f=d,b=d+g.length),this.removeStyleFromTo(f,b)),S.length){const{copyPasteData:T}=Ue();e&&S.join("")===T.copiedText&&!W.disableStyleCopyPaste&&(p=T.copiedTextStyle),this.insertNewStyleBlock(S,h,p)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:s}=e;this.compositionStart=i,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Ue();t.copiedText=this.getSelectedText(),W.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,s=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],s+=i.left+i.width),s}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(r===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=s.charIndex,a=this._getWidthBeforeCursor(r,o),l=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(o).length+l+1+this.missingNewlineOffset(r)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),r=s.lineIndex;if(r===0||t.metaKey||t.keyCode===33)return-i;const o=s.charIndex,a=this._getWidthBeforeCursor(r,o),l=this._getIndexOnLine(r-1,a),c=this._textLines[r].slice(0,o),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,r,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){r=!0;const h=o-s,d=o,u=Math.abs(h-e);a=Math.abs(d-e)<u?l:l-1;break}return r||(a=i.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===wt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=ls(0,this.selectionStart,s),this.selectionEnd=ls(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Y?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Y,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===wt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=Y,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const i="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Y&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=wt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=wt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Dl=n=>!!n.button;class Xm extends Ym{constructor(){super(...arguments),v(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new Wm(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:i}=t;this.canvas&&this.editable&&!Dl(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),i&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=i||this.isEditing)))}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const r=this.canvas._activeObject;if(r&&r!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Dl(e)||s||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Ee(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,r=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),r=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(r));const a=this._textLines[r].length,l=this.__charBounds[r];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&s++;break}o=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const pr="moveCursorUp",gr="moveCursorDown",fr="moveCursorLeft",mr="moveCursorRight",br="exitEditing",Al=(n,t)=>{const e=t.getRetinaScaling();n.setTransform(e,0,0,e,0,0);const i=t.viewportTransform;n.transform(i[0],i[1],i[2],i[3],i[4],i[5])},qm=_({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:br,27:br,33:pr,34:gr,35:mr,36:fr,37:fr,38:pr,39:mr,40:gr},keysMapRtl:{9:br,27:br,33:pr,34:gr,35:fr,36:mr,37:mr,38:pr,39:fr,40:gr},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class ti extends Xm{static getDefaults(){return _(_({},super.getDefaults()),ti.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,_(_({},ti.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof _o&&this.canvas.textEditingManager.remove(this),e instanceof _o&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),i=this.findAncestorsWithClipPath(),s=i.length>0;let r,o=t;if(s){r=xe(t.canvas),o=r.getContext("2d"),Al(o,this.canvas);const a=this.calcTransformMatrix();o.transform(a[0],a[1],a[2],a[3],a[4],a[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(o,e):this.renderCursor(o,e),s)for(const a of i){const l=a.clipPath,c=xe(t.canvas),h=c.getContext("2d");if(Al(h,this.canvas),!l.absolutePositioned){const d=a.calcTransformMatrix();h.transform(d[0],d[1],d[2],d[3],d[4],d[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(o,l,c)}s&&(t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const i=this._getLeftOffset(),s=this._getTopOffset(),r=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:r.left,topOffset:r.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0;const{charIndex:s,lineIndex:r}=this.get2DCursorLocation(t);for(let c=0;c<r;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(r),a=this.__charBounds[r][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[r].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===wt||this.textAlign===Re||this.textAlign===Rs?l.left*=-1:this.textAlign===Y||this.textAlign===Zr?l.left=o-(i>0?i:0):this.textAlign!==V&&this.textAlign!==Bs||(l.left=o-(i>0?i:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(s,r,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,r,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,r,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,i){const{color:s,opacity:r,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=r,t.fillRect(o,a,l,c)}renderSelection(t,e){const i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,i){const s=e.selectionStart,r=e.selectionEnd,o=this.textAlign.includes(Re),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(r),c=a.lineIndex,h=l.lineIndex,d=a.charIndex<0?0:a.charIndex,u=l.charIndex<0?0:l.charIndex;for(let p=c;p<=h;p++){const g=this._getLineLeftOffset(p)||0;let f=this.getHeightOfLine(p),b=0,m=0,y=0;if(p===c&&(m=this.__charBounds[c][d].left),p>=c&&p<h)y=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(u===0)y=this.__charBounds[h][u].left;else{const O=this._getWidthOfCharSpacing();y=this.__charBounds[h][u-1].left+this.__charBounds[h][u-1].width-O}b=f,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(f/=this.lineHeight);let w=i.left+g+m,S=f,T=0;const k=y-m;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",S=1,T=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===wt||this.textAlign===Re||this.textAlign===Rs?w=this.width-w-k:this.textAlign===Y||this.textAlign===Zr?w=i.left+g-y:this.textAlign!==V&&this.textAlign!==Bs||(w=i.left+g-y)),t.fillRect(w,i.top+i.topOffset+T,k,S),i.topOffset+=b}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Mt)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}v(ti,"ownDefaults",qm),v(ti,"type","IText"),D.setClass(ti),D.setClass(ti,"i-text");class vi extends ti{static getDefaults(){return _(_({},super.getDefaults()),vi.ownDefaults)}constructor(t,e){super(t,_(_({},vi.ownDefaults),e))}static createControls(){return{controls:kf()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Re)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const r={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
3318
+ `&&o>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(i++,s++),r[o]={line:e,offset:i},s+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return r}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[e];i&&(e=i.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,r=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(s=a.line,r=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const d=parseInt(h,10);if(d>=i&&(!r||d<e))for(const u in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,i){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,i)}_deleteStyleDeclaration(t,e){const i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const i=this.getGraphemeDataForRender(t),s=[];for(let r=0;r<i.wordsData.length;r++)s.push(...this._wrapLine(r,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map(((r,o)=>{let a=0;const l=e?this.graphemeSplit(r):this.wordSplit(r);return l.length===0?[{word:[],width:0}]:l.map((c=>{const h=e?[c]:this.graphemeSplit(c),d=this._measureWord(h,o,a);return s=Math.max(d,s),a+=h.length+i.length,{word:h,width:d}}))})),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=0;for(let o=0,a=t.length;o<a;o++)r+=this._getGraphemeBox(t[o],e,o+s,i,!0).kernedWidth,i=t[o];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:r}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let d=0,u=[],p=0,g=0,f=!0;e-=o;const b=Math.max(e,s,this.dynamicMinWidth),m=r[t];let y;for(p=0,y=0;y<m.length;y++){const{word:w,width:S}=m[y];p+=w.length,d+=g+S-a,d>b&&!f?(c.push(u),u=[],d=S,f=!0):d+=a,f||l||u.push(h),u=u.concat(w),g=l?0:this._measureWord([h],t,p),p++,f=!1}return y&&c.push(u),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),s=new Array(i.length);for(let r=0;r<i.length;r++)s[r]=i[r].join("");return e.lines=s,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const i=parseInt(e,10);if(this._textLines[i]){const s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}v(vi,"type","Textbox"),v(vi,"textLayoutProperties",[...ti.textLayoutProperties,"width"]),v(vi,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),D.setClass(vi);class Ml extends _n{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:r}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=ei(Qc(i,s)),l=new x(o,a);if(s.absolutePositioned)return{center:ss(s.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:d=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:d.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}v(Ml,"type","clip-path"),D.setClass(Ml);class Il extends _n{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new x(i.width||s.x,i.height||s.y)}}v(Il,"type","fixed"),D.setClass(Il);class Km extends Zs{subscribeTargets(t){const e=t.target;t.targets.reduce(((i,s)=>(s.parent&&i.add(s.parent),i)),new Set).forEach((i=>{i.layoutManager.subscribeTargets({target:i,targets:[e]})}))}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce(((s,r)=>(r.parent&&s.add(r.parent),s)),new Set).forEach((s=>{!i.some((r=>r.parent===s))&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})}))}}class Ri extends _i{static getDefaults(){return _(_({},super.getDefaults()),Ri.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Ri.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:r}=e;this.groupInit(t,{left:i,top:s,layoutManager:r??new Km})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach((s=>{const r=this._objects.findIndex((a=>a.isInFrontOf(s))),o=r===-1?this.size():r;this.insertAt(o,s)}))}canEnterGroup(t){return this.getObjects().some((e=>e.isDescendantOf(t)||t.isDescendantOf(e)))?(Ci("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const i=new Set;e.forEach((s=>{const{parent:r}=s;r&&i.add(r)})),t===Jo?i.forEach((s=>{s._onAfterObjectsChange(Jr,e)})):i.forEach((s=>{s._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=_(_({hasControls:!1},i),{},{forActiveSelection:!0});for(let r=0;r<this._objects.length;r++)this._objects[r]._renderControls(t,s);super._renderControls(t,e),t.restore()}}v(Ri,"type","ActiveSelection"),v(Ri,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),D.setClass(Ri),D.setClass(Ri,"activeSelection");class Zm{constructor(){v(this,"resources",{})}applyFilters(t,e,i,s,r){const o=r.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,s);const a={sourceWidth:i,sourceHeight:s,imageData:o.getImageData(0,0,i,s),originalEl:e,originalImageData:o.getImageData(0,0,i,s),canvasEl:r,ctx:o,filterBackend:this};t.forEach((c=>{c.applyTo(a)}));const{imageData:l}=a;return l.width===i&&l.height===s||(r.width=l.width,r.height=l.height),o.putImageData(l,0,0),a}}class fh{constructor(){let{tileSize:t=W.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};v(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),v(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=xe({width:t,height:e}),s=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)}applyFilters(t,e,i,s,r,o){const a=this.gl,l=r.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,i,s,c?void 0:e),targetTexture:this.createTexture(a,i,s),originalTexture:c||this.createTexture(a,i,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},d=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,d),t.forEach((u=>{u&&u.applyTo(h)})),(function(u){const p=u.targetCanvas,g=p.width,f=p.height,b=u.destinationWidth,m=u.destinationHeight;g===b&&f===m||(p.width=b,p.height=m)})(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(d),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,r){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:d,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:p,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,d,r||o),t.texParameteri(a,u,r||o),t.texParameteri(a,p,h),t.texParameteri(a,g,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,null),f}getCachedTexture(t,e,i){const{textureCache:s}=this;if(s[t])return s[t];{const r=this.createTexture(this.gl,e.width,e.height,e,i);return r&&(s[t]=r),r}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,s=e.targetCanvas,r=s.getContext("2d");if(!r)return;r.translate(0,s.height),r.scale(1,-1);const o=i.height-s.height;r.drawImage(i,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),s=e.destinationWidth,r=e.destinationHeight,o=s*r*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,r,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,r);i.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}let Xn;function Jm(){const{WebGLProbe:n}=Ue();return n.queryWebGL(ai()),W.enableGLFiltering&&n.isSupported(W.textureSize)?new fh({tileSize:W.textureSize}):new Zm}function qn(){return!Xn&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Xn=Jm()),Xn}const Qm=["filters","resizeFilter","src","crossOrigin","type"],mh=["cropX","cropY"];class se extends Nt{static getDefaults(){return _(_({},super.getDefaults()),se.ownDefaults)}constructor(t,e){super(),v(this,"_lastScaleX",1),v(this,"_lastScaleY",1),v(this,"_filterScalingX",1),v(this,"_filterScalingY",1),this.filters=[],Object.assign(this,se.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Si()),this.setElement(typeof t=="string"?(this.canvas&&Te(this.canvas.getElement())||ds()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){var e;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(i),(e=t.classList)===null||e===void 0||e.add(se.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=qn(!1);e instanceof fh&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((t=>{const e=this[t];e&&Ue().dispose(e),this[t]=void 0}))}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach((i=>{i&&e.push(i.toObject())})),_(_({},super.toObject([...mh,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,i=-this.width/2,s=-this.height/2;let r=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=Si();r.push('<clipPath id="imageCrop_'+c+`">
3319
3319
  `,' <rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
3320
3320
  `,`</clipPath>
3321
3321
  `),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(i-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
3322
3322
  `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(i,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
3323
- `)],this.fill=c}return r=this.paintFirst!==Mt?r.concat(o,t):r.concat(t,o),r}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return $r(t,{crossOrigin:e,signal:i}).then((s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)}))}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,r=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&r>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=r);const a=xe(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,qn().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter((r=>r&&!r.isNeutralState())),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const r=xe({width:i,height:s});this._element=r,this._filteredEl=r}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);qn().applyFilters(t,this._originalElement,i,s,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,r=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,d=a*i,u=l*s,p=Math.min(r*i,c-d),g=Math.min(o*s,h-u),f=-r/2,b=-o/2,m=Math.min(r,c/i-a),_=Math.min(o,h/s-l);e&&t.drawImage(e,d,u,p,g,f,b,m,_)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=Vg(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let r,o=this._element.width,a=this._element.height,l=1,c=1,h=0,d=0,u=0,p=0;return!t||t.alignX===re&&t.alignY===re?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=nm(this._element,s),r=(e-o*l)/2,t.alignX==="Min"&&(h=-r),t.alignX==="Max"&&(h=r),r=(i-a*c)/2,t.alignY==="Min"&&(d=-r),t.alignY==="Max"&&(d=r)),t.meetOrSlice==="slice"&&(l=c=om(this._element,s),r=o-e/l,t.alignX==="Mid"&&(u=r/2),t.alignX==="Max"&&(u=r),r=a-i/c,t.alignY==="Mid"&&(p=r/2),t.alignY==="Max"&&(p=r),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:d,cropX:u,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:r,crossOrigin:o,type:a}=t,l=ot(t,Zm);return Promise.all([$r(r,y(y({},e),{},{crossOrigin:o})),i&&Ys(i,e),s&&Ys([s],e),mn(l,e)]).then((c=>{let[h,d=[],[u]=[],p={}]=c;return new this(h,y(y({},l),{},{src:r,filters:d,resizeFilter:u},p))}))}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return $r(t,{crossOrigin:e,signal:i}).then((r=>new this(r,s)))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=hi(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"]||s.href,e,s).catch((r=>(wi("log","Unable to parse Image",r),null)))}}v(ee,"type","Image"),v(ee,"cacheProperties",[...ci,...mh]),v(ee,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(ee,"CSS_CANVAS","canvas-img"),v(ee,"ATTRIBUTE_NAMES",[...Ei,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),D.setClass(ee),D.setSVGClass(ee);vn(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const wn=n=>n.webgl!==void 0,Qo="precision highp float",Jm=`
3323
+ `)],this.fill=c}return r=this.paintFirst!==Mt?r.concat(o,t):r.concat(t,o),r}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return $r(t,{crossOrigin:e,signal:i}).then((s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)}))}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,r=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&r>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=r);const a=xe(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,qn().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter((r=>r&&!r.isNeutralState())),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const r=xe({width:i,height:s});this._element=r,this._filteredEl=r}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);qn().applyFilters(t,this._originalElement,i,s,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,r=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,d=a*i,u=l*s,p=Math.min(r*i,c-d),g=Math.min(o*s,h-u),f=-r/2,b=-o/2,m=Math.min(r,c/i-a),y=Math.min(o,h/s-l);e&&t.drawImage(e,d,u,p,g,f,b,m,y)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=Ug(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let r,o=this._element.width,a=this._element.height,l=1,c=1,h=0,d=0,u=0,p=0;return!t||t.alignX===oe&&t.alignY===oe?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=am(this._element,s),r=(e-o*l)/2,t.alignX==="Min"&&(h=-r),t.alignX==="Max"&&(h=r),r=(i-a*c)/2,t.alignY==="Min"&&(d=-r),t.alignY==="Max"&&(d=r)),t.meetOrSlice==="slice"&&(l=c=lm(this._element,s),r=o-e/l,t.alignX==="Mid"&&(u=r/2),t.alignX==="Max"&&(u=r),r=a-i/c,t.alignY==="Mid"&&(p=r/2),t.alignY==="Max"&&(p=r),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:d,cropX:u,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:r,crossOrigin:o,type:a}=t,l=ot(t,Qm);return Promise.all([$r(r,_(_({},e),{},{crossOrigin:o})),i&&Ys(i,e),s&&Ys([s],e),mn(l,e)]).then((c=>{let[h,d=[],[u]=[],p={}]=c;return new this(h,_(_({},l),{},{src:r,filters:d,resizeFilter:u},p))}))}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return $r(t,{crossOrigin:e,signal:i}).then((r=>new this(r,s)))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=hi(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"]||s.href,e,s).catch((r=>(Ci("log","Unable to parse Image",r),null)))}}v(se,"type","Image"),v(se,"cacheProperties",[...ci,...mh]),v(se,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(se,"CSS_CANVAS","canvas-img"),v(se,"ATTRIBUTE_NAMES",[...ki,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),D.setClass(se),D.setSVGClass(se);vn(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const wn=n=>n.webgl!==void 0,Qo="precision highp float",tb=`
3324
3324
  `.concat(Qo,`;
3325
3325
  varying vec2 vTexCoord;
3326
3326
  uniform sampler2D uTexture;
3327
3327
  void main() {
3328
3328
  gl_FragColor = texture2D(uTexture, vTexCoord);
3329
- }`),Qm=["type"],tb=["type"],eb=new RegExp(Qo,"g");class It{get type(){return this.constructor.type}constructor(){let t=ot(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Qm);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Jm}getVertexSource(){return`
3329
+ }`),eb=["type"],ib=["type"],sb=new RegExp(Qo,"g");class It{get type(){return this.constructor.type}constructor(){let t=ot(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},eb);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return tb}getVertexSource(){return`
3330
3330
  attribute vec2 aPosition;
3331
3331
  varying vec2 vTexCoord;
3332
3332
  void main() {
3333
3333
  vTexCoord = aPosition;
3334
3334
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
3335
- }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=Ue();s!=="highp"&&(e=e.replace(eb,Qo.replace("highp",s)));const r=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!r||!o||!a)throw new ze("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new ze("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new ze("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,r),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new ze('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const i=this.constructor.uniformLocations,s={};for(let r=0;r<i.length;r++)s[i[r]]=t.getUniformLocation(e,i[r]);return s}sendAttributeData(t,e,i){const s=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const i=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,s)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){wn(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,i=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:i}=t,s=xe({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return y({type:this.type},t.reduce(((e,i)=>(e[i]=this[i],e)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(ot(t,tb))}}v(It,"type","BaseFilter"),v(It,"uniformLocations",[]);const ib={multiply:`gl_FragColor.rgb *= uColor.rgb;
3335
+ }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=Ue();s!=="highp"&&(e=e.replace(sb,Qo.replace("highp",s)));const r=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!r||!o||!a)throw new ze("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new ze("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new ze("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,r),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new ze('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const i=this.constructor.uniformLocations,s={};for(let r=0;r<i.length;r++)s[i[r]]=t.getUniformLocation(e,i[r]);return s}sendAttributeData(t,e,i){const s=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const i=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,s)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){wn(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,i=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:i}=t,s=xe({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return _({type:this.type},t.reduce(((e,i)=>(e[i]=this[i],e)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(ot(t,ib))}}v(It,"type","BaseFilter"),v(It,"uniformLocations",[]);const rb={multiply:`gl_FragColor.rgb *= uColor.rgb;
3336
3336
  `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
3337
3337
  `,add:`gl_FragColor.rgb += uColor.rgb;
3338
3338
  `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
@@ -3368,10 +3368,10 @@ Resulting to default behavior: removing object from previous canvas and adding t
3368
3368
  vec4 color = texture2D(uTexture, vTexCoord);
3369
3369
  gl_FragColor = color;
3370
3370
  if (color.a > 0.0) {
3371
- `.concat(ib[this.mode],`
3371
+ `.concat(rb[this.mode],`
3372
3372
  }
3373
3373
  }
3374
- `)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new K(this.color).getSource(),s=this.alpha,r=i[0]*s,o=i[1]*s,a=i[2]*s,l=1-s;for(let c=0;c<e.length;c+=4){const h=e[c],d=e[c+1],u=e[c+2];let p,g,f;switch(this.mode){case"multiply":p=h*r/255,g=d*o/255,f=u*a/255;break;case"screen":p=255-(255-h)*(255-r)/255,g=255-(255-d)*(255-o)/255,f=255-(255-u)*(255-a)/255;break;case"add":p=h+r,g=d+o,f=u+a;break;case"difference":p=Math.abs(h-r),g=Math.abs(d-o),f=Math.abs(u-a);break;case"subtract":p=h-r,g=d-o,f=u-a;break;case"darken":p=Math.min(h,r),g=Math.min(d,o),f=Math.min(u,a);break;case"lighten":p=Math.max(h,r),g=Math.max(d,o),f=Math.max(u,a);break;case"overlay":p=r<128?2*h*r/255:255-2*(255-h)*(255-r)/255,g=o<128?2*d*o/255:255-2*(255-d)*(255-o)/255,f=a<128?2*u*a/255:255-2*(255-u)*(255-a)/255;break;case"exclusion":p=r+h-2*r*h/255,g=o+d-2*o*d/255,f=a+u-2*a*u/255;break;case"tint":p=r+h*l,g=o+d*l,f=a+u*l}e[c]=p,e[c+1]=g,e[c+2]=f}}sendUniformData(t,e){const i=new K(this.color).getSource();i[0]=this.alpha*i[0]/255,i[1]=this.alpha*i[1]/255,i[2]=this.alpha*i[2]/255,i[3]=this.alpha,t.uniform4fv(e.uColor,i)}}v(vr,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),v(vr,"type","BlendColor"),v(vr,"uniformLocations",["uColor"]),D.setClass(vr);const sb={multiply:`
3374
+ `)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new K(this.color).getSource(),s=this.alpha,r=i[0]*s,o=i[1]*s,a=i[2]*s,l=1-s;for(let c=0;c<e.length;c+=4){const h=e[c],d=e[c+1],u=e[c+2];let p,g,f;switch(this.mode){case"multiply":p=h*r/255,g=d*o/255,f=u*a/255;break;case"screen":p=255-(255-h)*(255-r)/255,g=255-(255-d)*(255-o)/255,f=255-(255-u)*(255-a)/255;break;case"add":p=h+r,g=d+o,f=u+a;break;case"difference":p=Math.abs(h-r),g=Math.abs(d-o),f=Math.abs(u-a);break;case"subtract":p=h-r,g=d-o,f=u-a;break;case"darken":p=Math.min(h,r),g=Math.min(d,o),f=Math.min(u,a);break;case"lighten":p=Math.max(h,r),g=Math.max(d,o),f=Math.max(u,a);break;case"overlay":p=r<128?2*h*r/255:255-2*(255-h)*(255-r)/255,g=o<128?2*d*o/255:255-2*(255-d)*(255-o)/255,f=a<128?2*u*a/255:255-2*(255-u)*(255-a)/255;break;case"exclusion":p=r+h-2*r*h/255,g=o+d-2*o*d/255,f=a+u-2*a*u/255;break;case"tint":p=r+h*l,g=o+d*l,f=a+u*l}e[c]=p,e[c+1]=g,e[c+2]=f}}sendUniformData(t,e){const i=new K(this.color).getSource();i[0]=this.alpha*i[0]/255,i[1]=this.alpha*i[1]/255,i[2]=this.alpha*i[2]/255,i[3]=this.alpha,t.uniform4fv(e.uColor,i)}}v(vr,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),v(vr,"type","BlendColor"),v(vr,"uniformLocations",["uColor"]),D.setClass(vr);const nb={multiply:`
3375
3375
  precision highp float;
3376
3376
  uniform sampler2D uTexture;
3377
3377
  uniform sampler2D uImage;
@@ -3397,7 +3397,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3397
3397
  color.a = color2.a;
3398
3398
  gl_FragColor = color;
3399
3399
  }
3400
- `},rb=["type","image"];class yr extends It{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return sb[this.mode]}getVertexSource(){return`
3400
+ `},ob=["type","image"];class yr extends It{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return nb[this.mode]}getVertexSource(){return`
3401
3401
  attribute vec2 aPosition;
3402
3402
  varying vec2 vTexCoord;
3403
3403
  varying vec2 vTexCoord2;
@@ -3407,7 +3407,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3407
3407
  vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
3408
3408
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
3409
3409
  }
3410
- `}applyToWebGL(t){const e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d(t){let{imageData:{data:e,width:i,height:s},filterBackend:{resources:r}}=t;const o=this.image;r.blendImage||(r.blendImage=ai());const a=r.blendImage,l=a.getContext("2d");a.width!==i||a.height!==s?(a.width=i,a.height=s):l.clearRect(0,0,i,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,i,s);const c=l.getImageData(0,0,i,s).data;for(let h=0;h<e.length;h+=4){const d=e[h],u=e[h+1],p=e[h+2],g=e[h+3],f=c[h],b=c[h+1],m=c[h+2],_=c[h+3];switch(this.mode){case"multiply":e[h]=d*f/255,e[h+1]=u*b/255,e[h+2]=p*m/255,e[h+3]=g*_/255;break;case"mask":e[h+3]=_}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return y(y({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,r=ot(t,rb);return ee.fromObject(s,e).then((o=>new this(y(y({},r),{},{image:o}))))}}v(yr,"type","BlendImage"),v(yr,"defaults",{mode:"multiply",alpha:1}),v(yr,"uniformLocations",["uTransformMatrix","uImage"]),D.setClass(yr);class _r extends It{getFragmentSource(){return`
3410
+ `}applyToWebGL(t){const e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d(t){let{imageData:{data:e,width:i,height:s},filterBackend:{resources:r}}=t;const o=this.image;r.blendImage||(r.blendImage=ai());const a=r.blendImage,l=a.getContext("2d");a.width!==i||a.height!==s?(a.width=i,a.height=s):l.clearRect(0,0,i,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,i,s);const c=l.getImageData(0,0,i,s).data;for(let h=0;h<e.length;h+=4){const d=e[h],u=e[h+1],p=e[h+2],g=e[h+3],f=c[h],b=c[h+1],m=c[h+2],y=c[h+3];switch(this.mode){case"multiply":e[h]=d*f/255,e[h+1]=u*b/255,e[h+2]=p*m/255,e[h+3]=g*y/255;break;case"mask":e[h+3]=y}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return _(_({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,r=ot(t,ob);return se.fromObject(s,e).then((o=>new this(_(_({},r),{},{image:o}))))}}v(yr,"type","BlendImage"),v(yr,"defaults",{mode:"multiply",alpha:1}),v(yr,"uniformLocations",["uTransformMatrix","uImage"]),D.setClass(yr);class _r extends It{getFragmentSource(){return`
3411
3411
  precision highp float;
3412
3412
  uniform sampler2D uTexture;
3413
3413
  uniform vec2 uDelta;
@@ -3436,7 +3436,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3436
3436
  gl_FragColor.rgb = color.rgb / totalC;
3437
3437
  gl_FragColor.a = color.a / totalA;
3438
3438
  }
3439
- `}applyTo(t){wn(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;this.aspectRatio=i/s,this.horizontal=!0;let r=this.getBlurValue()*i;const o=new Uint8ClampedArray(e),a=15,l=4*i;for(let c=0;c<e.length;c+=4){let h=0,d=0,u=0,p=0,g=0;const f=c-c%l,b=f+l;for(let m=-14;m<a;m++){const _=m/a,x=4*Math.floor(r*_),S=1-Math.abs(_);let T=c+x;T<f?T=f:T>b&&(T=b);const O=e[T+3]*S;h+=e[T]*O,d+=e[T+1]*O,u+=e[T+2]*O,p+=O,g+=S}o[c]=h/p,o[c+1]=d/p,o[c+2]=u/p,o[c+3]=p/g}this.horizontal=!1,r=this.getBlurValue()*s;for(let c=0;c<o.length;c+=4){let h=0,d=0,u=0,p=0,g=0;const f=c%l,b=o.length-l+f;for(let m=-14;m<a;m++){const _=m/a,x=Math.floor(r*_)*l,S=1-Math.abs(_);let T=c+x;T<f?T=f:T>b&&(T=b);const O=o[T+3]*S;h+=o[T]*O,d+=o[T+1]*O,u+=o[T+2]*O,p+=O,g+=S}e[c]=h/p,e[c+1]=d/p,e[c+2]=u/p,e[c+3]=p/g}}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return this.blur===0}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:i}=this;return e?i>1&&(t=1/i):i<1&&(t=i),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}v(_r,"type","Blur"),v(_r,"defaults",{blur:0}),v(_r,"uniformLocations",["uDelta"]),D.setClass(_r);class xr extends It{getFragmentSource(){return`
3439
+ `}applyTo(t){wn(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;this.aspectRatio=i/s,this.horizontal=!0;let r=this.getBlurValue()*i;const o=new Uint8ClampedArray(e),a=15,l=4*i;for(let c=0;c<e.length;c+=4){let h=0,d=0,u=0,p=0,g=0;const f=c-c%l,b=f+l;for(let m=-14;m<a;m++){const y=m/a,w=4*Math.floor(r*y),S=1-Math.abs(y);let T=c+w;T<f?T=f:T>b&&(T=b);const k=e[T+3]*S;h+=e[T]*k,d+=e[T+1]*k,u+=e[T+2]*k,p+=k,g+=S}o[c]=h/p,o[c+1]=d/p,o[c+2]=u/p,o[c+3]=p/g}this.horizontal=!1,r=this.getBlurValue()*s;for(let c=0;c<o.length;c+=4){let h=0,d=0,u=0,p=0,g=0;const f=c%l,b=o.length-l+f;for(let m=-14;m<a;m++){const y=m/a,w=Math.floor(r*y)*l,S=1-Math.abs(y);let T=c+w;T<f?T=f:T>b&&(T=b);const k=o[T+3]*S;h+=o[T]*k,d+=o[T+1]*k,u+=o[T+2]*k,p+=k,g+=S}e[c]=h/p,e[c+1]=d/p,e[c+2]=u/p,e[c+3]=p/g}}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return this.blur===0}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:i}=this;return e?i>1&&(t=1/i):i<1&&(t=i),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}v(_r,"type","Blur"),v(_r,"defaults",{blur:0}),v(_r,"uniformLocations",["uDelta"]),D.setClass(_r);class xr extends It{getFragmentSource(){return`
3440
3440
  precision highp float;
3441
3441
  uniform sampler2D uTexture;
3442
3442
  uniform float uBrightness;
@@ -3457,7 +3457,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3457
3457
  color *= uColorMatrix;
3458
3458
  color += uConstants;
3459
3459
  gl_FragColor = color;
3460
- }`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let r=0;r<e.length;r+=4){const o=e[r],a=e[r+1],l=e[r+2];if(e[r]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[r+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[r+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[r+3];e[r]+=c*i[3],e[r+1]+=c*i[8],e[r+2]+=c*i[13],e[r+3]=o*i[15]+a*i[16]+l*i[17]+c*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,s=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],r=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,r)}toObject(){return y(y({},super.toObject()),{},{matrix:[...this.matrix]})}}function Gi(n,t){var e;const i=(v(e=class extends es{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",n),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return D.setClass(i,n),i}v(es,"type","ColorMatrix"),v(es,"defaults",bh),v(es,"uniformLocations",["uColorMatrix","uConstants"]),D.setClass(es);Gi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);Gi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);Gi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);Gi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);Gi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);Gi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);Gi("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class Ll extends It{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){wn(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((e=>{e.applyTo(t)}))}toObject(){return{type:this.type,subFilters:this.subFilters.map((t=>t.toObject()))}}isNeutralState(){return!this.subFilters.some((t=>!t.isNeutralState()))}static fromObject(t,e){return Promise.all((t.subFilters||[]).map((i=>D.getClass(i.type).fromObject(i,e)))).then((i=>new this({subFilters:i})))}}v(Ll,"type","Composed"),D.setClass(Ll);class wr extends It{getFragmentSource(){return`
3460
+ }`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let r=0;r<e.length;r+=4){const o=e[r],a=e[r+1],l=e[r+2];if(e[r]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[r+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[r+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[r+3];e[r]+=c*i[3],e[r+1]+=c*i[8],e[r+2]+=c*i[13],e[r+3]=o*i[15]+a*i[16]+l*i[17]+c*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,s=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],r=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,r)}toObject(){return _(_({},super.toObject()),{},{matrix:[...this.matrix]})}}function Gi(n,t){var e;const i=(v(e=class extends es{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",n),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return D.setClass(i,n),i}v(es,"type","ColorMatrix"),v(es,"defaults",bh),v(es,"uniformLocations",["uColorMatrix","uConstants"]),D.setClass(es);Gi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);Gi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);Gi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);Gi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);Gi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);Gi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);Gi("BlackWhite",[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);class Ll extends It{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){wn(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((e=>{e.applyTo(t)}))}toObject(){return{type:this.type,subFilters:this.subFilters.map((t=>t.toObject()))}}isNeutralState(){return!this.subFilters.some((t=>!t.isNeutralState()))}static fromObject(t,e){return Promise.all((t.subFilters||[]).map((i=>D.getClass(i.type).fromObject(i,e)))).then((i=>new this({subFilters:i})))}}v(Ll,"type","Composed"),D.setClass(Ll);class wr extends It{getFragmentSource(){return`
3461
3461
  precision highp float;
3462
3462
  uniform sampler2D uTexture;
3463
3463
  uniform float uContrast;
@@ -3467,7 +3467,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3467
3467
  float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
3468
3468
  color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
3469
3469
  gl_FragColor = color;
3470
- }`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.floor(255*this.contrast),s=259*(i+255)/(255*(259-i));for(let r=0;r<e.length;r+=4)e[r]=s*(e[r]-128)+128,e[r+1]=s*(e[r+1]-128)+128,e[r+2]=s*(e[r+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}v(wr,"type","Contrast"),v(wr,"defaults",{contrast:0}),v(wr,"uniformLocations",["uContrast"]),D.setClass(wr);const nb={Convolute_3_1:`
3470
+ }`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.floor(255*this.contrast),s=259*(i+255)/(255*(259-i));for(let r=0;r<e.length;r+=4)e[r]=s*(e[r]-128)+128,e[r+1]=s*(e[r+1]-128)+128,e[r+2]=s*(e[r+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}v(wr,"type","Contrast"),v(wr,"defaults",{contrast:0}),v(wr,"uniformLocations",["uContrast"]),D.setClass(wr);const ab={Convolute_3_1:`
3471
3471
  precision highp float;
3472
3472
  uniform sampler2D uTexture;
3473
3473
  uniform float uMatrix[9];
@@ -3611,7 +3611,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3611
3611
  gl_FragColor = color;
3612
3612
  gl_FragColor.a = alpha;
3613
3613
  }
3614
- `};class Cr extends It{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return nb[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,r=Math.round(Math.sqrt(s.length)),o=Math.floor(r/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,d=this.opaque?1:0;let u,p,g,f,b,m,_,x,S,T,O,k,E;for(O=0;O<l;O++)for(T=0;T<a;T++){for(b=4*(O*a+T),u=0,p=0,g=0,f=0,E=0;E<r;E++)for(k=0;k<r;k++)_=O+E-o,m=T+k-o,_<0||_>=l||m<0||m>=a||(x=4*(_*a+m),S=s[E*r+k],u+=i[x]*S,p+=i[x+1]*S,g+=i[x+2]*S,d||(f+=i[x+3]*S));h[b]=u,h[b+1]=p,h[b+2]=g,h[b+3]=d?i[b+3]:f}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return y(y({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}v(Cr,"type","Convolute"),v(Cr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(Cr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),D.setClass(Cr);const vh="Gamma";class Sr extends It{getFragmentSource(){return`
3614
+ `};class Cr extends It{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return ab[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,r=Math.round(Math.sqrt(s.length)),o=Math.floor(r/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,d=this.opaque?1:0;let u,p,g,f,b,m,y,w,S,T,k,O,E;for(k=0;k<l;k++)for(T=0;T<a;T++){for(b=4*(k*a+T),u=0,p=0,g=0,f=0,E=0;E<r;E++)for(O=0;O<r;O++)y=k+E-o,m=T+O-o,y<0||y>=l||m<0||m>=a||(w=4*(y*a+m),S=s[E*r+O],u+=i[w]*S,p+=i[w+1]*S,g+=i[w+2]*S,d||(f+=i[w+3]*S));h[b]=u,h[b+1]=p,h[b+2]=g,h[b+3]=d?i[b+3]:f}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return _(_({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}v(Cr,"type","Convolute"),v(Cr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(Cr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),D.setClass(Cr);const vh="Gamma";class Sr extends It{getFragmentSource(){return`
3615
3615
  precision highp float;
3616
3616
  uniform sampler2D uTexture;
3617
3617
  uniform vec3 uGamma;
@@ -3625,7 +3625,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3625
3625
  gl_FragColor = color;
3626
3626
  gl_FragColor.rgb *= color.a;
3627
3627
  }
3628
- `}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.gamma,s=1/i[0],r=1/i[1],o=1/i[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,s),a.g[l]=255*Math.pow(l/255,r),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:vh,gamma:this.gamma.concat()}}}v(Sr,"type",vh),v(Sr,"defaults",{gamma:[1,1,1]}),v(Sr,"uniformLocations",["uGamma"]),D.setClass(Sr);const ob={average:`
3628
+ `}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.gamma,s=1/i[0],r=1/i[1],o=1/i[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,s),a.g[l]=255*Math.pow(l/255,r),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:vh,gamma:this.gamma.concat()}}}v(Sr,"type",vh),v(Sr,"defaults",{gamma:[1,1,1]}),v(Sr,"uniformLocations",["uGamma"]),D.setClass(Sr);const lb={average:`
3629
3629
  precision highp float;
3630
3630
  uniform sampler2D uTexture;
3631
3631
  varying vec2 vTexCoord;
@@ -3654,7 +3654,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3654
3654
  float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
3655
3655
  gl_FragColor = vec4(average, average, average, col.a);
3656
3656
  }
3657
- `};class Tr extends It{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(r+o+a)/3;break;case"lightness":i=(Math.min(r,o,a)+Math.max(r,o,a))/2;break;case"luminosity":i=.21*r+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return ob[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(Tr,"type","Grayscale"),v(Tr,"defaults",{mode:"average"}),v(Tr,"uniformLocations",["uMode"]),D.setClass(Tr);const ab=y(y({},bh),{},{rotation:0});class Kn extends es{calculateMatrix(){const t=this.rotation*Math.PI,e=ni(t),i=oi(t),s=1/3,r=Math.sqrt(s)*i,o=1-e;this.matrix=[e+o/3,s*o-r,s*o+r,0,0,s*o+r,e+s*o,s*o-r,0,0,s*o-r,s*o+r,e+s*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}v(Kn,"type","HueRotation"),v(Kn,"defaults",ab),D.setClass(Kn);class Er extends It{applyTo2d(t){let{imageData:{data:e}}=t;for(let i=0;i<e.length;i+=4)e[i]=255-e[i],e[i+1]=255-e[i+1],e[i+2]=255-e[i+2],this.alpha&&(e[i+3]=255-e[i+3])}getFragmentSource(){return`
3657
+ `};class Tr extends It{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(r+o+a)/3;break;case"lightness":i=(Math.min(r,o,a)+Math.max(r,o,a))/2;break;case"luminosity":i=.21*r+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return lb[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(Tr,"type","Grayscale"),v(Tr,"defaults",{mode:"average"}),v(Tr,"uniformLocations",["uMode"]),D.setClass(Tr);const cb=_(_({},bh),{},{rotation:0});class Kn extends es{calculateMatrix(){const t=this.rotation*Math.PI,e=ni(t),i=oi(t),s=1/3,r=Math.sqrt(s)*i,o=1-e;this.matrix=[e+o/3,s*o-r,s*o+r,0,0,s*o+r,e+s*o,s*o-r,0,0,s*o-r,s*o+r,e+s*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}v(Kn,"type","HueRotation"),v(Kn,"defaults",cb),D.setClass(Kn);class Er extends It{applyTo2d(t){let{imageData:{data:e}}=t;for(let i=0;i<e.length;i+=4)e[i]=255-e[i],e[i+1]=255-e[i+1],e[i+2]=255-e[i+2],this.alpha&&(e[i+3]=255-e[i+3])}getFragmentSource(){return`
3658
3658
  precision highp float;
3659
3659
  uniform sampler2D uTexture;
3660
3660
  uniform int uInvert;
@@ -3733,7 +3733,7 @@ void main() {
3733
3733
  `),`
3734
3734
  gl_FragColor = color / sum;
3735
3735
  }
3736
- `)}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){wn(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const i=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(i)/i}}applyTo2d(t){const e=t.imageData,i=this.scaleX,s=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/s;const r=e.width,o=e.height,a=Math.round(r*i),l=Math.round(o*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,r,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,r,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,r,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,r,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,s,r){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,d=i*a;const u=t.filterBackend.resources;let p=0,g=0;const f=e;let b=0;u.sliceByTwo||(u.sliceByTwo=ai());const m=u.sliceByTwo;(m.width<1.5*e||m.height<i)&&(m.width=1.5*e,m.height=i);const _=m.getContext("2d");for(_.clearRect(0,0,1.5*e,i),_.putImageData(o,0,0),s=Math.floor(s),r=Math.floor(r);!l||!c;)e=h,i=d,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),r<Math.floor(d*a)?d=Math.floor(d*a):(d=r,c=!0),_.drawImage(m,p,g,e,i,f,b,h,d),p=f,g=b,b+=d;return _.getImageData(p,g,s,r)}lanczosResize(t,e,i,s,r){const o=t.imageData.data,a=t.ctx.createImageData(s,r),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,d=this.rcpScaleY,u=2/this.rcpScaleX,p=2/this.rcpScaleY,g=Math.ceil(h*this.lanczosLobes/2),f=Math.ceil(d*this.lanczosLobes/2),b={},m={x:0,y:0},_={x:0,y:0};return(function x(S){let T,O,k,E,P,R,L,j,H,M,U;for(m.x=(S+.5)*h,_.x=Math.floor(m.x),T=0;T<r;T++){for(m.y=(T+.5)*d,_.y=Math.floor(m.y),P=0,R=0,L=0,j=0,H=0,O=_.x-g;O<=_.x+g;O++)if(!(O<0||O>=e)){M=Math.floor(1e3*Math.abs(O-m.x)),b[M]||(b[M]={});for(let q=_.y-f;q<=_.y+f;q++)q<0||q>=i||(U=Math.floor(1e3*Math.abs(q-m.y)),b[M][U]||(b[M][U]=c(Math.sqrt(Math.pow(M*u,2)+Math.pow(U*p,2))/1e3)),k=b[M][U],k>0&&(E=4*(q*e+O),P+=k,R+=k*o[E],L+=k*o[E+1],j+=k*o[E+2],H+=k*o[E+3]))}E=4*(T*s+S),l[E]=R/P,l[E+1]=L/P,l[E+2]=j/P,l[E+3]=H/P}return++S<s?x(S):a})(0)}bilinearFiltering(t,e,i,s,r){let o,a,l,c,h,d,u,p,g,f,b,m,_,x=0;const S=this.rcpScaleX,T=this.rcpScaleY,O=4*(e-1),k=t.imageData.data,E=t.ctx.createImageData(s,r),P=E.data;for(u=0;u<r;u++)for(p=0;p<s;p++)for(h=Math.floor(S*p),d=Math.floor(T*u),g=S*p-h,f=T*u-d,_=4*(d*e+h),b=0;b<4;b++)o=k[_+b],a=k[_+4+b],l=k[_+O+b],c=k[_+O+4+b],m=o*(1-g)*(1-f)+a*g*(1-f)+l*f*(1-g)+c*g*f,P[x++]=m;return E}hermiteFastResize(t,e,i,s,r){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,d=t.ctx.createImageData(s,r),u=d.data;for(let p=0;p<r;p++)for(let g=0;g<s;g++){const f=4*(g+p*s);let b=0,m=0,_=0,x=0,S=0,T=0,O=0;const k=(p+.5)*a;for(let E=Math.floor(p*a);E<(p+1)*a;E++){const P=Math.abs(k-(E+.5))/c,R=(g+.5)*o,L=P*P;for(let j=Math.floor(g*o);j<(g+1)*o;j++){let H=Math.abs(R-(j+.5))/l;const M=Math.sqrt(L+H*H);M>1&&M<-1||(b=2*M*M*M-3*M*M+1,b>0&&(H=4*(j+E*e),O+=b*h[H+3],_+=b,h[H+3]<255&&(b=b*h[H+3]/250),x+=b*h[H],S+=b*h[H+1],T+=b*h[H+2],m+=b))}}u[f]=x/m,u[f+1]=S/m,u[f+2]=T/m,u[f+3]=O/_}return d}}v(Dr,"type","Resize"),v(Dr,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),v(Dr,"uniformLocations",["uDelta","uTaps"]),D.setClass(Dr);class Ar extends It{getFragmentSource(){return`
3736
+ `)}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){wn(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const i=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(i)/i}}applyTo2d(t){const e=t.imageData,i=this.scaleX,s=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/s;const r=e.width,o=e.height,a=Math.round(r*i),l=Math.round(o*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,r,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,r,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,r,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,r,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,s,r){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,d=i*a;const u=t.filterBackend.resources;let p=0,g=0;const f=e;let b=0;u.sliceByTwo||(u.sliceByTwo=ai());const m=u.sliceByTwo;(m.width<1.5*e||m.height<i)&&(m.width=1.5*e,m.height=i);const y=m.getContext("2d");for(y.clearRect(0,0,1.5*e,i),y.putImageData(o,0,0),s=Math.floor(s),r=Math.floor(r);!l||!c;)e=h,i=d,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),r<Math.floor(d*a)?d=Math.floor(d*a):(d=r,c=!0),y.drawImage(m,p,g,e,i,f,b,h,d),p=f,g=b,b+=d;return y.getImageData(p,g,s,r)}lanczosResize(t,e,i,s,r){const o=t.imageData.data,a=t.ctx.createImageData(s,r),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,d=this.rcpScaleY,u=2/this.rcpScaleX,p=2/this.rcpScaleY,g=Math.ceil(h*this.lanczosLobes/2),f=Math.ceil(d*this.lanczosLobes/2),b={},m={x:0,y:0},y={x:0,y:0};return(function w(S){let T,k,O,E,P,R,L,j,H,M,U;for(m.x=(S+.5)*h,y.x=Math.floor(m.x),T=0;T<r;T++){for(m.y=(T+.5)*d,y.y=Math.floor(m.y),P=0,R=0,L=0,j=0,H=0,k=y.x-g;k<=y.x+g;k++)if(!(k<0||k>=e)){M=Math.floor(1e3*Math.abs(k-m.x)),b[M]||(b[M]={});for(let q=y.y-f;q<=y.y+f;q++)q<0||q>=i||(U=Math.floor(1e3*Math.abs(q-m.y)),b[M][U]||(b[M][U]=c(Math.sqrt(Math.pow(M*u,2)+Math.pow(U*p,2))/1e3)),O=b[M][U],O>0&&(E=4*(q*e+k),P+=O,R+=O*o[E],L+=O*o[E+1],j+=O*o[E+2],H+=O*o[E+3]))}E=4*(T*s+S),l[E]=R/P,l[E+1]=L/P,l[E+2]=j/P,l[E+3]=H/P}return++S<s?w(S):a})(0)}bilinearFiltering(t,e,i,s,r){let o,a,l,c,h,d,u,p,g,f,b,m,y,w=0;const S=this.rcpScaleX,T=this.rcpScaleY,k=4*(e-1),O=t.imageData.data,E=t.ctx.createImageData(s,r),P=E.data;for(u=0;u<r;u++)for(p=0;p<s;p++)for(h=Math.floor(S*p),d=Math.floor(T*u),g=S*p-h,f=T*u-d,y=4*(d*e+h),b=0;b<4;b++)o=O[y+b],a=O[y+4+b],l=O[y+k+b],c=O[y+k+4+b],m=o*(1-g)*(1-f)+a*g*(1-f)+l*f*(1-g)+c*g*f,P[w++]=m;return E}hermiteFastResize(t,e,i,s,r){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,d=t.ctx.createImageData(s,r),u=d.data;for(let p=0;p<r;p++)for(let g=0;g<s;g++){const f=4*(g+p*s);let b=0,m=0,y=0,w=0,S=0,T=0,k=0;const O=(p+.5)*a;for(let E=Math.floor(p*a);E<(p+1)*a;E++){const P=Math.abs(O-(E+.5))/c,R=(g+.5)*o,L=P*P;for(let j=Math.floor(g*o);j<(g+1)*o;j++){let H=Math.abs(R-(j+.5))/l;const M=Math.sqrt(L+H*H);M>1&&M<-1||(b=2*M*M*M-3*M*M+1,b>0&&(H=4*(j+E*e),k+=b*h[H+3],y+=b,h[H+3]<255&&(b=b*h[H+3]/250),w+=b*h[H],S+=b*h[H+1],T+=b*h[H+2],m+=b))}}u[f]=w/m,u[f+1]=S/m,u[f+2]=T/m,u[f+3]=k/y}return d}}v(Dr,"type","Resize"),v(Dr,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),v(Dr,"uniformLocations",["uDelta","uTaps"]),D.setClass(Dr);class Ar extends It{getFragmentSource(){return`
3737
3737
  precision highp float;
3738
3738
  uniform sampler2D uTexture;
3739
3739
  uniform float uSaturation;
@@ -3762,7 +3762,7 @@ void main() {
3762
3762
  color.b += max != color.b ? (max - color.b) * amt : 0.00;
3763
3763
  gl_FragColor = color;
3764
3764
  }
3765
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2],l=Math.max(r,o,a),c=(r+o+a)/3,h=2*Math.abs(l-c)/255*i;e[s]+=l!==r?(l-r)*h:0,e[s+1]+=l!==o?(l-o)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(Mr,"type","Vibrance"),v(Mr,"defaults",{vibrance:0}),v(Mr,"uniformLocations",["uVibrance"]),D.setClass(Mr);var lb=Object.defineProperty,cb=Object.getOwnPropertyDescriptor,Dt=(n,t,e,i)=>{for(var s=i>1?void 0:i?cb(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&lb(t,e,s),s};let ft=class extends vt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.handwrittenImageUrl=void 0,this.imageHeight=null,this.imageWidth=null,this.imageLeft=null,this.imageTop=null,this.displayType="default",this.backgroundFabImg=void 0,this.rect=void 0,this.areaPosition={left:0,top:0},this.uploadingText=void 0,this.handwrittenImage=void 0,this.clipMaskOverlay=void 0,this.areaSize={width:0,height:0},this._dimensionsUpdateTimeout=void 0,this.DEFAULT_BACKGROUND_URL="https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821",this.AREA_PERCENTAGES={default:{left:.084,top:.4899,width:.832,height:.45},fullSize:{left:.084,top:.06,width:.832,height:.879}},this.HANDWRITTEN_IMAGE_STYLES={transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",scalingLimitations:"preserveAspectRatio",bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10},this.CONTROL_VISIBILITY={tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1}}async handleBackgroundImageUrlChange(){this.canvas&&(this.removeBackgroundImage(),await this.loadBackgroundImage(),this.updateProcessedImgAreaPosition(),this.canvas.renderAll())}async handleHandwrittenImageUrlChange(){this.canvas&&(this.removeHandwrittenImage(),this.handwrittenImageUrl&&await this.loadHandwrittenImage(),this.updateProcessedImgAreaPosition(),this.resetHandwrittenImagePosition(),this.updateClipMaskOverlay(),this.canvas.renderAll())}handleHandwrittenImageDimensionsChange(){this.debounceUpdateDimensions()}firstUpdated(){this.initializeCanvas(),this.setupEventListeners(),this.loadInitialContent()}render(){return F`<canvas class="base-canvas"></canvas>`}initializeCanvas(){this.canvas=new _o(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0})}setupEventListeners(){document.addEventListener("pbo-image-processing",this.handleImageProcessing.bind(this))}async loadInitialContent(){this.backgroundImageUrl?(await this.loadBackgroundImage(),this.updateProcessedImgAreaPosition(),this.createUploadingText()):this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}removeBackgroundImage(){this.backgroundFabImg&&(this.canvas.remove(this.backgroundFabImg),this.backgroundFabImg=void 0)}async loadBackgroundImage(){const t=this.backgroundImageUrl||this.DEFAULT_BACKGROUND_URL;await this.appendBackgroundImageToCanvas(t)}async appendBackgroundImageToCanvas(t,e){const i=await ee.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),this.canvas.renderAll(),e&&e()}removeHandwrittenImage(){this.handwrittenImage&&(this.canvas.remove(this.handwrittenImage),this.handwrittenImage=void 0)}async loadHandwrittenImage(){this.handwrittenImage=await ee.fromURL(this.handwrittenImageUrl),this.configureHandwrittenImage(),this.setupHandwrittenImageEvents(),this.canvas.add(this.handwrittenImage)}configureHandwrittenImage(){if(!this.handwrittenImage)return;const t=this.calculateImageScale(),e=this.createClipRect();this.handwrittenImage.set({...this.HANDWRITTEN_IMAGE_STYLES,selectable:!0,lockRotation:!0,lockScalingFlip:!0,noScaleCache:!1,cornerSize:this.calculateCornerSize(),touchCornerSize:this.calculateTouchCornerSize(),left:this.areaPosition.left,top:this.areaPosition.top,scaleX:t,scaleY:t,clipPath:e}),this.handwrittenImage.setControlsVisibility(this.CONTROL_VISIBILITY),this.updateHandwrittenImageDimensions(t)}calculateImageScale(){if(!this.handwrittenImage)return 1;const t=this.areaSize.width/this.handwrittenImage.width,e=this.areaSize.height/this.handwrittenImage.height;return Math.min(t,e)}calculateCornerSize(){return this.areaSize.width*(bi()?.06:.03)}calculateTouchCornerSize(){return this.areaSize.width*(bi()?.2:.06)}createClipRect(){return new ie({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0})}updateHandwrittenImageDimensions(t){this.handwrittenImage&&this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*t,width:this.handwrittenImage.width*t})}setupHandwrittenImageEvents(){this.handwrittenImage&&(this.handwrittenImage.on("scaling",this.handleImageScaling.bind(this)),this.handwrittenImage.on("moving",this.handleImageMoving.bind(this)),this.handwrittenImage.on("selected",this.handleImageSelected.bind(this)),this.handwrittenImage.on("deselected",this.handleImageDeselected.bind(this)))}handleImageScaling(t){const{top:e,left:i,height:s,width:r,scaleX:o,scaleY:a}=t.transform.target;this.setHandwrittenImageDimensions({top:e,left:i,height:s*a,width:r*o})}handleImageMoving(t){const{top:e,left:i}=t.transform.target;this.setHandwrittenImageDimensions({top:e,left:i})}handleImageSelected(){this.showSelectionUI()}handleImageDeselected(){this.hideSelectionUI()}showSelectionUI(){var t,e;(t=this.rect)==null||t.set("visible",!0),(e=this.handwrittenImage)==null||e.set("clipPath",null),this.clipMaskOverlay?this.clipMaskOverlay.set("visible",!0):(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay)),this.canvas.bringObjectToFront(this.clipMaskOverlay),this.canvas.renderAll()}hideSelectionUI(){var t,e,i;(t=this.rect)==null||t.set("visible",!1),(e=this.handwrittenImage)==null||e.set({clipPath:this.createClipRect()}),(i=this.clipMaskOverlay)==null||i.set("visible",!1)}createClipMaskOverlay(){const t=this.canvas.getWidth(),e=this.canvas.getHeight(),{left:i,top:s}=this.areaPosition,{width:r,height:o}=this.areaSize,a="rgba(0,0,0,0.1)",l=[this.createMaskRect(0,0,t,s,a),this.createMaskRect(0,s+o,t,e-(s+o),a),this.createMaskRect(0,s,i,o,a),this.createMaskRect(i+r,s,t-(i+r),o,a)];return new _i(l,{selectable:!1,evented:!1})}createMaskRect(t,e,i,s,r){return new ie({left:t,top:e,width:i,height:s,fill:r,selectable:!1,evented:!1})}updateClipMaskOverlay(){this.clipMaskOverlay&&(this.canvas.remove(this.clipMaskOverlay),this.clipMaskOverlay=void 0),this.handwrittenImage&&this.canvas.getActiveObject()===this.handwrittenImage&&(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay),this.canvas.bringObjectToFront(this.clipMaskOverlay))}resetHandwrittenImagePosition(){if(!this.handwrittenImage)return;const t=this.areaSize.width/this.handwrittenImage.width,e=this.areaSize.height/this.handwrittenImage.height,i=Math.min(t,e);this.handwrittenImage.set({left:this.areaPosition.left,top:this.areaPosition.top,scaleX:i,scaleY:i});const s=new ie({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:s}),this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*i,width:this.handwrittenImage.width*i}),this.emitDimensionsChangedEvent()}updateProcessedImgAreaPosition(){const t=this.getAreaPercentages();this.areaPosition={left:t.left*this.canvas.getWidth(),top:t.top*this.canvas.getHeight()},this.areaSize={width:t.width*this.canvas.getWidth(),height:t.height*this.canvas.getHeight()},this.updateAreaRect()}getAreaPercentages(){return this.displayType==="default"?this.AREA_PERCENTAGES.default:this.AREA_PERCENTAGES.fullSize}updateAreaRect(){this.rect?this.rect.set({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height}):this.createAreaRect()}createAreaRect(){this.rect=new ie({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0.5)",visible:!1,evented:!1}),this.canvas.add(this.rect)}debounceUpdateDimensions(){this._dimensionsUpdateTimeout&&clearTimeout(this._dimensionsUpdateTimeout),this._dimensionsUpdateTimeout=setTimeout(()=>{var t;this.applyHandwrittenImageDimensions(),(t=this.canvas)==null||t.renderAll(),this.emitDimensionsChangedEvent()},300)}applyHandwrittenImageDimensions(){this.isValidForDimensionUpdate()&&(this.handwrittenImage.set({left:this.imageLeft,top:this.imageTop}),this.handwrittenImage.scaleToHeight(this.imageHeight),this.handwrittenImage.scaleToWidth(this.imageWidth))}isValidForDimensionUpdate(){return Es(this.handwrittenImage)&&Es(this.imageLeft)&&Es(this.imageTop)&&Es(this.imageWidth)&&Es(this.imageHeight)}setHandwrittenImageDimensions(t){const{top:e,left:i,height:s,width:r}=t;if(!this.hasValidDimensions(t)){console.warn("Invalid dimensions provided for handwritten image");return}this.updateDimensionIfChanged("imageLeft",i),this.updateDimensionIfChanged("imageTop",e),this.updateDimensionIfChanged("imageHeight",s),this.updateDimensionIfChanged("imageWidth",r)}hasValidDimensions(t){const{top:e,left:i,height:s,width:r}=t;return!!(e||i||s||r)}updateDimensionIfChanged(t,e){e&&this[t]!==e&&(this[t]=e)}emitDimensionsChangedEvent(){var t,e;this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft??0,top:this.imageTop??0,width:this.imageWidth??0,height:this.imageHeight??0,cardHeight:((t=this.backgroundFabImg)==null?void 0:t.height)??0,cardWidth:((e=this.backgroundFabImg)==null?void 0:e.width)??0}})}createUploadingText(){this.uploadingText=new vi("Uploading",{left:this.areaPosition.left,top:this.areaPosition.top+this.areaSize.height/2-this.areaSize.height/13/1.1,width:this.areaSize.width,textAlign:"center",fontSize:this.areaSize.height/13/1.1,fontFamily:"Arial",selectable:!1,evented:!1})}handleImageProcessing(t){const e=t.detail.isLoading;this.uploadingText&&(e?this.canvas.add(this.uploadingText):this.canvas.remove(this.uploadingText),this.canvas.renderAll())}};ft.styles=[bt,vg];Dt([C({attribute:"background-url"})],ft.prototype,"backgroundImageUrl",2);Dt([C({attribute:"handwritten-url"})],ft.prototype,"handwrittenImageUrl",2);Dt([C({type:Number,reflect:!0,attribute:"height"})],ft.prototype,"imageHeight",2);Dt([C({type:Number,reflect:!0,attribute:"width"})],ft.prototype,"imageWidth",2);Dt([C({type:Number,reflect:!0,attribute:"left"})],ft.prototype,"imageLeft",2);Dt([C({type:Number,reflect:!0,attribute:"top"})],ft.prototype,"imageTop",2);Dt([C({attribute:"display-type"})],ft.prototype,"displayType",2);Dt([B(".base-canvas")],ft.prototype,"baseCanvas",2);Dt([I()],ft.prototype,"canvas",2);Dt([I()],ft.prototype,"backgroundFabImg",2);Dt([I()],ft.prototype,"rect",2);Dt([I()],ft.prototype,"areaPosition",2);Dt([I()],ft.prototype,"uploadingText",2);Dt([I()],ft.prototype,"handwrittenImage",2);Dt([I()],ft.prototype,"clipMaskOverlay",2);Dt([I()],ft.prototype,"areaSize",2);Dt([G("backgroundImageUrl")],ft.prototype,"handleBackgroundImageUrlChange",1);Dt([G(["handwrittenImageUrl","displayType"])],ft.prototype,"handleHandwrittenImageUrlChange",1);Dt([G(["imageLeft","imageTop","imageWidth","imageHeight"])],ft.prototype,"handleHandwrittenImageDimensionsChange",1);ft=Dt([mt("pbo-handwritten-canvas")],ft);const rv=ft,hb=it`
3765
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2],l=Math.max(r,o,a),c=(r+o+a)/3,h=2*Math.abs(l-c)/255*i;e[s]+=l!==r?(l-r)*h:0,e[s+1]+=l!==o?(l-o)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(Mr,"type","Vibrance"),v(Mr,"defaults",{vibrance:0}),v(Mr,"uniformLocations",["uVibrance"]),D.setClass(Mr);var hb=Object.defineProperty,db=Object.getOwnPropertyDescriptor,Dt=(n,t,e,i)=>{for(var s=i>1?void 0:i?db(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&hb(t,e,s),s};let ft=class extends vt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.handwrittenImageUrl=void 0,this.imageHeight=null,this.imageWidth=null,this.imageLeft=null,this.imageTop=null,this.displayType="default",this.backgroundFabImg=void 0,this.rect=void 0,this.areaPosition={left:0,top:0},this.uploadingText=void 0,this.handwrittenImage=void 0,this.clipMaskOverlay=void 0,this.areaSize={width:0,height:0},this._dimensionsUpdateTimeout=void 0,this.DEFAULT_BACKGROUND_URL="https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821",this.AREA_PERCENTAGES={default:{left:.084,top:.4899,width:.832,height:.45},fullSize:{left:.084,top:.06,width:.832,height:.879}},this.HANDWRITTEN_IMAGE_STYLES={transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",scalingLimitations:"preserveAspectRatio",bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10},this.CONTROL_VISIBILITY={tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1}}async handleBackgroundImageUrlChange(){this.canvas&&(this.removeBackgroundImage(),await this.loadBackgroundImage(),this.updateProcessedImgAreaPosition(),this.canvas.renderAll())}async handleHandwrittenImageUrlChange(){this.canvas&&(this.removeHandwrittenImage(),this.handwrittenImageUrl&&await this.loadHandwrittenImage(),this.updateProcessedImgAreaPosition(),this.resetHandwrittenImagePosition(),this.updateClipMaskOverlay(),this.canvas.renderAll())}handleHandwrittenImageDimensionsChange(){this.debounceUpdateDimensions()}firstUpdated(){this.initializeCanvas(),this.setupEventListeners(),this.loadInitialContent()}render(){return F`<canvas class="base-canvas"></canvas>`}initializeCanvas(){this.canvas=new _o(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0})}setupEventListeners(){document.addEventListener("pbo-image-processing",this.handleImageProcessing.bind(this))}async loadInitialContent(){this.backgroundImageUrl?(await this.loadBackgroundImage(),this.updateProcessedImgAreaPosition(),this.createUploadingText()):this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}removeBackgroundImage(){this.backgroundFabImg&&(this.canvas.remove(this.backgroundFabImg),this.backgroundFabImg=void 0)}async loadBackgroundImage(){const n=this.backgroundImageUrl||this.DEFAULT_BACKGROUND_URL;await this.appendBackgroundImageToCanvas(n)}async appendBackgroundImageToCanvas(n,t){const e=await se.fromURL(n);e.selectable=!1,this.backgroundFabImg=e,this.canvas.setDimensions({width:e.width,height:e.height}),this.canvas.add(e),this.canvas.sendObjectToBack(e),this.canvas.renderAll(),t&&t()}removeHandwrittenImage(){this.handwrittenImage&&(this.canvas.remove(this.handwrittenImage),this.handwrittenImage=void 0)}async loadHandwrittenImage(){this.handwrittenImage=await se.fromURL(this.handwrittenImageUrl),this.configureHandwrittenImage(),this.setupHandwrittenImageEvents(),this.canvas.add(this.handwrittenImage)}configureHandwrittenImage(){if(!this.handwrittenImage)return;const n=this.calculateImageScale(),t=this.createClipRect();this.handwrittenImage.set({...this.HANDWRITTEN_IMAGE_STYLES,selectable:!0,lockRotation:!0,lockScalingFlip:!0,noScaleCache:!1,cornerSize:this.calculateCornerSize(),touchCornerSize:this.calculateTouchCornerSize(),left:this.areaPosition.left,top:this.areaPosition.top,scaleX:n,scaleY:n,clipPath:t}),this.handwrittenImage.setControlsVisibility(this.CONTROL_VISIBILITY),this.updateHandwrittenImageDimensions(n)}calculateImageScale(){if(!this.handwrittenImage)return 1;const n=this.areaSize.width/this.handwrittenImage.width,t=this.areaSize.height/this.handwrittenImage.height;return Math.min(n,t)}calculateCornerSize(){return this.areaSize.width*(bi()?.06:.03)}calculateTouchCornerSize(){return this.areaSize.width*(bi()?.2:.06)}createClipRect(){return new re({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0})}updateHandwrittenImageDimensions(n){this.handwrittenImage&&this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*n,width:this.handwrittenImage.width*n})}setupHandwrittenImageEvents(){this.handwrittenImage&&(this.handwrittenImage.on("scaling",this.handleImageScaling.bind(this)),this.handwrittenImage.on("moving",this.handleImageMoving.bind(this)),this.handwrittenImage.on("selected",this.handleImageSelected.bind(this)),this.handwrittenImage.on("deselected",this.handleImageDeselected.bind(this)))}handleImageScaling(n){const{top:t,left:e,height:i,width:s,scaleX:r,scaleY:o}=n.transform.target;this.setHandwrittenImageDimensions({top:t,left:e,height:i*o,width:s*r})}handleImageMoving(n){const{top:t,left:e}=n.transform.target;this.setHandwrittenImageDimensions({top:t,left:e})}handleImageSelected(){this.showSelectionUI()}handleImageDeselected(){this.hideSelectionUI()}showSelectionUI(){var n,t;(n=this.rect)==null||n.set("visible",!0),(t=this.handwrittenImage)==null||t.set("clipPath",null),this.clipMaskOverlay?this.clipMaskOverlay.set("visible",!0):(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay)),this.canvas.bringObjectToFront(this.clipMaskOverlay),this.canvas.renderAll()}hideSelectionUI(){var n,t,e;(n=this.rect)==null||n.set("visible",!1),(t=this.handwrittenImage)==null||t.set({clipPath:this.createClipRect()}),(e=this.clipMaskOverlay)==null||e.set("visible",!1)}createClipMaskOverlay(){const n=this.canvas.getWidth(),t=this.canvas.getHeight(),{left:e,top:i}=this.areaPosition,{width:s,height:r}=this.areaSize,o="rgba(0,0,0,0.1)",a=[this.createMaskRect(0,0,n,i,o),this.createMaskRect(0,i+r,n,t-(i+r),o),this.createMaskRect(0,i,e,r,o),this.createMaskRect(e+s,i,n-(e+s),r,o)];return new _i(a,{selectable:!1,evented:!1})}createMaskRect(n,t,e,i,s){return new re({left:n,top:t,width:e,height:i,fill:s,selectable:!1,evented:!1})}updateClipMaskOverlay(){this.clipMaskOverlay&&(this.canvas.remove(this.clipMaskOverlay),this.clipMaskOverlay=void 0),this.handwrittenImage&&this.canvas.getActiveObject()===this.handwrittenImage&&(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay),this.canvas.bringObjectToFront(this.clipMaskOverlay))}resetHandwrittenImagePosition(){if(!this.handwrittenImage)return;const n=this.areaSize.width/this.handwrittenImage.width,t=this.areaSize.height/this.handwrittenImage.height,e=Math.min(n,t);this.handwrittenImage.set({left:this.areaPosition.left,top:this.areaPosition.top,scaleX:e,scaleY:e});const i=new re({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:i}),this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*e,width:this.handwrittenImage.width*e}),this.emitDimensionsChangedEvent()}updateProcessedImgAreaPosition(){const n=this.getAreaPercentages();this.areaPosition={left:n.left*this.canvas.getWidth(),top:n.top*this.canvas.getHeight()},this.areaSize={width:n.width*this.canvas.getWidth(),height:n.height*this.canvas.getHeight()},this.updateAreaRect()}getAreaPercentages(){return this.displayType==="default"?this.AREA_PERCENTAGES.default:this.AREA_PERCENTAGES.fullSize}updateAreaRect(){this.rect?this.rect.set({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height}):this.createAreaRect()}createAreaRect(){this.rect=new re({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0.5)",visible:!1,evented:!1}),this.canvas.add(this.rect)}debounceUpdateDimensions(){this._dimensionsUpdateTimeout&&clearTimeout(this._dimensionsUpdateTimeout),this._dimensionsUpdateTimeout=setTimeout(()=>{var n;this.applyHandwrittenImageDimensions(),(n=this.canvas)==null||n.renderAll(),this.emitDimensionsChangedEvent()},300)}applyHandwrittenImageDimensions(){this.isValidForDimensionUpdate()&&(this.handwrittenImage.set({left:this.imageLeft,top:this.imageTop}),this.handwrittenImage.scaleToHeight(this.imageHeight),this.handwrittenImage.scaleToWidth(this.imageWidth))}isValidForDimensionUpdate(){return Es(this.handwrittenImage)&&Es(this.imageLeft)&&Es(this.imageTop)&&Es(this.imageWidth)&&Es(this.imageHeight)}setHandwrittenImageDimensions(n){const{top:t,left:e,height:i,width:s}=n;if(!this.hasValidDimensions(n)){console.warn("Invalid dimensions provided for handwritten image");return}this.updateDimensionIfChanged("imageLeft",e),this.updateDimensionIfChanged("imageTop",t),this.updateDimensionIfChanged("imageHeight",i),this.updateDimensionIfChanged("imageWidth",s)}hasValidDimensions(n){const{top:t,left:e,height:i,width:s}=n;return!!(t||e||i||s)}updateDimensionIfChanged(n,t){t&&this[n]!==t&&(this[n]=t)}emitDimensionsChangedEvent(){var n,t;this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft??0,top:this.imageTop??0,width:this.imageWidth??0,height:this.imageHeight??0,cardHeight:((n=this.backgroundFabImg)==null?void 0:n.height)??0,cardWidth:((t=this.backgroundFabImg)==null?void 0:t.width)??0}})}createUploadingText(){this.uploadingText=new vi("Uploading",{left:this.areaPosition.left,top:this.areaPosition.top+this.areaSize.height/2-this.areaSize.height/13/1.1,width:this.areaSize.width,textAlign:"center",fontSize:this.areaSize.height/13/1.1,fontFamily:"Arial",selectable:!1,evented:!1})}handleImageProcessing(n){const t=n.detail.isLoading;this.uploadingText&&(t?this.canvas.add(this.uploadingText):this.canvas.remove(this.uploadingText),this.canvas.renderAll())}};ft.styles=[bt,_g];Dt([C({attribute:"background-url"})],ft.prototype,"backgroundImageUrl",2);Dt([C({attribute:"handwritten-url"})],ft.prototype,"handwrittenImageUrl",2);Dt([C({type:Number,reflect:!0,attribute:"height"})],ft.prototype,"imageHeight",2);Dt([C({type:Number,reflect:!0,attribute:"width"})],ft.prototype,"imageWidth",2);Dt([C({type:Number,reflect:!0,attribute:"left"})],ft.prototype,"imageLeft",2);Dt([C({type:Number,reflect:!0,attribute:"top"})],ft.prototype,"imageTop",2);Dt([C({attribute:"display-type"})],ft.prototype,"displayType",2);Dt([B(".base-canvas")],ft.prototype,"baseCanvas",2);Dt([I()],ft.prototype,"canvas",2);Dt([I()],ft.prototype,"backgroundFabImg",2);Dt([I()],ft.prototype,"rect",2);Dt([I()],ft.prototype,"areaPosition",2);Dt([I()],ft.prototype,"uploadingText",2);Dt([I()],ft.prototype,"handwrittenImage",2);Dt([I()],ft.prototype,"clipMaskOverlay",2);Dt([I()],ft.prototype,"areaSize",2);Dt([G("backgroundImageUrl")],ft.prototype,"handleBackgroundImageUrlChange",1);Dt([G(["handwrittenImageUrl","displayType"])],ft.prototype,"handleHandwrittenImageUrlChange",1);Dt([G(["imageLeft","imageTop","imageWidth","imageHeight"])],ft.prototype,"handleHandwrittenImageDimensionsChange",1);ft=Dt([mt("pbo-handwritten-canvas")],ft);const ub=it`
3766
3766
  :host {
3767
3767
  display: block;
3768
3768
  width: auto;
@@ -3827,7 +3827,7 @@ void main() {
3827
3827
  resize: vertical;
3828
3828
  min-height: 96px;
3829
3829
  }
3830
- `;var db=Object.defineProperty,ub=Object.getOwnPropertyDescriptor,Ht=(n,t,e,i)=>{for(var s=i>1?void 0:i?ub(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&db(t,e,s),s};let Tt=class extends vt{constructor(){super(...arguments),this.hasSlotController=new Ni(this,"is-gift-label","premium-card-label","free-message-label"),this.hidden=!1,this.expand=!1,this.dividerConfig={topDivider:{visible:!1,persistent:!1},bottomDivider:{visible:!1,persistent:!1}},this.freeMessage="",this.isGift=!1,this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.debouncedFreeMessageChange=()=>{}}handleOnFreeMessageChange(){this.onFreeMessageChange&&(this.debouncedFreeMessageChange=ip(this.onFreeMessageChange,300))}handleIsGiftChange(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.emit("pbo_toggle_is_gift",{detail:{is_checked:this.isGift}})}handleIsFreeMessageCheckedChange(){var t;console.debug("isFreeMessageChecked",this.isFreeMessageChecked),this.isFreeMessageChecked&&(this.isPremiumChecked=!1),this.isFreeMessageChecked||(this.freeMessage="",console.debug("freeMessage is empty"),console.debug("onFreeMessageClear",this.onFreeMessageClear),(t=this.onFreeMessageClear)==null||t.call(this)),this.emit("pbo_toggle_free_message",{detail:{is_checked:this.isFreeMessageChecked}})}handleIsPremiumCheckedChange(){var t;this.isPremiumChecked?(this.isFreeMessageChecked=!1,this.emit("pbo-open-drawer")):this.emit("pbo-close-drawer"),(t=this.onPremiumSelected)==null||t.call(this,this.isPremiumChecked),this.emit("pbo_toggle_is_premium_card",{detail:{is_checked:this.isPremiumChecked}})}handleFreeMessageChange(){var t;this.freeMessage===""?(console.debug("freeMessage is empty"),(t=this.onFreeMessageClear)==null||t.call(this)):this.debouncedFreeMessageChange&&this.debouncedFreeMessageChange(this.freeMessage)}firstUpdated(){this.expand&&(this.isGift=!0)}setGiftOptionEnabled(t){this.isGift=t}setPremiumEnabled(t){this.isPremiumChecked=t}setFreeMessageEnabled(t){this.isFreeMessageChecked=t}render(){const t=this.hasSlotController.test("is-gift-label"),e=this.hasSlotController.test("premium-card-label"),i=this.hasSlotController.test("premium-card-description"),s=this.hasSlotController.test("free-message-label");return F`
3830
+ `;var pb=Object.defineProperty,gb=Object.getOwnPropertyDescriptor,Ht=(n,t,e,i)=>{for(var s=i>1?void 0:i?gb(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&pb(t,e,s),s};let Tt=class extends vt{constructor(){super(...arguments),this.hasSlotController=new Ni(this,"is-gift-label","premium-card-label","free-message-label"),this.hidden=!1,this.expand=!1,this.dividerConfig={topDivider:{visible:!1,persistent:!1},bottomDivider:{visible:!1,persistent:!1}},this.freeMessage="",this.isGift=!1,this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.debouncedFreeMessageChange=()=>{}}handleOnFreeMessageChange(){this.onFreeMessageChange&&(this.debouncedFreeMessageChange=ip(this.onFreeMessageChange,300))}handleIsGiftChange(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.emit("pbo_toggle_is_gift",{detail:{is_checked:this.isGift}})}handleIsFreeMessageCheckedChange(){var t;console.debug("isFreeMessageChecked",this.isFreeMessageChecked),this.isFreeMessageChecked&&(this.isPremiumChecked=!1),this.isFreeMessageChecked||(this.freeMessage="",console.debug("freeMessage is empty"),console.debug("onFreeMessageClear",this.onFreeMessageClear),(t=this.onFreeMessageClear)==null||t.call(this)),this.emit("pbo_toggle_free_message",{detail:{is_checked:this.isFreeMessageChecked}})}handleIsPremiumCheckedChange(){var t;this.isPremiumChecked?(this.isFreeMessageChecked=!1,this.emit("pbo-open-drawer")):this.emit("pbo-close-drawer"),(t=this.onPremiumSelected)==null||t.call(this,this.isPremiumChecked),this.emit("pbo_toggle_is_premium_card",{detail:{is_checked:this.isPremiumChecked}})}handleFreeMessageChange(){var t;this.freeMessage===""?(console.debug("freeMessage is empty"),(t=this.onFreeMessageClear)==null||t.call(this)):this.debouncedFreeMessageChange&&this.debouncedFreeMessageChange(this.freeMessage)}firstUpdated(){this.expand&&(this.isGift=!0)}setGiftOptionEnabled(t){this.isGift=t}setPremiumEnabled(t){this.isPremiumChecked=t}setFreeMessageEnabled(t){this.isFreeMessageChecked=t}render(){const t=this.hasSlotController.test("is-gift-label"),e=this.hasSlotController.test("premium-card-label"),i=this.hasSlotController.test("premium-card-description"),s=this.hasSlotController.test("free-message-label");return F`
3831
3831
  <div part="base" class="gift-options" ?hidden=${this.hidden}>
3832
3832
  <!-- 🎁 Is this a gift -->
3833
3833
  <div class="is-gift" part="is-gift option-container" ?hidden=${!t}>
@@ -3902,4 +3902,4 @@ void main() {
3902
3902
  ?hidden=${!this.dividerConfig.bottomDivider.visible||!this.isGift&&!this.dividerConfig.bottomDivider.persistent}
3903
3903
  />
3904
3904
  </div>
3905
- `}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};Tt.styles=[bt,hb];Tt.dependencies={"pbo-textarea":lt};Ht([C({type:Function})],Tt.prototype,"onPremiumSelected",2);Ht([C({type:Function})],Tt.prototype,"onFreeMessageChange",2);Ht([C({type:Function})],Tt.prototype,"onFreeMessageClear",2);Ht([C({type:Boolean,reflect:!0})],Tt.prototype,"hidden",2);Ht([C({type:Boolean,reflect:!0})],Tt.prototype,"expand",2);Ht([C({type:Object})],Tt.prototype,"dividerConfig",2);Ht([C()],Tt.prototype,"freeMessage",2);Ht([C()],Tt.prototype,"isGift",2);Ht([C()],Tt.prototype,"isPremiumChecked",2);Ht([C()],Tt.prototype,"isFreeMessageChecked",2);Ht([I()],Tt.prototype,"debouncedFreeMessageChange",2);Ht([G("onFreeMessageChange")],Tt.prototype,"handleOnFreeMessageChange",1);Ht([G("isGift")],Tt.prototype,"handleIsGiftChange",1);Ht([G("isFreeMessageChecked")],Tt.prototype,"handleIsFreeMessageCheckedChange",1);Ht([G("isPremiumChecked")],Tt.prototype,"handleIsPremiumCheckedChange",1);Ht([G("freeMessage")],Tt.prototype,"handleFreeMessageChange",1);Tt=Ht([mt("pbo-gift-options")],Tt);const ov=Tt,av=as,lv=ae,cv=Ne;export{Hr as MessageSelector,Tb as PboButton,kb as PboButtonGroup,Yb as PboCardSelection,Vb as PboCategory,Nb as PboDrawer,Rb as PboEditor,zb as PboEditorCardSlider,Qb as PboEditorSelector,cv as PboFakeLoading,He as PboFontSelector,ov as PboGiftOption,rv as PboHandwrittenCanvas,iv as PboHandwrittenForm,lv as PboImage,Gb as PboPageManager,Pb as PboRadioButton,Ab as PboRadioGroup,av as PboSpinner,Ib as PboTextarea,qb as PboTypeCanvas,Bb as PboTypeForm,Zb as PboZoomedPreview};
3905
+ `}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};Tt.styles=[bt,ub];Tt.dependencies={"pbo-textarea":lt};Ht([C({type:Function})],Tt.prototype,"onPremiumSelected",2);Ht([C({type:Function})],Tt.prototype,"onFreeMessageChange",2);Ht([C({type:Function})],Tt.prototype,"onFreeMessageClear",2);Ht([C({type:Boolean,reflect:!0})],Tt.prototype,"hidden",2);Ht([C({type:Boolean,reflect:!0})],Tt.prototype,"expand",2);Ht([C({type:Object})],Tt.prototype,"dividerConfig",2);Ht([C()],Tt.prototype,"freeMessage",2);Ht([C()],Tt.prototype,"isGift",2);Ht([C()],Tt.prototype,"isPremiumChecked",2);Ht([C()],Tt.prototype,"isFreeMessageChecked",2);Ht([I()],Tt.prototype,"debouncedFreeMessageChange",2);Ht([G("onFreeMessageChange")],Tt.prototype,"handleOnFreeMessageChange",1);Ht([G("isGift")],Tt.prototype,"handleIsGiftChange",1);Ht([G("isFreeMessageChecked")],Tt.prototype,"handleIsFreeMessageCheckedChange",1);Ht([G("isPremiumChecked")],Tt.prototype,"handleIsPremiumCheckedChange",1);Ht([G("freeMessage")],Tt.prototype,"handleFreeMessageChange",1);Tt=Ht([mt("pbo-gift-options")],Tt);const Qb=Tt,tv=as,ev=Jt,iv=Ve;export{Hr as MessageSelector,kb as PboButton,Pb as PboButtonGroup,Zb as PboCardSelection,Yb as PboCategory,De as PboDrawer,Nb as PboEditor,Wb as PboEditorCardSlider,xp as PboEditorSelector,iv as PboFakeLoading,He as PboFontSelector,Qb as PboGiftOption,ft as PboHandwrittenCanvas,bp as PboHandwrittenForm,ev as PboImage,Kb as PboPageManager,Ab as PboRadioButton,Ib as PboRadioGroup,tv as PboSpinner,Fb as PboTextarea,nt as PboTypeCanvas,Ub as PboTypeForm,Ne as PboZoomedPreview};