@pairbo/ui-kit 0.4.11 → 0.4.12
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/page-manager.js +73 -64
- package/dist/src/components/editor/editor.component.d.ts +1 -0
- package/dist/src/components/page-manager/page-manager.component.d.ts +1 -0
- package/dist/src/components/type-form/type-form.component.d.ts +2 -0
- package/dist/ui-kit.js +144 -135
- package/package.json +1 -1
package/dist/ui-kit.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const Ir=globalThis,wo=Ir.ShadowRoot&&(Ir.ShadyCSS===void 0||Ir.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Co=Symbol(),ca=new WeakMap;let jl=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Co)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(wo&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=ca.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&ca.set(e,t))}return t}toString(){return this.cssText}};const en=n=>new jl(typeof n=="string"?n:n+"",void 0,Co),
|
|
5
|
+
*/const Ir=globalThis,wo=Ir.ShadowRoot&&(Ir.ShadyCSS===void 0||Ir.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Co=Symbol(),ca=new WeakMap;let jl=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Co)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(wo&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=ca.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&ca.set(e,t))}return t}toString(){return this.cssText}};const en=n=>new jl(typeof n=="string"?n:n+"",void 0,Co),rt=(n,...t)=>{const e=n.length===1?n[0]:t.reduce((i,s,r)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[r+1],n[0]);return new jl(e,n,Co)},Ph=(n,t)=>{if(wo)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Ir.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},ha=wo?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return en(e)})(n):n;/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
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
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}),
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),ba=/'/g,va=/"/g,Bl=/^(?:script|style|textarea|title)$/i,Bh=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),L=Bh(1),ye=Symbol.for("lit-noChange"),J=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=J,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===J||t==null||t===""?(this._$AH!==J&&this._$AR(),this._$AH=J):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!==J&&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=J,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=J}_$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===J?t=J:t!==J&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}o&&!s&&this.j(t)}j(t){t===J?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===J?void 0:t}},Nh=class extends rn{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==J)}},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)??J)===ye)return;const i=this._$AH,s=t===J&&i!==J||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==J&&(i===J||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
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
* @license
|
|
41
41
|
* Copyright 2017 Google LLC
|
|
42
42
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
-
*/let qh;function Eo(n){return(t,e)=>Ul(t,e,{get(){return(this.renderRoot??qh??(qh=document.createDocumentFragment())).querySelectorAll(n)}})}const Kh=
|
|
43
|
+
*/let qh;function Eo(n){return(t,e)=>Ul(t,e,{get(){return(this.renderRoot??qh??(qh=document.createDocumentFragment())).querySelectorAll(n)}})}const Kh=rt`
|
|
44
44
|
:host {
|
|
45
45
|
display: block;
|
|
46
46
|
font-family: Arial, sans-serif;
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
background-color: #fff;
|
|
53
53
|
color: black;
|
|
54
54
|
}
|
|
55
|
-
`;var Zh=Object.getOwnPropertyDescriptor,Jh=(n,t,e,i)=>{for(var s=i>1?void 0:i?Zh(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(s)||s);return s};let Hr=class extends is{constructor(){super(),this.giftLabel="This is a gift?",this.premiumLabel="Add a premium greeting card",this.premiumDescription="Select a premium greeting card and add your personal message. You'll choose from our 100% recycled paper cards, priced at $6, and we'll package it with your gift for that extra thoughtful touch.",this.noteLabel="Add a free message",this.giftSelected=!1,this.premiumSelected=!1,this.freeMessageSelected=!1}toggleMessageSelector(){var t;const n=(t=this.shadowRoot)==null?void 0:t.querySelector(".message-selector");n&&n.classList.toggle("message-selector-hidden")}_onGiftChange(n){const t=n.target;this.giftSelected=t.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(n){n.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(n){n.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return
|
|
55
|
+
`;var Zh=Object.getOwnPropertyDescriptor,Jh=(n,t,e,i)=>{for(var s=i>1?void 0:i?Zh(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(s)||s);return s};let Hr=class extends is{constructor(){super(),this.giftLabel="This is a gift?",this.premiumLabel="Add a premium greeting card",this.premiumDescription="Select a premium greeting card and add your personal message. You'll choose from our 100% recycled paper cards, priced at $6, and we'll package it with your gift for that extra thoughtful touch.",this.noteLabel="Add a free message",this.giftSelected=!1,this.premiumSelected=!1,this.freeMessageSelected=!1}toggleMessageSelector(){var t;const n=(t=this.shadowRoot)==null?void 0:t.querySelector(".message-selector");n&&n.classList.toggle("message-selector-hidden")}_onGiftChange(n){const t=n.target;this.giftSelected=t.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(n){n.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(n){n.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return L`
|
|
56
56
|
<div class="message-selector">
|
|
57
57
|
<!-- Gift Checkbox: Always visible -->
|
|
58
58
|
<div>
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
</div>
|
|
68
68
|
|
|
69
69
|
<!-- Premium and Free Message Options: Only visible if gift is selected -->
|
|
70
|
-
${this.giftSelected?
|
|
70
|
+
${this.giftSelected?L`
|
|
71
71
|
<div>
|
|
72
72
|
<input
|
|
73
73
|
type="checkbox"
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
</ul>
|
|
104
104
|
</div>
|
|
105
105
|
</div>
|
|
106
|
-
`}};Hr.styles=[Kh,
|
|
106
|
+
`}};Hr.styles=[Kh,rt`
|
|
107
107
|
.message-selector {
|
|
108
108
|
text-align: left;
|
|
109
109
|
}
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
code {
|
|
125
125
|
font-family: monospace;
|
|
126
126
|
}
|
|
127
|
-
`];Hr.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}};Hr=Jh([mt("pairbo-message-selector")],Hr);const
|
|
127
|
+
`];Hr.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}};Hr=Jh([mt("pairbo-message-selector")],Hr);const vt=rt`
|
|
128
128
|
:host {
|
|
129
129
|
box-sizing: border-box;
|
|
130
130
|
text-shadow: none;
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
[hidden] {
|
|
142
142
|
display: none !important;
|
|
143
143
|
}
|
|
144
|
-
`,Qh=
|
|
144
|
+
`,Qh=rt`
|
|
145
145
|
:host {
|
|
146
146
|
display: block;
|
|
147
147
|
}
|
|
@@ -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 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,"&").replace(/>/g,">").replace(/</g,"<").replace(/'/g,"'").replace(/"/g,""")},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))},Re=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&&(Re(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 Re(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(){Re(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Re(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){z(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){Re(this.element,this.classNames.focusState)},n.prototype.enable=function(){Re(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(){Re(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;Re(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},$e=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=$e({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 $e(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 ze(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(ze(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&&(ze(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,ze(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,ze(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();ze(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(ze(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(ze(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 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>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:_,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 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(!ze(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=ze(t)?ze(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&&Re(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 _="".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=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($e(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($e(u,!0))}else{var p=d;(!h||!c)&&(p=ee(ee({},p),{value:p[e],label:p[i]}));var g=$e(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(_,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($e({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 $e(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return $e(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 $e(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($e(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){Re(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)}}/**
|
|
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 Ct={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"},Nt={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:Ct.ADD_CHOICE,choice:n}},id=function(n){return{type:Ct.REMOVE_CHOICE,choice:n}},sd=function(n){return{type:Ct.FILTER_CHOICES,results:n}},rd=function(n){return{type:Ct.ACTIVATE_CHOICES,active:n}},nd=function(n){return{type:Ct.ADD_GROUP,group:n}},xa=function(n){return{type:Ct.ADD_ITEM,item:n}},wa=function(n){return{type:Ct.REMOVE_ITEM,item:n}},nr=function(n,t){return{type:Ct.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,"&").replace(/>/g,">").replace(/</g,"<").replace(/'/g,"'").replace(/"/g,""")},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))},Re=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&&(Re(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 Re(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(){Re(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Re(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){z(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){Re(this.element,this.classNames.focusState)},n.prototype.enable=function(){Re(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(){Re(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;Re(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},$e=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=$e({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 $e(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 Ct.ADD_ITEM:{t.item.selected=!0;var r=t.item.element;r&&(r.selected=!0,r.setAttribute("selected","")),i.push(t.item);break}case Ct.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 Ct.REMOVE_CHOICE:{Oa(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case Ct.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 Ct.ADD_GROUP:{e.push(t.group);break}case Ct.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 Ct.ADD_CHOICE:{i.push(t.choice);break}case Ct.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 Ct.ADD_ITEM:case Ct.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case Ct.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 Ct.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case Ct.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 ze(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(ze(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&&(ze(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,ze(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,ze(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();ze(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(ze(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(ze(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 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),F=o?d:Math.min(u+P,d)+h,j=Array(F+2);j[F+1]=(1<<k)-1;for(let M=F;M>=R;M-=1){let U=M-1,K=e[n.charAt(U)];if(f&&(b[U]=+!!K),j[M]=(j[M+1]<<1|1)&K,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>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:_,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 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(!ze(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=ze(t)?ze(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&&Re(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 _="".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=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($e(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($e(u,!0))}else{var p=d;(!h||!c)&&(p=ee(ee({},p),{value:p[e],label:p[i]}));var g=$e(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(_,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($e({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 $e(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return $e(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 $e(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!==Nt.ESC_KEY&&e!==Nt.TAB_KEY&&e!==Nt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Nt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Nt.ENTER_KEY:return this._onEnterKey(t,i);case Nt.ESC_KEY:return this._onEscapeKey(t,i);case Nt.UP_KEY:case Nt.PAGE_UP_KEY:case Nt.DOWN_KEY:case Nt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Nt.DELETE_KEY:case Nt.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($e(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===Nt.DOWN_KEY||i===Nt.PAGE_DOWN_KEY?1:-1,r=t.metaKey||i===Nt.PAGE_DOWN_KEY||i===Nt.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){Re(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
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
* @license
|
|
173
173
|
* Copyright 2018 Google LLC
|
|
174
174
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
175
|
-
*/const fe=an(class extends ln{constructor(n){var t;if(super(n),n.type!==gi.ATTRIBUTE||n.name!=="class"||((t=n.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(n){return" "+Object.keys(n).filter(t=>n[t]).join(" ")+" "}update(n,[t]){var i,s;if(this.st===void 0){this.st=new Set,n.strings!==void 0&&(this.nt=new Set(n.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in t)t[r]&&!((i=this.nt)!=null&&i.has(r))&&this.st.add(r);return this.render(t)}const e=n.element.classList;for(const r of this.st)r in t||(e.remove(r),this.st.delete(r));for(const r in t){const o=!!t[r];o===this.st.has(r)||(s=this.nt)!=null&&s.has(r)||(o?(e.add(r),this.st.add(r)):(e.remove(r),this.st.delete(r)))}return ye}}),Js=
|
|
175
|
+
*/const fe=an(class extends ln{constructor(n){var t;if(super(n),n.type!==gi.ATTRIBUTE||n.name!=="class"||((t=n.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(n){return" "+Object.keys(n).filter(t=>n[t]).join(" ")+" "}update(n,[t]){var i,s;if(this.st===void 0){this.st=new Set,n.strings!==void 0&&(this.nt=new Set(n.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in t)t[r]&&!((i=this.nt)!=null&&i.has(r))&&this.st.add(r);return this.render(t)}const e=n.element.classList;for(const r of this.st)r in t||(e.remove(r),this.st.delete(r));for(const r in t){const o=!!t[r];o===this.st.has(r)||(s=this.nt)!=null&&s.has(r)||(o?(e.add(r),this.st.add(r)):(e.remove(r),this.st.delete(r)))}return ye}}),Js=rt`
|
|
176
176
|
.form-control .form-control__label {
|
|
177
177
|
display: none;
|
|
178
178
|
}
|
|
@@ -228,7 +228,7 @@
|
|
|
228
228
|
.form-control--has-help-text.form-control--radio-group .form-control__help-text {
|
|
229
229
|
margin-top: var(--pbo-spacing-2x);
|
|
230
230
|
}
|
|
231
|
-
`;function G(n,t){const e={waitUntilFirstUpdate:!1,...t};return function(i,s){const r=Array.isArray(n)?n:[n],{update:o}=i;i.update=function(a){r.forEach(l=>{const c=l;if(a.has(c)){const h=a.get(c),d=this[c];h!==d&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[s](h,d)}}),o.call(this,a)}}}class
|
|
231
|
+
`;function G(n,t){const e={waitUntilFirstUpdate:!1,...t};return function(i,s){const r=Array.isArray(n)?n:[n],{update:o}=i;i.update=function(a){r.forEach(l=>{const c=l;if(a.has(c)){const h=a.get(c),d=this[c];h!==d&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[s](h,d)}}),o.call(this,a)}}}class yt extends is{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}var Su=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,Ui=(n,t,e,i)=>{for(var s=i>1?void 0:i?Tu(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&&Su(t,e,s),s};let Ve=class extends yt{constructor(){super(...arguments),this.hasSlotController=new Ni(this,"help-text","label"),this.fonts=[{value:"comic",label:"🖊️ Comic Sans",font:"'Comic Sans MS', cursive"},{value:"times",label:"🔤 Times New Roman",font:"'Times New Roman', serif"},{value:"arial",label:"📜 Arial",font:"'Arial', sans-serif"},{value:"mono",label:"💻 Monospace",font:"'Courier New', monospace"}],this.disabled=!1,this.size="medium",this.label="",this._handleDocumentClick=n=>{var e;const t=n.composedPath();this&&!t.includes(this)&&((e=this._choices)==null||e.hideDropdown())}}get value(){var n;return(n=this._choices)==null?void 0:n.getValue().value}handleDisabledChanged(){var n;this._choices&&this.disabled?this._choices.disable():(n=this._choices)==null||n.enable()}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var n;(n=this._choices)==null||n.destroy(),this._choices=new nc(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:this.fonts.map((t,e)=>({value:t.value,label:t.label,customProperties:{font:t.font},selected:e===0})),placeholder:!1,shouldSortItems:!1,itemSelectText:"",callbackOnCreateTemplates:function(t,e,i){return{item:({classNames:s},r)=>{var a;const o=[i(s.item).join(" "),i(r.highlighted?s.highlightedState:s.itemSelectable).join(" ")].join(" ");return t(`
|
|
232
232
|
<div
|
|
233
233
|
class="${o}"
|
|
234
234
|
data-item
|
|
@@ -251,7 +251,7 @@
|
|
|
251
251
|
>
|
|
252
252
|
${r.label}
|
|
253
253
|
</div>
|
|
254
|
-
`)}}}}),this.choiceEl.addEventListener("change",t=>{const e=t.target;this.emit("pbo-font-change",{detail:{font:e.value}})})}render(){const n=this.hasSlotController.test("label"),t=this.label?!0:!!n;return
|
|
254
|
+
`)}}}}),this.choiceEl.addEventListener("change",t=>{const e=t.target;this.emit("pbo-font-change",{detail:{font:e.value}})})}render(){const n=this.hasSlotController.test("label"),t=this.label?!0:!!n;return L` <div
|
|
255
255
|
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":t})}
|
|
256
256
|
>
|
|
257
257
|
<label
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
<slot name="label">${this.label}</slot>
|
|
264
264
|
</label>
|
|
265
265
|
</div>
|
|
266
|
-
<select part="base" class="js-choice"></select>`}};Ve.styles=[
|
|
266
|
+
<select part="base" class="js-choice"></select>`}};Ve.styles=[vt,Qh,Js,en(oc)];Ui([C({type:Array})],Ve.prototype,"fonts",2);Ui([C({type:Boolean,reflect:!0})],Ve.prototype,"disabled",2);Ui([C()],Ve.prototype,"size",2);Ui([C()],Ve.prototype,"label",2);Ui([B(".js-choice")],Ve.prototype,"choiceEl",2);Ui([G("disabled",{waitUntilFirstUpdate:!0})],Ve.prototype,"handleDisabledChanged",1);Ve=Ui([mt("pbo-font-selector")],Ve);const ac=rt`
|
|
267
267
|
:host {
|
|
268
268
|
display: inline-block;
|
|
269
269
|
position: relative;
|
|
@@ -925,11 +925,11 @@
|
|
|
925
925
|
* Copyright 2020 Google LLC
|
|
926
926
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
927
927
|
*/const lc=Symbol.for(""),Eu=n=>{if((n==null?void 0:n.r)===lc)return n==null?void 0:n._$litStatic$},$a=(n,...t)=>({_$litStatic$:t.reduce((e,i,s)=>e+(r=>{if(r._$litStatic$!==void 0)return r._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${r}. Use 'unsafeStatic' to pass non-literal values, but
|
|
928
|
-
take care to ensure page security.`)})(i)+n[s+1],n[0]),r:lc}),Ra=new Map,ku=n=>(t,...e)=>{const i=e.length;let s,r;const o=[],a=[];let l,c=0,h=!1;for(;c<i;){for(l=t[c];c<i&&(r=e[c],(s=Eu(r))!==void 0);)l+=s+t[++c],h=!0;c!==i&&a.push(r),o.push(l),c++}if(c===i&&o.push(t[i]),h){const d=o.join("$$lit$$");(t=Ra.get(d))===void 0&&(o.raw=o,Ra.set(d,t=o)),e=a}return n(t,...e)},Ba=ku(
|
|
928
|
+
take care to ensure page security.`)})(i)+n[s+1],n[0]),r:lc}),Ra=new Map,ku=n=>(t,...e)=>{const i=e.length;let s,r;const o=[],a=[];let l,c=0,h=!1;for(;c<i;){for(l=t[c];c<i&&(r=e[c],(s=Eu(r))!==void 0);)l+=s+t[++c],h=!0;c!==i&&a.push(r),o.push(l),c++}if(c===i&&o.push(t[i]),h){const d=o.join("$$lit$$");(t=Ra.get(d))===void 0&&(o.raw=o,Ra.set(d,t=o)),e=a}return n(t,...e)},Ba=ku(L),ws=new WeakMap,Cs=new WeakMap,Ss=new WeakMap,Fn=new WeakSet,ar=new WeakMap;class Po{constructor(t,e){this.handleFormData=i=>{const s=this.options.disabled(this.host),r=this.options.name(this.host),o=this.options.value(this.host),a=this.host.tagName.toLowerCase()==="pbo-button";this.host.isConnected&&!s&&!a&&typeof r=="string"&&r.length>0&&typeof o<"u"&&(Array.isArray(o)?o.forEach(l=>{i.formData.append(r,l.toString())}):i.formData.append(r,o.toString()))},this.handleFormSubmit=i=>{var o;const s=this.options.disabled(this.host),r=this.options.reportValidity;this.form&&!this.form.noValidate&&((o=ws.get(this.form))==null||o.forEach(a=>{this.setUserInteracted(a,!0)})),this.form&&!this.form.noValidate&&!s&&!r(this.host)&&(i==null||i.preventDefault(),i==null||i.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),ar.set(this.host,[])},this.handleInteraction=i=>{const s=ar.get(this.host);s.includes(i.type)||s.push(i.type),s.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){const i=this.form.querySelectorAll("*");for(const s of i)if(typeof s.checkValidity=="function"&&!s.checkValidity())return!1}return!0},this.doAction=(i,s)=>{if(this.form){const r=document.createElement("button");r.type=i,r.style.position="absolute",r.style.width="0",r.style.height="0",r.style.clipPath="inset(50%)",r.style.overflow="hidden",r.style.whiteSpace="nowrap",s&&(r.name=s.name,r.value=s.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach(o=>{s.hasAttribute(o)&&r.setAttribute(o,s.getAttribute(o))})),this.form.append(r),r.click(),r.remove()}},(this.host=t).addController(this),this.options={form:i=>{const s=i.form;if(s){const o=i.getRootNode().querySelector(`#${s}`);if(o)return o}return i.closest("form")},name:i=>i.name,value:i=>i.value,defaultValue:i=>i.defaultValue,disabled:i=>i.disabled??!1,reportValidity:i=>typeof i.reportValidity=="function"?i.reportValidity():!0,checkValidity:i=>typeof i.checkValidity=="function"?i.checkValidity():!0,setValue:(i,s)=>i.value=s,assumeInteractionOn:["pbo-input"],...e}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),ar.set(this.host,[]),this.options.assumeInteractionOn.forEach(e=>{this.host.addEventListener(e,this.handleInteraction)})}hostDisconnected(){this.detachForm(),ar.delete(this.host),this.options.assumeInteractionOn.forEach(t=>{this.host.removeEventListener(t,this.handleInteraction)})}hostUpdated(){const t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(t){t?(this.form=t,ws.has(this.form)?ws.get(this.form).add(this.host):ws.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),Cs.has(this.form)||(Cs.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),Ss.has(this.form)||(Ss.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=ws.get(this.form);t&&(t.delete(this.host),t.size<=0&&(this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),Cs.has(this.form)&&(this.form.reportValidity=Cs.get(this.form),Cs.delete(this.form)),Ss.has(this.form)&&(this.form.checkValidity=Ss.get(this.form),Ss.delete(this.form)),this.form=void 0))}reportFormValidity(){if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const e of t)if(typeof e.reportValidity=="function"&&!e.reportValidity())return!1}return!0}setUserInteracted(t,e){e?Fn.add(t):Fn.delete(t),t.requestUpdate()}getForm(){return this.form??null}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}setValidity(t){const e=this.host,i=!!Fn.has(e),s=!!e.required;e.toggleAttribute("data-required",s),e.toggleAttribute("data-optional",!s),e.toggleAttribute("data-invalid",!t),e.toggleAttribute("data-valid",t),e.toggleAttribute("data-user-invalid",i&&!t),e.toggleAttribute("data-user-valid",i&&t)}updateValidity(){const t=this.host;this.setValidity(t.validity.valid)}emitInvalidEvent(t){const e=new CustomEvent("pbo-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||e.preventDefault(),this.host.dispatchEvent(e)||t==null||t.preventDefault()}}const cn=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),Ou=Object.freeze({...cn,valid:!1,valueMissing:!1}),Pu=Object.freeze({...cn,valid:!1,customError:!0});/**
|
|
929
929
|
* @license
|
|
930
930
|
* Copyright 2018 Google LLC
|
|
931
931
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
932
|
-
*/const Je=n=>n??
|
|
932
|
+
*/const Je=n=>n??J,Du=rt`
|
|
933
933
|
:host {
|
|
934
934
|
--track-width: 2px;
|
|
935
935
|
--track-color: rgb(128 128 128 / 25%);
|
|
@@ -986,12 +986,12 @@
|
|
|
986
986
|
stroke-dasharray: 0.05em, 3em;
|
|
987
987
|
}
|
|
988
988
|
}
|
|
989
|
-
`;var Au=Object.getOwnPropertyDescriptor,Mu=(n,t,e,i)=>{for(var s=i>1?void 0:i?Au(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(s)||s);return s};let as=class extends
|
|
989
|
+
`;var Au=Object.getOwnPropertyDescriptor,Mu=(n,t,e,i)=>{for(var s=i>1?void 0:i?Au(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(s)||s);return s};let as=class extends yt{render(){return L`
|
|
990
990
|
<svg part="base" class="spinner" role="progressbar" aria-label="loading">
|
|
991
991
|
<circle class="spinner__track"></circle>
|
|
992
992
|
<circle class="spinner__indicator"></circle>
|
|
993
993
|
</svg>
|
|
994
|
-
`}};as.styles=[
|
|
994
|
+
`}};as.styles=[vt,Du];as=Mu([mt("pbo-spinner")],as);var Iu=Object.defineProperty,Lu=Object.getOwnPropertyDescriptor,zt=(n,t,e,i)=>{for(var s=i>1?void 0:i?Lu(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&&Iu(t,e,s),s};let lt=class extends yt{constructor(){super(...arguments),this.formControlController=new Po(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new Ni(this,"[prefix]","prefix","suffix"),this.disabled=!1,this.href="",this.name="",this.value="",this.variant="default",this.outline=!1,this.size="medium",this.circle=!1,this.type="button",this.colorBlock=!1,this.loading=!1,this.error=!1,this.isIconButton=!1,this.hasFocus=!1}get validity(){return this.isButton()?this.button.validity:cn}get validationMessage(){return this.isButton()?this.button.validationMessage:""}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInvalid(){}handleClick(){this.type==="submit"&&this.formControlController.submit(this),this.type==="reset"&&this.formControlController.reset(this)}isButton(){return!this.href}isLink(){return!!this.href}doAction(t,e){}click(){this.button.click()}focus(){this.button.focus()}blur(){this.button.blur()}checkValidity(){return this.isButton()?this.button.checkValidity():!0}getForm(){return this.formControlController.getForm()}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}render(){const t=this.isLink(),e=t?$a`a`:$a`button`;return Ba`
|
|
995
995
|
<${e}
|
|
996
996
|
part="base"
|
|
997
997
|
class= ${fe({button:!0,"button--default":this.variant==="default","button--primary":this.variant==="primary","button--success":this.variant==="success","button--neutral":this.variant==="neutral","button--warning":this.variant==="warning","button--danger":this.variant==="danger","button--text":this.variant==="text","button--small":this.size==="small","button--medium":this.size==="medium","button--large":this.size==="large","button--standard":!this.outline,"button--outline":this.outline,"button--focused":this.hasFocus,"button--loading":this.loading,"button--has-label":this.hasSlotController.test("[default]"),"button--has-prefix":this.hasSlotController.test("prefix"),"button--has-suffix":this.hasSlotController.test("suffix"),"button--circle":this.circle,"button--disabled":this.disabled})}
|
|
@@ -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}>`}};
|
|
1012
|
+
</${e}>`}};lt.styles=[vt,ac];lt.dependencies={"pbo-spinner":as};zt([B(".button")],lt.prototype,"button",2);zt([B(".button--loading pbo-spinner")],lt.prototype,"spinner",2);zt([C({type:Boolean,reflect:!0})],lt.prototype,"disabled",2);zt([C()],lt.prototype,"href",2);zt([C()],lt.prototype,"name",2);zt([C()],lt.prototype,"value",2);zt([C({reflect:!0})],lt.prototype,"variant",2);zt([C({type:Boolean,reflect:!0})],lt.prototype,"outline",2);zt([C({reflect:!0})],lt.prototype,"size",2);zt([C({type:Boolean,reflect:!0})],lt.prototype,"circle",2);zt([C({reflect:!0})],lt.prototype,"type",2);zt([C({type:Boolean,reflect:!0,attribute:"color-block"})],lt.prototype,"colorBlock",2);zt([C({type:Boolean,reflect:!0})],lt.prototype,"loading",2);zt([C({type:Boolean,reflect:!0})],lt.prototype,"error",2);zt([I()],lt.prototype,"isIconButton",2);zt([I()],lt.prototype,"hasFocus",2);lt=zt([mt("pbo-button")],lt);const kb=lt,Fu=rt`
|
|
1013
1013
|
:host {
|
|
1014
1014
|
display: inline-block;
|
|
1015
1015
|
}
|
|
@@ -1018,7 +1018,7 @@
|
|
|
1018
1018
|
/* display: flex; */
|
|
1019
1019
|
/* flex-wrap: nowrap; */
|
|
1020
1020
|
}
|
|
1021
|
-
`;var ju=Object.defineProperty,$u=Object.getOwnPropertyDescriptor,hn=(n,t,e,i)=>{for(var s=i>1?void 0:i?$u(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&&ju(t,e,s),s};let xi=class extends
|
|
1021
|
+
`;var ju=Object.defineProperty,$u=Object.getOwnPropertyDescriptor,hn=(n,t,e,i)=>{for(var s=i>1?void 0:i?$u(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&&ju(t,e,s),s};let xi=class extends yt{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=Ts(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!0)}handleBlur(t){const e=Ts(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!1)}handleMouseOver(t){const e=Ts(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!0)}handleMouseOut(t){const e=Ts(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!1)}handleSlotChange(){const t=[...this.defaultSlot.assignedElements({flatten:!0})];t.forEach(e=>{const i=t.indexOf(e),s=Ts(e);s&&(s.toggleAttribute("data-pbo-button-group__button",!0),s.toggleAttribute("data-pbo-button-group__button--first",i===0),s.toggleAttribute("data-pbo-button-group__button--inner",i>0&&i<t.length-1),s.toggleAttribute("data-pbo-button-group__button--last",i===t.length-1),s.toggleAttribute("data-pbo-button-group__button--radio",s.tagName.toLowerCase()==="pbo-radio-button"))})}render(){return L`
|
|
1022
1022
|
<div
|
|
1023
1023
|
part="base"
|
|
1024
1024
|
class=${fe({"button-group":!0})}
|
|
@@ -1031,7 +1031,7 @@
|
|
|
1031
1031
|
>
|
|
1032
1032
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
1033
1033
|
</div>
|
|
1034
|
-
`}};xi.styles=[
|
|
1034
|
+
`}};xi.styles=[vt,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=rt`
|
|
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,Me=(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
|
|
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,Me=(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 yt{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 L`
|
|
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
|
-
`}};le.styles=[
|
|
1075
|
+
`}};le.styles=[vt,Ru];Me([B(".button")],le.prototype,"input",2);Me([B(".hidden-input")],le.prototype,"hiddenInput",2);Me([C({type:Boolean,reflect:!0})],le.prototype,"checked",2);Me([C()],le.prototype,"value",2);Me([C({type:Boolean,reflect:!0})],le.prototype,"disabled",2);Me([C({reflect:!0})],le.prototype,"size",2);Me([C({type:Boolean,reflect:!0})],le.prototype,"circle",2);Me([C({type:Boolean,reflect:!0,attribute:"icon-only"})],le.prototype,"iconOnly",2);Me([C({attribute:"aria-label"})],le.prototype,"ariaLabel",2);Me([I()],le.prototype,"hasFocus",2);le=Me([mt("pbo-radio-button")],le);const Ab=le,Vu=rt`
|
|
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,
|
|
1111
|
+
`;var Nu=Object.defineProperty,Uu=Object.getOwnPropertyDescriptor,Gt=(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 ft=class extends yt{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 L`
|
|
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
|
-
`}};ft.styles=[
|
|
1165
|
+
`}};ft.styles=[vt,Vu,Js];ft.dependencies={"pbo-button-group":xi};Gt([B("slot:not([name])")],ft.prototype,"defaultSlot",2);Gt([B(".radio-group__validation-input")],ft.prototype,"validationInput",2);Gt([I()],ft.prototype,"hasButtonGroup",2);Gt([I()],ft.prototype,"errorMessage",2);Gt([I()],ft.prototype,"defaultValue",2);Gt([C({type:Boolean,reflect:!0})],ft.prototype,"required",2);Gt([C()],ft.prototype,"name",2);Gt([C({reflect:!0})],ft.prototype,"value",2);Gt([C({attribute:"help-text"})],ft.prototype,"helpText",2);Gt([C()],ft.prototype,"label",2);Gt([C({type:Boolean,reflect:!0,attribute:"icon-group"})],ft.prototype,"iconGroup",2);Gt([C()],ft.prototype,"size",2);Gt([C({type:Boolean,reflect:!0})],ft.prototype,"disabled",2);Gt([C({reflect:!0})],ft.prototype,"form",2);Gt([G("value")],ft.prototype,"handleValueChange",1);ft=Gt([mt("pbo-radio-group")],ft);const Ib=ft,Wu=rt`
|
|
1166
1166
|
:host {
|
|
1167
1167
|
display: block;
|
|
1168
1168
|
position: relative;
|
|
@@ -1355,7 +1355,7 @@
|
|
|
1355
1355
|
* @license
|
|
1356
1356
|
* Copyright 2020 Google LLC
|
|
1357
1357
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1358
|
-
*/const Zu=an(class extends ln{constructor(n){if(super(n),n.type!==gi.PROPERTY&&n.type!==gi.ATTRIBUTE&&n.type!==gi.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Xu(n))throw Error("`live` bindings can only contain a single expression")}render(n){return n}update(n,[t]){if(t===ye||t===
|
|
1358
|
+
*/const Zu=an(class extends ln{constructor(n){if(super(n),n.type!==gi.PROPERTY&&n.type!==gi.ATTRIBUTE&&n.type!==gi.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Xu(n))throw Error("`live` bindings can only contain a single expression")}render(n){return n}update(n,[t]){if(t===ye||t===J)return t;const e=n.element,i=n.name;if(n.type===gi.PROPERTY){if(t===e[i])return ye}else if(n.type===gi.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(i))return ye}else if(n.type===gi.ATTRIBUTE&&e.getAttribute(i)===t+"")return ye;return no(n),t}});var Ju=Object.defineProperty,Qu=Object.getOwnPropertyDescriptor,Lt=(n,t,e,i)=>{for(var s=i>1?void 0:i?Qu(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&&Ju(t,e,s),s};let ct=class extends yt{constructor(){super(...arguments),this.formControlController=new Po(this,{assumeInteractionOn:["pbo-input"]}),this.hasSlotController=new Ni(this,"help-text"),this.hasFocus=!1,this.name="",this.value="",this.size="medium",this.filled=!1,this.title="",this.placeholder="",this.rows=4,this.resize="vertical",this.disabled=!1,this.readonly=!1,this.form="",this.required=!1,this.helpText=""}get validity(){return this.input.validity}get validationMessage(){return this.input.validationMessage}firstUpdated(){this.formControlController.updateValidity()}handleChange(){const t=this.removeEmojis(this.input.value);t!==this.input.value&&(this.input.value=t),this.value=t,this.emit("pbo-change")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInput(){const t=this.removeEmojis(this.input.value);if(t!==this.input.value){this.input.value=t;try{this.input.setSelectionRange(t.length,t.length)}catch{}}this.value=t,this.emit("pbo-input")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}focus(t){this.input.focus(t)}blur(){this.input.blur()}select(){this.input.select()}scrollPosition(t){if(t){typeof t.top=="number"&&(this.input.scrollTop=t.top),typeof t.left=="number"&&(this.input.scrollLeft=t.left);return}return{top:this.input.scrollTop,left:this.input.scrollTop}}setSelectionRange(t,e,i="none"){this.input.setSelectionRange(t,e,i)}setRangeText(t,e,i,s="preserve"){const r=e??this.input.selectionStart,o=i??this.input.selectionEnd;this.input.setRangeText(t,r,o,s),this.value!==this.input.value&&(this.value=this.input.value)}removeEmojis(t){const e=/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;return t.replace(e,"")}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(t){this.input.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("help-text"),e=this.helpText?!0:!!t;return L` <div
|
|
1359
1359
|
part="form-control"
|
|
1360
1360
|
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--has-help-text":e,invalid:!0})}
|
|
1361
1361
|
>
|
|
@@ -1401,7 +1401,7 @@
|
|
|
1401
1401
|
>
|
|
1402
1402
|
<slot name="help-text">${this.helpText}</slot>
|
|
1403
1403
|
</div>
|
|
1404
|
-
</div>`}};
|
|
1404
|
+
</div>`}};ct.styles=[vt,Wu,Js];Lt([B(".textarea__control")],ct.prototype,"input",2);Lt([B(".textarea__size-adjuster")],ct.prototype,"sizeAdjuster",2);Lt([I()],ct.prototype,"hasFocus",2);Lt([C()],ct.prototype,"name",2);Lt([C()],ct.prototype,"value",2);Lt([C({reflect:!0})],ct.prototype,"size",2);Lt([C({type:Boolean,reflect:!0})],ct.prototype,"filled",2);Lt([C()],ct.prototype,"title",2);Lt([C()],ct.prototype,"placeholder",2);Lt([C({type:Number})],ct.prototype,"rows",2);Lt([C()],ct.prototype,"resize",2);Lt([C({type:Boolean,reflect:!0})],ct.prototype,"disabled",2);Lt([C({type:Boolean,reflect:!0})],ct.prototype,"readonly",2);Lt([C({reflect:!0})],ct.prototype,"form",2);Lt([C({type:Boolean,reflect:!0})],ct.prototype,"required",2);Lt([C({type:Number})],ct.prototype,"minlength",2);Lt([C({type:Number})],ct.prototype,"maxlength",2);Lt([C({attribute:"help-text"})],ct.prototype,"helpText",2);ct=Lt([mt("pbo-textarea")],ct);const Fb=ct,tp=rt`
|
|
1405
1405
|
:host {
|
|
1406
1406
|
display: block;
|
|
1407
1407
|
}
|
|
@@ -1473,7 +1473,7 @@
|
|
|
1473
1473
|
grid-column: 7 / 11;
|
|
1474
1474
|
}
|
|
1475
1475
|
}
|
|
1476
|
-
`,ep=
|
|
1476
|
+
`,ep=rt`
|
|
1477
1477
|
:host {
|
|
1478
1478
|
display: block;
|
|
1479
1479
|
}
|
|
@@ -1518,7 +1518,7 @@
|
|
|
1518
1518
|
.skip::part(label) {
|
|
1519
1519
|
font-size: 14px;
|
|
1520
1520
|
}
|
|
1521
|
-
`,bi=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),Es=n=>n!=null,hc=n=>Object.entries(n).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});function ip(n,t){let e;return function(...i){clearTimeout(e),e=setTimeout(()=>n.apply(this,i),t)}}const dc=(n,t)=>Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2));var sp=Object.defineProperty,rp=Object.getOwnPropertyDescriptor,
|
|
1521
|
+
`,bi=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),Es=n=>n!=null,hc=n=>Object.entries(n).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});function ip(n,t){let e;return function(...i){clearTimeout(e),e=setTimeout(()=>n.apply(this,i),t)}}const dc=(n,t)=>Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2));var sp=Object.defineProperty,rp=Object.getOwnPropertyDescriptor,at=(n,t,e,i)=>{for(var s=i>1?void 0:i?rp(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&&sp(t,e,s),s};let X=class extends yt{constructor(){super(...arguments),this.resizeTimeout=null,this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.submitTypeForm=async t=>{console.error("submitTypingForm function not implemented",t)},this.loading=!1,this.disabled=!1,this.onClose=()=>{},this.ctaButtonPrimaryLabel="Add to Cart",this.hideColor=!1,this.CTA_STATES={danger:{type:"danger",message:"Add a message to Continue"},primary:{type:"primary",message:this.ctaButtonPrimaryLabel}},this.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=this.CTA_STATES.primary,this.validationError="",this.wrappedSubmitTypeForm=async t=>{console.warn("submitTypingForm function not implemented",t)},this.processedMessage="",this.maxChars=223,this.handleTextareaBlur=()=>{let t=this;for(;t;){const{overflow:e,overflowY:i}=getComputedStyle(t);if(/(auto|scroll)/.test(e+i)){t.scrollTo({top:t.scrollHeight,behavior:"smooth"});return}t=t.parentElement??t.getRootNode().host??null}},this.handleTypeCanvasProcessed=t=>{const e=t;this.processedMessage=e.detail.message},this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}handleCardChange(){this.card&&(this.card.hasEditorial===void 0&&(this.maxChars=223),this.maxChars=this.card.hasEditorial?223:600)}updateWrappedSubmitTypeForm(){this.wrappedSubmitTypeForm=async t=>{this.loading=!0,this.disabled=!0;try{await this.submitTypeForm(t),this.onClose(),this.emit("pbo-type-form-submitted")}catch(e){throw this.validationError="Something went wrong. Please try again.",e}finally{this.loading=!1,this.disabled=!1}}}firstUpdated(){this.CTA_STATES.primary.message=this.ctaButtonPrimaryLabel,this.textarea.addEventListener("blur",this.handleTextareaBlur)}get formData(){var e,i,s,r,o,a,l,c,h;const t={pboCardId:((e=this.card)==null?void 0:e.pboId)||"Unknown",productId:(i=this.card)==null?void 0:i.productId,barcode:(s=this.card)==null?void 0:s.barcode,sku:(r=this.card)==null?void 0:r.sku,variantId:(o=this.card)==null?void 0:o.variantId,font:((a=this.fontSelector)==null?void 0:a.value)||"",text:((l=this.textarea)==null?void 0:l.value)||"",processedMessage:this.processedMessage,color:this.hideColor?"rgb(0,0,0)":((c=this.textColor)==null?void 0:c.value)||"",alignment:((h=this.textAlignment)==null?void 0:h.value)||""};return hc(t)}handleFormChange(t){var e;this.ctaButtonState=this.CTA_STATES.primary,this.validationError="",this.charsNum=((e=this.textarea)==null?void 0:e.value.length)||0,this.emit("pbo-type-form-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(t){var i;t.preventDefault();const e=(i=t.submitter)==null?void 0:i.name;if(this.ctaButtonState.type==="danger"){e==="skip"&&this.wrappedSubmitTypeForm(this.formData);return}if(this.textarea.value===""||this.textarea.value===null||this.textarea.value===void 0){this.ctaButtonState=this.CTA_STATES.danger,this.textarea.focus();return}this.wrappedSubmitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize),window.addEventListener("pbo-type-canvas-processed",this.handleTypeCanvasProcessed)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),window.removeEventListener("pbo-type-canvas-processed",this.handleTypeCanvasProcessed),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const t=this.maxChars-this.charsNum;return L`
|
|
1522
1522
|
<form class="typing-form" @submit=${this.submitFormHandler}>
|
|
1523
1523
|
<pbo-textarea
|
|
1524
1524
|
exportparts="textarea:editor-textarea"
|
|
@@ -1548,29 +1548,29 @@
|
|
|
1548
1548
|
></pbo-font-selector>
|
|
1549
1549
|
|
|
1550
1550
|
<div class="color-alignment-container">
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1551
|
+
${this.hideColor?"":L`<pbo-radio-group
|
|
1552
|
+
class="text-color"
|
|
1553
|
+
@pbo-change=${e=>{this.handleFormChange(e),this.emit("pbo_edit_type_form",{detail:{action:"color"}})}}
|
|
1554
|
+
value="rgb(0,0,0)"
|
|
1555
|
+
label="Color"
|
|
1556
|
+
size="large"
|
|
1557
|
+
exportparts="form-control-label:color-selector-label,form-control-label:type-form-label"
|
|
1558
|
+
>
|
|
1559
|
+
<pbo-radio-button
|
|
1560
|
+
?disabled="${this.disabled}"
|
|
1561
|
+
value="rgb(0,0,0)"
|
|
1562
|
+
size="small"
|
|
1563
|
+
circle
|
|
1564
|
+
aria-label="Black"
|
|
1565
|
+
></pbo-radio-button>
|
|
1566
|
+
<pbo-radio-button
|
|
1567
|
+
?disabled="${this.disabled}"
|
|
1568
|
+
value="rgb(255,255,255)"
|
|
1569
|
+
size="small"
|
|
1570
|
+
circle
|
|
1571
|
+
aria-label="White"
|
|
1572
|
+
></pbo-radio-button>
|
|
1573
|
+
</pbo-radio-group>`}
|
|
1574
1574
|
|
|
1575
1575
|
<pbo-radio-group
|
|
1576
1576
|
class="text-alignment"
|
|
@@ -1646,7 +1646,7 @@
|
|
|
1646
1646
|
>
|
|
1647
1647
|
${this.validationError}
|
|
1648
1648
|
</div>
|
|
1649
|
-
${this.ctaButtonState.type==="danger"?
|
|
1649
|
+
${this.ctaButtonState.type==="danger"?L`
|
|
1650
1650
|
<pbo-button
|
|
1651
1651
|
exportparts="base:cta-link-button-base, label:cta-link-button-label"
|
|
1652
1652
|
name="skip"
|
|
@@ -1662,11 +1662,11 @@
|
|
|
1662
1662
|
`:""}
|
|
1663
1663
|
</div>
|
|
1664
1664
|
</form>
|
|
1665
|
-
`}};
|
|
1665
|
+
`}};X.styles=[vt,Js,ep];X.dependencies={"pbo-font-selector":Ve,"pbo-textarea":ct,"pbo-color-radio-group":ft,"pbo-radio-group":ft,"pbo-radio-button":ft,"pbo-button":lt};at([C({type:String,reflect:!0})],X.prototype,"cardInnerImageUrl",2);at([C()],X.prototype,"card",2);at([C()],X.prototype,"submitTypeForm",2);at([C({type:Boolean,reflect:!0})],X.prototype,"loading",2);at([C({type:Boolean,reflect:!0})],X.prototype,"disabled",2);at([C({type:Function})],X.prototype,"onClose",2);at([C({type:String,attribute:"cta-primary-label"})],X.prototype,"ctaButtonPrimaryLabel",2);at([C({type:Boolean,attribute:"hide-type-form-color-block"})],X.prototype,"hideColor",2);at([B(".greeting-text")],X.prototype,"textarea",2);at([B(".font-selector")],X.prototype,"fontSelector",2);at([B(".text-color")],X.prototype,"textColor",2);at([B(".text-alignment")],X.prototype,"textAlignment",2);at([B(".typing-form")],X.prototype,"typingForm",2);at([Eo(".cta-buttons pbo-button")],X.prototype,"ctaButtons",2);at([I()],X.prototype,"CTA_STATES",2);at([I()],X.prototype,"windowHeight",2);at([I()],X.prototype,"charsNum",2);at([I()],X.prototype,"ctaButtonState",2);at([I()],X.prototype,"validationError",2);at([I()],X.prototype,"wrappedSubmitTypeForm",2);at([I()],X.prototype,"processedMessage",2);at([I()],X.prototype,"maxChars",2);at([G("card")],X.prototype,"handleCardChange",1);at([G("submitTypeForm")],X.prototype,"updateWrappedSubmitTypeForm",1);X=at([mt("pbo-type-form")],X);/**
|
|
1666
1666
|
* @license
|
|
1667
1667
|
* Copyright 2017 Google LLC
|
|
1668
1668
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1669
|
-
*/const Wa=n=>Yu(n)?n._$litType$.h:n.strings,jn=an(class extends ln{constructor(n){super(n),this.et=new WeakMap}render(n){return[n]}update(n,[t]){const e=Ha(this.it)?Wa(this.it):null,i=Ha(t)?Wa(t):null;if(e!==null&&(i===null||e!==i)){const s=Ua(n).pop();let r=this.et.get(e);if(r===void 0){const o=document.createDocumentFragment();r=Nl(
|
|
1669
|
+
*/const Wa=n=>Yu(n)?n._$litType$.h:n.strings,jn=an(class extends ln{constructor(n){super(n),this.et=new WeakMap}render(n){return[n]}update(n,[t]){const e=Ha(this.it)?Wa(this.it):null,i=Ha(t)?Wa(t):null;if(e!==null&&(i===null||e!==i)){const s=Ua(n).pop();let r=this.et.get(e);if(r===void 0){const o=document.createDocumentFragment();r=Nl(J,o),r.setConnected(!1),this.et.set(e,r)}no(r,[s]),Na(r,void 0,s)}if(i!==null){if(e===null||e!==i){const s=this.et.get(i);if(s!==void 0){const r=Ua(s).pop();Ku(n),Na(n,void 0,r),no(n,[r])}}this.it=t}else this.it=void 0;return this.render(t)}}),np=rt`
|
|
1670
1670
|
:host {
|
|
1671
1671
|
display: block;
|
|
1672
1672
|
width: 100%;
|
|
@@ -1806,7 +1806,7 @@
|
|
|
1806
1806
|
width: 100%;
|
|
1807
1807
|
height: auto;
|
|
1808
1808
|
}
|
|
1809
|
-
`,op=
|
|
1809
|
+
`,op=rt`
|
|
1810
1810
|
:host {
|
|
1811
1811
|
--size: 70%;
|
|
1812
1812
|
--header-spacing: var(--pbo-spacing-large);
|
|
@@ -1891,7 +1891,7 @@
|
|
|
1891
1891
|
width: 100%;
|
|
1892
1892
|
height: var(--size);
|
|
1893
1893
|
}
|
|
1894
|
-
`;var ap=Object.defineProperty,lp=Object.getOwnPropertyDescriptor,Ei=(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 _e=class extends
|
|
1894
|
+
`;var ap=Object.defineProperty,lp=Object.getOwnPropertyDescriptor,Ei=(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 _e=class extends yt{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 L`
|
|
1895
1895
|
<div
|
|
1896
1896
|
part="base"
|
|
1897
1897
|
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})}
|
|
@@ -1913,7 +1913,7 @@
|
|
|
1913
1913
|
<slot part="body" class="drawer__body"></slot>
|
|
1914
1914
|
</div>
|
|
1915
1915
|
</div>
|
|
1916
|
-
`}};_e.styles=[
|
|
1916
|
+
`}};_e.styles=[vt,op];Ei([B(".drawer")],_e.prototype,"drawer",2);Ei([C({type:Boolean,reflect:!0})],_e.prototype,"open",2);Ei([C({reflect:!0})],_e.prototype,"placement",2);Ei([C({type:Boolean,reflect:!0})],_e.prototype,"radius",2);Ei([C({type:Boolean,reflect:!0})],_e.prototype,"contained",2);Ei([C({type:String})],_e.prototype,"label",2);Ei([G("open",{waitUntilFirstUpdate:!0})],_e.prototype,"handleOpenChange",1);_e=Ei([mt("pbo-drawer")],_e);const cp=rt`
|
|
1917
1917
|
:host {
|
|
1918
1918
|
display: block;
|
|
1919
1919
|
width: 100%;
|
|
@@ -1941,8 +1941,8 @@
|
|
|
1941
1941
|
display: block;
|
|
1942
1942
|
object-fit: contain;
|
|
1943
1943
|
}
|
|
1944
|
-
`;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 Ga(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?Ga(Object(e),!0).forEach((function(i){v(n,i,e[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Ga(Object(e)).forEach((function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))}))}return n}function
|
|
1945
|
-
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 pp={};let Xa;const Ne=()=>Xa||(Xa={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new up,dispose(){},copyPasteData:pp}),hs=()=>Ne().document,dn=()=>Ne().window,uc=()=>{var n;return Math.max((n=W.devicePixelRatio)!==null&&n!==void 0?n:dn().devicePixelRatio,1)},js=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)]}},oo="6.9.1";function Lr(){}const Qs=Math.PI/2,Nr=2*Math.PI,Do=Math.PI/180,Jt=Object.freeze([1,0,0,1,0,0]),Ao=16,ui=.4477152502,V="center",Y="left",ne="top",ao="bottom",wt="right",oe="none",Mo=/\r?\n/,pc="moving",un="scaling",gc="rotating",Io="rotate",fc="skewing",Ns="resizing",gp="modifyPoly",fp="modifyPath",Ur="changed",pn="scale",ce="scaleX",xe="scaleY",ds="skewX",us="skewY",Mt="fill",ae="stroke",Wr="modified",Xi="json",$n="svg",D=new class{constructor(){this[Xi]=new Map,this[$n]=new Map}has(n){return this[Xi].has(n)}getClass(n){const t=this[Xi].get(n);if(!t)throw new He("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[$n].get(n)}setSVGClass(n,t){this[$n].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 mp{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},ri=n=>{if(n===0)return 1;switch(Math.abs(n)/Qs){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},ni=n=>{if(n===0)return 0;const t=n/Qs,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]:Lo;const i=ni(t),s=ri(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 Lo=new w(0,0),Fr=n=>!!n&&Array.isArray(n._objects);function mc(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 bc extends mp{_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 dn().requestAnimationFrame(n)}function bp(n){return dn().cancelAnimationFrame(n)}let vp=0;const Ci=()=>vp++,oi=()=>{const n=hs().createElement("canvas");if(!n||n.getContext===void 0)throw new He("Failed to create `canvas` element");return n},yp=()=>hs().createElement("img"),we=n=>{const t=oi();return t.width=n.width,t.height=n.height,t},vc=(n,t,e)=>n.toDataURL("image/".concat(t),e),yc=(n,t,e)=>new Promise(((i,s)=>{n.toBlob(i,"image/".concat(t),e)})),Ct=n=>n*Do,ai=n=>n/Do,_p=n=>n.every(((t,e)=>t===Jt[e])),ie=(n,t,e)=>new w(n).transform(t,e),ke=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]],Fo=(n,t)=>n.reduceRight(((e,i)=>i&&e?Bt(i,e,t):i||e),void 0)||Jt.concat(),_c=n=>{let[t,e]=n;return Math.atan2(e,t)},Yr=n=>{const t=_c(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:ai(t),scaleX:i,scaleY:s,skewX:ai(r),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},tr=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function ps(){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=ri(i),r=ni(i);return[s,r,-r,s,t?t-(s*t-r*e):0,e?e-(r*t+s*e):0]}const jo=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},xc=n=>Math.tan(Ct(n)),wc=n=>[1,0,xc(n),1,0,0],Cc=n=>[1,xc(n),0,1,0,0],gn=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:r=0,skewY:o=0}=n,a=jo(i?-t:t,s?-e:e);return r&&(a=Bt(a,wc(r),!0)),o&&(a=Bt(a,Cc(o),!0)),a},xp=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let s=tr(t,e);i&&(s=Bt(s,ps({angle:i})));const r=gn(n);return _p(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 hp("loadImage"));const r=yp();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 He("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=n):a()}))},Us=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)}))}))},fn=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)?Us([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)}))}))},gs=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce(((t,e)=>(e in n&&(t[e]=n[e]),t)),{})},$o=(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)),Ws=n=>"matrix("+n.map((t=>et(t,W.NUM_FRACTION_DIGITS))).join(" ")+")",ve=n=>!!n&&n.toLive!==void 0,qa=n=>!!n&&typeof n.toObject=="function",Ka=n=>!!n&&n.offsetX!==void 0&&"source"in n,Mi=n=>!!n&&"multiSelectionStacking"in n;function Sc(n){const t=n&&Ee(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 Ee=n=>n.ownerDocument||null,Tc=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Ec=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))},lo=(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 Za(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=oe,n}class kc{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&&hs().getElementById(t)||oi();var i;if(e.hasAttribute("data-fabric"))throw new He("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;Ec(i,s,t,e)}setCSSDimensions(t){lo(this.lower.el,t)}calcOffset(){return(function(t){var e;const i=t&&Ee(t),s={left:0,top:0};if(!i)return s;const r=((e=Tc(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=Sc(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(){Ne().dispose(this.lower.el),delete this.lower}}const wp={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Jt]},Cp=["objects"];class er extends mc(bc){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 er.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 kc(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.
|
|
1944
|
+
`;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 Ga(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?Ga(Object(e),!0).forEach((function(i){v(n,i,e[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Ga(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 We(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}class Ya{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 Ya{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 Ya,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 He extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class hp extends He{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class dp{}class up extends dp{testPrecision(t,e){const i="precision ".concat(e,` float;
|
|
1945
|
+
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 pp={};let Xa;const Ne=()=>Xa||(Xa={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new up,dispose(){},copyPasteData:pp}),hs=()=>Ne().document,dn=()=>Ne().window,uc=()=>{var n;return Math.max((n=W.devicePixelRatio)!==null&&n!==void 0?n:dn().devicePixelRatio,1)},js=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)]}},oo="6.9.1";function Lr(){}const Qs=Math.PI/2,Nr=2*Math.PI,Do=Math.PI/180,Jt=Object.freeze([1,0,0,1,0,0]),Ao=16,ui=.4477152502,V="center",Y="left",ne="top",ao="bottom",St="right",oe="none",Mo=/\r?\n/,pc="moving",un="scaling",gc="rotating",Io="rotate",fc="skewing",Ns="resizing",gp="modifyPoly",fp="modifyPath",Ur="changed",pn="scale",ce="scaleX",xe="scaleY",ds="skewX",us="skewY",Mt="fill",ae="stroke",Wr="modified",Xi="json",$n="svg",D=new class{constructor(){this[Xi]=new Map,this[$n]=new Map}has(n){return this[Xi].has(n)}getClass(n){const t=this[Xi].get(n);if(!t)throw new He("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[$n].get(n)}setSVGClass(n,t){this[$n].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 mp{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},ri=n=>{if(n===0)return 1;switch(Math.abs(n)/Qs){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},ni=n=>{if(n===0)return 0;const t=n/Qs,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]:Lo;const i=ni(t),s=ri(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 Lo=new w(0,0),Fr=n=>!!n&&Array.isArray(n._objects);function mc(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 bc extends mp{_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 dn().requestAnimationFrame(n)}function bp(n){return dn().cancelAnimationFrame(n)}let vp=0;const Ci=()=>vp++,oi=()=>{const n=hs().createElement("canvas");if(!n||n.getContext===void 0)throw new He("Failed to create `canvas` element");return n},yp=()=>hs().createElement("img"),we=n=>{const t=oi();return t.width=n.width,t.height=n.height,t},vc=(n,t,e)=>n.toDataURL("image/".concat(t),e),yc=(n,t,e)=>new Promise(((i,s)=>{n.toBlob(i,"image/".concat(t),e)})),Tt=n=>n*Do,ai=n=>n/Do,_p=n=>n.every(((t,e)=>t===Jt[e])),ie=(n,t,e)=>new w(n).transform(t,e),ke=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]],Fo=(n,t)=>n.reduceRight(((e,i)=>i&&e?Bt(i,e,t):i||e),void 0)||Jt.concat(),_c=n=>{let[t,e]=n;return Math.atan2(e,t)},Yr=n=>{const t=_c(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:ai(t),scaleX:i,scaleY:s,skewX:ai(r),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},tr=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function ps(){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=Tt(n),s=ri(i),r=ni(i);return[s,r,-r,s,t?t-(s*t-r*e):0,e?e-(r*t+s*e):0]}const jo=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},xc=n=>Math.tan(Tt(n)),wc=n=>[1,0,xc(n),1,0,0],Cc=n=>[1,xc(n),0,1,0,0],gn=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:r=0,skewY:o=0}=n,a=jo(i?-t:t,s?-e:e);return r&&(a=Bt(a,wc(r),!0)),o&&(a=Bt(a,Cc(o),!0)),a},xp=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let s=tr(t,e);i&&(s=Bt(s,ps({angle:i})));const r=gn(n);return _p(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 hp("loadImage"));const r=yp();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 He("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=n):a()}))},Us=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)}))}))},fn=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)?Us([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)}))}))},gs=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce(((t,e)=>(e in n&&(t[e]=n[e]),t)),{})},$o=(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)),Ws=n=>"matrix("+n.map((t=>et(t,W.NUM_FRACTION_DIGITS))).join(" ")+")",ve=n=>!!n&&n.toLive!==void 0,qa=n=>!!n&&typeof n.toObject=="function",Ka=n=>!!n&&n.offsetX!==void 0&&"source"in n,Mi=n=>!!n&&"multiSelectionStacking"in n;function Sc(n){const t=n&&Ee(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 Ee=n=>n.ownerDocument||null,Tc=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Ec=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))},lo=(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 Za(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=oe,n}class kc{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&&hs().getElementById(t)||oi();var i;if(e.hasAttribute("data-fabric"))throw new He("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;Ec(i,s,t,e)}setCSSDimensions(t){lo(this.lower.el,t)}calcOffset(){return(function(t){var e;const i=t&&Ee(t),s={left:0,top:0};if(!i)return s;const r=((e=Tc(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=Sc(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(){Ne().dispose(this.lower.el),delete this.lower}}const wp={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Jt]},Cp=["objects"];class er extends mc(bc){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 er.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 kc(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.
|
|
1946
1946
|
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?uc():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=ie(t,ke(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 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=ke(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 w(a.x,o.y),bl:new w(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(bp(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 ie(this.getCenterPoint(),ke(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:oo},gs(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,`)" >
|
|
1947
1947
|
`)),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push(`</g>
|
|
1948
1948
|
`),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" ?>
|
|
@@ -1961,13 +1961,13 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
1961
1961
|
`.concat(s,`]]></style>
|
|
1962
1962
|
`):""}_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")]?Ws(ke(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"||!Ka(i)?r:i.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!Ka(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
|
|
1963
1963
|
`))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
|
|
1964
|
-
`)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new He("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:r=[]}=s,o=nt(s,Cp),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:d}=o,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Us(r,{reviver:e,signal:i}),fn({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=we(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 vc(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 yc(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=we({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(er,"ownDefaults",wp);const Sp=["touchstart","touchmove","touchend"],Tp=n=>{const t=Sc(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)},co=n=>Sp.includes(n.type)||n.pointerType==="touch",Ja=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}},Ep=["translateX","translateY","scaleX","scaleY"],kp=(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=nt(e,Ep),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)},Op=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},Oc=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}),Ro=(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)},mn=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Jt;return Bt(ke(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt),n)},ss=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jt;return n.transform(mn(t,e))},Pp=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jt;return n.transform(mn(t,e),!0)},Dp=(n,t,e)=>{const i=mn(t,e);return Xr(n,Bt(i,n.calcOwnMatrix())),i},Pc=(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)},Ap={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Pt=n=>typeof n=="string"?Ap[n]:n-.5,qr="not-allowed";function Dc(n){return Pt(n.originX)===Pt(V)&&Pt(n.originY)===Pt(V)}function Qa(n){return .5-Pt(n)}const Pe=(n,t)=>n[t],Ac=(n,t,e,i)=>({e:n,transform:t,pointer:new w(e,i)});function Mc(n,t){const e=n.getTotalAngle()+ai(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Bo(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 Mp=(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)&&Pc(pc,Ac(n,t,e,i)),c||h},Kr=n=>n.replace(/\s+/g," "),tl={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"},Rn=(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),el=(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]},il=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"),sl=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 tl&&(t=tl[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]=el(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=el(...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(sl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=sl(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,il(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=Rn(h,c,i+1/3),a=Rn(h,c,i),l=Rn(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),il(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")?ai(i):e.includes("turn")?360*i:i}}const rs=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ao;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}},Ip=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}},Gs=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 Ic{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=Gs(Mt,this.fill);return[Gs(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(Ws(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,`" >
|
|
1964
|
+
`)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new He("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:r=[]}=s,o=ot(s,Cp),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:d}=o,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Us(r,{reviver:e,signal:i}),fn({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=we(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 vc(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 yc(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=we({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(er,"ownDefaults",wp);const Sp=["touchstart","touchmove","touchend"],Tp=n=>{const t=Sc(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)},co=n=>Sp.includes(n.type)||n.pointerType==="touch",Ja=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}},Ep=["translateX","translateY","scaleX","scaleY"],kp=(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,Ep),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)},Op=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},Oc=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}),Ro=(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)},mn=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Jt;return Bt(ke(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt),n)},ss=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jt;return n.transform(mn(t,e))},Pp=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jt;return n.transform(mn(t,e),!0)},Dp=(n,t,e)=>{const i=mn(t,e);return Xr(n,Bt(i,n.calcOwnMatrix())),i},Pc=(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)},Ap={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Pt=n=>typeof n=="string"?Ap[n]:n-.5,qr="not-allowed";function Dc(n){return Pt(n.originX)===Pt(V)&&Pt(n.originY)===Pt(V)}function Qa(n){return .5-Pt(n)}const Pe=(n,t)=>n[t],Ac=(n,t,e,i)=>({e:n,transform:t,pointer:new w(e,i)});function Mc(n,t){const e=n.getTotalAngle()+ai(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Bo(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(-Tt(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 Mp=(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)&&Pc(pc,Ac(n,t,e,i)),c||h},Kr=n=>n.replace(/\s+/g," "),tl={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"},Rn=(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),el=(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]},il=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"),sl=n=>{let[t,e,i,s=1]=n;const r=Math.round(.3*t+.59*e+.11*i);return[r,r,r,s]};class Z{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof Z)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 tl&&(t=tl[t]),t==="transparent"?[255,255,255,0]:Z.sourceFromHex(t)||Z.sourceFromRgb(t)||Z.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]=el(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=el(...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(sl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=sl(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof Z||(t=new Z(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 Z.fromRgba(t)}static fromRgba(t){return new Z(Z.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,il(e[4])]}}static fromHsl(t){return Z.fromHsla(t)}static fromHsla(t){return new Z(Z.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=(Z.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=Rn(h,c,i+1/3),a=Rn(h,c,i),l=Rn(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),il(e[4])]}static fromHex(t){return new Z(Z.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")?ai(i):e.includes("turn")?360*i:i}}const rs=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ao;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}},Ip=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}},Gs=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 Z(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 Ic{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=Gs(Mt,this.fill);return[Gs(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(Ws(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,`" >
|
|
1965
1965
|
`).concat(l.toClipPathSVG(i),`</clipPath>
|
|
1966
1966
|
`)),h&&g.push("<g ",a,this.getSvgCommons(),` >
|
|
1967
1967
|
`),g.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
|
|
1968
1968
|
`);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>
|
|
1969
1969
|
`),h&&g.push(`</g>
|
|
1970
|
-
`),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==Mt?' paint-order="'.concat(this.paintFirst,'" '):""}}function bn(n){return new RegExp("^("+n.join("|")+")\\b","i")}const Hi="textDecorationThickness",Lc=["fontSize","fontWeight","fontFamily","fontStyle"],Fc=["underline","overline","linethrough"],jc=[...Lc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],$c=[...jc,...Fc,"textBackgroundColor","direction",Hi],Lp=[...Lc,...Fc,ae,"strokeWidth",Mt,"deltaY","textBackgroundColor",Hi],Fp={_reNewline:Mo,_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,[Hi]:66.667},Be="justify",Zr="justify-left",$s="justify-right",Rs="justify-center";var rl,nl,ol;const Oe=String.raw(rl||(rl=We(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),Bn=String.raw(nl||(nl=We(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),jp=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Oe+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Oe+"))?\\s+(.*)"),$p={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":Hi},zn="font-size",Hn="clip-path";bn(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);bn(["symbol","image","marker","pattern","view","svg"]);const al=bn(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(ol||(ol=We(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),Oe,Bn,Oe,Bn,Oe,Bn,Oe));const Rp=new w(1,0),Rc=new w,Bc=(n,t)=>n.rotate(t),ho=(n,t)=>new w(t).subtract(n),uo=n=>n.distanceFrom(Rc),po=(n,t)=>Math.atan2(Bs(n,t),zp(n,t)),Bp=n=>po(Rp,n),zo=n=>n.eq(Rc)?n:n.scalarDivide(uo(n)),zc=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return zo(new w(-n.y,n.x).scalarMultiply(t?1:-1))},Bs=(n,t)=>n.x*t.y-n.y*t.x,zp=(n,t)=>n.x*t.x+n.y*t.y,ll=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const i=Bs(t,e),s=Bs(t,n),r=Bs(e,n);return i>=0?s>=0&&r<=0:!(s<=0&&r>=0)},cl="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",hl=new RegExp("(?:\\s|^)"+cl+cl+"("+Oe+"?(?: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]=(hl.exec(e)||[]).map((o=>parseFloat(o)||0));return{color:(e.replace(hl,"")||"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=Bc(new w(this.offsetX,this.offsetY),
|
|
1970
|
+
`),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==Mt?' paint-order="'.concat(this.paintFirst,'" '):""}}function bn(n){return new RegExp("^("+n.join("|")+")\\b","i")}const Hi="textDecorationThickness",Lc=["fontSize","fontWeight","fontFamily","fontStyle"],Fc=["underline","overline","linethrough"],jc=[...Lc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],$c=[...jc,...Fc,"textBackgroundColor","direction",Hi],Lp=[...Lc,...Fc,ae,"strokeWidth",Mt,"deltaY","textBackgroundColor",Hi],Fp={_reNewline:Mo,_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,[Hi]:66.667},Be="justify",Zr="justify-left",$s="justify-right",Rs="justify-center";var rl,nl,ol;const Oe=String.raw(rl||(rl=We(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),Bn=String.raw(nl||(nl=We(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),jp=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Oe+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Oe+"))?\\s+(.*)"),$p={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":Hi},zn="font-size",Hn="clip-path";bn(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);bn(["symbol","image","marker","pattern","view","svg"]);const al=bn(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(ol||(ol=We(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),Oe,Bn,Oe,Bn,Oe,Bn,Oe));const Rp=new w(1,0),Rc=new w,Bc=(n,t)=>n.rotate(t),ho=(n,t)=>new w(t).subtract(n),uo=n=>n.distanceFrom(Rc),po=(n,t)=>Math.atan2(Bs(n,t),zp(n,t)),Bp=n=>po(Rp,n),zo=n=>n.eq(Rc)?n:n.scalarDivide(uo(n)),zc=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return zo(new w(-n.y,n.x).scalarMultiply(t?1:-1))},Bs=(n,t)=>n.x*t.y-n.y*t.x,zp=(n,t)=>n.x*t.x+n.y*t.y,ll=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const i=Bs(t,e),s=Bs(t,n),r=Bs(e,n);return i>=0?s>=0&&r<=0:!(s<=0&&r>=0)},cl="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",hl=new RegExp("(?:\\s|^)"+cl+cl+"("+Oe+"?(?: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]=(hl.exec(e)||[]).map((o=>parseFloat(o)||0));return{color:(e.replace(hl,"")||"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=Bc(new w(this.offsetX,this.offsetY),Tt(-t.angle)),i=new Z(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,`%" >
|
|
1971
1971
|
<feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(et(this.blur?this.blur/2:0,W.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
|
|
1972
1972
|
<feOffset dx="`).concat(et(e.x,W.NUM_FRACTION_DIGITS),'" dy="').concat(et(e.y,W.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
|
|
1973
1973
|
<feFlood flood-color="`).concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),`"/>
|
|
@@ -1977,44 +1977,44 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
1977
1977
|
<feMergeNode in="SourceGraphic"></feMergeNode>
|
|
1978
1978
|
</feMerge>
|
|
1979
1979
|
</filter>
|
|
1980
|
-
`)}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:$o(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)),Hp=[ne,Y,ce,xe,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",ds,us],ci=[Mt,ae,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Vp={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},Np=(n,t,e,i)=>-e*Math.cos(n/i*Qs)+e+t,Up=()=>!1;class Ho{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:o=Np,onStart:a=Lr,onChange:l=Lr,onComplete:c=Lr,abort:h=Up,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 Wp=["startValue","endValue"];class Gp extends Ho{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(y(y({},nt(t,Wp)),{},{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 Yp=["startValue","endValue"];class Xp extends Ho{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(y(y({},nt(t,Yp)),{},{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 qp=["startValue","endValue","easing","onChange","onComplete","abort"],Kp=(n,t,e,i)=>t+e*(1-Math.cos(n/i*Qs)),Vn=n=>n&&((t,e,i)=>n(new K(t).toRgba(),e,i));class Zp extends Ho{constructor(t){let{startValue:e,endValue:i,easing:s=Kp,onChange:r,onComplete:o,abort:a}=t,l=nt(t,qp);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:Vn(r),onComplete:Vn(o),abort:Vn(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 Hc(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new Xp(n):new Gp(n);return t.start(),t}function Jp(n){const t=new Zp(n);return t.start(),t}class pt{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=ho(e,i),o=ho(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 pt("Intersection").append(new w(t.x+b*a,t.y+b*l)):new pt}if(p===0||g===0){const b=r||o||pt.isPointContained(t,i,s)||pt.isPointContained(e,i,s)||pt.isPointContained(i,t,e)||pt.isPointContained(s,t,e);return new pt(b?"Coincident":void 0)}return new pt("Parallel")}static intersectSegmentLine(t,e,i,s){return pt.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return pt.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 pt,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=pt.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 pt.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new pt,s=t.length,r=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=pt.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 pt("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 pt.intersectPolygonPolygon(t,[s,o,r,a])}}class Qp extends bc{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,ke(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=>ie(a,o)))}return r}intersectsWithRect(t,e){return pt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=pt.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 pt.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(xe,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?ai(_c(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Jt.concat()}calcACoords(){const t=ps({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=tr(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=xp(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):Ro(o,a,gn(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?ie(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,ne)}}const tg=["type"],eg=["extraParam"];let qe=class Rr extends Qp{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=oi(),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]=js.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!==xe||(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=we(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=ke(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)||Jt,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===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=we({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=Oc(this),i=this.group,s=this.shadow,r=Math.abs,o=t.enableRetinaScaling?uc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(_=>new er(_,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Op(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Dp(this,this.getViewportTransform()),this.setCoords();const c=oi(),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 vc(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return yc(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&&Ne().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?Jp(h):Hc(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=Yt=>et(Yt,i),kt=y(y({},gs(this,t)),{},{type:this.constructor.type,version:oo,originX:d,originY:u,left:N(c),top:N(h),width:N(p),height:N(g),fill:qa(r)?r.toObject():r,stroke:qa(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 $o(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=nt(t,tg),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,r=nt(i,eg);return fn(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",Hp),v(qe,"cacheProperties",ci),v(qe,"ownDefaults",Vp),v(qe,"type","FabricObject"),v(qe,"colorProperties",[Mt,ae,"backgroundColor"]),v(qe,"customProperties",[]),D.setClass(qe),D.setClass(qe,"object");const fs=(n,t,e)=>(i,s,r,o)=>{const a=t(i,s,r,o);return a&&Pc(n,y(y({},Ac(i,s,r,o)),e)),a};function ms(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 dl=fs(Ns,ms(((n,t,e,i)=>{const s=Bo(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=Dc(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 ig(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 sg(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 Se{constructor(t){v(this,"visible",!0),v(this,"actionName",pn),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)&&pt.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=Fo([tr(i,s),ps({angle:t}),jo((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"?ig.call(this,t,e,i,s,r):sg.call(this,t,e,i,s,r)}}const rg=(n,t,e)=>e.lockRotation?qr:t.cursorStyle,ng=fs(gc,ms(((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=ai(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 Vc(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Nc(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 og=["e","se","s","sw","w","nw","n","ne","e"],As=(n,t,e)=>{const i=Vc(n,e);if(Nc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return qr;const s=Mc(e,t);return"".concat(og[s],"-resize")};function Vo(n,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,o=s.by,a=Vc(n,r);let l,c,h,d,u,p;if(Nc(r,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Bo(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);Dc(t)&&(c*=2,h*=2),t.signX!==u&&o!=="y"&&(t.originX=Qa(t.originX),c*=-1,t.signX=u),t.signY!==p&&o!=="x"&&(t.originY=Qa(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(xe,h)):(!Pe(r,"lockScalingX")&&r.set(ce,c),!Pe(r,"lockScalingY")&&r.set(xe,h)),g!==r.scaleX||f!==r.scaleY}const cr=fs(un,ms(((n,t,e,i)=>Vo(n,t,e,i)))),ag=fs(un,ms(((n,t,e,i)=>Vo(n,t,e,i,{by:"x"})))),lg=fs(un,ms(((n,t,e,i)=>Vo(n,t,e,i,{by:"y"})))),cg=["target","ex","ey","skewingSide"],Nn={x:{counterAxis:"y",scale:ce,skew:ds,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:xe,skew:us,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},hg=["ns","nesw","ew","nwse"],dg=(n,t,e)=>{if(t.x!==0&&Pe(e,"lockSkewingY")||t.y!==0&&Pe(e,"lockSkewingX"))return qr;const i=Mc(e,t)%4;return"".concat(hg[i],"-resize")};function Uc(n,t,e,i,s){const{target:r}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Nn[n];if(Pe(r,l))return!1;const{origin:d,flip:u}=Nn[o],p=Pt(e[d])*(r[u]?-1:1),g=-Math.sign(p)*(r[h]?-1:1),f=.5*-((r[c]===0&&Bo(e,V,V,i,s)[n]>0||r[c]>0?1:-1)*g)+.5;return fs(fc,ms(((m,_,x,S)=>(function(T,O,k){let{target:E,ex:P,ey:R,skewingSide:L}=O,j=nt(O,cg);const{skew:H}=Nn[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,Yt=ai(Math.atan(kt));E.set(H,Yt);const Xt=U!==E[H];if(Xt&&T==="y"){const{skewX:Le,scaleX:me}=E,jt=E._getTransformedDimensions({skewY:U}),Fe=E._getTransformedDimensions(),he=Le!==0?jt.x/Fe.x:1;he!==1&&E.set(ce,he*me)}return Xt})(n,_,new w(x,S)))))(t,y(y({},e),{},{[a]:f,skewingSide:g}),i,s)}const ug=(n,t,e,i)=>Uc("x",n,t,e,i),pg=(n,t,e,i)=>Uc("y",n,t,e,i);function vn(n,t){return n[t.canvas.altActionKey]}const hr=(n,t,e)=>{const i=vn(n,e);return t.x===0?i?ds:xe:t.y===0?i?us:ce:""},Qi=(n,t,e)=>vn(n,e)?dg(0,t,e):As(n,t,e),ul=(n,t,e,i)=>vn(n,t.target)?pg(n,t,e,i):ag(n,t,e,i),pl=(n,t,e,i)=>vn(n,t.target)?ug(n,t,e,i):lg(n,t,e,i),Wc=()=>({ml:new Se({x:-.5,y:0,cursorStyleHandler:Qi,actionHandler:ul,getActionName:hr}),mr:new Se({x:.5,y:0,cursorStyleHandler:Qi,actionHandler:ul,getActionName:hr}),mb:new Se({x:0,y:.5,cursorStyleHandler:Qi,actionHandler:pl,getActionName:hr}),mt:new Se({x:0,y:-.5,cursorStyleHandler:Qi,actionHandler:pl,getActionName:hr}),tl:new Se({x:-.5,y:-.5,cursorStyleHandler:As,actionHandler:cr}),tr:new Se({x:.5,y:-.5,cursorStyleHandler:As,actionHandler:cr}),bl:new Se({x:-.5,y:.5,cursorStyleHandler:As,actionHandler:cr}),br:new Se({x:.5,y:.5,cursorStyleHandler:As,actionHandler:cr}),mtr:new Se({x:0,y:-.5,actionHandler:ng,cursorStyleHandler:rg,offsetY:-40,withConnection:!0,actionName:Io})}),gg=()=>({mr:new Se({x:.5,y:0,actionHandler:dl,cursorStyleHandler:Qi,actionName:Ns}),ml:new Se({x:-.5,y:0,actionHandler:dl,cursorStyleHandler:Qi,actionName:Ns})}),fg=()=>y(y({},Wc()),gg());class Ys extends qe{static getDefaults(){return y(y({},super.getDefaults()),Ys.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ys.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Wc()}}_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(pn))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=tr(e.x,e.y),s=ps({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=Ro(this.width,this.height,gn(e)),o=this.isStrokeAccountedForInDimensions()?Lo:(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 Gc(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(Ys,"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 Ys{}Gc(Nt,[Ic]),D.setClass(Nt),D.setClass(Nt,"object");const mg=(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 Yc{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=ho(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 bg=new w;class ns extends Yc{static getOrthogonalRotationFactor(t,e){const i=e?po(t,e):Bp(t);return Math.abs(i)<Qs?-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=po(this.AB,this.AC),this.bisector=zo(Bc(this.AB.eq(bg)?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=zc(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?uo(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return uo(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=>{ll(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=>{ll(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=Bs(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 gl extends Yc{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(zc(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(zo(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 vg=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 gl(r,r,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new ns(r,l,c,t).project()):i.push(...new gl(r,o===0?c:l,t).project())})),i},No=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},yg=n=>n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">");let ks;const Uo=n=>{if(ks||ks||(ks="Intl"in dn()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),ks){const t=ks.segment(n);return Array.from(t).map((e=>{let{segment:i}=e;return i}))}return _g(n)},_g=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=xg(n,i))!==!1&&t.push(e);return t},xg=(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},Wo=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)},wg=(n,t)=>{const e=t.split(`
|
|
1981
|
-
`),i=[];let s=-1,r={};n=No(n);for(let o=0;o<e.length;o++){const a=Uo(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&&(Wo(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},Cg=(n,t)=>{if(!Array.isArray(n))return No(n);const e=t.split(Mo),i={};let s=-1,r=0;for(let o=0;o<e.length;o++){const a=Uo(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},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 fl(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 Sg(n,t){let e=!0;const i=fl(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=fl(s=s.parentElement,o);return r.length===0})(n,t)),i&&e&&t.length===0}const Tg=n=>{var t;return(t=$p[n])!==null&&t!==void 0?t:n},Eg=new RegExp("(".concat(Oe,")"),"gi"),kg=n=>Kr(n.replace(Eg," $1 ").replace(/,/gi," "));var ml,bl,vl,yl,_l,xl,wl;const Zt="(".concat(Oe,")"),Og=String.raw(ml||(ml=We(["(skewX)(",")"],["(skewX)\\(","\\)"])),Zt),Pg=String.raw(bl||(bl=We(["(skewY)(",")"],["(skewY)\\(","\\)"])),Zt),Dg=String.raw(vl||(vl=We(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Zt,Zt,Zt),Ag=String.raw(yl||(yl=We(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Zt,Zt),Mg=String.raw(_l||(_l=We(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Zt,Zt),Ig=String.raw(xl||(xl=We(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Zt,Zt,Zt,Zt,Zt,Zt),Go="(?:".concat(Ig,"|").concat(Mg,"|").concat(Dg,"|").concat(Ag,"|").concat(Og,"|").concat(Pg,")"),Lg="(?:".concat(Go,"*)"),Fg=String.raw(wl||(wl=We(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Lg),jg=new RegExp(Fg),$g=new RegExp(Go),Rg=new RegExp(Go,"g");function go(n){const t=[];if(!(n=kg(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!jg.test(n))return[...Jt];for(const e of n.matchAll(Rg)){const i=$g.exec(e[0]);if(!i)continue;let s=Jt;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=tr(l,c);break;case Io:s=ps({angle:l},{x:c,y:h});break;case pn:s=jo(l,c);break;case ds:s=wc(l);break;case us:s=Cc(l);break;case"matrix":s=[l,c,h,d,u,p]}t.push(s)}return Fo(t)}function Bg(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,go(t)):go(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"?
|
|
1982
|
-
`)]}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=nt(s,Ug);return new this(y(y(y({},e),h),{},{left:r,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}v(re,"type","Rect"),v(re,"cacheProperties",[...ci,...Xc]),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",Yo="removed",Qr="imperative",qc=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:r,group:o}=t,a=o&&o!==n?mn(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?Pp(new w(i,i),void 0,n.calcTransformMatrix()):Lo,d=!e&&c?i:0,u=Ro(s+d,r+d,Fo([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class yn{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(yn,"type","strategy");class fo extends yn{shouldPerformLayout(t){return!0}}v(fo,"type","fit-content"),D.setClass(fo);const Wg=["strategy"],Gg=["target","strategy","bubbles","prevStrategy"],Kc="layoutManager";class Xs{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new fo;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,pc,Ns,gc,un,fc,Ur,gp,fp].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===Yo&&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=nt(t,Wg);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?Jt:ke(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=nt(t,Gg),{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:Kc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}D.setClass(Xs,Kc);const Yg=["type","objects","layoutManager"];class Xg extends Xs{performLayout(){}}class _i extends mc(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 Xs,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(Yo,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(ke(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(...ke(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=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",` >
|
|
1980
|
+
`)}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:$o(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)),Hp=[ne,Y,ce,xe,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",ds,us],ci=[Mt,ae,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Vp={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},Np=(n,t,e,i)=>-e*Math.cos(n/i*Qs)+e+t,Up=()=>!1;class Ho{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:o=Np,onStart:a=Lr,onChange:l=Lr,onComplete:c=Lr,abort:h=Up,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 Wp=["startValue","endValue"];class Gp extends Ho{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(y(y({},ot(t,Wp)),{},{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 Yp=["startValue","endValue"];class Xp extends Ho{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(y(y({},ot(t,Yp)),{},{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 qp=["startValue","endValue","easing","onChange","onComplete","abort"],Kp=(n,t,e,i)=>t+e*(1-Math.cos(n/i*Qs)),Vn=n=>n&&((t,e,i)=>n(new Z(t).toRgba(),e,i));class Zp extends Ho{constructor(t){let{startValue:e,endValue:i,easing:s=Kp,onChange:r,onComplete:o,abort:a}=t,l=ot(t,qp);const c=new Z(e).getSource(),h=new Z(i).getSource();super(y(y({},l),{},{startValue:c,byValue:h.map(((d,u)=>d-c[u])),easing:s,onChange:Vn(r),onComplete:Vn(o),abort:Vn(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 Hc(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new Xp(n):new Gp(n);return t.start(),t}function Jp(n){const t=new Zp(n);return t.start(),t}class pt{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=ho(e,i),o=ho(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 pt("Intersection").append(new w(t.x+b*a,t.y+b*l)):new pt}if(p===0||g===0){const b=r||o||pt.isPointContained(t,i,s)||pt.isPointContained(e,i,s)||pt.isPointContained(i,t,e)||pt.isPointContained(s,t,e);return new pt(b?"Coincident":void 0)}return new pt("Parallel")}static intersectSegmentLine(t,e,i,s){return pt.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return pt.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 pt,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=pt.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 pt.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new pt,s=t.length,r=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=pt.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 pt("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 pt.intersectPolygonPolygon(t,[s,o,r,a])}}class Qp extends bc{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,ke(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=>ie(a,o)))}return r}intersectsWithRect(t,e){return pt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=pt.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 pt.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(xe,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?ai(_c(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Jt.concat()}calcACoords(){const t=ps({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=tr(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=xp(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):Ro(o,a,gn(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(Tt(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,V,V,e,i);return this.angle?s.rotate(Tt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?ie(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,ne)}}const tg=["type"],eg=["extraParam"];let qe=class Rr extends Qp{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=oi(),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]=js.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!==xe||(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=we(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=ke(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)||Jt,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===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=we({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=Oc(this),i=this.group,s=this.shadow,r=Math.abs,o=t.enableRetinaScaling?uc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(_=>new er(_,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Op(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Dp(this,this.getViewportTransform()),this.setCoords();const c=oi(),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 vc(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return yc(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&&Ne().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?Jp(h):Hc(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:F,backgroundColor:j,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:K,skewY:Q}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const N=Yt=>et(Yt,i),kt=y(y({},gs(this,t)),{},{type:this.constructor.type,version:oo,originX:d,originY:u,left:N(c),top:N(h),width:N(p),height:N(g),fill:qa(r)?r.toObject():r,stroke:qa(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:F,backgroundColor:j,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:N(K),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 $o(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,tg),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,r=ot(i,eg);return fn(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",Hp),v(qe,"cacheProperties",ci),v(qe,"ownDefaults",Vp),v(qe,"type","FabricObject"),v(qe,"colorProperties",[Mt,ae,"backgroundColor"]),v(qe,"customProperties",[]),D.setClass(qe),D.setClass(qe,"object");const fs=(n,t,e)=>(i,s,r,o)=>{const a=t(i,s,r,o);return a&&Pc(n,y(y({},Ac(i,s,r,o)),e)),a};function ms(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 dl=fs(Ns,ms(((n,t,e,i)=>{const s=Bo(t,t.originX,t.originY,e,i);if(Pt(t.originX)===Pt(V)||Pt(t.originX)===Pt(St)&&s.x<0||Pt(t.originX)===Pt(Y)&&s.x>0){const{target:r}=t,o=r.strokeWidth/(r.strokeUniform?r.scaleX:1),a=Dc(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 ig(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 sg(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(Tt(u)),n["".concat(l,"Rect")](-h,-d,r,o),c&&n.strokeRect(-h,-d,r,o),n.restore()}class Se{constructor(t){v(this,"visible",!0),v(this,"actionName",pn),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)&&pt.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=Fo([tr(i,s),ps({angle:t}),jo((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"?ig.call(this,t,e,i,s,r):sg.call(this,t,e,i,s,r)}}const rg=(n,t,e)=>e.lockRotation?qr:t.cursorStyle,ng=fs(gc,ms(((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=ai(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 Vc(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Nc(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 og=["e","se","s","sw","w","nw","n","ne","e"],As=(n,t,e)=>{const i=Vc(n,e);if(Nc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return qr;const s=Mc(e,t);return"".concat(og[s],"-resize")};function Vo(n,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,o=s.by,a=Vc(n,r);let l,c,h,d,u,p;if(Nc(r,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Bo(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);Dc(t)&&(c*=2,h*=2),t.signX!==u&&o!=="y"&&(t.originX=Qa(t.originX),c*=-1,t.signX=u),t.signY!==p&&o!=="x"&&(t.originY=Qa(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(xe,h)):(!Pe(r,"lockScalingX")&&r.set(ce,c),!Pe(r,"lockScalingY")&&r.set(xe,h)),g!==r.scaleX||f!==r.scaleY}const cr=fs(un,ms(((n,t,e,i)=>Vo(n,t,e,i)))),ag=fs(un,ms(((n,t,e,i)=>Vo(n,t,e,i,{by:"x"})))),lg=fs(un,ms(((n,t,e,i)=>Vo(n,t,e,i,{by:"y"})))),cg=["target","ex","ey","skewingSide"],Nn={x:{counterAxis:"y",scale:ce,skew:ds,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:xe,skew:us,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},hg=["ns","nesw","ew","nwse"],dg=(n,t,e)=>{if(t.x!==0&&Pe(e,"lockSkewingY")||t.y!==0&&Pe(e,"lockSkewingX"))return qr;const i=Mc(e,t)%4;return"".concat(hg[i],"-resize")};function Uc(n,t,e,i,s){const{target:r}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Nn[n];if(Pe(r,l))return!1;const{origin:d,flip:u}=Nn[o],p=Pt(e[d])*(r[u]?-1:1),g=-Math.sign(p)*(r[h]?-1:1),f=.5*-((r[c]===0&&Bo(e,V,V,i,s)[n]>0||r[c]>0?1:-1)*g)+.5;return fs(fc,ms(((m,_,x,S)=>(function(T,O,k){let{target:E,ex:P,ey:R,skewingSide:F}=O,j=ot(O,cg);const{skew:H}=Nn[T],M=k.subtract(new w(P,R)).divide(new w(E.scaleX,E.scaleY))[T],U=E[H],K=j[H],Q=Math.tan(Tt(K)),N=T==="y"?E._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:E._getTransformedDimensions({scaleX:1,scaleY:1}).y,kt=2*M*F/Math.max(N,1)+Q,Yt=ai(Math.atan(kt));E.set(H,Yt);const Xt=U!==E[H];if(Xt&&T==="y"){const{skewX:Le,scaleX:me}=E,jt=E._getTransformedDimensions({skewY:U}),Fe=E._getTransformedDimensions(),he=Le!==0?jt.x/Fe.x:1;he!==1&&E.set(ce,he*me)}return Xt})(n,_,new w(x,S)))))(t,y(y({},e),{},{[a]:f,skewingSide:g}),i,s)}const ug=(n,t,e,i)=>Uc("x",n,t,e,i),pg=(n,t,e,i)=>Uc("y",n,t,e,i);function vn(n,t){return n[t.canvas.altActionKey]}const hr=(n,t,e)=>{const i=vn(n,e);return t.x===0?i?ds:xe:t.y===0?i?us:ce:""},Qi=(n,t,e)=>vn(n,e)?dg(0,t,e):As(n,t,e),ul=(n,t,e,i)=>vn(n,t.target)?pg(n,t,e,i):ag(n,t,e,i),pl=(n,t,e,i)=>vn(n,t.target)?ug(n,t,e,i):lg(n,t,e,i),Wc=()=>({ml:new Se({x:-.5,y:0,cursorStyleHandler:Qi,actionHandler:ul,getActionName:hr}),mr:new Se({x:.5,y:0,cursorStyleHandler:Qi,actionHandler:ul,getActionName:hr}),mb:new Se({x:0,y:.5,cursorStyleHandler:Qi,actionHandler:pl,getActionName:hr}),mt:new Se({x:0,y:-.5,cursorStyleHandler:Qi,actionHandler:pl,getActionName:hr}),tl:new Se({x:-.5,y:-.5,cursorStyleHandler:As,actionHandler:cr}),tr:new Se({x:.5,y:-.5,cursorStyleHandler:As,actionHandler:cr}),bl:new Se({x:-.5,y:.5,cursorStyleHandler:As,actionHandler:cr}),br:new Se({x:.5,y:.5,cursorStyleHandler:As,actionHandler:cr}),mtr:new Se({x:0,y:-.5,actionHandler:ng,cursorStyleHandler:rg,offsetY:-40,withConnection:!0,actionName:Io})}),gg=()=>({mr:new Se({x:.5,y:0,actionHandler:dl,cursorStyleHandler:Qi,actionName:Ns}),ml:new Se({x:-.5,y:0,actionHandler:dl,cursorStyleHandler:Qi,actionName:Ns})}),fg=()=>y(y({},Wc()),gg());class Ys extends qe{static getDefaults(){return y(y({},super.getDefaults()),Ys.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ys.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Wc()}}_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(pn))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=tr(e.x,e.y),s=ps({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(Tt(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(Tt(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=Ro(this.width,this.height,gn(e)),o=this.isStrokeAccountedForInDimensions()?Lo:(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 Gc(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(Ys,"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 Ut extends Ys{}Gc(Ut,[Ic]),D.setClass(Ut),D.setClass(Ut,"object");const mg=(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 Yc{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=ho(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(Tt(this.options.skewY)),e.x+=e.y*Math.tan(Tt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const bg=new w;class ns extends Yc{static getOrthogonalRotationFactor(t,e){const i=e?po(t,e):Bp(t);return Math.abs(i)<Qs?-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=po(this.AB,this.AC),this.bisector=zo(Bc(this.AB.eq(bg)?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=zc(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?uo(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return uo(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=>{ll(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(Tt(s)),Math.tan(Tt(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=>{ll(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=Bs(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 gl extends Yc{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(zc(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(zo(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 vg=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 gl(r,r,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new ns(r,l,c,t).project()):i.push(...new gl(r,o===0?c:l,t).project())})),i},No=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},yg=n=>n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">");let ks;const Uo=n=>{if(ks||ks||(ks="Intl"in dn()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),ks){const t=ks.segment(n);return Array.from(t).map((e=>{let{segment:i}=e;return i}))}return _g(n)},_g=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=xg(n,i))!==!1&&t.push(e);return t},xg=(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},Wo=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)},wg=(n,t)=>{const e=t.split(`
|
|
1981
|
+
`),i=[];let s=-1,r={};n=No(n);for(let o=0;o<e.length;o++){const a=Uo(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&&(Wo(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},Cg=(n,t)=>{if(!Array.isArray(n))return No(n);const e=t.split(Mo),i={};let s=-1,r=0;for(let o=0;o<e.length;o++){const a=Uo(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},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 fl(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 Sg(n,t){let e=!0;const i=fl(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=fl(s=s.parentElement,o);return r.length===0})(n,t)),i&&e&&t.length===0}const Tg=n=>{var t;return(t=$p[n])!==null&&t!==void 0?t:n},Eg=new RegExp("(".concat(Oe,")"),"gi"),kg=n=>Kr(n.replace(Eg," $1 ").replace(/,/gi," "));var ml,bl,vl,yl,_l,xl,wl;const Zt="(".concat(Oe,")"),Og=String.raw(ml||(ml=We(["(skewX)(",")"],["(skewX)\\(","\\)"])),Zt),Pg=String.raw(bl||(bl=We(["(skewY)(",")"],["(skewY)\\(","\\)"])),Zt),Dg=String.raw(vl||(vl=We(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Zt,Zt,Zt),Ag=String.raw(yl||(yl=We(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Zt,Zt),Mg=String.raw(_l||(_l=We(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Zt,Zt),Ig=String.raw(xl||(xl=We(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Zt,Zt,Zt,Zt,Zt,Zt),Go="(?:".concat(Ig,"|").concat(Mg,"|").concat(Dg,"|").concat(Ag,"|").concat(Og,"|").concat(Pg,")"),Lg="(?:".concat(Go,"*)"),Fg=String.raw(wl||(wl=We(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Lg),jg=new RegExp(Fg),$g=new RegExp(Go),Rg=new RegExp(Go,"g");function go(n){const t=[];if(!(n=kg(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!jg.test(n))return[...Jt];for(const e of n.matchAll(Rg)){const i=$g.exec(e[0]);if(!i)continue;let s=Jt;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=tr(l,c);break;case Io:s=ps({angle:l},{x:c,y:h});break;case pn:s=jo(l,c);break;case ds:s=wc(l);break;case us:s=Cc(l);break;case"matrix":s=[l,c,h,d,u,p]}t.push(s)}return Fo(t)}function Bg(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,go(t)):go(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"?St:V;else if(n==="charSpacing"||n===Hi)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 zg(n,t){const e=n.match(jp);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 Hg(n,t){n.replace(/;\s*$/,"").split(";").forEach((e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()}))}function Vg(n){const t={},e=n.getAttribute("style");return e&&(typeof e=="string"?Hg(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 Ng={stroke:"strokeOpacity",fill:"fillOpacity"};function hi(n,t,e){if(!n)return{};let i,s={},r=Ao;n.parentNode&&al.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)Sg(c,u.split(" "))&&(d=y(y({},d),h[u]));return d})(n,e)),Vg(n));o[Hn]&&n.setAttribute(Hn,o[Hn]),o[zn]&&(i=rs(o[zn],r),o[zn]="".concat(i));const a={};for(const c in o){const h=Tg(c),d=Bg(h,o[c],s,i);a[h]=d}a&&a.font&&zg(a.font,a);const l=y(y({},s),a);return al.test(n.nodeName)?l:(function(c){const h=Ut.getDefaults();return Object.entries(Ng).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 Z(c[u]);c[u]=g.setAlpha(et(g.getAlpha()*c[p],2)).toRgba()})),c})(l)}const Ug=["left","top","width","height","visible"],Xc=["rx","ry"];class re extends Ut{static getDefaults(){return y(y({},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([...Xc,...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,`" />
|
|
1982
|
+
`)]}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,Ug);return new this(y(y(y({},e),h),{},{left:r,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}v(re,"type","Rect"),v(re,"cacheProperties",[...ci,...Xc]),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",Yo="removed",Qr="imperative",qc=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:r,group:o}=t,a=o&&o!==n?mn(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?Pp(new w(i,i),void 0,n.calcTransformMatrix()):Lo,d=!e&&c?i:0,u=Ro(s+d,r+d,Fo([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class yn{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(yn,"type","strategy");class fo extends yn{shouldPerformLayout(t){return!0}}v(fo,"type","fit-content"),D.setClass(fo);const Wg=["strategy"],Gg=["target","strategy","bubbles","prevStrategy"],Kc="layoutManager";class Xs{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new fo;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,pc,Ns,gc,un,fc,Ur,gp,fp].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===Yo&&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,Wg);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?Jt:ke(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,Gg),{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:Kc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}D.setClass(Xs,Kc);const Yg=["type","objects","layoutManager"];class Xg extends Xs{performLayout(){}}class _i extends mc(Ut){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 Xs,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(Yo,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(ke(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=Ut.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(...ke(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=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",` >
|
|
1983
1983
|
`],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>
|
|
1984
|
-
`),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=nt(t,Yg);return Promise.all([Us(s,e),fn(o,e)]).then((a=>{let[l,c]=a;const h=new this(l,y(y(y({},o),c),{},{layoutManager:new Xg}));if(r){const d=D.getClass(r.type),u=D.getClass(r.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Xs;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 qg=(n,t)=>Math.min(t.width/n.width,t.height/n.height),Kg=(n,t)=>Math.max(t.width/n.width,t.height/n.height),mo="\\s*,?\\s*",Os="".concat(mo,"(").concat(Oe,")"),Zg="".concat(Os).concat(Os).concat(Os).concat(mo,"([01])").concat(mo,"([01])").concat(Os).concat(Os),Jg={m:"l",M:"L"},Qg=(n,t,e,i,s,r,o,a,l,c,h)=>{const d=ri(n),u=ni(n),p=ri(t),g=ni(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]},Cl=(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 Sl(n,t,e,i,s,r,o,a){let l;if(W.cachesBoundsOfCurve&&(l=[...arguments].join(),js.boundsOfCurveCache[l]))return js.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,_=Zc(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&&(js.boundsOfCurveCache[l]=x),x}const tf=(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=_*Do,E=ni(k),P=ri(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,Yt=-T*N*R/Q,Xt=P*kt-E*Yt+.5*u,Le=E*kt+P*Yt+.5*p;let me=Cl(1,0,(R-kt)/Q,(L-Yt)/N),jt=Cl((R-kt)/Q,(L-Yt)/N,(-R-kt)/Q,(-L-Yt)/N);m===0&&jt>0?jt-=2*O:m===1&&jt<0&&(jt+=2*O);const Fe=Math.ceil(Math.abs(jt/O*2)),he=[],At=jt/Fe,$t=8/3*Math.sin(At/4)*Math.sin(At/4)/Math.sin(At/2);let de=me+At;for(let _t=0;_t<Fe;_t++)he[_t]=Qg(me,de,P,E,Q,N,Xt,Le,$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},ef=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":tf(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),Zc=(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)},Jc=n=>n**2,Qc=n=>2*n*(1-n),th=n=>(1-n)**2,sf=(n,t,e,i,s,r,o,a)=>l=>{const c=Jc(l),h=Qc(l),d=th(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)},rf=(n,t,e,i,s,r)=>o=>{const a=Jc(o),l=Qc(o),c=th(o);return new w(s*a+e*l+n*c,r*a+i*l+t*c)},nf=(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)},Tl=(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},of=(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)})},eh=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=Zc(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=sf(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=Tl(t,s,r),s=c[5],r=c[6];break;case"Q":t=rf(s,r,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=nf(s,r,c[1],c[2],c[3],c[4]),e.length=Tl(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},af=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:eh(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 of(s,t)}},lf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),El=new RegExp(Zg,"g"),cf=new RegExp(Oe,"gi"),hf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},df=n=>{var t;const e=[],i=(t=n.match(lf))!==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=hf[r.toLowerCase()];let a=[];if(r==="a"||r==="A"){El.lastIndex=0;for(let l=null;l=El.exec(s);)a.push(...l.slice(1))}else a=s.match(cf)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=Jg[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},uf=(n,t)=>n.map((e=>e.map(((i,s)=>s===0||t===void 0?i:et(i,t))).join(" "))).join(" ");function bo(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 pf extends kc{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=oi();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=hs().createElement("div");return t.setAttribute("data-fabric","wrapper"),bo(t,{position:"relative"}),Za(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;bo(t,y(y({},i),{},{"touch-action":s?"manipulation":oe})),Za(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;Ec(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),lo(this.upper.el,t),lo(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(),Ne().dispose(this.upper.el),delete this.upper,delete this.container}}class _n extends er{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()),_n.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 pf(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 mg(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===pn||e===ce||e===xe||e===Ns?s=this.centeredScaling||t.centeredScaling:e===Io&&(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=ao:["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):Mp,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({},Oc(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,co(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=ri(h)*r,u=ni(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 pt.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=Tp(t),o=s.width||0,a=s.height||0;o&&a||(ne in s&&ao 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=oi(),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=gs(t,["angle","flipX","flipY",Y,ce,xe,ds,us,ne]);return kp(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(_n,"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 gf{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 ff=["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)},mf={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 vo extends _n{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new gf(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(Tc(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=Ee(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)}Ja(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",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&&Ja(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=Ee(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=Ee(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=Ee(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=Ee(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),co(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),co(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=nt(e,ff);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=mf[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=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 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 ih={x1:0,y1:0,x2:0,y2:0},bf=y(y({},ih),{},{r1:0,r2:0}),ts=(n,t)=>isNaN(n)&&typeof t=="number"?t:n;function sh(n){return n&&/%$/.test(n)&&Number.isFinite(parseFloat(n))}function rh(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(sh(n)?100:1):NaN;return ls(0,ts(e,t),1)}const vf=/\s*;\s*/,yf=/\s*:\s*/;function _f(n,t){let e,i;const s=n.getAttribute("style");if(s){const o=s.split(vf);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(yf).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:rh(n.getAttribute("offset"),0),color:r.toRgb(),opacity:ts(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function xf(n,t){const e=[],i=n.getElementsByTagName("stop"),s=rh(t,1);for(let r=i.length;r--;)e.push(_f(i[r],s));return e}function nh(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function oh(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Ce(n,t){return n.getAttribute(t)}function wf(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&&sh(d)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=r),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l}),{})})(nh(n)==="linear"?(function(e){return{x1:Ce(e,"x1")||0,y1:Ce(e,"y1")||0,x2:Ce(e,"x2")||"100%",y2:Ce(e,"y2")||0}})(n):(function(e){return{x1:Ce(e,"fx")||Ce(e,"cx")||"50%",y1:Ce(e,"fy")||Ce(e,"cy")||"50%",r1:0,x2:Ce(e,"cx")||"50%",y2:Ce(e,"cy")||"50%",r2:Ce(e,"r")||"50%"}})(n),y(y({},t),{},{gradientUnits:oh(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"?bf:ih),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({},gs(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():Jt.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(Ws(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,`">
|
|
1984
|
+
`),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,Yg);return Promise.all([Us(s,e),fn(o,e)]).then((a=>{let[l,c]=a;const h=new this(l,y(y(y({},o),c),{},{layoutManager:new Xg}));if(r){const d=D.getClass(r.type),u=D.getClass(r.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Xs;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 qg=(n,t)=>Math.min(t.width/n.width,t.height/n.height),Kg=(n,t)=>Math.max(t.width/n.width,t.height/n.height),mo="\\s*,?\\s*",Os="".concat(mo,"(").concat(Oe,")"),Zg="".concat(Os).concat(Os).concat(Os).concat(mo,"([01])").concat(mo,"([01])").concat(Os).concat(Os),Jg={m:"l",M:"L"},Qg=(n,t,e,i,s,r,o,a,l,c,h)=>{const d=ri(n),u=ni(n),p=ri(t),g=ni(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]},Cl=(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 Sl(n,t,e,i,s,r,o,a){let l;if(W.cachesBoundsOfCurve&&(l=[...arguments].join(),js.boundsOfCurveCache[l]))return js.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,_=Zc(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&&(js.boundsOfCurveCache[l]=x),x}const tf=(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=_*Do,E=ni(k),P=ri(k),R=.5*(-P*u-E*p),F=.5*(-P*p+E*u),j=g**2,H=f**2,M=F**2,U=R**2,K=j*H-j*M-H*U;let Q=Math.abs(g),N=Math.abs(f);if(K<0){const wt=Math.sqrt(1-K/(j*H));Q*=wt,N*=wt}else T=(b===m?-1:1)*Math.sqrt(K/(j*M+H*U));const kt=T*Q*F/N,Yt=-T*N*R/Q,Xt=P*kt-E*Yt+.5*u,Le=E*kt+P*Yt+.5*p;let me=Cl(1,0,(R-kt)/Q,(F-Yt)/N),jt=Cl((R-kt)/Q,(F-Yt)/N,(-R-kt)/Q,(-F-Yt)/N);m===0&&jt>0?jt-=2*O:m===1&&jt<0&&(jt+=2*O);const Fe=Math.ceil(Math.abs(jt/O*2)),he=[],At=jt/Fe,$t=8/3*Math.sin(At/4)*Math.sin(At/4)/Math.sin(At/2);let de=me+At;for(let wt=0;wt<Fe;wt++)he[wt]=Qg(me,de,P,E,Q,N,Xt,Le,$t,x,S),x=he[wt][5],S=he[wt][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},ef=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":tf(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),Zc=(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)},Jc=n=>n**2,Qc=n=>2*n*(1-n),th=n=>(1-n)**2,sf=(n,t,e,i,s,r,o,a)=>l=>{const c=Jc(l),h=Qc(l),d=th(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)},rf=(n,t,e,i,s,r)=>o=>{const a=Jc(o),l=Qc(o),c=th(o);return new w(s*a+e*l+n*c,r*a+i*l+t*c)},nf=(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)},Tl=(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},of=(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)})},eh=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=Zc(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=sf(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=Tl(t,s,r),s=c[5],r=c[6];break;case"Q":t=rf(s,r,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=nf(s,r,c[1],c[2],c[3],c[4]),e.length=Tl(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},af=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:eh(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 of(s,t)}},lf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),El=new RegExp(Zg,"g"),cf=new RegExp(Oe,"gi"),hf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},df=n=>{var t;const e=[],i=(t=n.match(lf))!==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=hf[r.toLowerCase()];let a=[];if(r==="a"||r==="A"){El.lastIndex=0;for(let l=null;l=El.exec(s);)a.push(...l.slice(1))}else a=s.match(cf)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=Jg[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},uf=(n,t)=>n.map((e=>e.map(((i,s)=>s===0||t===void 0?i:et(i,t))).join(" "))).join(" ");function bo(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 pf extends kc{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=oi();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=hs().createElement("div");return t.setAttribute("data-fabric","wrapper"),bo(t,{position:"relative"}),Za(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;bo(t,y(y({},i),{},{"touch-action":s?"manipulation":oe})),Za(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;Ec(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),lo(this.upper.el,t),lo(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(),Ne().dispose(this.upper.el),delete this.upper,delete this.container}}class _n extends er{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()),_n.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 pf(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 mg(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===pn||e===ce||e===xe||e===Ns?s=this.centeredScaling||t.centeredScaling:e===Io&&(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=St:["mr","tr","br"].includes(e)&&(i.x=Y),["tl","mt","tr"].includes(e)?i.y=ao:["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):Mp,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:Tt(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:y(y({},Oc(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,Ut.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,co(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=ri(h)*r,u=ni(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 pt.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=Tp(t),o=s.width||0,a=s.height||0;o&&a||(ne in s&&ao in s&&(a=Math.abs(s.top-s.bottom)),St 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=oi(),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=gs(t,["angle","flipX","flipY",Y,ce,xe,ds,us,ne]);return kp(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(_n,"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 gf{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 ff=["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)},mf={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 vo extends _n{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new gf(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(Tc(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=Ee(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)}Ja(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",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&&Ja(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=Ee(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=Ee(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=Ee(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=Ee(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),co(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),co(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,ff);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=mf[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=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 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 ih={x1:0,y1:0,x2:0,y2:0},bf=y(y({},ih),{},{r1:0,r2:0}),ts=(n,t)=>isNaN(n)&&typeof t=="number"?t:n;function sh(n){return n&&/%$/.test(n)&&Number.isFinite(parseFloat(n))}function rh(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(sh(n)?100:1):NaN;return ls(0,ts(e,t),1)}const vf=/\s*;\s*/,yf=/\s*:\s*/;function _f(n,t){let e,i;const s=n.getAttribute("style");if(s){const o=s.split(vf);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(yf).map((h=>h.trim()));l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const r=new Z(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:rh(n.getAttribute("offset"),0),color:r.toRgb(),opacity:ts(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function xf(n,t){const e=[],i=n.getElementsByTagName("stop"),s=rh(t,1);for(let r=i.length;r--;)e.push(_f(i[r],s));return e}function nh(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function oh(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Ce(n,t){return n.getAttribute(t)}function wf(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&&sh(d)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=r),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l}),{})})(nh(n)==="linear"?(function(e){return{x1:Ce(e,"x1")||0,y1:Ce(e,"y1")||0,x2:Ce(e,"x2")||"100%",y2:Ce(e,"y2")||0}})(n):(function(e){return{x1:Ce(e,"fx")||Ce(e,"cx")||"50%",y1:Ce(e,"fy")||Ce(e,"cy")||"50%",r1:0,x2:Ce(e,"cx")||"50%",y2:Ce(e,"cy")||"50%",r2:Ce(e,"r")||"50%"}})(n),y(y({},t),{},{gradientUnits:oh(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"?bf:ih),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 Z(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return y(y({},gs(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():Jt.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(Ws(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,`">
|
|
1985
1985
|
`)}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,`">
|
|
1986
1986
|
`),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:";",`"/>
|
|
1987
1987
|
`)})),i.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
|
|
1988
|
-
`),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
|
|
1989
|
-
`)}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,o=
|
|
1990
|
-
`)]}_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(...Sl(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(...Sl(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({},
|
|
1991
|
-
`];{const{radius:e}=this,i=
|
|
1992
|
-
`]}}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({},
|
|
1993
|
-
`)]}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],
|
|
1994
|
-
`)]}_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 Pf(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,...lh]),v(Ze,"ownDefaults",{rx:0,ry:0}),v(Ze,"ATTRIBUTE_NAMES",[...ki,"cx","cy","rx","ry"]),D.setClass(Ze),D.setSVGClass(Ze);const Df=["left","top"],ch={exactBoundingBox:!1};class Te extends
|
|
1995
|
-
`)]}_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(Pf(t.getAttribute("points")),y(y({},
|
|
1996
|
-
`)}const If=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Gn;class Kt extends hh{static getDefaults(){return y(y({},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=eh(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(Be)&&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===Be||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=ao}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=js.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 Gn||(Gn=we({width:0,height:0}).getContext("2d")),Gn})();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=af(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(Be),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=Wo(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=we({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===Be||s===Rs&&!o||s===$s&&!o||s===Zr&&!o?0:(s===V&&(a=i/2),s===wt&&(a=i),s===Rs&&(a=i/2),s===$s&&(a=i),r==="rtl"&&(s===wt||s===Be||s===$s?a=0:s===Y||s===Zr?a=-i:s!==V&&s!==Rs||(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,Hi),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,Hi);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(",")||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 Uo(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
|
|
1997
|
-
`];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([...$c,...t])),{},{styles:wg(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=y(y({},e),s),{textAnchor:o=Y,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:d=0,fontSize:u=Ao,strokeWidth:p=1}=r,g=
|
|
1988
|
+
`),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 Z(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=oh(t),r=e._findCenterFromElement();return new this(y({id:t.getAttribute("id")||void 0,type:nh(t),coords:wf(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:xf(t,i.opacity),gradientUnits:s,gradientTransform:go(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 Cf=["type","source","patternTransform"];class Un{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({},gs(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(`
|
|
1989
|
+
`)}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,o=ot(t,Cf);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(Un,"type","Pattern"),D.setClass(Un),D.setClass(Un,"pattern");const Sf=["path","left","top"],Tf=["d"];class Ii extends Ut{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:r}=e,o=ot(e,Sf);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=ef(Array.isArray(t)?t:df(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=uf(this.path,W.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
|
|
1990
|
+
`)]}_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(...Sl(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(...Sl(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,Tf)),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 Ef=["left","top","radius"],ah=["radius","startAngle","endAngle","counterClockwise"];class Ke extends Ut{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,Tt(this.startAngle),Tt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(ce)}getRadiusY(){return this.get("radius")*this.get(xe)}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([...ah,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
|
|
1991
|
+
`];{const{radius:e}=this,i=Tt(this.startAngle),s=Tt(this.endAngle),r=ri(i)*e,o=ni(i)*e,a=ri(s)*e,l=ni(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",` />
|
|
1992
|
+
`]}}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,Ef)),{},{radius:a,left:r-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}v(Ke,"type","Circle"),v(Ke,"cacheProperties",[...ci,...ah]),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 kf=["x1","y1","x2","y2"],Of=["x1","y1","x2","y2"],yo=["x1","x2","y1","y2"];class Li extends Ut{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 w(r+a/2,o+l/2);this.setPositionByOrigin(c,V,V)}_set(t,e){return super._set(t,e),yo.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,`" />
|
|
1993
|
+
`)]}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,kf))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,o=ot(t,Of);return this._fromObject(y(y({},o),{},{points:[e,i,s,r]}),{extraParam:"points"})}}v(Li,"type","Line"),v(Li,"cacheProperties",[...ci,...yo]),v(Li,"ATTRIBUTE_NAMES",ki.concat(yo)),D.setClass(Li),D.setSVGClass(Li);class $i extends Ut{static getDefaults(){return y(y({},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 lh=["rx","ry"];class Ze extends Ut{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(xe)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...lh,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
|
|
1994
|
+
`)]}_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 Pf(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,...lh]),v(Ze,"ownDefaults",{rx:0,ry:0}),v(Ze,"ATTRIBUTE_NAMES",[...ki,"cx","cy","rx","ry"]),D.setClass(Ze),D.setSVGClass(Ze);const Df=["left","top"],ch={exactBoundingBox:!1};class Te extends Ut{static getDefaults(){return y(y({},super.getDefaults()),Te.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,Te.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 vg(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=gn(y(y({},t),{},{scaleX:1,scaleY:1})),r=ei(this.points.map((c=>ie(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(Tt(this.skewX)),l-=a*Math.tan(Tt(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===xe)&&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(""),`" />
|
|
1995
|
+
`)]}_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(Pf(t.getAttribute("points")),y(y({},ot(hi(t,this.ATTRIBUTE_NAMES,i),Df)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(Te,"ownDefaults",ch),v(Te,"type","Polyline"),v(Te,"layoutProperties",[ds,us,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(Te,"cacheProperties",[...ci,"points"]),v(Te,"ATTRIBUTE_NAMES",[...ki]),D.setClass(Te),D.setSVGClass(Te);class ur extends Te{isOpen(){return!1}}v(ur,"ownDefaults",ch),v(ur,"type","Polygon"),D.setClass(ur),D.setSVGClass(ur);class hh extends Ut{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=$o(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({},gs(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(hh,"_styleProperties",Lp);const Af=/ +/g,Mf=/"/g;function Wn(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=Gs(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}),`
|
|
1996
|
+
`)}const If=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Gn;class Kt extends hh{static getDefaults(){return y(y({},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=eh(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(Be)&&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===Be||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=ao}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=js.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 Gn||(Gn=we({width:0,height:0}).getContext("2d")),Gn})();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===St,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 St: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=af(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===St?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(Be),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:St),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=Wo(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=we({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===Be||s===Rs&&!o||s===$s&&!o||s===Zr&&!o?0:(s===V&&(a=i/2),s===St&&(a=i),s===Rs&&(a=i/2),s===$s&&(a=i),r==="rtl"&&(s===St||s===Be||s===$s?a=0:s===Y||s===Zr?a=-i:s!==V&&s!==Rs||(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,Hi),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,Hi);const U=this.getHeightOfChar(c,j),K=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+K-a*Q,M.kernedWidth,Q),t.restore()}else if((S!==m||T!==_||U!==E||O!==x||K!==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=K}else b+=M.kernedWidth}let R=s+g+f;this.direction==="rtl"&&(R=this.width-R-b),t.fillStyle=T;const F=this.fontSize*O/1e3;S&&T&&O&&t.fillRect(R,k+l*E+P-a*F,b-o,F),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 Uo(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
|
|
1997
|
+
`];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([...$c,...t])),{},{styles:wg(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=y(y({},e),s),{textAnchor:o=Y,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:d=0,fontSize:u=Ao,strokeWidth:p=1}=r,g=ot(r,If),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===St&&(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:Cg(t.styles||{},t.text)}),{extraParam:"text"})}}v(Kt,"textLayoutProperties",jc),v(Kt,"cacheProperties",[...ci,...$c]),v(Kt,"ownDefaults",Fp),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")),Gc(Kt,[class extends Ic{_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:Ws(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(Mf,"'"),'" '),'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>
|
|
1998
1998
|
`]}_getSVGTextAndBg(n,t){const e=[],i=[];let s,r=n;this.backgroundColor&&i.push(...Wn(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(Af)),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(ai(h),r),'"'));const b=ps({angle:ai(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(yg(n),"</tspan>")}_setSVGTextLineText(n,t,e,i){const s=this.getHeightOfLine(t),r=this.textAlign.includes(Be),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=Wo(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(...Wn(c,e+l,i,a,r)),l=d,a=u,c=o):a+=p}o&&n.push(...Wn(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?Gs(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?Gs(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 Lf{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,_=No(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,bo(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()},Ee(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)||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 kl=/[ \n\.,;!\?\-]/;class Ff 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 Hc({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||!Mo.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!kl.test(r);)s+=e,r=i[s];return e===-1&&kl.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;Ee(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]===`
|
|
1999
|
-
`?(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 jf extends Ff{initHiddenTextarea(){const t=this.canvas&&Ee(this.canvas.getElement())||hs(),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}=Ne();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}=Ne();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 Ol=n=>!!n.button;class $f extends jf{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 Lf(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&&!Ol(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||Ol(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(ke(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",Pl=(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])},Rf=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 $f{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 vo&&this.canvas.textEditingManager.remove(this),e instanceof vo&&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=we(t.canvas),o=r.getContext("2d"),Pl(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=we(t.canvas),h=c.getContext("2d");if(Pl(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===Be||this.textAlign===$s?l.left*=-1:this.textAlign===Y||this.textAlign===Zr?l.left=o-(i>0?i:0):this.textAlign!==V&&this.textAlign!==Rs||(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(Be),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===Be||this.textAlign===$s?x=this.width-x-O:this.textAlign===Y||this.textAlign===Zr?x=i.left+g-_:this.textAlign!==V&&this.textAlign!==Rs||(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",Rf),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:fg()}}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(Be)&&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]===`
|
|
2000
|
-
`&&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 Dl extends yn{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(Dl,"type","clip-path"),D.setClass(Dl);class Al extends yn{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new w(i.width||s.x,i.height||s.y)}}v(Al,"type","fixed"),D.setClass(Al);class Bf extends Xs{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 y(y({},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 Bf})}_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===Yo?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(Ri,"type","ActiveSelection"),v(Ri,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),D.setClass(Ri),D.setClass(Ri,"activeSelection");class zf{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 dh{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=we({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 Yn;function Hf(){const{WebGLProbe:n}=Ne();return n.queryWebGL(oi()),W.enableGLFiltering&&n.isSupported(W.textureSize)?new dh({tileSize:W.textureSize}):new zf}function Xn(){return!Yn&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Yn=Hf()),Yn}const Vf=["filters","resizeFilter","src","crossOrigin","type"],uh=["cropX","cropY"];class se extends Nt{static getDefaults(){return y(y({},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(Ci()),this.setElement(typeof t=="string"?(this.canvas&&Ee(this.canvas.getElement())||hs()).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=Xn(!1);e instanceof dh&&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&&Ne().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([...uh,...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+`">
|
|
1999
|
+
`?(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===St&&(this._selectionDirection=Y,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===St?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=St:this._selectionDirection===Y&&(this._selectionDirection=St,this.selectionStart=e),this.selectionEnd=i)}}class jf extends Ff{initHiddenTextarea(){const t=this.canvas&&Ee(this.canvas.getElement())||hs(),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}=Ne();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}=Ne();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===St);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===St&&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=St,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=St,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Ol=n=>!!n.button;class $f extends jf{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 Lf(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&&!Ol(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||Ol(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(ke(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",Pl=(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])},Rf=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 $f{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 vo&&this.canvas.textEditingManager.remove(this),e instanceof vo&&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=we(t.canvas),o=r.getContext("2d"),Pl(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=we(t.canvas),h=c.getContext("2d");if(Pl(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===St||this.textAlign===Be||this.textAlign===$s?l.left*=-1:this.textAlign===Y||this.textAlign===Zr?l.left=o-(i>0?i:0):this.textAlign!==V&&this.textAlign!==Rs||(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(Be),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===St||this.textAlign===Be||this.textAlign===$s?x=this.width-x-O:this.textAlign===Y||this.textAlign===Zr?x=i.left+g-_:this.textAlign!==V&&this.textAlign!==Rs||(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",Rf),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:fg()}}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(Be)&&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]===`
|
|
2000
|
+
`&&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 Dl extends yn{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(Dl,"type","clip-path"),D.setClass(Dl);class Al extends yn{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new w(i.width||s.x,i.height||s.y)}}v(Al,"type","fixed"),D.setClass(Al);class Bf extends Xs{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 y(y({},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 Bf})}_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===Yo?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(Ri,"type","ActiveSelection"),v(Ri,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),D.setClass(Ri),D.setClass(Ri,"activeSelection");class zf{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 dh{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=we({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 Yn;function Hf(){const{WebGLProbe:n}=Ne();return n.queryWebGL(oi()),W.enableGLFiltering&&n.isSupported(W.textureSize)?new dh({tileSize:W.textureSize}):new zf}function Xn(){return!Yn&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Yn=Hf()),Yn}const Vf=["filters","resizeFilter","src","crossOrigin","type"],uh=["cropX","cropY"];class se extends Ut{static getDefaults(){return y(y({},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(Ci()),this.setElement(typeof t=="string"?(this.canvas&&Ee(this.canvas.getElement())||hs()).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=Xn(!1);e instanceof dh&&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&&Ne().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([...uh,...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+`">
|
|
2001
2001
|
`,' <rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
|
|
2002
2002
|
`,`</clipPath>
|
|
2003
2003
|
`),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>
|
|
2004
2004
|
`)),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(),`" />
|
|
2005
|
-
`)],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=we(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,Xn().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=we({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);Xn().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=Ip(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=qg(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=Kg(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=
|
|
2005
|
+
`)],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=we(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,Xn().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=we({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);Xn().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=Ip(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=qg(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=Kg(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,Vf);return Promise.all([$r(r,y(y({},e),{},{crossOrigin:o})),i&&Us(i,e),s&&Us([s],e),fn(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(se,"type","Image"),v(se,"cacheProperties",[...ci,...uh]),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);bn(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const xn=n=>n.webgl!==void 0,Xo="precision highp float",Nf=`
|
|
2006
2006
|
`.concat(Xo,`;
|
|
2007
2007
|
varying vec2 vTexCoord;
|
|
2008
2008
|
uniform sampler2D uTexture;
|
|
2009
2009
|
void main() {
|
|
2010
2010
|
gl_FragColor = texture2D(uTexture, vTexCoord);
|
|
2011
|
-
}`),Uf=["type"],Wf=["type"],Gf=new RegExp(Xo,"g");class It{get type(){return this.constructor.type}constructor(){let t=
|
|
2011
|
+
}`),Uf=["type"],Wf=["type"],Gf=new RegExp(Xo,"g");class It{get type(){return this.constructor.type}constructor(){let t=ot(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Uf);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Nf}getVertexSource(){return`
|
|
2012
2012
|
attribute vec2 aPosition;
|
|
2013
2013
|
varying vec2 vTexCoord;
|
|
2014
2014
|
void main() {
|
|
2015
2015
|
vTexCoord = aPosition;
|
|
2016
2016
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
2017
|
-
}`}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"}}=Ne();s!=="highp"&&(e=e.replace(Gf,Xo.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 He("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new He("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 He("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 He('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){xn(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=we({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(
|
|
2017
|
+
}`}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"}}=Ne();s!=="highp"&&(e=e.replace(Gf,Xo.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 He("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new He("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 He("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 He('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){xn(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=we({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,Wf))}}v(It,"type","BaseFilter"),v(It,"uniformLocations",[]);const Yf={multiply:`gl_FragColor.rgb *= uColor.rgb;
|
|
2018
2018
|
`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
|
|
2019
2019
|
`,add:`gl_FragColor.rgb += uColor.rgb;
|
|
2020
2020
|
`,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
|
|
@@ -2053,7 +2053,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2053
2053
|
`.concat(Yf[this.mode],`
|
|
2054
2054
|
}
|
|
2055
2055
|
}
|
|
2056
|
-
`)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new
|
|
2056
|
+
`)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new Z(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 Z(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 Xf={multiply:`
|
|
2057
2057
|
precision highp float;
|
|
2058
2058
|
uniform sampler2D uTexture;
|
|
2059
2059
|
uniform sampler2D uImage;
|
|
@@ -2089,7 +2089,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2089
2089
|
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
|
2090
2090
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
2091
2091
|
}
|
|
2092
|
-
`}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=oi());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=
|
|
2092
|
+
`}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=oi());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,qf);return se.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`
|
|
2093
2093
|
precision highp float;
|
|
2094
2094
|
uniform sampler2D uTexture;
|
|
2095
2095
|
uniform vec2 uDelta;
|
|
@@ -2399,7 +2399,7 @@ void main() {
|
|
|
2399
2399
|
gl_FragColor.a = 0.0;
|
|
2400
2400
|
}
|
|
2401
2401
|
}
|
|
2402
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new
|
|
2402
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new Z(this.color).getSource(),r=[s[0]-i,s[1]-i,s[2]-i],o=[s[0]+i,s[1]+i,s[2]+i];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>r[0]&&c>r[1]&&h>r[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const i=new Z(this.color).getSource(),s=this.distance,r=[0+i[0]/255-s,0+i[1]/255-s,0+i[2]/255-s,1],o=[i[0]/255+s,i[1]/255+s,i[2]/255+s,1];t.uniform4fv(e.uLow,r),t.uniform4fv(e.uHigh,o)}}v(Pr,"type","RemoveColor"),v(Pr,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),v(Pr,"uniformLocations",["uLow","uHigh"]),D.setClass(Pr);class Dr extends It{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),s=new Array(i);for(let r=1;r<=i;r++)s[r-1]=t(r*e);return s}generateShader(t){const e=new Array(t);for(let i=1;i<=t;i++)e[i-1]="".concat(i,".0 * uDelta");return`
|
|
2403
2403
|
precision highp float;
|
|
2404
2404
|
uniform sampler2D uTexture;
|
|
2405
2405
|
uniform vec2 uDelta;
|
|
@@ -2415,7 +2415,7 @@ void main() {
|
|
|
2415
2415
|
`),`
|
|
2416
2416
|
gl_FragColor = color / sum;
|
|
2417
2417
|
}
|
|
2418
|
-
`)}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){xn(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=oi());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,
|
|
2418
|
+
`)}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){xn(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=oi());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,F,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,F=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 K=_.y-f;K<=_.y+f;K++)K<0||K>=i||(U=Math.floor(1e3*Math.abs(K-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*(K*e+O),P+=k,R+=k*o[E],F+=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]=F/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,F=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(F+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`
|
|
2419
2419
|
precision highp float;
|
|
2420
2420
|
uniform sampler2D uTexture;
|
|
2421
2421
|
uniform float uSaturation;
|
|
@@ -2444,7 +2444,7 @@ void main() {
|
|
|
2444
2444
|
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
2445
2445
|
gl_FragColor = color;
|
|
2446
2446
|
}
|
|
2447
|
-
`}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 Qf=Object.defineProperty,tm=Object.getOwnPropertyDescriptor,Dt=(n,t,e,i)=>{for(var s=i>1?void 0:i?tm(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&&Qf(t,e,s),s};let ct=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 vo(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 se.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 se.fromURL(this.handwrittenImageUrl),this.configureHandwrittenImage(),this.setupHandwrittenImageEvents(),this.canvas.add(this.handwrittenImage)}configureHandwrittenImage(){if(!this.handwrittenImage)return;const t=this.calculateImageScale(),e=this.createClipRect(),i=this.handwrittenImage.width*t,s=this.handwrittenImage.height*t,r=this.areaPosition.left+(this.areaSize.width-i)/2,o=this.areaPosition.top+(this.areaSize.height-s)/2;this.handwrittenImage.set({...this.HANDWRITTEN_IMAGE_STYLES,selectable:!0,lockRotation:!0,lockScalingFlip:!0,noScaleCache:!1,cornerSize:this.calculateCornerSize(),touchCornerSize:this.calculateTouchCornerSize(),left:r,top:o,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 re({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0})}updateHandwrittenImageDimensions(t){if(!this.handwrittenImage)return;const e=this.handwrittenImage.width*t,i=this.handwrittenImage.height*t;this.setHandwrittenImageDimensions({left:this.areaPosition.left+(this.areaSize.width-e)/2,top:this.areaPosition.top+(this.areaSize.height-i)/2,width:e,height:i})}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 re({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),s=this.handwrittenImage.width*i,r=this.handwrittenImage.height*i,o=this.areaPosition.left+(this.areaSize.width-s)/2,a=this.areaPosition.top+(this.areaSize.height-r)/2;this.handwrittenImage.set({left:o,top:a,scaleX:i,scaleY:i});const l=new re({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:l}),this.setHandwrittenImageDimensions({top:a,left:o,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 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 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())}};ct.styles=[bt,cp];Dt([C({attribute:"background-url"})],ct.prototype,"backgroundImageUrl",2);Dt([C({attribute:"handwritten-url"})],ct.prototype,"handwrittenImageUrl",2);Dt([C({type:Number,reflect:!0,attribute:"height"})],ct.prototype,"imageHeight",2);Dt([C({type:Number,reflect:!0,attribute:"width"})],ct.prototype,"imageWidth",2);Dt([C({type:Number,reflect:!0,attribute:"left"})],ct.prototype,"imageLeft",2);Dt([C({type:Number,reflect:!0,attribute:"top"})],ct.prototype,"imageTop",2);Dt([C({attribute:"display-type"})],ct.prototype,"displayType",2);Dt([B(".base-canvas")],ct.prototype,"baseCanvas",2);Dt([I()],ct.prototype,"canvas",2);Dt([I()],ct.prototype,"backgroundFabImg",2);Dt([I()],ct.prototype,"rect",2);Dt([I()],ct.prototype,"areaPosition",2);Dt([I()],ct.prototype,"uploadingText",2);Dt([I()],ct.prototype,"handwrittenImage",2);Dt([I()],ct.prototype,"clipMaskOverlay",2);Dt([I()],ct.prototype,"areaSize",2);Dt([G("backgroundImageUrl")],ct.prototype,"handleBackgroundImageUrlChange",1);Dt([G(["handwrittenImageUrl","displayType"])],ct.prototype,"handleHandwrittenImageUrlChange",1);Dt([G(["imageLeft","imageTop","imageWidth","imageHeight"])],ct.prototype,"handleHandwrittenImageDimensionsChange",1);ct=Dt([mt("pbo-handwritten-canvas")],ct);const em=st`
|
|
2447
|
+
`}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 Qf=Object.defineProperty,tm=Object.getOwnPropertyDescriptor,Dt=(n,t,e,i)=>{for(var s=i>1?void 0:i?tm(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&&Qf(t,e,s),s};let ht=class extends yt{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 L`<canvas class="base-canvas"></canvas>`}initializeCanvas(){this.canvas=new vo(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 se.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 se.fromURL(this.handwrittenImageUrl),this.configureHandwrittenImage(),this.setupHandwrittenImageEvents(),this.canvas.add(this.handwrittenImage)}configureHandwrittenImage(){if(!this.handwrittenImage)return;const t=this.calculateImageScale(),e=this.createClipRect(),i=this.handwrittenImage.width*t,s=this.handwrittenImage.height*t,r=this.areaPosition.left+(this.areaSize.width-i)/2,o=this.areaPosition.top+(this.areaSize.height-s)/2;this.handwrittenImage.set({...this.HANDWRITTEN_IMAGE_STYLES,selectable:!0,lockRotation:!0,lockScalingFlip:!0,noScaleCache:!1,cornerSize:this.calculateCornerSize(),touchCornerSize:this.calculateTouchCornerSize(),left:r,top:o,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 re({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0})}updateHandwrittenImageDimensions(t){if(!this.handwrittenImage)return;const e=this.handwrittenImage.width*t,i=this.handwrittenImage.height*t;this.setHandwrittenImageDimensions({left:this.areaPosition.left+(this.areaSize.width-e)/2,top:this.areaPosition.top+(this.areaSize.height-i)/2,width:e,height:i})}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 re({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),s=this.handwrittenImage.width*i,r=this.handwrittenImage.height*i,o=this.areaPosition.left+(this.areaSize.width-s)/2,a=this.areaPosition.top+(this.areaSize.height-r)/2;this.handwrittenImage.set({left:o,top:a,scaleX:i,scaleY:i});const l=new re({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:l}),this.setHandwrittenImageDimensions({top:a,left:o,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 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 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())}};ht.styles=[vt,cp];Dt([C({attribute:"background-url"})],ht.prototype,"backgroundImageUrl",2);Dt([C({attribute:"handwritten-url"})],ht.prototype,"handwrittenImageUrl",2);Dt([C({type:Number,reflect:!0,attribute:"height"})],ht.prototype,"imageHeight",2);Dt([C({type:Number,reflect:!0,attribute:"width"})],ht.prototype,"imageWidth",2);Dt([C({type:Number,reflect:!0,attribute:"left"})],ht.prototype,"imageLeft",2);Dt([C({type:Number,reflect:!0,attribute:"top"})],ht.prototype,"imageTop",2);Dt([C({attribute:"display-type"})],ht.prototype,"displayType",2);Dt([B(".base-canvas")],ht.prototype,"baseCanvas",2);Dt([I()],ht.prototype,"canvas",2);Dt([I()],ht.prototype,"backgroundFabImg",2);Dt([I()],ht.prototype,"rect",2);Dt([I()],ht.prototype,"areaPosition",2);Dt([I()],ht.prototype,"uploadingText",2);Dt([I()],ht.prototype,"handwrittenImage",2);Dt([I()],ht.prototype,"clipMaskOverlay",2);Dt([I()],ht.prototype,"areaSize",2);Dt([G("backgroundImageUrl")],ht.prototype,"handleBackgroundImageUrlChange",1);Dt([G(["handwrittenImageUrl","displayType"])],ht.prototype,"handleHandwrittenImageUrlChange",1);Dt([G(["imageLeft","imageTop","imageWidth","imageHeight"])],ht.prototype,"handleHandwrittenImageDimensionsChange",1);ht=Dt([mt("pbo-handwritten-canvas")],ht);const em=rt`
|
|
2448
2448
|
:host {
|
|
2449
2449
|
display: block;
|
|
2450
2450
|
width: 100%;
|
|
@@ -2502,9 +2502,9 @@ void main() {
|
|
|
2502
2502
|
.type-canvas-container.image-loading pbo-image {
|
|
2503
2503
|
display: block;
|
|
2504
2504
|
}
|
|
2505
|
-
`;var im=Object.defineProperty,sm=Object.getOwnPropertyDescriptor,
|
|
2505
|
+
`;var im=Object.defineProperty,sm=Object.getOwnPropertyDescriptor,_t=(n,t,e,i)=>{for(var s=i>1?void 0:i?sm(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&&im(t,e,s),s};const Kn=[{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}}],Ps={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 it=class extends yt{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=Kn.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=Kn.find(o=>o.family===this.font)||Kn[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(`
|
|
2506
2506
|
`);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(`
|
|
2507
|
-
`);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/Ps.width,this.areaPosition={left:this.inchToPixel(Ps.displayArea[this.displayType].x,this.dpi),top:this.inchToPixel(Ps.displayArea[this.displayType].y,this.dpi)},this.areaSize={width:this.inchToPixel(Ps.displayArea[this.displayType].width,this.dpi),height:this.inchToPixel(Ps.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
|
|
2507
|
+
`);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/Ps.width,this.areaPosition={left:this.inchToPixel(Ps.displayArea[this.displayType].x,this.dpi),top:this.inchToPixel(Ps.displayArea[this.displayType].y,this.dpi)},this.areaSize={width:this.inchToPixel(Ps.displayArea[this.displayType].width,this.dpi),height:this.inchToPixel(Ps.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 L`
|
|
2508
2508
|
<div
|
|
2509
2509
|
class="${fe({"type-canvas-container":!0,"image-loading":this.imgLoading})}
|
|
2510
2510
|
"
|
|
@@ -2512,7 +2512,7 @@ void main() {
|
|
|
2512
2512
|
<canvas class="base-canvas"></canvas>
|
|
2513
2513
|
<pbo-image skeleton></pbo-image>
|
|
2514
2514
|
</div>
|
|
2515
|
-
`}};it.styles=[
|
|
2515
|
+
`}};it.styles=[vt,em];_t([C({attribute:"background-url"})],it.prototype,"backgroundImageUrl",2);_t([C()],it.prototype,"message",2);_t([C()],it.prototype,"font",2);_t([C()],it.prototype,"color",2);_t([C()],it.prototype,"alignment",2);_t([C({attribute:"display-type"})],it.prototype,"displayType",2);_t([B(".base-canvas")],it.prototype,"canvas",2);_t([B(".type-canvas-container")],it.prototype,"canvasContainer",2);_t([I()],it.prototype,"scale",2);_t([I()],it.prototype,"logicalSize",2);_t([I()],it.prototype,"areaPosition",2);_t([I()],it.prototype,"areaSize",2);_t([I()],it.prototype,"imgLoading",2);_t([I()],it.prototype,"backgroundImage",2);_t([I()],it.prototype,"resizeObserver",2);_t([I()],it.prototype,"dpi",2);_t([I()],it.prototype,"fontConfig",2);_t([I()],it.prototype,"processedMessage",2);_t([G("backgroundImageUrl")],it.prototype,"handleBackgroundImageUrlChange",1);_t([G("backgroundImage")],it.prototype,"handleBackgroundImageChange",1);_t([G("processedMessage")],it.prototype,"handleProcessedMessageChange",1);it=_t([mt("pbo-type-canvas")],it);const rm=rt`
|
|
2516
2516
|
:host {
|
|
2517
2517
|
display: block;
|
|
2518
2518
|
height: 100%;
|
|
@@ -2566,7 +2566,7 @@ void main() {
|
|
|
2566
2566
|
outline-offset: 2px;
|
|
2567
2567
|
border-radius: 50%;
|
|
2568
2568
|
}
|
|
2569
|
-
`;var nm=Object.defineProperty,om=Object.getOwnPropertyDescriptor,Gi=(n,t,e,i)=>{for(var s=i>1?void 0:i?om(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&&nm(t,e,s),s};let Ae=class extends
|
|
2569
|
+
`;var nm=Object.defineProperty,om=Object.getOwnPropertyDescriptor,Gi=(n,t,e,i)=>{for(var s=i>1?void 0:i?om(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&&nm(t,e,s),s};let Ae=class extends yt{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 L`
|
|
2570
2570
|
<div class="panel" @touchmove=${this.handleTouchMove} @touchend=${this.handleTouchEnd}>
|
|
2571
2571
|
<div class="zoomed-preview">
|
|
2572
2572
|
<div
|
|
@@ -2592,7 +2592,7 @@ void main() {
|
|
|
2592
2592
|
</svg>
|
|
2593
2593
|
</button>
|
|
2594
2594
|
</div>
|
|
2595
|
-
`}};Ae.styles=[
|
|
2595
|
+
`}};Ae.styles=[vt,rm];Gi([C()],Ae.prototype,"formData",2);Gi([C()],Ae.prototype,"cardUrl",2);Gi([C()],Ae.prototype,"close",2);Gi([C()],Ae.prototype,"handwrittenPreviewProps",2);Gi([C({type:Boolean,reflect:!0,attribute:"pinch-to-close-disabled"})],Ae.prototype,"pinchToCloseDisabled",2);Gi([I()],Ae.prototype,"distance",2);Ae=Gi([mt("pbo-zoomed-preview")],Ae);const am=rt`
|
|
2596
2596
|
:host,
|
|
2597
2597
|
:host * {
|
|
2598
2598
|
max-height: 100%;
|
|
@@ -2640,15 +2640,15 @@ void main() {
|
|
|
2640
2640
|
background-color: #f3f3f3;
|
|
2641
2641
|
}
|
|
2642
2642
|
}
|
|
2643
|
-
`;var lm=Object.defineProperty,cm=Object.getOwnPropertyDescriptor,Ge=(n,t,e,i)=>{for(var s=i>1?void 0:i?cm(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&&lm(t,e,s),s};let Qt=class extends
|
|
2644
|
-
${this.loaded?"":
|
|
2643
|
+
`;var lm=Object.defineProperty,cm=Object.getOwnPropertyDescriptor,Ge=(n,t,e,i)=>{for(var s=i>1?void 0:i?cm(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&&lm(t,e,s),s};let Qt=class extends yt{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?L`<div class="skeleton"></div>`:L`
|
|
2644
|
+
${this.loaded?"":L` <div class="skeleton"></div>`}
|
|
2645
2645
|
<img
|
|
2646
2646
|
src=${this.src}
|
|
2647
2647
|
alt=${this.alt}
|
|
2648
2648
|
class=${fe({loaded:this.loaded,hidden:!this.loaded})}
|
|
2649
2649
|
@error=${()=>this.handleError()}
|
|
2650
2650
|
/>
|
|
2651
|
-
`}};Qt.styles=[
|
|
2651
|
+
`}};Qt.styles=[vt,am];Ge([C()],Qt.prototype,"skeletonHeight",2);Ge([C()],Qt.prototype,"skeletonWidth",2);Ge([C()],Qt.prototype,"src",2);Ge([C()],Qt.prototype,"alt",2);Ge([C()],Qt.prototype,"placeholder",2);Ge([C({type:Boolean})],Qt.prototype,"skeleton",2);Ge([I()],Qt.prototype,"loaded",2);Ge([B("img")],Qt.prototype,"imgEl",2);Ge([G("src")],Qt.prototype,"handleSrcChange",1);Qt=Ge([mt("pbo-image")],Qt);var hm=Object.defineProperty,dm=Object.getOwnPropertyDescriptor,Ft=(n,t,e,i)=>{for(var s=i>1?void 0:i?dm(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&&hm(t,e,s),s};let dt=class extends yt{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=[L`<pbo-image src="${e.medias.cover.url}" alt="" />`,L`<pbo-type-canvas
|
|
2652
2652
|
background-url=${e.medias.insert.url}
|
|
2653
2653
|
message=${(i=this.livePreviewProps)==null?void 0:i.text}
|
|
2654
2654
|
alignment=${((s=this.livePreviewProps)==null?void 0:s.alignment)||"left"}
|
|
@@ -2656,7 +2656,7 @@ void main() {
|
|
|
2656
2656
|
font=${(o=this.livePreviewProps)==null?void 0:o.font}
|
|
2657
2657
|
display-type=${e.hasEditorial?"default":"fullSize"}
|
|
2658
2658
|
@click="${this.handleOpenZoomedClick}"
|
|
2659
|
-
></pbo-type-canvas>`,
|
|
2659
|
+
></pbo-type-canvas>`,L`<pbo-image src="${e.medias.rendered_2.url}" alt="" />`])}handleFocusIndexChange(t,e){var i,s,r,o;this.thumbnailElements.length!==0&&t!==e&&((i=this.thumbnailElements[t])==null||i.classList.remove("active"),(s=this.thumbnailElements[e])==null||s.classList.add("active"),(r=this.mainSlideElements[t])==null||r.classList.remove("active"),(o=this.mainSlideElements[e])==null||o.classList.add("active"),this.requestUpdate())}handleAllowPinchToToggle(){this.allowPinchToToggle=this.type!=="handwritten"||this.focusIndex!==1||!0}focusOn(t){if(t<0||t>=this.thumbnailElements.length){console.warn("Invalid index:",t);return}this.focusIndex=t}get mainSlides(){return this.card?[L`<pbo-image src="${this.card.medias.cover.url}" alt="" />`,L`<pbo-type-canvas
|
|
2660
2660
|
background-url=${this.card.medias.insert.url}
|
|
2661
2661
|
message=${this.livePreviewProps.text}
|
|
2662
2662
|
alignment=${this.livePreviewProps.alignment}
|
|
@@ -2664,7 +2664,7 @@ void main() {
|
|
|
2664
2664
|
font=${this.livePreviewProps.font}
|
|
2665
2665
|
display-type=${this.card.hasEditorial?"default":"fullSize"}
|
|
2666
2666
|
@click="${this.handleOpenZoomedClick}"
|
|
2667
|
-
></pbo-type-canvas>`,
|
|
2667
|
+
></pbo-type-canvas>`,L`<img src="${this.card.medias.rendered_2.url}" alt="" />`][this.focusIndex]:[]}zoomIcon(){return L`<svg
|
|
2668
2668
|
aria-hidden="true"
|
|
2669
2669
|
stroke="currentColor"
|
|
2670
2670
|
fill="none"
|
|
@@ -2681,7 +2681,7 @@ void main() {
|
|
|
2681
2681
|
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
2682
2682
|
<line x1="11" y1="8" x2="11" y2="14"></line>
|
|
2683
2683
|
<line x1="8" y1="11" x2="14" y2="11"></line>
|
|
2684
|
-
</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
|
|
2684
|
+
</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 L`
|
|
2685
2685
|
<div class="card--slider--wrapper">
|
|
2686
2686
|
<div id="thumbnails" class="thumbnails">
|
|
2687
2687
|
<button
|
|
@@ -2728,17 +2728,17 @@ void main() {
|
|
|
2728
2728
|
>
|
|
2729
2729
|
<div class="main-slide" @click="${this.handleOpenZoomedClick}">
|
|
2730
2730
|
<pbo-image src="${(s=this.card)==null?void 0:s.medias.cover.url}" alt=""></pbo-image>
|
|
2731
|
-
${bi()?
|
|
2731
|
+
${bi()?L`<button
|
|
2732
2732
|
class="zoomed-preview-open-button"
|
|
2733
2733
|
type="button"
|
|
2734
2734
|
aria-label="Open zoomed preview"
|
|
2735
2735
|
@click="${this.handleOpenZoomedClick}"
|
|
2736
2736
|
>
|
|
2737
2737
|
${this.zoomIcon()}
|
|
2738
|
-
</button>`:
|
|
2738
|
+
</button>`:J}
|
|
2739
2739
|
</div>
|
|
2740
2740
|
<div class="main-slide" @click="${this.handleOpenZoomedClick}">
|
|
2741
|
-
${jn(this.type==="type"?
|
|
2741
|
+
${jn(this.type==="type"?L`<pbo-type-canvas
|
|
2742
2742
|
background-url=${(r=this.card)==null?void 0:r.medias.insert.url}
|
|
2743
2743
|
message=${(o=this.livePreviewProps)==null?void 0:o.text}
|
|
2744
2744
|
alignment=${((a=this.livePreviewProps)==null?void 0:a.alignment)||"left"}
|
|
@@ -2746,32 +2746,32 @@ void main() {
|
|
|
2746
2746
|
font=${(c=this.livePreviewProps)==null?void 0:c.font}
|
|
2747
2747
|
display-type=${(h=this.card)!=null&&h.hasEditorial?"default":"fullSize"}
|
|
2748
2748
|
@click="${this.handleOpenZoomedClick}"
|
|
2749
|
-
></pbo-type-canvas>`:
|
|
2749
|
+
></pbo-type-canvas>`:L`<pbo-handwritten-canvas
|
|
2750
2750
|
id="handwritten-main-canvas"
|
|
2751
2751
|
background-url=${(d=this.card)==null?void 0:d.medias.insert.url}
|
|
2752
2752
|
handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
|
|
2753
2753
|
display-type=${(u=this.card)!=null&&u.hasEditorial?"default":"fullSize"}
|
|
2754
2754
|
@click="${this.handleOpenZoomedClick}"
|
|
2755
2755
|
></pbo-handwritten-canvas>`)}
|
|
2756
|
-
${bi()?
|
|
2756
|
+
${bi()?L`<button
|
|
2757
2757
|
class="zoomed-preview-open-button"
|
|
2758
2758
|
type="button"
|
|
2759
2759
|
aria-label="Open zoomed preview"
|
|
2760
2760
|
@click="${this.handleOpenZoomedClick}"
|
|
2761
2761
|
>
|
|
2762
2762
|
${this.zoomIcon()}
|
|
2763
|
-
</button>`:
|
|
2763
|
+
</button>`:J}
|
|
2764
2764
|
</div>
|
|
2765
2765
|
<div class="main-slide" @click=${this.handleOpenZoomedClick}>
|
|
2766
2766
|
<pbo-image src="${(p=this.card)==null?void 0:p.medias.rendered_2.url}" alt=""></pbo-image>
|
|
2767
|
-
${bi()?
|
|
2767
|
+
${bi()?L`<button
|
|
2768
2768
|
class="zoomed-preview-open-button"
|
|
2769
2769
|
type="button"
|
|
2770
2770
|
aria-label="Open zoomed preview"
|
|
2771
2771
|
@click="${this.handleOpenZoomedClick}"
|
|
2772
2772
|
>
|
|
2773
2773
|
${this.zoomIcon()}
|
|
2774
|
-
</button>`:
|
|
2774
|
+
</button>`:J}
|
|
2775
2775
|
</div>
|
|
2776
2776
|
</div>
|
|
2777
2777
|
</div>
|
|
@@ -2795,7 +2795,7 @@ void main() {
|
|
|
2795
2795
|
alt=""
|
|
2796
2796
|
style=${ge({display:this.focusIndex===0?"block":"none"})}
|
|
2797
2797
|
/>
|
|
2798
|
-
${jn(this.type==="type"?
|
|
2798
|
+
${jn(this.type==="type"?L`<pbo-type-canvas
|
|
2799
2799
|
background-url=${(b=this.card)==null?void 0:b.medias.insert.url}
|
|
2800
2800
|
message=${(m=this.livePreviewProps)==null?void 0:m.text}
|
|
2801
2801
|
alignment=${((_=this.livePreviewProps)==null?void 0:_.alignment)||"left"}
|
|
@@ -2804,15 +2804,15 @@ void main() {
|
|
|
2804
2804
|
display-type=${(T=this.card)!=null&&T.hasEditorial?"default":"fullSize"}
|
|
2805
2805
|
@click="${this.handleOpenZoomedClick}"
|
|
2806
2806
|
style=${ge({display:this.focusIndex===1?"block":"none"})}
|
|
2807
|
-
></pbo-type-canvas>`:
|
|
2808
|
-
${jn(this.type==="handwritten"?
|
|
2807
|
+
></pbo-type-canvas>`:J)}
|
|
2808
|
+
${jn(this.type==="handwritten"?L`<pbo-handwritten-canvas
|
|
2809
2809
|
id="handwritten-zoomed-preview-canvas"
|
|
2810
2810
|
background-url=${(O=this.card)==null?void 0:O.medias.insert.url}
|
|
2811
2811
|
handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
|
|
2812
2812
|
display-type=${(k=this.card)!=null&&k.hasEditorial?"default":"fullSize"}
|
|
2813
2813
|
@click="${this.handleOpenZoomedClick}"
|
|
2814
2814
|
style=${ge({display:this.focusIndex===1?"block":"none"})}
|
|
2815
|
-
></pbo-handwritten-canvas>`:
|
|
2815
|
+
></pbo-handwritten-canvas>`:J)}
|
|
2816
2816
|
<img
|
|
2817
2817
|
src="${(E=this.card)==null?void 0:E.medias.rendered_2.url}"
|
|
2818
2818
|
alt=""
|
|
@@ -2820,7 +2820,7 @@ void main() {
|
|
|
2820
2820
|
/>
|
|
2821
2821
|
</pbo-zoomed-preview>
|
|
2822
2822
|
</pbo-drawer>
|
|
2823
|
-
`}};
|
|
2823
|
+
`}};dt.styles=[vt,np];dt.dependencies={"pbo-image":Qt,"pbo-type-canvas":it,"pbo-handwritten-canvas":ht,"pbo-drawer":_e,"pbo-zoomed-preview":Ae};Ft([C({type:Object})],dt.prototype,"card",2);Ft([C({type:Number,reflect:!0})],dt.prototype,"focusIndex",2);Ft([C({type:Object})],dt.prototype,"livePreviewProps",2);Ft([C()],dt.prototype,"handwrittenPreviewProps",2);Ft([C()],dt.prototype,"type",2);Ft([I()],dt.prototype,"allowPinchToToggle",2);Ft([I()],dt.prototype,"distance",2);Ft([B("#thumbnails")],dt.prototype,"thumbnailCarousel",2);Ft([B("#main-carousel")],dt.prototype,"mainCarousel",2);Ft([B(".editor__zoomed")],dt.prototype,"zoomedPreview",2);Ft([B(".main-slide.active")],dt.prototype,"activeMainSlide",2);Ft([B("pbo-type-canvas")],dt.prototype,"typeCanvas",2);Ft([Eo(".thumbnail")],dt.prototype,"thumbnailElements",2);Ft([Eo(".main-slide")],dt.prototype,"mainSlideElements",2);Ft([I()],dt.prototype,"mainImageTemplates",2);Ft([G("card")],dt.prototype,"handleCardChange",1);Ft([G("focusIndex")],dt.prototype,"handleFocusIndexChange",1);Ft([G("type"),G("focusIndex")],dt.prototype,"handleAllowPinchToToggle",1);dt=Ft([mt("pbo-editor-card-slider")],dt);const um=rt`
|
|
2824
2824
|
:host {
|
|
2825
2825
|
display: block;
|
|
2826
2826
|
}
|
|
@@ -2923,7 +2923,7 @@ void main() {
|
|
|
2923
2923
|
.submit-error:not(:empty) {
|
|
2924
2924
|
display: block;
|
|
2925
2925
|
}
|
|
2926
|
-
`,pm=
|
|
2926
|
+
`,pm=rt`
|
|
2927
2927
|
:host {
|
|
2928
2928
|
display: block;
|
|
2929
2929
|
}
|
|
@@ -2946,14 +2946,14 @@ void main() {
|
|
|
2946
2946
|
display: flex;
|
|
2947
2947
|
align-items: center;
|
|
2948
2948
|
}
|
|
2949
|
-
`;var gm=Object.defineProperty,fm=Object.getOwnPropertyDescriptor,ir=(n,t,e,i)=>{for(var s=i>1?void 0:i?fm(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&&gm(t,e,s),s};let Ue=class extends
|
|
2949
|
+
`;var gm=Object.defineProperty,fm=Object.getOwnPropertyDescriptor,ir=(n,t,e,i)=>{for(var s=i>1?void 0:i?fm(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&&gm(t,e,s),s};let Ue=class extends yt{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 L`<div
|
|
2950
2950
|
class="${fe({"fake-loading":!0,"fake-loading--linear":this.loadingPattern==="linear","fake-loading--random":this.loadingPattern==="random","fake-loading--loading":!0})}"
|
|
2951
2951
|
>
|
|
2952
2952
|
<pbo-spinner
|
|
2953
2953
|
style="${ge({"--track-width":"3px","--indicator-color":"black"})}"
|
|
2954
2954
|
></pbo-spinner>
|
|
2955
2955
|
<span>${Math.round(this.progress)}%</span>
|
|
2956
|
-
</div>`}};Ue.styles=[
|
|
2956
|
+
</div>`}};Ue.styles=[vt,pm];Ue.dependencies={"pbo-spinner":as};ir([C({type:Boolean,reflect:!0})],Ue.prototype,"loading",2);ir([C({type:Number})],Ue.prototype,"loadingTime",2);ir([C()],Ue.prototype,"loadingPattern",2);ir([I()],Ue.prototype,"progress",2);Ue=ir([mt("pbo-fake-loading")],Ue);var mm=Object.defineProperty,bm=Object.getOwnPropertyDescriptor,nt=(n,t,e,i)=>{for(var s=i>1?void 0:i?bm(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&&mm(t,e,s),s};let q=class extends yt{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 L`
|
|
2957
2957
|
<form
|
|
2958
2958
|
name="handwritten-form"
|
|
2959
2959
|
class="handwritten-form"
|
|
@@ -3000,9 +3000,9 @@ void main() {
|
|
|
3000
3000
|
/>
|
|
3001
3001
|
|
|
3002
3002
|
<!-- Fake loading -->
|
|
3003
|
-
${this.isImageProcessing?
|
|
3003
|
+
${this.isImageProcessing?L`<div class="fake-loading-container">
|
|
3004
3004
|
<pbo-fake-loading ?loading=${this.isImageProcessing}></pbo-fake-loading>
|
|
3005
|
-
</div>`:
|
|
3005
|
+
</div>`:J}
|
|
3006
3006
|
|
|
3007
3007
|
<div class="buttons-container">
|
|
3008
3008
|
<!-- Upload button -->
|
|
@@ -3046,7 +3046,7 @@ void main() {
|
|
|
3046
3046
|
</pbo-button>
|
|
3047
3047
|
</div>
|
|
3048
3048
|
</form>
|
|
3049
|
-
`}};
|
|
3049
|
+
`}};q.styles=[vt,um];q.dependencies={"pbo-button":lt,"pbo-fake-loading":Ue};nt([C()],q.prototype,"card",2);nt([C()],q.prototype,"submitHandwrittenForm",2);nt([C()],q.prototype,"getProcessedImg",2);nt([C({type:Function})],q.prototype,"onClose",2);nt([C({type:Boolean,reflect:!0,attribute:"loading"})],q.prototype,"isSubmitLoading",2);nt([C({type:String,attribute:"cta-primary-label"})],q.prototype,"ctaPrimaryLabel",2);nt([C({type:Boolean,reflect:!0,attribute:"disabled"})],q.prototype,"isSubmitDisabled",2);nt([B(".pixel-input")],q.prototype,"imageInput",2);nt([B(".handwritten-form")],q.prototype,"handwrittenForm",2);nt([B("pbo-button[name='upload']")],q.prototype,"uploadButton",2);nt([B("pbo-button[name='save']")],q.prototype,"saveButton",2);nt([B("pbo-button[name='reupload']")],q.prototype,"reuploadButton",2);nt([I()],q.prototype,"isProcessingError",2);nt([I()],q.prototype,"submitError",2);nt([I()],q.prototype,"isImageProcessing",2);nt([I()],q.prototype,"sourceImg",2);nt([I()],q.prototype,"processedImg",2);nt([I()],q.prototype,"handwrittenDimensions",2);nt([G("isSubmitLoading")],q.prototype,"handleSubmitLoadingChange",1);nt([G("isSubmitDisabled")],q.prototype,"handleSubmitDisabledChange",1);nt([G("isProcessingError")],q.prototype,"handleProcessingErrorChange",1);nt([G("sourceImg")],q.prototype,"handleSourceImgChange",1);nt([G("processedFileUrl")],q.prototype,"handleProcessImageChange",1);nt([G("isImageProcessing")],q.prototype,"handleImageProcessingChange",1);nt([G("processedImg")],q.prototype,"handleProcessedImgChange",1);q=nt([mt("pbo-handwritten-form")],q);const vm=q,ym=rt`
|
|
3050
3050
|
:host {
|
|
3051
3051
|
display: block;
|
|
3052
3052
|
}
|
|
@@ -3088,7 +3088,7 @@ void main() {
|
|
|
3088
3088
|
.choices.is-open .choices__inner {
|
|
3089
3089
|
box-shadow: 0 0 0 var(--pbo-focus-ring-width, 3px) var(--pbo-focus-ring-color);
|
|
3090
3090
|
}
|
|
3091
|
-
`;var _m=Object.defineProperty,xm=Object.getOwnPropertyDescriptor,bs=(n,t,e,i)=>{for(var s=i>1?void 0:i?xm(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&&_m(t,e,s),s};let li=class extends
|
|
3091
|
+
`;var _m=Object.defineProperty,xm=Object.getOwnPropertyDescriptor,bs=(n,t,e,i)=>{for(var s=i>1?void 0:i?xm(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&&_m(t,e,s),s};let li=class extends yt{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:`
|
|
3092
3092
|
<div class="choice-wrapper">
|
|
3093
3093
|
<span class="label">Type message
|
|
3094
3094
|
<svg
|
|
@@ -3167,7 +3167,7 @@ void main() {
|
|
|
3167
3167
|
></path>
|
|
3168
3168
|
</svg>
|
|
3169
3169
|
</span>
|
|
3170
|
-
</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
|
|
3170
|
+
</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 L` <div
|
|
3171
3171
|
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})}
|
|
3172
3172
|
>
|
|
3173
3173
|
<label
|
|
@@ -3179,7 +3179,7 @@ void main() {
|
|
|
3179
3179
|
<slot name="label">${this.label}</slot>
|
|
3180
3180
|
</label>
|
|
3181
3181
|
</div>
|
|
3182
|
-
<select part="base" class="js-choice"></select>`}};li.styles=[
|
|
3182
|
+
<select part="base" class="js-choice"></select>`}};li.styles=[vt,ym,Js,en(oc)];bs([C()],li.prototype,"size",2);bs([C()],li.prototype,"label",2);bs([C({type:Boolean,reflect:!0})],li.prototype,"disabled",2);bs([G("disabled",{waitUntilFirstUpdate:!0})],li.prototype,"handleDisabledChanged",1);bs([B(".js-choice")],li.prototype,"choiceEl",2);li=bs([mt("pbo-editor-selector")],li);const wm=li;var Cm=Object.defineProperty,Sm=Object.getOwnPropertyDescriptor,Ht=(n,t,e,i)=>{for(var s=i>1?void 0:i?Sm(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&&Cm(t,e,s),s};let bt=class extends yt{constructor(){super(...arguments),this.card=null,this.onClose=()=>{},this.typeFormCtaLabel="",this.handwrittenFormCtaLabel="",this.hideColor=!1,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.slider.focusIndex!==1&&this.slider.focusOn(1)},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 L`
|
|
3183
3183
|
<div class="editor">
|
|
3184
3184
|
<div class="editor__card" part="editor-card-slider-container">
|
|
3185
3185
|
<pbo-editor-card-slider
|
|
@@ -3214,6 +3214,7 @@ void main() {
|
|
|
3214
3214
|
cta-link-button-base
|
|
3215
3215
|
"
|
|
3216
3216
|
cta-primary-label=${this.typeFormCtaLabel}
|
|
3217
|
+
?hide-type-form-color-block=${this.hideColor}
|
|
3217
3218
|
.submitTypeForm=${this.submitTypeForm}
|
|
3218
3219
|
.onClose=${this.onClose}
|
|
3219
3220
|
style=${ge({display:this.editorType==="type"?"block":"none"})}
|
|
@@ -3234,7 +3235,7 @@ void main() {
|
|
|
3234
3235
|
></pbo-handwritten-form>
|
|
3235
3236
|
</div>
|
|
3236
3237
|
</div>
|
|
3237
|
-
`}};
|
|
3238
|
+
`}};bt.styles=[vt,tp];bt.dependencies={"pbo-editor-card-slider":dt,"pbo-type-form":X,"pbo-handwritten-form":vm,"pbo-editor-selector":wm};Ht([C({type:Object})],bt.prototype,"card",2);Ht([C()],bt.prototype,"submitTypeForm",2);Ht([C()],bt.prototype,"submitHandwrittenForm",2);Ht([C()],bt.prototype,"getProcessedImg",2);Ht([C({type:Function})],bt.prototype,"onClose",2);Ht([C({type:String,attribute:"type-form-cta-primary-label"})],bt.prototype,"typeFormCtaLabel",2);Ht([C({type:String,attribute:"handwritten-form-cta-primary-label"})],bt.prototype,"handwrittenFormCtaLabel",2);Ht([C({type:Boolean,attribute:"hide-type-form-color-block"})],bt.prototype,"hideColor",2);Ht([B("pbo-type-form")],bt.prototype,"typeForm",2);Ht([B("pbo-handwritten-form")],bt.prototype,"handwrittenForm",2);Ht([B("pbo-editor-card-slider")],bt.prototype,"slider",2);Ht([I()],bt.prototype,"formData",2);Ht([I()],bt.prototype,"handwrittenFormState",2);Ht([I()],bt.prototype,"editorType",2);Ht([G("card")],bt.prototype,"handleCardChange",1);Ht([G("editorType")],bt.prototype,"handleEditorTypeChange",1);bt=Ht([mt("pbo-editor")],bt);const Gb=bt,Yb=X,Xb=dt,Tm=rt`
|
|
3238
3239
|
:host {
|
|
3239
3240
|
display: block;
|
|
3240
3241
|
--title-font-size: 18.75px;
|
|
@@ -3428,7 +3429,7 @@ void main() {
|
|
|
3428
3429
|
* @license
|
|
3429
3430
|
* Copyright 2021 Google LLC
|
|
3430
3431
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
3431
|
-
*/function*fh(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}function qo(n){return typeof n=="number"}function _o(n){return typeof n=="string"}function wn(n){return typeof n=="boolean"}function Il(n){return Object.prototype.toString.call(n)==="[object Object]"}function gt(n){return Math.abs(n)}function Ko(n){return Math.sign(n)}function zs(n,t){return gt(n-t)}function km(n,t){if(n===0||t===0||gt(n)<=gt(t))return 0;const e=zs(gt(n),gt(t));return gt(e/n)}function Om(n){return Math.round(n*100)/100}function qs(n){return Ks(n).map(Number)}function De(n){return n[sr(n)]}function sr(n){return Math.max(0,n.length-1)}function Zo(n,t){return t===sr(n)}function Ll(n,t=0){return Array.from(Array(n),(e,i)=>t+i)}function Ks(n){return Object.keys(n)}function mh(n,t){return[n,t].reduce((e,i)=>(Ks(i).forEach(s=>{const r=e[s],o=i[s],a=Il(r)&&Il(o);e[s]=a?mh(r,o):o}),e),{})}function xo(n,t){return typeof t.MouseEvent<"u"&&n instanceof t.MouseEvent}function Pm(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 _o(n)?e[n](l):n(t,l,c)}return{measure:o}}function Zs(){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 Dm(n,t,e,i){const s=Zs(),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 Am(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 Vi(n=0,t=0){const e=gt(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 bh(n,t,e){const{constrain:i}=Vi(0,n),s=n+1;let r=o(t);function o(u){return e?gt((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 bh(n,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function Mm(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=Zs(),E=Zs(),P=Vi(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(!_)return;function tt(qt){(wn(_)||_(A,qt))&&he(qt)}const Ot=t;k.add(Ot,"dragstart",qt=>qt.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 Xt(){k.clear(),E.clear()}function Le(){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 Fe(A,tt){const Ot=d.add(Ko(A)*-1),qt=h.byDistance(A,!g).distance;return g||gt(A)<P?qt:b&&tt?qt*.5:h.byIndex(Ot.get(),0).distance}function he(A){const tt=xo(A,i);kt=tt,N=g&&tt&&!A.buttons&&H,H=zs(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),Le(),M=r.readPoint(A),U=r.readPoint(A,x),u.emit("pointerDown")))}function At(A){if(!xo(A,i)&&A.touches.length>=2)return $t(A);const Ot=r.readPoint(A),qt=r.readPoint(A,x),je=zs(Ot,M),Ye=zs(qt,U);if(!Q&&!kt&&(!A.cancelable||(Q=je>Ye,!Q)))return $t(A);const Oi=r.pointerMove(A);je>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(),je=Fe(S(qt),Ot),Ye=km(qt,je),Oi=j-10*Ye,di=m+Ye/50;Q=!1,q=!1,E.clear(),c.useDuration(Oi).useFriction(di),l.distance(je,!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 Im(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(xo(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&>(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function Lm(){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 Fm(n){function t(i){return n*(i/100)}return{measure:t}}function jm(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(gt(k-O)>=.5){b.reInit(),t.emit("resize");break}}}l=new ResizeObserver(_=>{(wn(r)||r(b,_))&&m(_)}),e.requestAnimationFrame(()=>{a.forEach(_=>l.observe(_))})}function g(){d=!0,l&&l.disconnect()}return{init:p,destroy:g}}function $m(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=Ko(E),d=h,T}function p(){const O=i.get()-t.get();return gt(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 Rm(n,t,e,i,s){const r=s.measure(10),o=s.measure(50),a=Vi(.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=gt(n[g]-t.get()),b=e.get()-t.get(),m=a.constrain(f/o);e.subtract(b*m),!p&>(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 Bm(n,t,e,i,s){const r=Vi(-t+n,0),o=d(),a=h(),l=u();function c(g,f){return zs(g,f)<=1}function h(){const g=o[0],f=De(o),b=o.lastIndexOf(g),m=o.indexOf(f)+1;return Vi(b,m)}function d(){return e.map((g,f)=>{const{min:b,max:m}=r,_=r.constrain(g),x=!f,S=Zo(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 zm(n,t,e){const i=t[0],s=e?i-n:De(t);return{limit:Vi(s,i)}}function Hm(n,t,e,i){const r=t.min+.1,o=t.max+.1,{reachedMin:a,reachedMax:l}=Vi(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 Vm(n){const{max:t,length:e}=n;function i(r){const o=r-t;return e?o/-e:0}return{get:i}}function Nm(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=>De(f)[o]-f[0][r]).map(gt)}function u(){return i.map(f=>e[r]-f[r]).map(f=>-gt(f))}function p(){return a(c).map(f=>f[0]).map((f,b)=>f+l[b])}return{snaps:c,snapsAligned:h}}function Um(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,_=Zo(b,f);if(m){const x=De(b[0])+1;return Ll(x)}if(_){const x=sr(r)-De(b)[0]+1;return Ll(x,De(b)[0])}return g})}return{slideRegistry:c}}function Wm(n,t,e,i,s){const{reachedAny:r,removeOffset:o,constrain:a}=i;function l(g){return g.concat().sort((f,b)=>gt(f)-gt(b))[0]}function c(g){const f=n?o(g):a(g),b=t.map((_,x)=>({diff:h(_-f,0),index:x})).sort((_,x)=>gt(_.diff)-gt(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(_=>Ko(_)===f);return m.length?l(m):De(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 Gm(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 Ym(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));qo(_)&&(s.useDuration(0),i.index(_,0),o.emit("slideFocus"))}r.add(document,"keydown",d,!1),t.forEach((f,b)=>{r.add(f,"focus",m=>{(wn(a)||a(p,m))&&g(b)},l)})}function d(p){p.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function Ms(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 qo(l)?l:l.get()}return{get:e,set:i,add:s,subtract:r}}function vh(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=Om(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 Xm(n,t,e,i,s,r,o,a,l){const h=qs(s),d=qs(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:Ms(-1),translate:vh(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 qm(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||(wn(e)||e(l,h))&&c(h)}),i.observe(n,{childList:!0})}function o(){i&&i.disconnect(),s=!0}return{init:r,destroy:o}}function Km(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 Ks(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 Zm(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 gt(t[a]-_[a])}function f(){if(!c)return 0;const _=r.getComputedStyle(De(i));return parseFloat(_.getPropertyValue(`margin-${l}`))}function b(){return e.map((_,x,S)=>{const T=!x,O=Zo(S,x);return T?u[x]+h:O?u[x]+d:S[x+1][a]-_[a]}).map(gt)}return{slideSizes:u,slideSizesWithGaps:p,startGap:h,endGap:d}}function Jm(n,t,e,i,s,r,o,a,l){const{startEdge:c,endEdge:h,direction:d}=n,u=qo(e);function p(m,_){return qs(m).filter(x=>x%_===0).map(x=>m.slice(x,x+_))}function g(m){return m.length?qs(m).reduce((_,x,S)=>{const T=De(_)||0,O=T===0,k=x===sr(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=gt(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 Qm(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=Lm(),P=E.measure(t),R=e.map(E.measure),L=Am(l,c),j=L.measureSize(P),H=Fm(j),M=Pm(a,j),U=!d&&!!_,q=d||!!_,{slideSizes:Q,slideSizesWithGaps:N,startGap:kt,endGap:Yt}=Zm(L,P,R,e,q,s),Xt=Jm(L,j,b,d,P,R,kt,Yt,k),{snaps:Le,snapsAligned:me}=Nm(L,M,P,R,Xt),jt=-De(Le)+De(N),{snapsContained:Fe,scrollContainLimit:he}=Bm(j,jt,me,_,k),At=U?Fe:me,{limit:$t}=zm(jt,At,d),de=bh(sr(At),h,d),_t=de.clone(),ut=qs(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=Dm(i,s,()=>A(Tn),Yi=>tt(Tn,Yi)),qt=.68,je=At[de.get()],Ye=Ms(je),Oi=Ms(je),di=Ms(je),Pi=Ms(je),vs=$m(Ye,di,Oi,Pi,u,qt),Cn=Wm(d,At,jt,$t,Pi),Sn=Gm(Ot,de,_t,vs,Cn,Pi,o),ta=Vm($t),ea=Zs(),yh=Km(t,e,o,f),{slideRegistry:ia}=Um(U,_,At,he,Xt,ut),_h=Ym(n,e,ia,Sn,vs,ea,o,O),Tn={ownerDocument:i,ownerWindow:s,eventHandler:o,containerRect:P,slideRects:R,animation:Ot,axis:L,dragHandler:Mm(L,n,i,s,Pi,Im(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:jm(t,o,s,e,L,x,E),scrollBody:vs,scrollBounds:Rm($t,di,Pi,vs,H),scrollLooper:Hm(jt,$t,di,[Ye,di,Oi,Pi]),scrollProgress:ta,scrollSnapList:At.map(ta.get),scrollSnaps:At,scrollTarget:Cn,scrollTo:Sn,slideLooper:Xm(L,j,jt,Q,N,Le,At,di,e),slideFocus:_h,slidesHandler:qm(t,o,S),slidesInView:yh,slideIndexes:ut,slideRegistry:ia,slidesToScroll:Xt,target:Pi,translate:vh(L,t)};return Tn}function tb(){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 eb={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 ib(n){function t(r,o){return mh(r,o||{})}function e(r){const o=r.breakpoints||{},a=Ks(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=>Ks(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(n.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function sb(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 Jo(n,t,e){const i=n.ownerDocument,s=i.defaultView,r=ib(s),o=sb(r),a=Zs(),l=tb(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=r,{on:u,off:p,emit:g}=l,f=L;let b=!1,m,_=c(eb,Jo.globalOptions),x=c(_),S=[],T,O,k;function E(){const{container:ut,slides:A}=x;O=(_o(ut)?n.querySelector(ut):ut)||n.children[0];const Ot=_o(A)?O.querySelectorAll(A):A;k=[].slice.call(Ot||O.children)}function P(ut){const A=Qm(n,O,k,i,s,ut,l);if(ut.loop&&!A.slideLooper.canLoop()){const tt=Object.assign({},ut,{loop:!1});return P(tt)}return A}function R(ut,A){b||(_=c(_,ut),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(ut,A){const tt=Xt();j(),R(c({startIndex:tt},ut),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(ut,A,tt){!x.active||b||(m.scrollBody.useBaseFriction().useDuration(A===!0?0:x.duration),m.scrollTo.index(ut,tt||0))}function U(ut){const A=m.index.add(1).get();M(A,ut,-1)}function q(ut){const A=m.index.add(-1).get();M(A,ut,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 Le(){return m.indexPrevious.get()}function me(){return m.slidesInView.get()}function jt(){return m.slidesInView.get(!1)}function Fe(){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:Fe,previousScrollSnap:Le,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}Jo.globalOptions=void 0;var rb=Object.defineProperty,nb=Object.getOwnPropertyDescriptor,Ie=(n,t,e,i)=>{for(var s=i>1?void 0:i?nb(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&&rb(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=Jo(this.emblaViewport,t);if(this.skeleton)return;const i=this.addPrevNextBtnsClickHandlers(e,this.emblaPrevButton,this.emblaNextButton),s=()=>{const r=e.canScrollPrev()||e.canScrollNext();this.emblaPrevButton.style.visibility=r?"visible":"hidden",this.emblaNextButton.style.visibility=r?"visible":"hidden"};e.on("destroy",i),e.on("init",s),e.on("reInit",s)},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`
|
|
3432
|
+
*/function*fh(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}function qo(n){return typeof n=="number"}function _o(n){return typeof n=="string"}function wn(n){return typeof n=="boolean"}function Il(n){return Object.prototype.toString.call(n)==="[object Object]"}function gt(n){return Math.abs(n)}function Ko(n){return Math.sign(n)}function zs(n,t){return gt(n-t)}function km(n,t){if(n===0||t===0||gt(n)<=gt(t))return 0;const e=zs(gt(n),gt(t));return gt(e/n)}function Om(n){return Math.round(n*100)/100}function qs(n){return Ks(n).map(Number)}function De(n){return n[sr(n)]}function sr(n){return Math.max(0,n.length-1)}function Zo(n,t){return t===sr(n)}function Ll(n,t=0){return Array.from(Array(n),(e,i)=>t+i)}function Ks(n){return Object.keys(n)}function mh(n,t){return[n,t].reduce((e,i)=>(Ks(i).forEach(s=>{const r=e[s],o=i[s],a=Il(r)&&Il(o);e[s]=a?mh(r,o):o}),e),{})}function xo(n,t){return typeof t.MouseEvent<"u"&&n instanceof t.MouseEvent}function Pm(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 _o(n)?e[n](l):n(t,l,c)}return{measure:o}}function Zs(){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 Dm(n,t,e,i){const s=Zs(),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 Am(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 Vi(n=0,t=0){const e=gt(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 bh(n,t,e){const{constrain:i}=Vi(0,n),s=n+1;let r=o(t);function o(u){return e?gt((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 bh(n,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function Mm(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=Zs(),E=Zs(),P=Vi(50,225).constrain(p.measure(20)),R={mouse:300,touch:400},F={mouse:500,touch:600},j=g?43:25;let H=!1,M=0,U=0,K=!1,Q=!1,N=!1,kt=!1;function Yt(A){if(!_)return;function tt(qt){(wn(_)||_(A,qt))&&he(qt)}const Ot=t;k.add(Ot,"dragstart",qt=>qt.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 Xt(){k.clear(),E.clear()}function Le(){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?F:R)[kt?"mouse":"touch"]}function Fe(A,tt){const Ot=d.add(Ko(A)*-1),qt=h.byDistance(A,!g).distance;return g||gt(A)<P?qt:b&&tt?qt*.5:h.byIndex(Ot.get(),0).distance}function he(A){const tt=xo(A,i);kt=tt,N=g&&tt&&!A.buttons&&H,H=zs(s.get(),o.get())>=2,!(tt&&A.button!==0)&&(me(A.target)||(K=!0,r.pointerDown(A),c.useFriction(0).useDuration(0),s.set(o),Le(),M=r.readPoint(A),U=r.readPoint(A,x),u.emit("pointerDown")))}function At(A){if(!xo(A,i)&&A.touches.length>=2)return $t(A);const Ot=r.readPoint(A),qt=r.readPoint(A,x),je=zs(Ot,M),Ye=zs(qt,U);if(!Q&&!kt&&(!A.cancelable||(Q=je>Ye,!Q)))return $t(A);const Oi=r.pointerMove(A);je>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(),je=Fe(S(qt),Ot),Ye=km(qt,je),Oi=j-10*Ye,di=m+Ye/50;Q=!1,K=!1,E.clear(),c.useDuration(Oi).useFriction(di),l.distance(je,!g),kt=!1,u.emit("pointerUp")}function de(A){N&&(A.stopPropagation(),A.preventDefault(),N=!1)}function wt(){return K}return{init:Yt,destroy:Xt,pointerDown:wt}}function Im(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(xo(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&>(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function Lm(){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 Fm(n){function t(i){return n*(i/100)}return{measure:t}}function jm(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(gt(k-O)>=.5){b.reInit(),t.emit("resize");break}}}l=new ResizeObserver(_=>{(wn(r)||r(b,_))&&m(_)}),e.requestAnimationFrame(()=>{a.forEach(_=>l.observe(_))})}function g(){d=!0,l&&l.disconnect()}return{init:p,destroy:g}}function $m(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=Ko(E),d=h,T}function p(){const O=i.get()-t.get();return gt(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 Rm(n,t,e,i,s){const r=s.measure(10),o=s.measure(50),a=Vi(.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=gt(n[g]-t.get()),b=e.get()-t.get(),m=a.constrain(f/o);e.subtract(b*m),!p&>(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 Bm(n,t,e,i,s){const r=Vi(-t+n,0),o=d(),a=h(),l=u();function c(g,f){return zs(g,f)<=1}function h(){const g=o[0],f=De(o),b=o.lastIndexOf(g),m=o.indexOf(f)+1;return Vi(b,m)}function d(){return e.map((g,f)=>{const{min:b,max:m}=r,_=r.constrain(g),x=!f,S=Zo(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 zm(n,t,e){const i=t[0],s=e?i-n:De(t);return{limit:Vi(s,i)}}function Hm(n,t,e,i){const r=t.min+.1,o=t.max+.1,{reachedMin:a,reachedMax:l}=Vi(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 Vm(n){const{max:t,length:e}=n;function i(r){const o=r-t;return e?o/-e:0}return{get:i}}function Nm(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=>De(f)[o]-f[0][r]).map(gt)}function u(){return i.map(f=>e[r]-f[r]).map(f=>-gt(f))}function p(){return a(c).map(f=>f[0]).map((f,b)=>f+l[b])}return{snaps:c,snapsAligned:h}}function Um(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,_=Zo(b,f);if(m){const x=De(b[0])+1;return Ll(x)}if(_){const x=sr(r)-De(b)[0]+1;return Ll(x,De(b)[0])}return g})}return{slideRegistry:c}}function Wm(n,t,e,i,s){const{reachedAny:r,removeOffset:o,constrain:a}=i;function l(g){return g.concat().sort((f,b)=>gt(f)-gt(b))[0]}function c(g){const f=n?o(g):a(g),b=t.map((_,x)=>({diff:h(_-f,0),index:x})).sort((_,x)=>gt(_.diff)-gt(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(_=>Ko(_)===f);return m.length?l(m):De(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 Gm(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 Ym(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));qo(_)&&(s.useDuration(0),i.index(_,0),o.emit("slideFocus"))}r.add(document,"keydown",d,!1),t.forEach((f,b)=>{r.add(f,"focus",m=>{(wn(a)||a(p,m))&&g(b)},l)})}function d(p){p.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function Ms(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 qo(l)?l:l.get()}return{get:e,set:i,add:s,subtract:r}}function vh(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=Om(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 Xm(n,t,e,i,s,r,o,a,l){const h=qs(s),d=qs(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(F=>{const j=P?0:-e,H=P?e:0,M=P?"end":"start",U=R[F][M];return{index:F,loopPoint:U,slideLocation:Ms(-1),translate:vh(n,l[F]),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,F=E();F!==R.get()&&(P.to(F),R.set(F))})}function T(){u.forEach(k=>k.translate.clear())}return{canLoop:x,clear:T,loop:S,loopPoints:u}}function qm(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||(wn(e)||e(l,h))&&c(h)}),i.observe(n,{childList:!0})}function o(){i&&i.disconnect(),s=!0}return{init:r,destroy:o}}function Km(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 Ks(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 Zm(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 gt(t[a]-_[a])}function f(){if(!c)return 0;const _=r.getComputedStyle(De(i));return parseFloat(_.getPropertyValue(`margin-${l}`))}function b(){return e.map((_,x,S)=>{const T=!x,O=Zo(S,x);return T?u[x]+h:O?u[x]+d:S[x+1][a]-_[a]}).map(gt)}return{slideSizes:u,slideSizesWithGaps:p,startGap:h,endGap:d}}function Jm(n,t,e,i,s,r,o,a,l){const{startEdge:c,endEdge:h,direction:d}=n,u=qo(e);function p(m,_){return qs(m).filter(x=>x%_===0).map(x=>m.slice(x,x+_))}function g(m){return m.length?qs(m).reduce((_,x,S)=>{const T=De(_)||0,O=T===0,k=x===sr(m),E=s[c]-r[T][c],P=s[c]-r[x][h],R=!i&&O?d(o):0,F=!i&&k?d(a):0,j=gt(P-F-(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 Qm(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=Lm(),P=E.measure(t),R=e.map(E.measure),F=Am(l,c),j=F.measureSize(P),H=Fm(j),M=Pm(a,j),U=!d&&!!_,K=d||!!_,{slideSizes:Q,slideSizesWithGaps:N,startGap:kt,endGap:Yt}=Zm(F,P,R,e,K,s),Xt=Jm(F,j,b,d,P,R,kt,Yt,k),{snaps:Le,snapsAligned:me}=Nm(F,M,P,R,Xt),jt=-De(Le)+De(N),{snapsContained:Fe,scrollContainLimit:he}=Bm(j,jt,me,_,k),At=U?Fe:me,{limit:$t}=zm(jt,At,d),de=bh(sr(At),h,d),wt=de.clone(),ut=qs(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=Dm(i,s,()=>A(Tn),Yi=>tt(Tn,Yi)),qt=.68,je=At[de.get()],Ye=Ms(je),Oi=Ms(je),di=Ms(je),Pi=Ms(je),vs=$m(Ye,di,Oi,Pi,u,qt),Cn=Wm(d,At,jt,$t,Pi),Sn=Gm(Ot,de,wt,vs,Cn,Pi,o),ta=Vm($t),ea=Zs(),yh=Km(t,e,o,f),{slideRegistry:ia}=Um(U,_,At,he,Xt,ut),_h=Ym(n,e,ia,Sn,vs,ea,o,O),Tn={ownerDocument:i,ownerWindow:s,eventHandler:o,containerRect:P,slideRects:R,animation:Ot,axis:F,dragHandler:Mm(F,n,i,s,Pi,Im(F,s),Ye,Ot,Sn,vs,Cn,de,o,H,p,g,m,qt,T),eventStore:ea,percentOfView:H,index:de,indexPrevious:wt,limit:$t,location:Ye,offsetLocation:di,previousLocation:Oi,options:r,resizeHandler:jm(t,o,s,e,F,x,E),scrollBody:vs,scrollBounds:Rm($t,di,Pi,vs,H),scrollLooper:Hm(jt,$t,di,[Ye,di,Oi,Pi]),scrollProgress:ta,scrollSnapList:At.map(ta.get),scrollSnaps:At,scrollTarget:Cn,scrollTo:Sn,slideLooper:Xm(F,j,jt,Q,N,Le,At,di,e),slideFocus:_h,slidesHandler:qm(t,o,S),slidesInView:yh,slideIndexes:ut,slideRegistry:ia,slidesToScroll:Xt,target:Pi,translate:vh(F,t)};return Tn}function tb(){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 eb={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 ib(n){function t(r,o){return mh(r,o||{})}function e(r){const o=r.breakpoints||{},a=Ks(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=>Ks(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(n.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function sb(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 Jo(n,t,e){const i=n.ownerDocument,s=i.defaultView,r=ib(s),o=sb(r),a=Zs(),l=tb(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=r,{on:u,off:p,emit:g}=l,f=F;let b=!1,m,_=c(eb,Jo.globalOptions),x=c(_),S=[],T,O,k;function E(){const{container:ut,slides:A}=x;O=(_o(ut)?n.querySelector(ut):ut)||n.children[0];const Ot=_o(A)?O.querySelectorAll(A):A;k=[].slice.call(Ot||O.children)}function P(ut){const A=Qm(n,O,k,i,s,ut,l);if(ut.loop&&!A.slideLooper.canLoop()){const tt=Object.assign({},ut,{loop:!1});return P(tt)}return A}function R(ut,A){b||(_=c(_,ut),x=h(_),S=A||S,E(),m=P(x),d([_,...S.map(({options:tt})=>tt)]).forEach(tt=>a.add(tt,"change",F)),x.active&&(m.translate.to(m.location.get()),m.animation.init(),m.slidesInView.init(),m.slideFocus.init(wt),m.eventHandler.init(wt),m.resizeHandler.init(wt),m.slidesHandler.init(wt),m.options.loop&&m.slideLooper.loop(),O.offsetParent&&k.length&&m.dragHandler.init(wt),T=o.init(wt,S)))}function F(ut,A){const tt=Xt();j(),R(c({startIndex:tt},ut),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(ut,A,tt){!x.active||b||(m.scrollBody.useBaseFriction().useDuration(A===!0?0:x.duration),m.scrollTo.index(ut,tt||0))}function U(ut){const A=m.index.add(1).get();M(A,ut,-1)}function K(ut){const A=m.index.add(-1).get();M(A,ut,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 Le(){return m.indexPrevious.get()}function me(){return m.slidesInView.get()}function jt(){return m.slidesInView.get(!1)}function Fe(){return T}function he(){return m}function At(){return n}function $t(){return O}function de(){return k}const wt={canScrollNext:Q,canScrollPrev:N,containerNode:$t,internalEngine:he,destroy:H,off:p,on:u,emit:g,plugins:Fe,previousScrollSnap:Le,reInit:f,rootNode:At,scrollNext:U,scrollPrev:K,scrollProgress:Yt,scrollSnapList:kt,scrollTo:M,selectedScrollSnap:Xt,slideNodes:de,slidesInView:me,slidesNotInView:jt};return R(t,e),setTimeout(()=>l.emit("init"),0),wt}Jo.globalOptions=void 0;var rb=Object.defineProperty,nb=Object.getOwnPropertyDescriptor,Ie=(n,t,e,i)=>{for(var s=i>1?void 0:i?nb(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&&rb(t,e,s),s};let Wt=class extends yt{constructor(){super(...arguments),this.cards=[],this.skeleton=!1,this.title="",this.firstUpdated=()=>{const t={align:"start",axis:"x",loop:!1},e=Jo(this.emblaViewport,t);if(this.skeleton)return;const i=this.addPrevNextBtnsClickHandlers(e,this.emblaPrevButton,this.emblaNextButton),s=()=>{const r=e.canScrollPrev()||e.canScrollNext();this.emblaPrevButton.style.visibility=r?"visible":"hidden",this.emblaNextButton.style.visibility=r?"visible":"hidden"};e.on("destroy",i),e.on("init",s),e.on("reInit",s)},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?L`
|
|
3432
3433
|
<div class="category-container skeleton">
|
|
3433
3434
|
<div class="title"></div>
|
|
3434
3435
|
<section class="embla">
|
|
@@ -3450,7 +3451,7 @@ void main() {
|
|
|
3450
3451
|
</div>
|
|
3451
3452
|
</section>
|
|
3452
3453
|
</div>
|
|
3453
|
-
`:
|
|
3454
|
+
`:L`
|
|
3454
3455
|
<div class="category-container">
|
|
3455
3456
|
<div class="title" part="category-title">${this.title}</div>
|
|
3456
3457
|
<div class="embla__button_container embla__button_container--prev">
|
|
@@ -3470,7 +3471,7 @@ void main() {
|
|
|
3470
3471
|
<section class="embla">
|
|
3471
3472
|
<div class="embla__viewport">
|
|
3472
3473
|
<div class="embla__container">
|
|
3473
|
-
${fh(this.cards,t=>
|
|
3474
|
+
${fh(this.cards,t=>L`
|
|
3474
3475
|
<div class="embla__slide">
|
|
3475
3476
|
<button
|
|
3476
3477
|
class="embla__slide__button"
|
|
@@ -3501,7 +3502,7 @@ void main() {
|
|
|
3501
3502
|
</button>
|
|
3502
3503
|
</div>
|
|
3503
3504
|
</div>
|
|
3504
|
-
`}};
|
|
3505
|
+
`}};Wt.styles=[vt,Tm,en(Em)];Wt.dependencies={"pbo-image":Qt};Ie([C({type:Array})],Wt.prototype,"cards",2);Ie([C({type:Boolean,reflect:!0})],Wt.prototype,"skeleton",2);Ie([C({type:String})],Wt.prototype,"title",2);Ie([B("#category-carousel")],Wt.prototype,"imageCarousel",2);Ie([B(".embla")],Wt.prototype,"emblaNode",2);Ie([B(".embla__viewport")],Wt.prototype,"emblaViewport",2);Ie([B(".embla__button--prev")],Wt.prototype,"emblaPrevButton",2);Ie([B(".embla__button--next")],Wt.prototype,"emblaNextButton",2);Ie([B(".embla__container")],Wt.prototype,"emblaContainerEl",2);Ie([I()],Wt.prototype,"imageSplide",2);Wt=Ie([mt("pbo-category")],Wt);const Kb=Wt,Zb=_e,ob=rt`
|
|
3505
3506
|
:host {
|
|
3506
3507
|
display: block;
|
|
3507
3508
|
width: 100%;
|
|
@@ -3567,6 +3568,13 @@ void main() {
|
|
|
3567
3568
|
transition:
|
|
3568
3569
|
transform 0.2s ease-in-out,
|
|
3569
3570
|
color 0.2s ease-in-out;
|
|
3571
|
+
position: relative;
|
|
3572
|
+
}
|
|
3573
|
+
|
|
3574
|
+
.icon-button::after {
|
|
3575
|
+
content: "";
|
|
3576
|
+
position: absolute;
|
|
3577
|
+
inset: -12px;
|
|
3570
3578
|
}
|
|
3571
3579
|
|
|
3572
3580
|
/* Apply hover effect */
|
|
@@ -3653,26 +3661,26 @@ void main() {
|
|
|
3653
3661
|
height: 100%;
|
|
3654
3662
|
padding: var(--pbo-spacing-large);
|
|
3655
3663
|
}
|
|
3656
|
-
`,ab=
|
|
3664
|
+
`,ab=rt`
|
|
3657
3665
|
:host {
|
|
3658
3666
|
display: block;
|
|
3659
3667
|
}
|
|
3660
|
-
`;var lb=Object.defineProperty,cb=Object.getOwnPropertyDescriptor,Qo=(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 Si=class extends
|
|
3668
|
+
`;var lb=Object.defineProperty,cb=Object.getOwnPropertyDescriptor,Qo=(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 Si=class extends yt{constructor(){super(...arguments),this.categories=[],this.loading=!0}render(){return this.loading?L`
|
|
3661
3669
|
<pbo-category skeleton></pbo-category>
|
|
3662
3670
|
<pbo-category skeleton></pbo-category>
|
|
3663
|
-
`:
|
|
3664
|
-
${fh(this.categories,t=>
|
|
3671
|
+
`:L`
|
|
3672
|
+
${fh(this.categories,t=>L`<pbo-category
|
|
3665
3673
|
.cards=${t.cards}
|
|
3666
3674
|
.name=${t.name}
|
|
3667
3675
|
title=${t.name}
|
|
3668
3676
|
exportparts="category-title"
|
|
3669
3677
|
>
|
|
3670
3678
|
</pbo-category>`)}
|
|
3671
|
-
`}};Si.styles=[
|
|
3679
|
+
`}};Si.styles=[vt,ab];Si.dependencies={"pbo-category":Wt};Qo([C({type:Array})],Si.prototype,"categories",2);Qo([C({type:Boolean,reflect:!0})],Si.prototype,"loading",2);Si=Qo([mt("pbo-card-selection")],Si);var hb=Object.defineProperty,db=Object.getOwnPropertyDescriptor,xt=(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 st=class extends yt{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.hideColor=!1,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 L`
|
|
3672
3680
|
<div part="base" class="page-manager">
|
|
3673
3681
|
<div class="header" part="header">
|
|
3674
3682
|
<div class="back-button" part="back-button">
|
|
3675
|
-
${this.currentPage!=="selection"?
|
|
3683
|
+
${this.currentPage!=="selection"?L`<button
|
|
3676
3684
|
@click=${this.goToSelector}
|
|
3677
3685
|
class="icon-button"
|
|
3678
3686
|
aria-label="Back to card selection"
|
|
@@ -3715,12 +3723,12 @@ void main() {
|
|
|
3715
3723
|
</div>
|
|
3716
3724
|
<!-- Body -->
|
|
3717
3725
|
<div class="body" part="body">
|
|
3718
|
-
${this.isError?
|
|
3726
|
+
${this.isError?L` <div class="error-container" role="alert" aria-live="assertive">
|
|
3719
3727
|
<div class="error-message">
|
|
3720
3728
|
<h4 class="notification">
|
|
3721
3729
|
An error occurred while loading the page. Please refresh the page and try again.
|
|
3722
3730
|
</h4>
|
|
3723
|
-
${this.errorMessage&&this.errorMessage!==""?
|
|
3731
|
+
${this.errorMessage&&this.errorMessage!==""?L`<p class="error-message">${this.errorMessage}</p>`:J}
|
|
3724
3732
|
</div>
|
|
3725
3733
|
<pbo-button
|
|
3726
3734
|
variant="primary"
|
|
@@ -3730,7 +3738,7 @@ void main() {
|
|
|
3730
3738
|
>
|
|
3731
3739
|
Refresh page now
|
|
3732
3740
|
</pbo-button>
|
|
3733
|
-
</div>`:
|
|
3741
|
+
</div>`:J}
|
|
3734
3742
|
<div
|
|
3735
3743
|
class="category-selection"
|
|
3736
3744
|
?hidden=${this.currentPage!=="selection"}
|
|
@@ -3753,6 +3761,7 @@ void main() {
|
|
|
3753
3761
|
.card=${this.selectedCard}
|
|
3754
3762
|
type-form-cta-primary-label=${this.typeFormCtaLabel}
|
|
3755
3763
|
handwritten-form-cta-primary-label=${this.handwrittenFormCtaLabel}
|
|
3764
|
+
?hide-type-form-color-block=${this.hideColor}
|
|
3756
3765
|
.submitTypeForm=${this.submitTypeForm}
|
|
3757
3766
|
.submitHandwrittenForm=${this.submitHandwrittenForm}
|
|
3758
3767
|
.getProcessedImg=${this.getProcessedImg}
|
|
@@ -3762,7 +3771,7 @@ void main() {
|
|
|
3762
3771
|
</div>
|
|
3763
3772
|
</div>
|
|
3764
3773
|
</div>
|
|
3765
|
-
`}};
|
|
3774
|
+
`}};st.styles=[vt,ob];st.dependencies={"pbo-button":lt,"pbo-card-selection":Si,"pbo-editor":bt};xt([B("pbo-card-selection")],st.prototype,"cardSelectionEl",2);xt([B(".title")],st.prototype,"titleEl",2);xt([C({type:Function})],st.prototype,"onClose",2);xt([C({type:String,reflect:!0})],st.prototype,"currentPage",2);xt([C()],st.prototype,"categories",2);xt([C()],st.prototype,"submitTypeForm",2);xt([C()],st.prototype,"submitHandwrittenForm",2);xt([C()],st.prototype,"getProcessedImg",2);xt([C({type:Boolean})],st.prototype,"isLoadingCategories",2);xt([C({type:Boolean})],st.prototype,"isError",2);xt([C({type:String})],st.prototype,"errorMessage",2);xt([C({type:String,attribute:"selection-title"})],st.prototype,"selectionTitle",2);xt([C({type:String,attribute:"editor-title"})],st.prototype,"editorTitle",2);xt([C({type:String,attribute:"type-form-cta-primary-label"})],st.prototype,"typeFormCtaLabel",2);xt([C({type:String,attribute:"handwritten-form-cta-primary-label"})],st.prototype,"handwrittenFormCtaLabel",2);xt([C({type:Boolean,attribute:"hide-type-form-color-block"})],st.prototype,"hideColor",2);xt([I()],st.prototype,"selectedCard",2);xt([I()],st.prototype,"selectedCardId",2);xt([I()],st.prototype,"selectedCardDetails",2);xt([G("getProcessedImg")],st.prototype,"handleGetProcessedImgUpdate",1);xt([G("categories")],st.prototype,"handleCategoriesUpdate",1);st=xt([mt("pbo-page-manager")],st);const tv=st,ev=Si,iv=it,sv=Ae,rv=ht,ub=rt`
|
|
3766
3775
|
:host {
|
|
3767
3776
|
display: block;
|
|
3768
3777
|
width: auto;
|
|
@@ -3827,7 +3836,7 @@ void main() {
|
|
|
3827
3836
|
resize: vertical;
|
|
3828
3837
|
min-height: 96px;
|
|
3829
3838
|
}
|
|
3830
|
-
`;var pb=Object.defineProperty,gb=Object.getOwnPropertyDescriptor,
|
|
3839
|
+
`;var pb=Object.defineProperty,gb=Object.getOwnPropertyDescriptor,Vt=(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 Et=class extends yt{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 L`
|
|
3831
3840
|
<div part="base" class="gift-options" ?hidden=${this.hidden}>
|
|
3832
3841
|
<!-- 🎁 Is this a gift -->
|
|
3833
3842
|
<div class="is-gift" part="is-gift option-container" ?hidden=${!t}>
|
|
@@ -3902,4 +3911,4 @@ void main() {
|
|
|
3902
3911
|
?hidden=${!this.dividerConfig.bottomDivider.visible||!this.isGift&&!this.dividerConfig.bottomDivider.persistent}
|
|
3903
3912
|
/>
|
|
3904
3913
|
</div>
|
|
3905
|
-
`}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};
|
|
3914
|
+
`}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};Et.styles=[vt,ub];Et.dependencies={"pbo-textarea":ct};Vt([C({type:Function})],Et.prototype,"onPremiumSelected",2);Vt([C({type:Function})],Et.prototype,"onFreeMessageChange",2);Vt([C({type:Function})],Et.prototype,"onFreeMessageClear",2);Vt([C({type:Boolean,reflect:!0})],Et.prototype,"hidden",2);Vt([C({type:Boolean,reflect:!0})],Et.prototype,"expand",2);Vt([C({type:Object})],Et.prototype,"dividerConfig",2);Vt([C()],Et.prototype,"freeMessage",2);Vt([C()],Et.prototype,"isGift",2);Vt([C()],Et.prototype,"isPremiumChecked",2);Vt([C()],Et.prototype,"isFreeMessageChecked",2);Vt([I()],Et.prototype,"debouncedFreeMessageChange",2);Vt([G("onFreeMessageChange")],Et.prototype,"handleOnFreeMessageChange",1);Vt([G("isGift")],Et.prototype,"handleIsGiftChange",1);Vt([G("isFreeMessageChecked")],Et.prototype,"handleIsFreeMessageCheckedChange",1);Vt([G("isPremiumChecked")],Et.prototype,"handleIsPremiumCheckedChange",1);Vt([G("freeMessage")],Et.prototype,"handleFreeMessageChange",1);Et=Vt([mt("pbo-gift-options")],Et);const ov=Et,av=as,lv=Qt,cv=Ue;export{Hr as MessageSelector,kb as PboButton,Pb as PboButtonGroup,ev as PboCardSelection,Kb as PboCategory,Zb as PboDrawer,Gb as PboEditor,Xb as PboEditorCardSlider,wm as PboEditorSelector,cv as PboFakeLoading,Ve as PboFontSelector,ov as PboGiftOption,rv as PboHandwrittenCanvas,vm as PboHandwrittenForm,lv as PboImage,tv as PboPageManager,Ab as PboRadioButton,Ib as PboRadioGroup,av as PboSpinner,Fb as PboTextarea,iv as PboTypeCanvas,Yb as PboTypeForm,sv as PboZoomedPreview};
|