@pdfme/ui 5.3.8-dev.50 → 5.3.8-dev.56
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/index.es.js +17 -15
- package/dist/index.umd.js +11 -11
- package/dist/types/__tests__/assets/helper.d.ts +3 -0
- package/dist/types/__tests__/components/Designer.test.d.ts +1 -0
- package/dist/types/__tests__/components/Preview.test.d.ts +1 -0
- package/dist/types/__tests__/helper.test.d.ts +1 -0
- package/dist/types/{components → src/components}/Designer/RightSidebar/ListView/SelectableSortableContainer.d.ts +1 -1
- package/dist/types/src/components/Designer/RightSidebar/ListView/index.d.ts +4 -0
- package/dist/types/{components → src/components}/Paper.d.ts +1 -1
- package/dist/types/{components → src/components}/Preview.d.ts +2 -2
- package/dist/types/src/contexts.d.ts +10 -0
- package/dist/types/{helper.d.ts → src/helper.d.ts} +2 -4
- package/package.json +2 -1
- package/src/helper.ts +10 -5
- package/src/hooks.ts +13 -5
- package/tsconfig.json +8 -10
- package/dist/types/components/Designer/RightSidebar/ListView/index.d.ts +0 -4
- package/dist/types/contexts.d.ts +0 -85
- /package/dist/types/{Designer.d.ts → src/Designer.d.ts} +0 -0
- /package/dist/types/{Form.d.ts → src/Form.d.ts} +0 -0
- /package/dist/types/{Viewer.d.ts → src/Viewer.d.ts} +0 -0
- /package/dist/types/{class.d.ts → src/class.d.ts} +0 -0
- /package/dist/types/{components → src/components}/AppContextProvider.d.ts +0 -0
- /package/dist/types/{components → src/components}/CtlBar.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/Guides.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/Mask.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/Moveable.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/Padding.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/Selecto.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/index.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/LeftSidebar.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/PluginIcon.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/AlignWidget.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/ButtonGroupWidget.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/WidgetRenderer.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/index.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/ListView/Item.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/ListView/SelectableSortableItem.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/index.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/index.d.ts +0 -0
- /package/dist/types/{components → src/components}/ErrorScreen.d.ts +0 -0
- /package/dist/types/{components → src/components}/Renderer.d.ts +0 -0
- /package/dist/types/{components → src/components}/Root.d.ts +0 -0
- /package/dist/types/{components → src/components}/Spinner.d.ts +0 -0
- /package/dist/types/{components → src/components}/StaticSchema.d.ts +0 -0
- /package/dist/types/{components → src/components}/UnitPager.d.ts +0 -0
- /package/dist/types/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/dist/types/{hooks.d.ts → src/hooks.d.ts} +0 -0
- /package/dist/types/{i18n.d.ts → src/i18n.d.ts} +0 -0
- /package/dist/types/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/types/{theme.d.ts → src/theme.d.ts} +0 -0
- /package/dist/types/{types.d.ts → src/types.d.ts} +0 -0
package/dist/index.es.js
CHANGED
@@ -82360,7 +82360,7 @@ const DEFAULT_OPACITY = 1, HEX_COLOR_PATTERN = "^#(?:[A-Fa-f0-9]{6})$", getBody$
|
|
82360
82360
|
});
|
82361
82361
|
};
|
82362
82362
|
/**
|
82363
|
-
* @license lucide v0.
|
82363
|
+
* @license lucide v0.477.0 - ISC
|
82364
82364
|
*
|
82365
82365
|
* This source code is licensed under the ISC license.
|
82366
82366
|
* See the LICENSE file in the root directory of this source tree.
|
@@ -82371,7 +82371,7 @@ const AlignCenter = [
|
|
82371
82371
|
["path", { d: "M21 6H3" }]
|
82372
82372
|
];
|
82373
82373
|
/**
|
82374
|
-
* @license lucide v0.
|
82374
|
+
* @license lucide v0.477.0 - ISC
|
82375
82375
|
*
|
82376
82376
|
* This source code is licensed under the ISC license.
|
82377
82377
|
* See the LICENSE file in the root directory of this source tree.
|
@@ -82382,7 +82382,7 @@ const AlignJustify = [
|
|
82382
82382
|
["path", { d: "M3 6h18" }]
|
82383
82383
|
];
|
82384
82384
|
/**
|
82385
|
-
* @license lucide v0.
|
82385
|
+
* @license lucide v0.477.0 - ISC
|
82386
82386
|
*
|
82387
82387
|
* This source code is licensed under the ISC license.
|
82388
82388
|
* See the LICENSE file in the root directory of this source tree.
|
@@ -82393,7 +82393,7 @@ const AlignLeft = [
|
|
82393
82393
|
["path", { d: "M21 6H3" }]
|
82394
82394
|
];
|
82395
82395
|
/**
|
82396
|
-
* @license lucide v0.
|
82396
|
+
* @license lucide v0.477.0 - ISC
|
82397
82397
|
*
|
82398
82398
|
* This source code is licensed under the ISC license.
|
82399
82399
|
* See the LICENSE file in the root directory of this source tree.
|
@@ -82404,7 +82404,7 @@ const AlignRight = [
|
|
82404
82404
|
["path", { d: "M21 6H3" }]
|
82405
82405
|
];
|
82406
82406
|
/**
|
82407
|
-
* @license lucide v0.
|
82407
|
+
* @license lucide v0.477.0 - ISC
|
82408
82408
|
*
|
82409
82409
|
* This source code is licensed under the ISC license.
|
82410
82410
|
* See the LICENSE file in the root directory of this source tree.
|
@@ -82415,7 +82415,7 @@ const ArrowDownToLine = [
|
|
82415
82415
|
["path", { d: "M19 21H5" }]
|
82416
82416
|
];
|
82417
82417
|
/**
|
82418
|
-
* @license lucide v0.
|
82418
|
+
* @license lucide v0.477.0 - ISC
|
82419
82419
|
*
|
82420
82420
|
* This source code is licensed under the ISC license.
|
82421
82421
|
* See the LICENSE file in the root directory of this source tree.
|
@@ -82426,7 +82426,7 @@ const ArrowUpToLine = [
|
|
82426
82426
|
["path", { d: "M12 7v14" }]
|
82427
82427
|
];
|
82428
82428
|
/**
|
82429
|
-
* @license lucide v0.
|
82429
|
+
* @license lucide v0.477.0 - ISC
|
82430
82430
|
*
|
82431
82431
|
* This source code is licensed under the ISC license.
|
82432
82432
|
* See the LICENSE file in the root directory of this source tree.
|
@@ -82437,7 +82437,7 @@ const Strikethrough = [
|
|
82437
82437
|
["line", { x1: "4", x2: "20", y1: "12", y2: "12" }]
|
82438
82438
|
];
|
82439
82439
|
/**
|
82440
|
-
* @license lucide v0.
|
82440
|
+
* @license lucide v0.477.0 - ISC
|
82441
82441
|
*
|
82442
82442
|
* This source code is licensed under the ISC license.
|
82443
82443
|
* See the LICENSE file in the root directory of this source tree.
|
@@ -82450,7 +82450,7 @@ const TextCursorInput = [
|
|
82450
82450
|
["path", { d: "M9 7v10" }]
|
82451
82451
|
];
|
82452
82452
|
/**
|
82453
|
-
* @license lucide v0.
|
82453
|
+
* @license lucide v0.477.0 - ISC
|
82454
82454
|
*
|
82455
82455
|
* This source code is licensed under the ISC license.
|
82456
82456
|
* See the LICENSE file in the root directory of this source tree.
|
@@ -82888,8 +82888,8 @@ const arrayBufferToBase64 = (a) => {
|
|
82888
82888
|
height: c.height
|
82889
82889
|
}));
|
82890
82890
|
else {
|
82891
|
-
const b = await getB64BasePdf(c);
|
82892
|
-
p = await pdf2size(
|
82891
|
+
const b = await getB64BasePdf(c), g = b64toUint8Array(b);
|
82892
|
+
p = await pdf2size(g);
|
82893
82893
|
}
|
82894
82894
|
const v = d.length, A = p.length;
|
82895
82895
|
return (v < A ? d.concat(new Array(A - v).fill(cloneDeep$1([]))) : d.slice(0, p.length)).map((b, g) => (Object.values(b).forEach((x) => {
|
@@ -138692,11 +138692,13 @@ const { Text: Text$4 } = Typography, Item = React.memo(
|
|
138692
138692
|
() => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII="
|
138693
138693
|
), T = S.map(() => ({ width: B, height: R }));
|
138694
138694
|
} else {
|
138695
|
-
const B = await getB64BasePdf(C),
|
138696
|
-
|
138697
|
-
|
138695
|
+
const B = await getB64BasePdf(C), R = b64toUint8Array(B), O = new ArrayBuffer(R.byteLength);
|
138696
|
+
new Uint8Array(O).set(R);
|
138697
|
+
const [M, _] = await Promise.all([
|
138698
|
+
pdf2size(O),
|
138699
|
+
pdf2img(O.slice(), { scale: u })
|
138698
138700
|
]);
|
138699
|
-
T =
|
138701
|
+
T = M, I = T[0].width * ZOOM, P = T[0].height * ZOOM, $ = _.map(arrayBufferToBase64);
|
138700
138702
|
}
|
138701
138703
|
const E = Math.min(
|
138702
138704
|
getScale(w.width, I),
|
package/dist/index.umd.js
CHANGED
@@ -139,52 +139,52 @@ endstream`,s}copyBytesInto(s,c){this.updateDict();const u=c;c+=this.dict.copyByt
|
|
139
139
|
`,""),q=widthOfTextAtSize(J,y,m,P),Y=heightOfFontAtSize(y,m),Z=I*m*H;k===""&&(k=`\r
|
140
140
|
`);let ee=M;S==="center"?ee+=(B-q)/2:S==="right"&&(ee+=B-q);let re=E-mm2pt(v.position.y)-F-Z;if(v.strikethrough&&q>0){const V=ee+q+1,K=re+Y/3;d.drawLine({start:rotatePoint({x:ee,y:K},j,O.angle),end:rotatePoint({x:V,y:K},j,O.angle),thickness:1/12*m,color:C,opacity:D})}if(v.underline&&q>0){const V=ee+q+1,K=re-Y/12;d.drawLine({start:rotatePoint({x:ee,y:K},j,O.angle),end:rotatePoint({x:V,y:K},j,O.angle),thickness:1/12*m,color:C,opacity:D})}if(O.angle!==0){const V=rotatePoint({x:ee,y:re},j,O.angle);ee=V.x,re=V.y}let ae=P;if(S==="justify"&&k.slice(-1)!==`
|
141
141
|
`){const V=N.segment(J)[Symbol.iterator](),K=Array.from(V).length;ae+=(B-q)/K}d.pushOperators(u.setCharacterSpacing(ae)),d.drawText(J,{x:ee,y:re,rotate:O,size:m,color:C,lineHeight:I*m,font:T,opacity:D})})};/**
|
142
|
-
* @license lucide v0.
|
142
|
+
* @license lucide v0.477.0 - ISC
|
143
143
|
*
|
144
144
|
* This source code is licensed under the ISC license.
|
145
145
|
* See the LICENSE file in the root directory of this source tree.
|
146
146
|
*/const AlignCenter=[["path",{d:"M17 12H7"}],["path",{d:"M19 18H5"}],["path",{d:"M21 6H3"}]];/**
|
147
|
-
* @license lucide v0.
|
147
|
+
* @license lucide v0.477.0 - ISC
|
148
148
|
*
|
149
149
|
* This source code is licensed under the ISC license.
|
150
150
|
* See the LICENSE file in the root directory of this source tree.
|
151
151
|
*/const AlignJustify=[["path",{d:"M3 12h18"}],["path",{d:"M3 18h18"}],["path",{d:"M3 6h18"}]];/**
|
152
|
-
* @license lucide v0.
|
152
|
+
* @license lucide v0.477.0 - ISC
|
153
153
|
*
|
154
154
|
* This source code is licensed under the ISC license.
|
155
155
|
* See the LICENSE file in the root directory of this source tree.
|
156
156
|
*/const AlignLeft=[["path",{d:"M15 12H3"}],["path",{d:"M17 18H3"}],["path",{d:"M21 6H3"}]];/**
|
157
|
-
* @license lucide v0.
|
157
|
+
* @license lucide v0.477.0 - ISC
|
158
158
|
*
|
159
159
|
* This source code is licensed under the ISC license.
|
160
160
|
* See the LICENSE file in the root directory of this source tree.
|
161
161
|
*/const AlignRight=[["path",{d:"M21 12H9"}],["path",{d:"M21 18H7"}],["path",{d:"M21 6H3"}]];/**
|
162
|
-
* @license lucide v0.
|
162
|
+
* @license lucide v0.477.0 - ISC
|
163
163
|
*
|
164
164
|
* This source code is licensed under the ISC license.
|
165
165
|
* See the LICENSE file in the root directory of this source tree.
|
166
166
|
*/const ArrowDownToLine=[["path",{d:"M12 17V3"}],["path",{d:"m6 11 6 6 6-6"}],["path",{d:"M19 21H5"}]];/**
|
167
|
-
* @license lucide v0.
|
167
|
+
* @license lucide v0.477.0 - ISC
|
168
168
|
*
|
169
169
|
* This source code is licensed under the ISC license.
|
170
170
|
* See the LICENSE file in the root directory of this source tree.
|
171
171
|
*/const ArrowUpToLine=[["path",{d:"M5 3h14"}],["path",{d:"m18 13-6-6-6 6"}],["path",{d:"M12 7v14"}]];/**
|
172
|
-
* @license lucide v0.
|
172
|
+
* @license lucide v0.477.0 - ISC
|
173
173
|
*
|
174
174
|
* This source code is licensed under the ISC license.
|
175
175
|
* See the LICENSE file in the root directory of this source tree.
|
176
176
|
*/const Strikethrough=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12"}]];/**
|
177
|
-
* @license lucide v0.
|
177
|
+
* @license lucide v0.477.0 - ISC
|
178
178
|
*
|
179
179
|
* This source code is licensed under the ISC license.
|
180
180
|
* See the LICENSE file in the root directory of this source tree.
|
181
181
|
*/const TextCursorInput=[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7"}],["path",{d:"M9 7v10"}]];/**
|
182
|
-
* @license lucide v0.
|
182
|
+
* @license lucide v0.477.0 - ISC
|
183
183
|
*
|
184
184
|
* This source code is licensed under the ISC license.
|
185
185
|
* See the LICENSE file in the root directory of this source tree.
|
186
186
|
*/const Underline=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20"}]],TextStrikethroughIcon=createSvgStr(Strikethrough),TextUnderlineIcon=createSvgStr(Underline),TextAlignLeftIcon=createSvgStr(AlignLeft),TextAlignCenterIcon=createSvgStr(AlignCenter),TextAlignRightIcon=createSvgStr(AlignRight),TextAlignJustifyIcon=createSvgStr(AlignJustify),TextVerticalAlignTopIcon=createSvgStr(ArrowUpToLine),TextVerticalAlignMiddleIcon='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M8 19h3v4h2v-4h3l-4-4l-4 4zm8-14h-3V1h-2v4H8l4 4l4-4zM4 11v2h16v-2H4z" fill="currentColor"></path></svg>',TextVerticalAlignBottomIcon=createSvgStr(ArrowDownToLine);var Formatter;(function(a){a.STRIKETHROUGH="strikethrough",a.UNDERLINE="underline",a.ALIGNMENT="alignment",a.VERTICAL_ALIGNMENT="verticalAlignment"})(Formatter||(Formatter={}));function getExtraFormatterSchema(a){const s=[{key:Formatter.STRIKETHROUGH,icon:TextStrikethroughIcon,type:"boolean"},{key:Formatter.UNDERLINE,icon:TextUnderlineIcon,type:"boolean"},{key:Formatter.ALIGNMENT,icon:TextAlignLeftIcon,type:"select",value:DEFAULT_ALIGNMENT},{key:Formatter.ALIGNMENT,icon:TextAlignCenterIcon,type:"select",value:ALIGN_CENTER},{key:Formatter.ALIGNMENT,icon:TextAlignRightIcon,type:"select",value:ALIGN_RIGHT},{key:Formatter.ALIGNMENT,icon:TextAlignJustifyIcon,type:"select",value:ALIGN_JUSTIFY},{key:Formatter.VERTICAL_ALIGNMENT,icon:TextVerticalAlignTopIcon,type:"select",value:DEFAULT_VERTICAL_ALIGNMENT},{key:Formatter.VERTICAL_ALIGNMENT,icon:TextVerticalAlignMiddleIcon,type:"select",value:VERTICAL_ALIGN_MIDDLE},{key:Formatter.VERTICAL_ALIGNMENT,icon:TextVerticalAlignBottomIcon,type:"select",value:VERTICAL_ALIGN_BOTTOM}];return{title:a("schemas.text.format"),widget:"ButtonGroup",buttons:s,span:24}}const UseDynamicFontSize=a=>{const{rootElement:s,changeSchemas:c,activeSchema:u,i18n:d}=a,p=document.createElement("input");p.type="checkbox",p.checked=!!(u!=null&&u.dynamicFontSize),p.onchange=b=>{const g=b.target.checked?{min:DEFAULT_DYNAMIC_MIN_FONT_SIZE,max:DEFAULT_DYNAMIC_MAX_FONT_SIZE,fit:DEFAULT_DYNAMIC_FIT}:void 0;c([{key:"dynamicFontSize",value:g,schemaId:u.id}])};const v=document.createElement("label"),A=document.createElement("span");A.innerText=d("schemas.text.dynamicFontSize")||"",A.style.cssText="margin-left: 0.5rem",v.style.cssText="display: flex; width: 100%;",v.appendChild(p),v.appendChild(A),s.appendChild(v)},propPanel={schema:({options:a,activeSchema:s,i18n:c})=>{const u=a.font||{[DEFAULT_FONT_NAME]:{data:"",fallback:!0}},d=Object.keys(u),p=getFallbackFontName(u),v=!!(s!=null&&s.dynamicFontSize);return{fontName:{title:c("schemas.text.fontName"),type:"string",widget:"select",default:p,placeholder:p,props:{options:d.map(b=>({label:b,value:b}))},span:12},fontSize:{title:c("schemas.text.size"),type:"number",widget:"inputNumber",span:6,disabled:v,props:{min:0}},characterSpacing:{title:c("schemas.text.spacing"),type:"number",widget:"inputNumber",span:6,props:{min:0}},formatter:getExtraFormatterSchema(c),lineHeight:{title:c("schemas.text.lineHeight"),type:"number",widget:"inputNumber",props:{step:.1,min:0},span:8},useDynamicFontSize:{type:"boolean",widget:"UseDynamicFontSize",bind:!1,span:16},dynamicFontSize:{type:"object",widget:"card",column:3,properties:{min:{title:c("schemas.text.min"),type:"number",widget:"inputNumber",hidden:!v,props:{min:0}},max:{title:c("schemas.text.max"),type:"number",widget:"inputNumber",hidden:!v,props:{min:0}},fit:{title:c("schemas.text.fit"),type:"string",widget:"select",hidden:!v,props:{options:[{label:c("schemas.horizontal"),value:DYNAMIC_FIT_HORIZONTAL},{label:c("schemas.vertical"),value:DYNAMIC_FIT_VERTICAL}]}}}},fontColor:{title:c("schemas.textColor"),type:"string",widget:"color",props:{disabledAlpha:!0},rules:[{pattern:HEX_COLOR_PATTERN,message:c("validation.hexColor")}]},backgroundColor:{title:c("schemas.bgColor"),type:"string",widget:"color",props:{disabledAlpha:!0},rules:[{pattern:HEX_COLOR_PATTERN,message:c("validation.hexColor")}]}}},widgets:{UseDynamicFontSize},defaultSchema:{name:"",type:"text",content:"Type Something...",position:{x:0,y:0},width:45,height:10,rotate:0,alignment:DEFAULT_ALIGNMENT,verticalAlignment:DEFAULT_VERTICAL_ALIGNMENT,fontSize:DEFAULT_FONT_SIZE,lineHeight:DEFAULT_LINE_HEIGHT,characterSpacing:DEFAULT_CHARACTER_SPACING,dynamicFontSize:void 0,fontColor:DEFAULT_FONT_COLOR,fontName:void 0,backgroundColor:"",opacity:DEFAULT_OPACITY,strikethrough:!1,underline:!1}},replaceUnsupportedChars=(a,s)=>{const c={},u=p=>{if(p in c)return c[p];const v=s.hasGlyphForCodePoint(p.codePointAt(0)||0);return c[p]=v,v};return a.split(/(\r\n|\n|\r)/).map(p=>/\r\n|\n|\r/.test(p)?p:p.split("").map(v=>/\s/.test(v)||v.charCodeAt(0)<32||u(v)?v:"〿").join("")).join("")},uiRender=async a=>{const{value:s,schema:c,mode:u,onChange:d,stopEditing:p,tabIndex:v,placeholder:A,options:b,_cache:g}=a,x=isEditable(u,c)&&A&&!s,y=w=>{let I=w.innerText;return I.endsWith(`
|
187
|
-
`)&&(I=I.slice(0,-1)),I},f=(b==null?void 0:b.font)||getDefaultFont(),m=await getFontKitFont(c.fontName,f,g),C=buildStyledTextContainer(a,m,x?A:s),S=replaceUnsupportedChars(s,m);if(!isEditable(u,c)){C.innerHTML=S.split("").map((w,I)=>`<span style="letter-spacing:${String(s).length===I+1?0:"inherit"};">${w}</span>`).join("");return}if(makeElementPlainTextContentEditable(C),C.tabIndex=v||0,C.innerText=u==="designer"?s:S,C.addEventListener("blur",w=>{d&&d({key:"content",value:y(w.target)}),p&&p()}),c.dynamicFontSize){let w;C.addEventListener("keyup",()=>{setTimeout(()=>{(async()=>{if(!C.textContent)return;w=calculateDynamicFontSize({textSchema:c,fontKitFont:m,value:y(C),startingFontSize:w}),C.style.fontSize=`${w}pt`;const{topAdj:I,bottomAdj:P}=getBrowserVerticalFontAdjustments(m,w??c.fontSize??DEFAULT_FONT_SIZE,c.lineHeight??DEFAULT_LINE_HEIGHT,c.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT);C.style.paddingTop=`${I}px`,C.style.marginBottom=`${P}px`})()},0)})}x&&(C.style.color=PLACEHOLDER_FONT_COLOR,C.addEventListener("focus",()=>{C.innerText===A&&(C.innerText="",C.style.color=c.fontColor??DEFAULT_FONT_COLOR)})),u==="designer"&&setTimeout(()=>{C.focus();const w=window.getSelection(),I=document.createRange();w&&I&&(I.selectNodeContents(C),I.collapse(!1),w==null||w.removeAllRanges(),w==null||w.addRange(I))})},buildStyledTextContainer=(a,s,c)=>{const{schema:u,rootElement:d,mode:p,options:v,_cache:A}=a;v!=null&&v.font||getDefaultFont();let b;u.dynamicFontSize&&c&&(b=calculateDynamicFontSize({textSchema:u,fontKitFont:s,value:c,startingFontSize:b}));const{topAdj:g,bottomAdj:x}=getBrowserVerticalFontAdjustments(s,b??u.fontSize??DEFAULT_FONT_SIZE,u.lineHeight??DEFAULT_LINE_HEIGHT,u.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT),y=g.toString(),f=x.toString(),m=document.createElement("div"),C={padding:0,resize:"none",backgroundColor:getBackgroundColor(c,u),border:"none",display:"flex",flexDirection:"column",justifyContent:mapVerticalAlignToFlex(u.verticalAlignment),width:"100%",height:"100%",cursor:isEditable(p,u)?"text":"default"};Object.assign(m.style,C),d.innerHTML="",d.appendChild(m);const S=[];u.strikethrough&&S.push("line-through"),u.underline&&S.push("underline");const w={fontFamily:u.fontName?`'${u.fontName}'`:"inherit",color:u.fontColor?u.fontColor:DEFAULT_FONT_COLOR,fontSize:`${b??u.fontSize??DEFAULT_FONT_SIZE}pt`,letterSpacing:`${u.characterSpacing??DEFAULT_CHARACTER_SPACING}pt`,lineHeight:`${u.lineHeight??DEFAULT_LINE_HEIGHT}em`,textAlign:u.alignment??DEFAULT_ALIGNMENT,whiteSpace:"pre-wrap",wordBreak:"break-word",resize:"none",border:"none",outline:"none",marginBottom:`${f}px`,paddingTop:`${y}px`,backgroundColor:"transparent",textDecoration:S.join(" ")},I=document.createElement("div");return I.id="text-"+String(u.id),Object.assign(I.style,w),m.appendChild(I),I},makeElementPlainTextContentEditable=a=>{if(!isFirefox()){a.contentEditable="plaintext-only";return}a.contentEditable="true",a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),document.execCommand("insertLineBreak",!1,void 0))}),a.addEventListener("paste",s=>{var d;s.preventDefault();const c=(d=s.clipboardData)==null?void 0:d.getData("text"),u=window.getSelection();u!=null&&u.rangeCount&&(u.deleteFromDocument(),u.getRangeAt(0).insertNode(document.createTextNode(c||"")),u.collapseToEnd())})},mapVerticalAlignToFlex=a=>{switch(a){case VERTICAL_ALIGN_TOP:return"flex-start";case VERTICAL_ALIGN_MIDDLE:return"center";case VERTICAL_ALIGN_BOTTOM:return"flex-end"}return"flex-start"},getBackgroundColor=(a,s)=>!a||!s.backgroundColor?"transparent":s.backgroundColor,textSchema={pdf:pdfRender,ui:uiRender,propPanel,icon:createSvgStr(TextCursorInput)},builtInPlugins={Text:textSchema},I18nContext=reactExports.createContext(i18n),FontContext=reactExports.createContext(getDefaultFont()),PluginsRegistry=reactExports.createContext(builtInPlugins),OptionsContext=reactExports.createContext({}),CacheContext=reactExports.createContext(new Map),hotkeys=function(a,s){return hotkeys$1(a,s)};hotkeys.shift=!1,hotkeys.unbind=function(a){typeof hotkeys$1.unbind=="function"&&hotkeys$1.unbind(a)};const uuid$6=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const s=Math.random()*16|0;return(a=="x"?s:s&3|8).toString(16)}),set$2=(a,s,c)=>{s=Array.isArray(s)?s:s.replace("[",".").replace("]","").split(".");let u=a;s.forEach((d,p,v)=>{if(p==s.length-1)u[d]=c;else{if(!u.hasOwnProperty(d)){const A=v[p+1];u[d]=String(Number(A))===A?[]:{}}u=u[d]}})},debounce$1=(a,s=20)=>{let c=null;return(...d)=>{c&&clearTimeout(c),c=setTimeout(()=>a(...d),s)}},shift=(a,s,c)=>{c&&(s=-s);const u=`${a}`.split("e");return+`${u[0]}e${u[1]?Number(u[1])+s:s}`},round$1=(a,s)=>shift(Math.round(shift(a,s,!1)),s,!0),flatten=a=>[].concat(...a),up="up",shiftUp="shift+up",down="down",shiftDown="shift+down",left="left",shiftLeft="shift+left",right="right",shiftRight="shift+right",rmWin="backspace",rmMac="delete",esc="esc",copyWin="ctrl+c",copyMac="command+c",pasteWin="ctrl+v",pasteMac="command+v",redoWin="ctrl+y",redoMac="shift+command+z",undoWin="ctrl+z",undoMac="command+z",saveWin="ctrl+s",saveMac="command+s",selectAllWin="ctrl+a",selectAllMac="command+a",keys$2=[up,shiftUp,down,shiftDown,left,shiftLeft,right,shiftRight,rmMac,rmWin,esc,copyWin,copyMac,pasteWin,pasteMac,redoWin,redoMac,undoWin,undoMac,saveWin,saveMac,selectAllWin,selectAllMac],initShortCuts=a=>{hotkeys(keys$2.join(),(s,c)=>{switch(c.shortcut){case up:case shiftUp:s.preventDefault(),a.move("up",hotkeys.shift);break;case down:case shiftDown:s.preventDefault(),a.move("down",hotkeys.shift);break;case left:case shiftLeft:s.preventDefault(),a.move("left",hotkeys.shift);break;case right:case shiftRight:s.preventDefault(),a.move("right",hotkeys.shift);break;case rmWin:case rmMac:a.remove();break;case esc:a.esc();break;case copyWin:case copyMac:a.copy();break;case pasteWin:case pasteMac:a.paste();break;case redoWin:case redoMac:a.redo();break;case undoWin:case undoMac:a.undo();break;case saveWin:case saveMac:s.preventDefault(),a.save();break;case selectAllWin:case selectAllMac:s.preventDefault(),a.selectAll();break}})},destroyShortCuts=()=>{hotkeys.unbind(keys$2.join())};function detectMimeType(a){const s=new DataView(a);return s.getUint8(0)===137&&s.getUint8(1)===80&&s.getUint8(2)===78&&s.getUint8(3)===71?"image/png":s.getUint8(0)===255&&s.getUint8(1)===216&&s.getUint8(2)===255?"image/jpeg":""}const arrayBufferToBase64=a=>{const s=detectMimeType(a),c=new Uint8Array(a);let u="";for(let p=0;p<c.length;p++)u+=String.fromCharCode(c[p]);const d=btoa(u);return s?`data:${s};base64,${d}`:`data:application/octet-stream;base64,${d}`},convertSchemasForUI=a=>(a.schemas.forEach(s=>{s.forEach(c=>{c.id=uuid$6(),c.content=c.content||""})}),a.schemas),template2SchemasList=async a=>{const s=cloneDeep$1(a),{basePdf:c,schemas:u}=s,d=convertSchemasForUI(s);let p=[];if(isBlankPdf(c))p=u.map(()=>({width:c.width,height:c.height}));else{const b=await getB64BasePdf(c);p=await pdf2size(b64toUint8Array(b))}const v=d.length,A=p.length;return(v<A?d.concat(new Array(A-v).fill(cloneDeep$1([]))):d.slice(0,p.length)).map((b,g)=>(Object.values(b).forEach(x=>{const{width:y,height:f}=p[g],m=x.position.x+x.width,C=x.position.y+x.height;if(y<m){const S=m-y;x.position.x+=S}if(f<C){const S=C-f;x.position.y+=S}}),b))},schemasList2template=(a,s)=>({schemas:cloneDeep$1(a).map(c=>c.map(u=>(delete u.id,u))),basePdf:s}),getUniqueSchemaName=a=>{const{copiedSchemaName:s,schema:c,stackUniqueSchemaNames:u}=a,d=c.map(g=>g.name).concat(u),p=d.reduce((g,x)=>Object.assign(g,{originalName:x,copiedNum:0}),{}),v=g=>g.replace(/ copy$| copy [0-9]*$/,"");d.filter(g=>/ copy$| copy [0-9]*$/.test(g)).forEach(g=>{const x=v(g),y=g.match(/[0-9]*$/),f=y&&y[0]?Number(y[0]):1;(p[x]??0)<f&&(p[x]=f)});const A=v(s);if(p[A]){const g=p[A],x=`${A} copy ${g+1}`;return u.push(x),x}const b=`${s} copy`;return u.push(b),b},moveCommandToChangeSchemasArg=a=>{const{command:s,activeSchemas:c,isShift:u,pageSize:d}=a,p=s==="up"||s==="down"?"y":"x",v=u?.1:1,A=b=>{let g=0;const{position:x}=b;switch(s){case"up":g=round$1(x.y-v,2);break;case"down":g=round$1(x.y+v,2);break;case"left":g=round$1(x.x-v,2);break;case"right":g=round$1(x.x+v,2);break}return g>0?g:0};return c.map(b=>{let g=A(b);const{width:x,height:y}=b;return p==="x"?g=g>d.width-x?round$1(d.width-x,2):g:g=g>d.height-y?round$1(d.height-y,2):g,{key:`position.${p}`,value:g,schemaId:b.id}})},getPagesScrollTopByIndex=(a,s,c)=>a.slice(0,s).reduce((u,d)=>u+(d.height*ZOOM+RULER_HEIGHT*c)*c,0),getSidebarContentHeight=a=>a-RULER_HEIGHT-RULER_HEIGHT/2-30,handlePositionSizeChange=(a,s,c,u,d)=>{const p=isBlankPdf(u)?u.padding:[0,0,0,0],[v,A,b,g]=p,{width:x,height:y}=d,f=(m,C,S)=>Math.min(Math.max(Number(m),C),S);s==="position.x"?a.position.x=f(c,g,x-a.width-A):s==="position.y"?a.position.y=f(c,v,y-a.height-b):s==="width"?a.width=f(c,0,x-a.position.x-A):s==="height"&&(a.height=f(c,0,y-a.position.y-b))},handleTypeChange=(a,s,c,u)=>{var v;if(s!=="type")return;const d=["id","name","type","position","required"];Object.keys(a).forEach(A=>{d.includes(A)||delete a[A]});const p=(v=Object.values(u).find(A=>(A==null?void 0:A.propPanel.defaultSchema.type)===c))==null?void 0:v.propPanel;Object.keys((p==null?void 0:p.defaultSchema)||{}).forEach(A=>{a.hasOwnProperty(A)||(a[A]=p==null?void 0:p.defaultSchema[A])}),a.readOnly&&(a.required=!1)},changeSchemas=a=>{const{objs:s,schemas:c,basePdf:u,pluginsRegistry:d,pageSize:p,commitSchemas:v}=a,A=s.reduce((b,{key:g,value:x,schemaId:y})=>{const f=b.find(m=>m.id===y);return f&&(set$2(f,g,x),g==="type"?handleTypeChange(f,g,x,d):["position.x","position.y","width","height"].includes(g)&&handlePositionSizeChange(f,g,x,u,p)),b},cloneDeep$1(c));v(A)},getMaxZoom=()=>{const a=reactExports.useContext(OptionsContext);return a.maxZoom?a.maxZoom/100:DEFAULT_MAX_ZOOM};class BaseUIClass{constructor(s){this.lang=DEFAULT_LANG,this.font=getDefaultFont(),this.pluginsRegistry=builtInPlugins,this.options={},this.setSize=debounce$1(()=>{if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.render()},100),this.resizeObserver=new ResizeObserver(this.setSize),checkUIProps(s);const{domContainer:c,template:u,options:d={},plugins:p={}}=s;this.domContainer=c,this.template=cloneDeep$1(u),this.options=d,this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.resizeObserver.observe(this.domContainer);const{lang:v,font:A}=d;v&&(this.lang=v),A&&(this.font=A),Object.values(p).length>0&&(this.pluginsRegistry=p)}getLang(){return this.lang}getFont(){return this.font}getPluginsRegistry(){return this.pluginsRegistry}getOptions(){return this.options}getTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$1(s),this.render()}updateOptions(s){checkUIOptions(s);const{lang:c,font:u}=s||{};c&&(this.lang=c),u&&(this.font=u),this.options=Object.assign(this.options,s),this.render()}destroy(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.unmountComponentAtNode(this.domContainer),this.resizeObserver.unobserve(this.domContainer),this.domContainer=null}}class PreviewUI extends BaseUIClass{constructor(s){super(s),checkPreviewProps(s),this.inputs=convertToStingObjectArray(cloneDeep$1(s.inputs))}getInputs(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.inputs}setInputs(s){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);checkInputs(s),this.inputs=convertToStingObjectArray(s),this.render()}}function convertToStingObjectArray(a){return a.map(s=>{const c={};return Object.keys(s).forEach(u=>{const d=s[u];Array.isArray(d)?c[u]=JSON.stringify(d):c[u]=d}),c})}function useCombinedRefs(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return reactExports.useMemo(()=>u=>{s.forEach(d=>d(u))},s)}const canUseDOM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function isWindow$4(a){const s=Object.prototype.toString.call(a);return s==="[object Window]"||s==="[object global]"}function isNode$1(a){return"nodeType"in a}function getWindow$1(a){var s,c;return a?isWindow$4(a)?a:isNode$1(a)&&(s=(c=a.ownerDocument)==null?void 0:c.defaultView)!=null?s:window:window}function isDocument(a){const{Document:s}=getWindow$1(a);return a instanceof s}function isHTMLElement(a){return isWindow$4(a)?!1:a instanceof getWindow$1(a).HTMLElement}function isSVGElement(a){return a instanceof getWindow$1(a).SVGElement}function getOwnerDocument(a){return a?isWindow$4(a)?a.document:isNode$1(a)?isDocument(a)?a:isHTMLElement(a)||isSVGElement(a)?a.ownerDocument:document:document:document}const useIsomorphicLayoutEffect$1=canUseDOM?reactExports.useLayoutEffect:reactExports.useEffect;function useEvent$1(a){const s=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{s.current=a}),reactExports.useCallback(function(){for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return s.current==null?void 0:s.current(...u)},[])}function useInterval(){const a=reactExports.useRef(null),s=reactExports.useCallback((u,d)=>{a.current=setInterval(u,d)},[]),c=reactExports.useCallback(()=>{a.current!==null&&(clearInterval(a.current),a.current=null)},[]);return[s,c]}function useLatestValue(a,s){s===void 0&&(s=[a]);const c=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{c.current!==a&&(c.current=a)},s),c}function useLazyMemo(a,s){const c=reactExports.useRef();return reactExports.useMemo(()=>{const u=a(c.current);return c.current=u,u},[...s])}function useNodeRef(a){const s=useEvent$1(a),c=reactExports.useRef(null),u=reactExports.useCallback(d=>{d!==c.current&&(s==null||s(d,c.current)),c.current=d},[]);return[c,u]}function usePrevious$2(a){const s=reactExports.useRef();return reactExports.useEffect(()=>{s.current=a},[a]),s.current}let ids={};function useUniqueId(a,s){return reactExports.useMemo(()=>{if(s)return s;const c=ids[a]==null?0:ids[a]+1;return ids[a]=c,a+"-"+c},[a,s])}function createAdjustmentFn(a){return function(s){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];return u.reduce((p,v)=>{const A=Object.entries(v);for(const[b,g]of A){const x=p[b];x!=null&&(p[b]=x+a*g)}return p},{...s})}}const add$1=createAdjustmentFn(1),subtract=createAdjustmentFn(-1);function hasViewportRelativeCoordinates(a){return"clientX"in a&&"clientY"in a}function isKeyboardEvent(a){if(!a)return!1;const{KeyboardEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function isTouchEvent(a){if(!a)return!1;const{TouchEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function getEventCoordinates(a){if(isTouchEvent(a)){if(a.touches&&a.touches.length){const{clientX:s,clientY:c}=a.touches[0];return{x:s,y:c}}else if(a.changedTouches&&a.changedTouches.length){const{clientX:s,clientY:c}=a.changedTouches[0];return{x:s,y:c}}}return hasViewportRelativeCoordinates(a)?{x:a.clientX,y:a.clientY}:null}const CSS$1=Object.freeze({Translate:{toString(a){if(!a)return;const{x:s,y:c}=a;return"translate3d("+(s?Math.round(s):0)+"px, "+(c?Math.round(c):0)+"px, 0)"}},Scale:{toString(a){if(!a)return;const{scaleX:s,scaleY:c}=a;return"scaleX("+s+") scaleY("+c+")"}},Transform:{toString(a){if(a)return[CSS$1.Translate.toString(a),CSS$1.Scale.toString(a)].join(" ")}},Transition:{toString(a){let{property:s,duration:c,easing:u}=a;return s+" "+c+"ms "+u}}}),SELECTOR="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function findFirstFocusableNode(a){return a.matches(SELECTOR)?a:a.querySelector(SELECTOR)}const hiddenStyles={display:"none"};function HiddenText(a){let{id:s,value:c}=a;return React.createElement("div",{id:s,style:hiddenStyles},c)}function LiveRegion(a){let{id:s,announcement:c,ariaLiveType:u="assertive"}=a;const d={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return React.createElement("div",{id:s,style:d,role:"status","aria-live":u,"aria-atomic":!0},c)}function useAnnouncement(){const[a,s]=reactExports.useState("");return{announce:reactExports.useCallback(u=>{u!=null&&s(u)},[]),announcement:a}}const DndMonitorContext=reactExports.createContext(null);function useDndMonitor(a){const s=reactExports.useContext(DndMonitorContext);reactExports.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(a)},[a,s])}function useDndMonitorProvider(){const[a]=reactExports.useState(()=>new Set),s=reactExports.useCallback(u=>(a.add(u),()=>a.delete(u)),[a]);return[reactExports.useCallback(u=>{let{type:d,event:p}=u;a.forEach(v=>{var A;return(A=v[d])==null?void 0:A.call(v,p)})},[a]),s]}const defaultScreenReaderInstructions={draggable:`
|
187
|
+
`)&&(I=I.slice(0,-1)),I},f=(b==null?void 0:b.font)||getDefaultFont(),m=await getFontKitFont(c.fontName,f,g),C=buildStyledTextContainer(a,m,x?A:s),S=replaceUnsupportedChars(s,m);if(!isEditable(u,c)){C.innerHTML=S.split("").map((w,I)=>`<span style="letter-spacing:${String(s).length===I+1?0:"inherit"};">${w}</span>`).join("");return}if(makeElementPlainTextContentEditable(C),C.tabIndex=v||0,C.innerText=u==="designer"?s:S,C.addEventListener("blur",w=>{d&&d({key:"content",value:y(w.target)}),p&&p()}),c.dynamicFontSize){let w;C.addEventListener("keyup",()=>{setTimeout(()=>{(async()=>{if(!C.textContent)return;w=calculateDynamicFontSize({textSchema:c,fontKitFont:m,value:y(C),startingFontSize:w}),C.style.fontSize=`${w}pt`;const{topAdj:I,bottomAdj:P}=getBrowserVerticalFontAdjustments(m,w??c.fontSize??DEFAULT_FONT_SIZE,c.lineHeight??DEFAULT_LINE_HEIGHT,c.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT);C.style.paddingTop=`${I}px`,C.style.marginBottom=`${P}px`})()},0)})}x&&(C.style.color=PLACEHOLDER_FONT_COLOR,C.addEventListener("focus",()=>{C.innerText===A&&(C.innerText="",C.style.color=c.fontColor??DEFAULT_FONT_COLOR)})),u==="designer"&&setTimeout(()=>{C.focus();const w=window.getSelection(),I=document.createRange();w&&I&&(I.selectNodeContents(C),I.collapse(!1),w==null||w.removeAllRanges(),w==null||w.addRange(I))})},buildStyledTextContainer=(a,s,c)=>{const{schema:u,rootElement:d,mode:p,options:v,_cache:A}=a;v!=null&&v.font||getDefaultFont();let b;u.dynamicFontSize&&c&&(b=calculateDynamicFontSize({textSchema:u,fontKitFont:s,value:c,startingFontSize:b}));const{topAdj:g,bottomAdj:x}=getBrowserVerticalFontAdjustments(s,b??u.fontSize??DEFAULT_FONT_SIZE,u.lineHeight??DEFAULT_LINE_HEIGHT,u.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT),y=g.toString(),f=x.toString(),m=document.createElement("div"),C={padding:0,resize:"none",backgroundColor:getBackgroundColor(c,u),border:"none",display:"flex",flexDirection:"column",justifyContent:mapVerticalAlignToFlex(u.verticalAlignment),width:"100%",height:"100%",cursor:isEditable(p,u)?"text":"default"};Object.assign(m.style,C),d.innerHTML="",d.appendChild(m);const S=[];u.strikethrough&&S.push("line-through"),u.underline&&S.push("underline");const w={fontFamily:u.fontName?`'${u.fontName}'`:"inherit",color:u.fontColor?u.fontColor:DEFAULT_FONT_COLOR,fontSize:`${b??u.fontSize??DEFAULT_FONT_SIZE}pt`,letterSpacing:`${u.characterSpacing??DEFAULT_CHARACTER_SPACING}pt`,lineHeight:`${u.lineHeight??DEFAULT_LINE_HEIGHT}em`,textAlign:u.alignment??DEFAULT_ALIGNMENT,whiteSpace:"pre-wrap",wordBreak:"break-word",resize:"none",border:"none",outline:"none",marginBottom:`${f}px`,paddingTop:`${y}px`,backgroundColor:"transparent",textDecoration:S.join(" ")},I=document.createElement("div");return I.id="text-"+String(u.id),Object.assign(I.style,w),m.appendChild(I),I},makeElementPlainTextContentEditable=a=>{if(!isFirefox()){a.contentEditable="plaintext-only";return}a.contentEditable="true",a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),document.execCommand("insertLineBreak",!1,void 0))}),a.addEventListener("paste",s=>{var d;s.preventDefault();const c=(d=s.clipboardData)==null?void 0:d.getData("text"),u=window.getSelection();u!=null&&u.rangeCount&&(u.deleteFromDocument(),u.getRangeAt(0).insertNode(document.createTextNode(c||"")),u.collapseToEnd())})},mapVerticalAlignToFlex=a=>{switch(a){case VERTICAL_ALIGN_TOP:return"flex-start";case VERTICAL_ALIGN_MIDDLE:return"center";case VERTICAL_ALIGN_BOTTOM:return"flex-end"}return"flex-start"},getBackgroundColor=(a,s)=>!a||!s.backgroundColor?"transparent":s.backgroundColor,textSchema={pdf:pdfRender,ui:uiRender,propPanel,icon:createSvgStr(TextCursorInput)},builtInPlugins={Text:textSchema},I18nContext=reactExports.createContext(i18n),FontContext=reactExports.createContext(getDefaultFont()),PluginsRegistry=reactExports.createContext(builtInPlugins),OptionsContext=reactExports.createContext({}),CacheContext=reactExports.createContext(new Map),hotkeys=function(a,s){return hotkeys$1(a,s)};hotkeys.shift=!1,hotkeys.unbind=function(a){typeof hotkeys$1.unbind=="function"&&hotkeys$1.unbind(a)};const uuid$6=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const s=Math.random()*16|0;return(a=="x"?s:s&3|8).toString(16)}),set$2=(a,s,c)=>{s=Array.isArray(s)?s:s.replace("[",".").replace("]","").split(".");let u=a;s.forEach((d,p,v)=>{if(p==s.length-1)u[d]=c;else{if(!u.hasOwnProperty(d)){const A=v[p+1];u[d]=String(Number(A))===A?[]:{}}u=u[d]}})},debounce$1=(a,s=20)=>{let c=null;return(...d)=>{c&&clearTimeout(c),c=setTimeout(()=>a(...d),s)}},shift=(a,s,c)=>{c&&(s=-s);const u=`${a}`.split("e");return+`${u[0]}e${u[1]?Number(u[1])+s:s}`},round$1=(a,s)=>shift(Math.round(shift(a,s,!1)),s,!0),flatten=a=>[].concat(...a),up="up",shiftUp="shift+up",down="down",shiftDown="shift+down",left="left",shiftLeft="shift+left",right="right",shiftRight="shift+right",rmWin="backspace",rmMac="delete",esc="esc",copyWin="ctrl+c",copyMac="command+c",pasteWin="ctrl+v",pasteMac="command+v",redoWin="ctrl+y",redoMac="shift+command+z",undoWin="ctrl+z",undoMac="command+z",saveWin="ctrl+s",saveMac="command+s",selectAllWin="ctrl+a",selectAllMac="command+a",keys$2=[up,shiftUp,down,shiftDown,left,shiftLeft,right,shiftRight,rmMac,rmWin,esc,copyWin,copyMac,pasteWin,pasteMac,redoWin,redoMac,undoWin,undoMac,saveWin,saveMac,selectAllWin,selectAllMac],initShortCuts=a=>{hotkeys(keys$2.join(),(s,c)=>{switch(c.shortcut){case up:case shiftUp:s.preventDefault(),a.move("up",hotkeys.shift);break;case down:case shiftDown:s.preventDefault(),a.move("down",hotkeys.shift);break;case left:case shiftLeft:s.preventDefault(),a.move("left",hotkeys.shift);break;case right:case shiftRight:s.preventDefault(),a.move("right",hotkeys.shift);break;case rmWin:case rmMac:a.remove();break;case esc:a.esc();break;case copyWin:case copyMac:a.copy();break;case pasteWin:case pasteMac:a.paste();break;case redoWin:case redoMac:a.redo();break;case undoWin:case undoMac:a.undo();break;case saveWin:case saveMac:s.preventDefault(),a.save();break;case selectAllWin:case selectAllMac:s.preventDefault(),a.selectAll();break}})},destroyShortCuts=()=>{hotkeys.unbind(keys$2.join())};function detectMimeType(a){const s=new DataView(a);return s.getUint8(0)===137&&s.getUint8(1)===80&&s.getUint8(2)===78&&s.getUint8(3)===71?"image/png":s.getUint8(0)===255&&s.getUint8(1)===216&&s.getUint8(2)===255?"image/jpeg":""}const arrayBufferToBase64=a=>{const s=detectMimeType(a),c=new Uint8Array(a);let u="";for(let p=0;p<c.length;p++)u+=String.fromCharCode(c[p]);const d=btoa(u);return s?`data:${s};base64,${d}`:`data:application/octet-stream;base64,${d}`},convertSchemasForUI=a=>(a.schemas.forEach(s=>{s.forEach(c=>{c.id=uuid$6(),c.content=c.content||""})}),a.schemas),template2SchemasList=async a=>{const s=cloneDeep$1(a),{basePdf:c,schemas:u}=s,d=convertSchemasForUI(s);let p=[];if(isBlankPdf(c))p=u.map(()=>({width:c.width,height:c.height}));else{const b=await getB64BasePdf(c),g=b64toUint8Array(b);p=await pdf2size(g)}const v=d.length,A=p.length;return(v<A?d.concat(new Array(A-v).fill(cloneDeep$1([]))):d.slice(0,p.length)).map((b,g)=>(Object.values(b).forEach(x=>{const{width:y,height:f}=p[g],m=x.position.x+x.width,C=x.position.y+x.height;if(y<m){const S=m-y;x.position.x+=S}if(f<C){const S=C-f;x.position.y+=S}}),b))},schemasList2template=(a,s)=>({schemas:cloneDeep$1(a).map(c=>c.map(u=>(delete u.id,u))),basePdf:s}),getUniqueSchemaName=a=>{const{copiedSchemaName:s,schema:c,stackUniqueSchemaNames:u}=a,d=c.map(g=>g.name).concat(u),p=d.reduce((g,x)=>Object.assign(g,{originalName:x,copiedNum:0}),{}),v=g=>g.replace(/ copy$| copy [0-9]*$/,"");d.filter(g=>/ copy$| copy [0-9]*$/.test(g)).forEach(g=>{const x=v(g),y=g.match(/[0-9]*$/),f=y&&y[0]?Number(y[0]):1;(p[x]??0)<f&&(p[x]=f)});const A=v(s);if(p[A]){const g=p[A],x=`${A} copy ${g+1}`;return u.push(x),x}const b=`${s} copy`;return u.push(b),b},moveCommandToChangeSchemasArg=a=>{const{command:s,activeSchemas:c,isShift:u,pageSize:d}=a,p=s==="up"||s==="down"?"y":"x",v=u?.1:1,A=b=>{let g=0;const{position:x}=b;switch(s){case"up":g=round$1(x.y-v,2);break;case"down":g=round$1(x.y+v,2);break;case"left":g=round$1(x.x-v,2);break;case"right":g=round$1(x.x+v,2);break}return g>0?g:0};return c.map(b=>{let g=A(b);const{width:x,height:y}=b;return p==="x"?g=g>d.width-x?round$1(d.width-x,2):g:g=g>d.height-y?round$1(d.height-y,2):g,{key:`position.${p}`,value:g,schemaId:b.id}})},getPagesScrollTopByIndex=(a,s,c)=>a.slice(0,s).reduce((u,d)=>u+(d.height*ZOOM+RULER_HEIGHT*c)*c,0),getSidebarContentHeight=a=>a-RULER_HEIGHT-RULER_HEIGHT/2-30,handlePositionSizeChange=(a,s,c,u,d)=>{const p=isBlankPdf(u)?u.padding:[0,0,0,0],[v,A,b,g]=p,{width:x,height:y}=d,f=(m,C,S)=>Math.min(Math.max(Number(m),C),S);s==="position.x"?a.position.x=f(c,g,x-a.width-A):s==="position.y"?a.position.y=f(c,v,y-a.height-b):s==="width"?a.width=f(c,0,x-a.position.x-A):s==="height"&&(a.height=f(c,0,y-a.position.y-b))},handleTypeChange=(a,s,c,u)=>{var v;if(s!=="type")return;const d=["id","name","type","position","required"];Object.keys(a).forEach(A=>{d.includes(A)||delete a[A]});const p=(v=Object.values(u).find(A=>(A==null?void 0:A.propPanel.defaultSchema.type)===c))==null?void 0:v.propPanel;Object.keys((p==null?void 0:p.defaultSchema)||{}).forEach(A=>{a.hasOwnProperty(A)||(a[A]=p==null?void 0:p.defaultSchema[A])}),a.readOnly&&(a.required=!1)},changeSchemas=a=>{const{objs:s,schemas:c,basePdf:u,pluginsRegistry:d,pageSize:p,commitSchemas:v}=a,A=s.reduce((b,{key:g,value:x,schemaId:y})=>{const f=b.find(m=>m.id===y);return f&&(set$2(f,g,x),g==="type"?handleTypeChange(f,g,x,d):["position.x","position.y","width","height"].includes(g)&&handlePositionSizeChange(f,g,x,u,p)),b},cloneDeep$1(c));v(A)},getMaxZoom=()=>{const a=reactExports.useContext(OptionsContext);return a.maxZoom?a.maxZoom/100:DEFAULT_MAX_ZOOM};class BaseUIClass{constructor(s){this.lang=DEFAULT_LANG,this.font=getDefaultFont(),this.pluginsRegistry=builtInPlugins,this.options={},this.setSize=debounce$1(()=>{if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.render()},100),this.resizeObserver=new ResizeObserver(this.setSize),checkUIProps(s);const{domContainer:c,template:u,options:d={},plugins:p={}}=s;this.domContainer=c,this.template=cloneDeep$1(u),this.options=d,this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.resizeObserver.observe(this.domContainer);const{lang:v,font:A}=d;v&&(this.lang=v),A&&(this.font=A),Object.values(p).length>0&&(this.pluginsRegistry=p)}getLang(){return this.lang}getFont(){return this.font}getPluginsRegistry(){return this.pluginsRegistry}getOptions(){return this.options}getTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$1(s),this.render()}updateOptions(s){checkUIOptions(s);const{lang:c,font:u}=s||{};c&&(this.lang=c),u&&(this.font=u),this.options=Object.assign(this.options,s),this.render()}destroy(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.unmountComponentAtNode(this.domContainer),this.resizeObserver.unobserve(this.domContainer),this.domContainer=null}}class PreviewUI extends BaseUIClass{constructor(s){super(s),checkPreviewProps(s),this.inputs=convertToStingObjectArray(cloneDeep$1(s.inputs))}getInputs(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.inputs}setInputs(s){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);checkInputs(s),this.inputs=convertToStingObjectArray(s),this.render()}}function convertToStingObjectArray(a){return a.map(s=>{const c={};return Object.keys(s).forEach(u=>{const d=s[u];Array.isArray(d)?c[u]=JSON.stringify(d):c[u]=d}),c})}function useCombinedRefs(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return reactExports.useMemo(()=>u=>{s.forEach(d=>d(u))},s)}const canUseDOM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function isWindow$4(a){const s=Object.prototype.toString.call(a);return s==="[object Window]"||s==="[object global]"}function isNode$1(a){return"nodeType"in a}function getWindow$1(a){var s,c;return a?isWindow$4(a)?a:isNode$1(a)&&(s=(c=a.ownerDocument)==null?void 0:c.defaultView)!=null?s:window:window}function isDocument(a){const{Document:s}=getWindow$1(a);return a instanceof s}function isHTMLElement(a){return isWindow$4(a)?!1:a instanceof getWindow$1(a).HTMLElement}function isSVGElement(a){return a instanceof getWindow$1(a).SVGElement}function getOwnerDocument(a){return a?isWindow$4(a)?a.document:isNode$1(a)?isDocument(a)?a:isHTMLElement(a)||isSVGElement(a)?a.ownerDocument:document:document:document}const useIsomorphicLayoutEffect$1=canUseDOM?reactExports.useLayoutEffect:reactExports.useEffect;function useEvent$1(a){const s=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{s.current=a}),reactExports.useCallback(function(){for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return s.current==null?void 0:s.current(...u)},[])}function useInterval(){const a=reactExports.useRef(null),s=reactExports.useCallback((u,d)=>{a.current=setInterval(u,d)},[]),c=reactExports.useCallback(()=>{a.current!==null&&(clearInterval(a.current),a.current=null)},[]);return[s,c]}function useLatestValue(a,s){s===void 0&&(s=[a]);const c=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{c.current!==a&&(c.current=a)},s),c}function useLazyMemo(a,s){const c=reactExports.useRef();return reactExports.useMemo(()=>{const u=a(c.current);return c.current=u,u},[...s])}function useNodeRef(a){const s=useEvent$1(a),c=reactExports.useRef(null),u=reactExports.useCallback(d=>{d!==c.current&&(s==null||s(d,c.current)),c.current=d},[]);return[c,u]}function usePrevious$2(a){const s=reactExports.useRef();return reactExports.useEffect(()=>{s.current=a},[a]),s.current}let ids={};function useUniqueId(a,s){return reactExports.useMemo(()=>{if(s)return s;const c=ids[a]==null?0:ids[a]+1;return ids[a]=c,a+"-"+c},[a,s])}function createAdjustmentFn(a){return function(s){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];return u.reduce((p,v)=>{const A=Object.entries(v);for(const[b,g]of A){const x=p[b];x!=null&&(p[b]=x+a*g)}return p},{...s})}}const add$1=createAdjustmentFn(1),subtract=createAdjustmentFn(-1);function hasViewportRelativeCoordinates(a){return"clientX"in a&&"clientY"in a}function isKeyboardEvent(a){if(!a)return!1;const{KeyboardEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function isTouchEvent(a){if(!a)return!1;const{TouchEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function getEventCoordinates(a){if(isTouchEvent(a)){if(a.touches&&a.touches.length){const{clientX:s,clientY:c}=a.touches[0];return{x:s,y:c}}else if(a.changedTouches&&a.changedTouches.length){const{clientX:s,clientY:c}=a.changedTouches[0];return{x:s,y:c}}}return hasViewportRelativeCoordinates(a)?{x:a.clientX,y:a.clientY}:null}const CSS$1=Object.freeze({Translate:{toString(a){if(!a)return;const{x:s,y:c}=a;return"translate3d("+(s?Math.round(s):0)+"px, "+(c?Math.round(c):0)+"px, 0)"}},Scale:{toString(a){if(!a)return;const{scaleX:s,scaleY:c}=a;return"scaleX("+s+") scaleY("+c+")"}},Transform:{toString(a){if(a)return[CSS$1.Translate.toString(a),CSS$1.Scale.toString(a)].join(" ")}},Transition:{toString(a){let{property:s,duration:c,easing:u}=a;return s+" "+c+"ms "+u}}}),SELECTOR="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function findFirstFocusableNode(a){return a.matches(SELECTOR)?a:a.querySelector(SELECTOR)}const hiddenStyles={display:"none"};function HiddenText(a){let{id:s,value:c}=a;return React.createElement("div",{id:s,style:hiddenStyles},c)}function LiveRegion(a){let{id:s,announcement:c,ariaLiveType:u="assertive"}=a;const d={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return React.createElement("div",{id:s,style:d,role:"status","aria-live":u,"aria-atomic":!0},c)}function useAnnouncement(){const[a,s]=reactExports.useState("");return{announce:reactExports.useCallback(u=>{u!=null&&s(u)},[]),announcement:a}}const DndMonitorContext=reactExports.createContext(null);function useDndMonitor(a){const s=reactExports.useContext(DndMonitorContext);reactExports.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(a)},[a,s])}function useDndMonitorProvider(){const[a]=reactExports.useState(()=>new Set),s=reactExports.useCallback(u=>(a.add(u),()=>a.delete(u)),[a]);return[reactExports.useCallback(u=>{let{type:d,event:p}=u;a.forEach(v=>{var A;return(A=v[d])==null?void 0:A.call(v,p)})},[a]),s]}const defaultScreenReaderInstructions={draggable:`
|
188
188
|
To pick up a draggable item, press the space bar.
|
189
189
|
While dragging, use the arrow keys to move the item.
|
190
190
|
Press space again to drop the item in its new position, or press escape to cancel.
|
@@ -771,7 +771,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
771
771
|
*
|
772
772
|
* This source code is licensed under the ISC license.
|
773
773
|
* See the LICENSE file in the root directory of this source tree.
|
774
|
-
*/const X=createLucideIcon("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function arrayMove(a,s,c){const u=a.slice();return u.splice(c<0?u.length+c:c,0,u.splice(s,1)[0]),u}function getSortedRects(a,s){return a.reduce((c,u,d)=>{const p=s.get(u);return p&&(c[d]=p),c},Array(a.length))}function isValidIndex(a){return a!==null&&a>=0}function itemsEqual(a,s){if(a===s)return!0;if(a.length!==s.length)return!1;for(let c=0;c<a.length;c++)if(a[c]!==s[c])return!1;return!0}function normalizeDisabled(a){return typeof a=="boolean"?{draggable:a,droppable:a}:a}const rectSortingStrategy=a=>{let{rects:s,activeIndex:c,overIndex:u,index:d}=a;const p=arrayMove(s,u,c),v=s[d],A=p[d];return!A||!v?null:{x:A.left-v.left,y:A.top-v.top,scaleX:A.width/v.width,scaleY:A.height/v.height}},defaultScale$1={scaleX:1,scaleY:1},verticalListSortingStrategy=a=>{var s;let{activeIndex:c,activeNodeRect:u,index:d,rects:p,overIndex:v}=a;const A=(s=p[c])!=null?s:u;if(!A)return null;if(d===c){const g=p[v];return g?{x:0,y:c<v?g.top+g.height-(A.top+A.height):g.top-A.top,...defaultScale$1}:null}const b=getItemGap$1(p,d,c);return d>c&&d<=v?{x:0,y:-A.height-b,...defaultScale$1}:d<c&&d>=v?{x:0,y:A.height+b,...defaultScale$1}:{x:0,y:0,...defaultScale$1}};function getItemGap$1(a,s,c){const u=a[s],d=a[s-1],p=a[s+1];return u?c<s?d?u.top-(d.top+d.height):p?p.top-(u.top+u.height):0:p?p.top-(u.top+u.height):d?u.top-(d.top+d.height):0:0}const ID_PREFIX="Sortable",Context$1=React.createContext({activeIndex:-1,containerId:ID_PREFIX,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:rectSortingStrategy,disabled:{draggable:!1,droppable:!1}});function SortableContext(a){let{children:s,id:c,items:u,strategy:d=rectSortingStrategy,disabled:p=!1}=a;const{active:v,dragOverlay:A,droppableRects:b,over:g,measureDroppableContainers:x}=useDndContext(),y=useUniqueId(ID_PREFIX,c),f=A.rect!==null,m=reactExports.useMemo(()=>u.map(B=>typeof B=="object"&&"id"in B?B.id:B),[u]),C=v!=null,S=v?m.indexOf(v.id):-1,w=g?m.indexOf(g.id):-1,I=reactExports.useRef(m),P=!itemsEqual(m,I.current),$=w!==-1&&S===-1||P,T=normalizeDisabled(p);useIsomorphicLayoutEffect$1(()=>{P&&C&&x(m)},[P,m,C,x]),reactExports.useEffect(()=>{I.current=m},[m]);const E=reactExports.useMemo(()=>({activeIndex:S,containerId:y,disabled:T,disableTransforms:$,items:m,overIndex:w,useDragOverlay:f,sortedRects:getSortedRects(m,b),strategy:d}),[S,y,T.draggable,T.droppable,$,m,w,b,f,d]);return React.createElement(Context$1.Provider,{value:E},s)}const defaultNewIndexGetter=a=>{let{id:s,items:c,activeIndex:u,overIndex:d}=a;return arrayMove(c,u,d).indexOf(s)},defaultAnimateLayoutChanges=a=>{let{containerId:s,isSorting:c,wasDragging:u,index:d,items:p,newIndex:v,previousItems:A,previousContainerId:b,transition:g}=a;return!g||!u||A!==p&&d===v?!1:c?!0:v!==d&&s===b},defaultTransition={duration:200,easing:"ease"},transitionProperty="transform",disabledTransition=CSS$1.Transition.toString({property:transitionProperty,duration:0,easing:"linear"}),defaultAttributes={roleDescription:"sortable"};function useDerivedTransform(a){let{disabled:s,index:c,node:u,rect:d}=a;const[p,v]=reactExports.useState(null),A=reactExports.useRef(c);return useIsomorphicLayoutEffect$1(()=>{if(!s&&c!==A.current&&u.current){const b=d.current;if(b){const g=getClientRect$1(u.current,{ignoreTransform:!0}),x={x:b.left-g.left,y:b.top-g.top,scaleX:b.width/g.width,scaleY:b.height/g.height};(x.x||x.y)&&v(x)}}c!==A.current&&(A.current=c)},[s,c,u,d]),reactExports.useEffect(()=>{p&&v(null)},[p]),p}function useSortable(a){let{animateLayoutChanges:s=defaultAnimateLayoutChanges,attributes:c,disabled:u,data:d,getNewIndex:p=defaultNewIndexGetter,id:v,strategy:A,resizeObserverConfig:b,transition:g=defaultTransition}=a;const{items:x,containerId:y,activeIndex:f,disabled:m,disableTransforms:C,sortedRects:S,overIndex:w,useDragOverlay:I,strategy:P}=reactExports.useContext(Context$1),$=normalizeLocalDisabled(u,m),T=x.indexOf(v),E=reactExports.useMemo(()=>({sortable:{containerId:y,index:T,items:x},...d}),[y,d,T,x]),B=reactExports.useMemo(()=>x.slice(x.indexOf(v)),[x,v]),{rect:R,node:O,isOver:M,setNodeRef:_}=useDroppable({id:v,data:E,disabled:$.droppable,resizeObserverConfig:{updateMeasurementsFor:B,...b}}),{active:D,activatorEvent:U,activeNodeRect:G,attributes:Q,setNodeRef:L,listeners:F,isDragging:j,over:N,setActivatorNodeRef:k,transform:H}=useDraggable({id:v,data:E,attributes:{...defaultAttributes,...c},disabled:$.draggable}),J=useCombinedRefs(_,L),q=!!D,Y=q&&!C&&isValidIndex(f)&&isValidIndex(w),Z=!I&&j,ee=Z&&Y?H:null,ae=Y?ee??(A??P)({rects:S,activeNodeRect:G,activeIndex:f,overIndex:w,index:T}):null,V=isValidIndex(f)&&isValidIndex(w)?p({id:v,items:x,activeIndex:f,overIndex:w}):T,K=D==null?void 0:D.id,te=reactExports.useRef({activeId:K,items:x,newIndex:V,containerId:y}),oe=x!==te.current.items,fe=s({active:D,containerId:y,isDragging:j,isSorting:q,id:v,index:T,items:x,newIndex:te.current.newIndex,previousItems:te.current.items,previousContainerId:te.current.containerId,transition:g,wasDragging:te.current.activeId!=null}),me=useDerivedTransform({disabled:!fe,index:T,node:O,rect:R});return reactExports.useEffect(()=>{q&&te.current.newIndex!==V&&(te.current.newIndex=V),y!==te.current.containerId&&(te.current.containerId=y),x!==te.current.items&&(te.current.items=x)},[q,V,y,x]),reactExports.useEffect(()=>{if(K===te.current.activeId)return;if(K!=null&&te.current.activeId==null){te.current.activeId=K;return}const be=setTimeout(()=>{te.current.activeId=K},50);return()=>clearTimeout(be)},[K]),{active:D,activeIndex:f,attributes:Q,data:E,rect:R,index:T,newIndex:V,items:x,isOver:M,isSorting:q,isDragging:j,listeners:F,node:O,overIndex:w,over:N,setNodeRef:J,setActivatorNodeRef:k,setDroppableNodeRef:_,setDraggableNodeRef:L,transform:me??ae,transition:Ee()};function Ee(){if(me||oe&&te.current.newIndex===T)return disabledTransition;if(!(Z&&!isKeyboardEvent(U)||!g)&&(q||fe))return CSS$1.Transition.toString({...g,property:transitionProperty})}}function normalizeLocalDisabled(a,s){var c,u;return typeof a=="boolean"?{draggable:a,droppable:!1}:{draggable:(c=a==null?void 0:a.draggable)!=null?c:s.draggable,droppable:(u=a==null?void 0:a.droppable)!=null?u:s.droppable}}function hasSortableData(a){if(!a)return!1;const s=a.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const directions=[KeyboardCode.Down,KeyboardCode.Right,KeyboardCode.Up,KeyboardCode.Left],sortableKeyboardCoordinates=(a,s)=>{let{context:{active:c,collisionRect:u,droppableRects:d,droppableContainers:p,over:v,scrollableAncestors:A}}=s;if(directions.includes(a.code)){if(a.preventDefault(),!c||!u)return;const b=[];p.getEnabled().forEach(y=>{if(!y||y!=null&&y.disabled)return;const f=d.get(y.id);if(f)switch(a.code){case KeyboardCode.Down:u.top<f.top&&b.push(y);break;case KeyboardCode.Up:u.top>f.top&&b.push(y);break;case KeyboardCode.Left:u.left>f.left&&b.push(y);break;case KeyboardCode.Right:u.left<f.left&&b.push(y);break}});const g=closestCorners({collisionRect:u,droppableRects:d,droppableContainers:b});let x=getFirstCollision(g,"id");if(x===(v==null?void 0:v.id)&&g.length>1&&(x=g[1].id),x!=null){const y=p.get(c.id),f=p.get(x),m=f?d.get(f.id):null,C=f==null?void 0:f.node.current;if(C&&m&&y&&f){const w=getScrollableAncestors(C).some((B,R)=>A[R]!==B),I=isSameContainer(y,f),P=isAfter(y,f),$=w||!I?{x:0,y:0}:{x:P?u.width-m.width:0,y:P?u.height-m.height:0},T={x:m.left,y:m.top};return $.x&&$.y?T:subtract(T,$)}}}};function isSameContainer(a,s){return!hasSortableData(a)||!hasSortableData(s)?!1:a.data.current.sortable.containerId===s.data.current.sortable.containerId}function isAfter(a,s){return!hasSortableData(a)||!hasSortableData(s)||!isSameContainer(a,s)?!1:a.data.current.sortable.index<s.data.current.sortable.index}const{Text:Text$4}=Typography,Item=React.memo(React.forwardRef(({icon:a,value:s,status:c,title:u,required:d,readOnly:p,style:v,dragOverlay:A,onClick:b,onMouseEnter:g,onMouseLeave:x,dragging:y,fadeIn:f,listeners:m,sorting:C,transition:S,transform:w,...I},P)=>{const $=reactExports.useContext(I18nContext);reactExports.useEffect(()=>{if(A)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[A]);const{x:T,y:E,scaleX:B,scaleY:R}=w||{x:0,y:0,scaleX:1,scaleY:1};return jsxRuntimeExports.jsx("li",{style:{marginTop:10,transition:S,transform:`translate(${T}px, ${E}px) scale(${B}, ${R})`},onMouseEnter:g,onMouseLeave:x,ref:P,children:jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer",gap:"0.5rem",...v},...I,onClick:()=>b&&b(),children:[jsxRuntimeExports.jsx(Button$1,{...m,style:{display:"flex",alignItems:"center",background:"none",boxShadow:"none",border:"none",paddingLeft:"0.25rem"},icon:jsxRuntimeExports.jsx(GripVertical,{size:15,style:{cursor:"grab"}})}),a,jsxRuntimeExports.jsx(Text$4,{style:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",width:"100%"},title:u||"",children:c===void 0?s:jsxRuntimeExports.jsxs("span",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(CircleAlert,{size:15,style:{marginRight:"0.25rem"}}),c==="is-warning"?$("noKeyName"):s,c==="is-danger"?$("notUniq"):""]})}),p&&jsxRuntimeExports.jsx(Lock,{size:15,style:{marginRight:"0.5rem"}}),d&&jsxRuntimeExports.jsx("span",{style:{color:"red",marginRight:"0.5rem"},children:"*"})]})})})),usePrevious=a=>{const s=reactExports.useRef(null);return reactExports.useEffect(()=>{s.current=a}),s.current},getScale=(a,s)=>Math.floor((a/s>1?1:a/s)*100)/100,useUIPreProcessor=({template:a,size:s,zoomLevel:c,maxZoom:u})=>{const[d,p]=reactExports.useState([]),[v,A]=reactExports.useState([]),[b,g]=reactExports.useState(0),[x,y]=reactExports.useState(null),f=async m=>{const{template:{basePdf:C,schemas:S},size:w}=m;let I,P,$,T;if(isBlankPdf(C)){const{width:B,height:R}=C;I=B*ZOOM,P=R*ZOOM,$=S.map(()=>"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII="),T=S.map(()=>({width:B,height:R}))}else{const B=await getB64BasePdf(C),[R,O]=await Promise.all([pdf2size(b64toUint8Array(B)),pdf2img(b64toUint8Array(B),{scale:u})]);T=R,I=T[0].width*ZOOM,P=T[0].height*ZOOM,$=O.map(arrayBufferToBase64)}const E=Math.min(getScale(w.width,I),getScale(w.height-RULER_HEIGHT,P));return{backgrounds:$,pageSizes:T,scale:E}};return reactExports.useEffect(()=>{f({template:a,size:s}).then(({pageSizes:m,scale:C,backgrounds:S})=>{A(m),g(C),p(S)}).catch(m=>{y(m),console.error("[@pdfme/ui]",m)})},[a,s]),{backgrounds:d,pageSizes:v,scale:b*c,error:x,refresh:m=>f({template:m,size:s}).then(({pageSizes:C,scale:S,backgrounds:w})=>{A(C),g(S),p(w)})}},useScrollPageCursor=({ref:a,pageSizes:s,scale:c,pageCursor:u,onChangePageCursor:d})=>{const p=reactExports.useCallback(()=>{if(!s[0]||!a.current)return;const v=a.current.scrollTop,{top:A}=a.current.getBoundingClientRect(),b=s.reduce((x,y,f)=>{let m=(y.height*ZOOM+RULER_HEIGHT)*c;return f===0?m+=A-m/2:m+=x[f-1],x.concat(m)},[]);let g=0;b.forEach((x,y)=>{v>x&&(g=y+1>=b.length?b.length-1:y+1)}),g!==u&&d(g)},[d,u,s,a,c]);reactExports.useEffect(()=>{var v;return(v=a.current)==null||v.addEventListener("scroll",p),()=>{var A;(A=a.current)==null||A.removeEventListener("scroll",p)}},[a,p])},useMountStatus=()=>{const[a,s]=reactExports.useState(!1);return reactExports.useEffect(()=>{const c=setTimeout(()=>s(!0),500);return()=>clearTimeout(c)},[]),a},useInitEvents=({pageCursor:a,pageSizes:s,activeElements:c,template:u,schemasList:d,changeSchemas:p,commitSchemas:v,removeSchemas:A,onSaveTemplate:b,past:g,future:x,setSchemasList:y,onEdit:f,onEditEnd:m})=>{const C=reactExports.useRef(null),S=reactExports.useCallback(()=>{const I=()=>{const $=c.map(T=>T.id);return d[a].filter(T=>$.includes(T.id))},P=$=>{const T=$==="undo",E=T?g:x;if(E.current.length<=0)return;(T?x:g).current.push(cloneDeep$1(d[a]));const B=cloneDeep$1(d);B[a]=E.current.pop(),y(B)};initShortCuts({move:($,T)=>{const E=s[a],B=I(),R=moveCommandToChangeSchemasArg({command:$,activeSchemas:B,pageSize:E,isShift:T});p(R)},copy:()=>{const $=I();$.length!==0&&(C.current=$)},paste:()=>{if(!C.current||C.current.length===0)return;const $=d[a],T=[],E=C.current.map(B=>{const R=uuid$6(),O=getUniqueSchemaName({copiedSchemaName:B.name,schema:$,stackUniqueSchemaNames:T}),{height:M,width:_,position:D}=B,U=s[a],G={x:D.x+10>U.width-_?U.width-_:D.x+10,y:D.y+10>U.height-M?U.height-M:D.y+10};return Object.assign(cloneDeep$1(B),{id:R,name:O,position:G})});v(d[a].concat(E)),f(E.map(B=>document.getElementById(B.id))),C.current=E},redo:()=>P("redo"),undo:()=>P("undo"),save:()=>b&&b(schemasList2template(d,u.basePdf)),remove:()=>A(I().map($=>$.id)),esc:m,selectAll:()=>f(d[a].map($=>document.getElementById($.id)))})},[u,c,a,s,p,v,d,b,A,g,x,y,C,f,m]),w=reactExports.useCallback(()=>{destroyShortCuts()},[]);reactExports.useEffect(()=>(S(),w),[S,w])},getWithModifiedSize=(a,s,c,u)=>{const p=new DOMParser().parseFromString(a,"text/html"),v=A=>{(A.tagName==="SVG"||A.tagName==="svg")&&(A.setAttribute("width",c.toString()),A.setAttribute("height",c.toString())),Array.from(A.children).forEach(b=>v(b))};return Array.from(p.body.children).forEach(A=>v(A)),jsxRuntimeExports.jsx("div",{style:u,title:s,dangerouslySetInnerHTML:{__html:p.body.innerHTML}})},PluginIcon=a=>{var g;const{plugin:s,label:c,size:u,styles:d}=a,{token:p}=theme.useToken(),A=((g=reactExports.useContext(OptionsContext).icons)==null?void 0:g[s.propPanel.defaultSchema.type])??s.icon,b={...d,color:p.colorText,display:"flex",justifyContent:"center"};return A?u?getWithModifiedSize(A,c,u,b):jsxRuntimeExports.jsx("div",{style:b,title:c,dangerouslySetInnerHTML:{__html:A}}):jsxRuntimeExports.jsx("div",{style:{...d,overflow:"hidden",fontSize:10},title:c,children:c})},SelectableSortableItem=({isSelected:a,style:s,onSelect:c,onEdit:u,schema:d,schemas:p,onMouseEnter:v,onMouseLeave:A})=>{const{token:b}=theme.useToken(),g=reactExports.useContext(I18nContext),x=reactExports.useContext(PluginsRegistry),{setNodeRef:y,listeners:f,isDragging:m,isSorting:C,transform:S,transition:w}=useSortable({id:d.id}),I=useMountStatus(),P=m&&!I,$={...f,onClick:M=>c(d.id,M.shiftKey)},[T,E]=Object.entries(x).find(([M,_])=>(_==null?void 0:_.propPanel.defaultSchema.type)===d.type);let B;d.name?p.find(M=>d.name&&M.name===d.name&&M.id!==d.id)&&(B="is-danger"):B="is-warning";let R=g("edit");B==="is-warning"?R=g("plsInputName"):B==="is-danger"&&(R=g("fieldMustUniq"));const O=a?{background:b.colorPrimary,opacity:C||m?.5:1}:{};return jsxRuntimeExports.jsx(Item,{ref:y,onMouseEnter:v,onMouseLeave:A,onClick:()=>u(d.id),icon:E&&jsxRuntimeExports.jsx(PluginIcon,{plugin:E,label:T,size:20}),value:d.name,status:B,title:R,required:d.required,readOnly:d.readOnly,style:{...O,...s},dragging:m,sorting:C,transition:w,transform:S,fadeIn:P,listeners:$})},SelectableSortableContainer=a=>{const{token:s}=theme.useToken(),{schemas:c,onEdit:u,onSortEnd:d,hoveringSchemaId:p,onChangeHoveringSchemaId:v}=a,[A,b]=reactExports.useState([]),[g,x]=reactExports.useState(null),[y,f]=reactExports.useState(null),m=reactExports.useContext(PluginsRegistry),C=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:15}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),S=P=>A.map($=>$.id).includes(P),w=(P,$)=>{if($)if(S(P)){const T=A.filter(E=>E.id!==P);b(T)}else{const T=c.find(B=>B.id===P),E=A.concat(T);b(E)}else b([])},I=P=>{const $=typeof P=="string"?c.find(B=>B.id===P):P,[T,E]=Object.entries(m).find(([B,R])=>(R==null?void 0:R.propPanel.defaultSchema.type)===($==null?void 0:$.type));return E?jsxRuntimeExports.jsx(PluginIcon,{plugin:E,label:T,size:20,styles:{marginRight:"0.5rem"}}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})};return jsxRuntimeExports.jsx(DndContext,{sensors:C,collisionDetection:closestCorners,onDragStart:({active:P})=>{f(String(P.id)),x(c),S(String(P.id))?A.length>0&&d(A.reduce(($,T)=>T.id===String(P.id)?$:$.filter(E=>E!==T),c)):b([])},onDragEnd:({active:P,over:$})=>{const T=($==null?void 0:$.id)||"",E=c.map(R=>R.id).indexOf(String(P.id)),B=c.map(R=>R.id).indexOf(String(T));if(A.length){let R=[...c];R=arrayMove(R,E,B),R.splice(B+1,0,...A.filter(O=>O.id!==y)),d(R),b([])}else E!==B&&d(arrayMove(c,E,B));f(null)},onDragCancel:()=>{g&&d(g),f(null),x(null)},children:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{style:{height:"100%",overflowY:"auto"},children:jsxRuntimeExports.jsx(SortableContext,{items:c,strategy:verticalListSortingStrategy,children:jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",borderRadius:5},children:c.map(P=>jsxRuntimeExports.jsx(SelectableSortableItem,{style:{border:`1px solid ${P.id===p?s.colorPrimary:"transparent"}`},schema:P,schemas:c,isSelected:S(P.id)||y===P.id,onEdit:u,onSelect:w,onMouseEnter:()=>v(P.id),onMouseLeave:()=>v(null)},P.id))})})}),reactDomExports.createPortal(jsxRuntimeExports.jsx(DragOverlay,{adjustScale:!0,children:y?(()=>{const P=c.find($=>$.id===y);return P?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none"},children:jsxRuntimeExports.jsx(Item,{icon:I(y),value:P.name,required:P.required,readOnly:P.readOnly,style:{background:s.colorPrimary},dragOverlay:!0})}),jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none"},children:A.filter($=>$.id!==y).map($=>jsxRuntimeExports.jsx(Item,{icon:I($),value:$.name,required:$.required,readOnly:$.readOnly,style:{background:s.colorPrimary},dragOverlay:!0},$.id))})]}):null})():null}),document.body)]})})},{Text:Text$3}=Typography,{TextArea:TextArea$2}=Input$1,headHeight=40,ListView=a=>{const{schemas:s,onSortEnd:c,onEdit:u,size:d,hoveringSchemaId:p,onChangeHoveringSchemaId:v,changeSchemas:A}=a,{token:b}=theme.useToken(),g=reactExports.useContext(I18nContext),[x,y]=reactExports.useState(!1),[f,m]=reactExports.useState(""),C=getSidebarContentHeight(d.height),S=()=>{const I=f.split(`
|
774
|
+
*/const X=createLucideIcon("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function arrayMove(a,s,c){const u=a.slice();return u.splice(c<0?u.length+c:c,0,u.splice(s,1)[0]),u}function getSortedRects(a,s){return a.reduce((c,u,d)=>{const p=s.get(u);return p&&(c[d]=p),c},Array(a.length))}function isValidIndex(a){return a!==null&&a>=0}function itemsEqual(a,s){if(a===s)return!0;if(a.length!==s.length)return!1;for(let c=0;c<a.length;c++)if(a[c]!==s[c])return!1;return!0}function normalizeDisabled(a){return typeof a=="boolean"?{draggable:a,droppable:a}:a}const rectSortingStrategy=a=>{let{rects:s,activeIndex:c,overIndex:u,index:d}=a;const p=arrayMove(s,u,c),v=s[d],A=p[d];return!A||!v?null:{x:A.left-v.left,y:A.top-v.top,scaleX:A.width/v.width,scaleY:A.height/v.height}},defaultScale$1={scaleX:1,scaleY:1},verticalListSortingStrategy=a=>{var s;let{activeIndex:c,activeNodeRect:u,index:d,rects:p,overIndex:v}=a;const A=(s=p[c])!=null?s:u;if(!A)return null;if(d===c){const g=p[v];return g?{x:0,y:c<v?g.top+g.height-(A.top+A.height):g.top-A.top,...defaultScale$1}:null}const b=getItemGap$1(p,d,c);return d>c&&d<=v?{x:0,y:-A.height-b,...defaultScale$1}:d<c&&d>=v?{x:0,y:A.height+b,...defaultScale$1}:{x:0,y:0,...defaultScale$1}};function getItemGap$1(a,s,c){const u=a[s],d=a[s-1],p=a[s+1];return u?c<s?d?u.top-(d.top+d.height):p?p.top-(u.top+u.height):0:p?p.top-(u.top+u.height):d?u.top-(d.top+d.height):0:0}const ID_PREFIX="Sortable",Context$1=React.createContext({activeIndex:-1,containerId:ID_PREFIX,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:rectSortingStrategy,disabled:{draggable:!1,droppable:!1}});function SortableContext(a){let{children:s,id:c,items:u,strategy:d=rectSortingStrategy,disabled:p=!1}=a;const{active:v,dragOverlay:A,droppableRects:b,over:g,measureDroppableContainers:x}=useDndContext(),y=useUniqueId(ID_PREFIX,c),f=A.rect!==null,m=reactExports.useMemo(()=>u.map(B=>typeof B=="object"&&"id"in B?B.id:B),[u]),C=v!=null,S=v?m.indexOf(v.id):-1,w=g?m.indexOf(g.id):-1,I=reactExports.useRef(m),P=!itemsEqual(m,I.current),$=w!==-1&&S===-1||P,T=normalizeDisabled(p);useIsomorphicLayoutEffect$1(()=>{P&&C&&x(m)},[P,m,C,x]),reactExports.useEffect(()=>{I.current=m},[m]);const E=reactExports.useMemo(()=>({activeIndex:S,containerId:y,disabled:T,disableTransforms:$,items:m,overIndex:w,useDragOverlay:f,sortedRects:getSortedRects(m,b),strategy:d}),[S,y,T.draggable,T.droppable,$,m,w,b,f,d]);return React.createElement(Context$1.Provider,{value:E},s)}const defaultNewIndexGetter=a=>{let{id:s,items:c,activeIndex:u,overIndex:d}=a;return arrayMove(c,u,d).indexOf(s)},defaultAnimateLayoutChanges=a=>{let{containerId:s,isSorting:c,wasDragging:u,index:d,items:p,newIndex:v,previousItems:A,previousContainerId:b,transition:g}=a;return!g||!u||A!==p&&d===v?!1:c?!0:v!==d&&s===b},defaultTransition={duration:200,easing:"ease"},transitionProperty="transform",disabledTransition=CSS$1.Transition.toString({property:transitionProperty,duration:0,easing:"linear"}),defaultAttributes={roleDescription:"sortable"};function useDerivedTransform(a){let{disabled:s,index:c,node:u,rect:d}=a;const[p,v]=reactExports.useState(null),A=reactExports.useRef(c);return useIsomorphicLayoutEffect$1(()=>{if(!s&&c!==A.current&&u.current){const b=d.current;if(b){const g=getClientRect$1(u.current,{ignoreTransform:!0}),x={x:b.left-g.left,y:b.top-g.top,scaleX:b.width/g.width,scaleY:b.height/g.height};(x.x||x.y)&&v(x)}}c!==A.current&&(A.current=c)},[s,c,u,d]),reactExports.useEffect(()=>{p&&v(null)},[p]),p}function useSortable(a){let{animateLayoutChanges:s=defaultAnimateLayoutChanges,attributes:c,disabled:u,data:d,getNewIndex:p=defaultNewIndexGetter,id:v,strategy:A,resizeObserverConfig:b,transition:g=defaultTransition}=a;const{items:x,containerId:y,activeIndex:f,disabled:m,disableTransforms:C,sortedRects:S,overIndex:w,useDragOverlay:I,strategy:P}=reactExports.useContext(Context$1),$=normalizeLocalDisabled(u,m),T=x.indexOf(v),E=reactExports.useMemo(()=>({sortable:{containerId:y,index:T,items:x},...d}),[y,d,T,x]),B=reactExports.useMemo(()=>x.slice(x.indexOf(v)),[x,v]),{rect:R,node:O,isOver:M,setNodeRef:_}=useDroppable({id:v,data:E,disabled:$.droppable,resizeObserverConfig:{updateMeasurementsFor:B,...b}}),{active:D,activatorEvent:U,activeNodeRect:G,attributes:Q,setNodeRef:L,listeners:F,isDragging:j,over:N,setActivatorNodeRef:k,transform:H}=useDraggable({id:v,data:E,attributes:{...defaultAttributes,...c},disabled:$.draggable}),J=useCombinedRefs(_,L),q=!!D,Y=q&&!C&&isValidIndex(f)&&isValidIndex(w),Z=!I&&j,ee=Z&&Y?H:null,ae=Y?ee??(A??P)({rects:S,activeNodeRect:G,activeIndex:f,overIndex:w,index:T}):null,V=isValidIndex(f)&&isValidIndex(w)?p({id:v,items:x,activeIndex:f,overIndex:w}):T,K=D==null?void 0:D.id,te=reactExports.useRef({activeId:K,items:x,newIndex:V,containerId:y}),oe=x!==te.current.items,fe=s({active:D,containerId:y,isDragging:j,isSorting:q,id:v,index:T,items:x,newIndex:te.current.newIndex,previousItems:te.current.items,previousContainerId:te.current.containerId,transition:g,wasDragging:te.current.activeId!=null}),me=useDerivedTransform({disabled:!fe,index:T,node:O,rect:R});return reactExports.useEffect(()=>{q&&te.current.newIndex!==V&&(te.current.newIndex=V),y!==te.current.containerId&&(te.current.containerId=y),x!==te.current.items&&(te.current.items=x)},[q,V,y,x]),reactExports.useEffect(()=>{if(K===te.current.activeId)return;if(K!=null&&te.current.activeId==null){te.current.activeId=K;return}const be=setTimeout(()=>{te.current.activeId=K},50);return()=>clearTimeout(be)},[K]),{active:D,activeIndex:f,attributes:Q,data:E,rect:R,index:T,newIndex:V,items:x,isOver:M,isSorting:q,isDragging:j,listeners:F,node:O,overIndex:w,over:N,setNodeRef:J,setActivatorNodeRef:k,setDroppableNodeRef:_,setDraggableNodeRef:L,transform:me??ae,transition:Ee()};function Ee(){if(me||oe&&te.current.newIndex===T)return disabledTransition;if(!(Z&&!isKeyboardEvent(U)||!g)&&(q||fe))return CSS$1.Transition.toString({...g,property:transitionProperty})}}function normalizeLocalDisabled(a,s){var c,u;return typeof a=="boolean"?{draggable:a,droppable:!1}:{draggable:(c=a==null?void 0:a.draggable)!=null?c:s.draggable,droppable:(u=a==null?void 0:a.droppable)!=null?u:s.droppable}}function hasSortableData(a){if(!a)return!1;const s=a.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const directions=[KeyboardCode.Down,KeyboardCode.Right,KeyboardCode.Up,KeyboardCode.Left],sortableKeyboardCoordinates=(a,s)=>{let{context:{active:c,collisionRect:u,droppableRects:d,droppableContainers:p,over:v,scrollableAncestors:A}}=s;if(directions.includes(a.code)){if(a.preventDefault(),!c||!u)return;const b=[];p.getEnabled().forEach(y=>{if(!y||y!=null&&y.disabled)return;const f=d.get(y.id);if(f)switch(a.code){case KeyboardCode.Down:u.top<f.top&&b.push(y);break;case KeyboardCode.Up:u.top>f.top&&b.push(y);break;case KeyboardCode.Left:u.left>f.left&&b.push(y);break;case KeyboardCode.Right:u.left<f.left&&b.push(y);break}});const g=closestCorners({collisionRect:u,droppableRects:d,droppableContainers:b});let x=getFirstCollision(g,"id");if(x===(v==null?void 0:v.id)&&g.length>1&&(x=g[1].id),x!=null){const y=p.get(c.id),f=p.get(x),m=f?d.get(f.id):null,C=f==null?void 0:f.node.current;if(C&&m&&y&&f){const w=getScrollableAncestors(C).some((B,R)=>A[R]!==B),I=isSameContainer(y,f),P=isAfter(y,f),$=w||!I?{x:0,y:0}:{x:P?u.width-m.width:0,y:P?u.height-m.height:0},T={x:m.left,y:m.top};return $.x&&$.y?T:subtract(T,$)}}}};function isSameContainer(a,s){return!hasSortableData(a)||!hasSortableData(s)?!1:a.data.current.sortable.containerId===s.data.current.sortable.containerId}function isAfter(a,s){return!hasSortableData(a)||!hasSortableData(s)||!isSameContainer(a,s)?!1:a.data.current.sortable.index<s.data.current.sortable.index}const{Text:Text$4}=Typography,Item=React.memo(React.forwardRef(({icon:a,value:s,status:c,title:u,required:d,readOnly:p,style:v,dragOverlay:A,onClick:b,onMouseEnter:g,onMouseLeave:x,dragging:y,fadeIn:f,listeners:m,sorting:C,transition:S,transform:w,...I},P)=>{const $=reactExports.useContext(I18nContext);reactExports.useEffect(()=>{if(A)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[A]);const{x:T,y:E,scaleX:B,scaleY:R}=w||{x:0,y:0,scaleX:1,scaleY:1};return jsxRuntimeExports.jsx("li",{style:{marginTop:10,transition:S,transform:`translate(${T}px, ${E}px) scale(${B}, ${R})`},onMouseEnter:g,onMouseLeave:x,ref:P,children:jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer",gap:"0.5rem",...v},...I,onClick:()=>b&&b(),children:[jsxRuntimeExports.jsx(Button$1,{...m,style:{display:"flex",alignItems:"center",background:"none",boxShadow:"none",border:"none",paddingLeft:"0.25rem"},icon:jsxRuntimeExports.jsx(GripVertical,{size:15,style:{cursor:"grab"}})}),a,jsxRuntimeExports.jsx(Text$4,{style:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",width:"100%"},title:u||"",children:c===void 0?s:jsxRuntimeExports.jsxs("span",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(CircleAlert,{size:15,style:{marginRight:"0.25rem"}}),c==="is-warning"?$("noKeyName"):s,c==="is-danger"?$("notUniq"):""]})}),p&&jsxRuntimeExports.jsx(Lock,{size:15,style:{marginRight:"0.5rem"}}),d&&jsxRuntimeExports.jsx("span",{style:{color:"red",marginRight:"0.5rem"},children:"*"})]})})})),usePrevious=a=>{const s=reactExports.useRef(null);return reactExports.useEffect(()=>{s.current=a}),s.current},getScale=(a,s)=>Math.floor((a/s>1?1:a/s)*100)/100,useUIPreProcessor=({template:a,size:s,zoomLevel:c,maxZoom:u})=>{const[d,p]=reactExports.useState([]),[v,A]=reactExports.useState([]),[b,g]=reactExports.useState(0),[x,y]=reactExports.useState(null),f=async m=>{const{template:{basePdf:C,schemas:S},size:w}=m;let I,P,$,T;if(isBlankPdf(C)){const{width:B,height:R}=C;I=B*ZOOM,P=R*ZOOM,$=S.map(()=>"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII="),T=S.map(()=>({width:B,height:R}))}else{const B=await getB64BasePdf(C),R=b64toUint8Array(B),O=new ArrayBuffer(R.byteLength);new Uint8Array(O).set(R);const[M,_]=await Promise.all([pdf2size(O),pdf2img(O.slice(),{scale:u})]);T=M,I=T[0].width*ZOOM,P=T[0].height*ZOOM,$=_.map(arrayBufferToBase64)}const E=Math.min(getScale(w.width,I),getScale(w.height-RULER_HEIGHT,P));return{backgrounds:$,pageSizes:T,scale:E}};return reactExports.useEffect(()=>{f({template:a,size:s}).then(({pageSizes:m,scale:C,backgrounds:S})=>{A(m),g(C),p(S)}).catch(m=>{y(m),console.error("[@pdfme/ui]",m)})},[a,s]),{backgrounds:d,pageSizes:v,scale:b*c,error:x,refresh:m=>f({template:m,size:s}).then(({pageSizes:C,scale:S,backgrounds:w})=>{A(C),g(S),p(w)})}},useScrollPageCursor=({ref:a,pageSizes:s,scale:c,pageCursor:u,onChangePageCursor:d})=>{const p=reactExports.useCallback(()=>{if(!s[0]||!a.current)return;const v=a.current.scrollTop,{top:A}=a.current.getBoundingClientRect(),b=s.reduce((x,y,f)=>{let m=(y.height*ZOOM+RULER_HEIGHT)*c;return f===0?m+=A-m/2:m+=x[f-1],x.concat(m)},[]);let g=0;b.forEach((x,y)=>{v>x&&(g=y+1>=b.length?b.length-1:y+1)}),g!==u&&d(g)},[d,u,s,a,c]);reactExports.useEffect(()=>{var v;return(v=a.current)==null||v.addEventListener("scroll",p),()=>{var A;(A=a.current)==null||A.removeEventListener("scroll",p)}},[a,p])},useMountStatus=()=>{const[a,s]=reactExports.useState(!1);return reactExports.useEffect(()=>{const c=setTimeout(()=>s(!0),500);return()=>clearTimeout(c)},[]),a},useInitEvents=({pageCursor:a,pageSizes:s,activeElements:c,template:u,schemasList:d,changeSchemas:p,commitSchemas:v,removeSchemas:A,onSaveTemplate:b,past:g,future:x,setSchemasList:y,onEdit:f,onEditEnd:m})=>{const C=reactExports.useRef(null),S=reactExports.useCallback(()=>{const I=()=>{const $=c.map(T=>T.id);return d[a].filter(T=>$.includes(T.id))},P=$=>{const T=$==="undo",E=T?g:x;if(E.current.length<=0)return;(T?x:g).current.push(cloneDeep$1(d[a]));const B=cloneDeep$1(d);B[a]=E.current.pop(),y(B)};initShortCuts({move:($,T)=>{const E=s[a],B=I(),R=moveCommandToChangeSchemasArg({command:$,activeSchemas:B,pageSize:E,isShift:T});p(R)},copy:()=>{const $=I();$.length!==0&&(C.current=$)},paste:()=>{if(!C.current||C.current.length===0)return;const $=d[a],T=[],E=C.current.map(B=>{const R=uuid$6(),O=getUniqueSchemaName({copiedSchemaName:B.name,schema:$,stackUniqueSchemaNames:T}),{height:M,width:_,position:D}=B,U=s[a],G={x:D.x+10>U.width-_?U.width-_:D.x+10,y:D.y+10>U.height-M?U.height-M:D.y+10};return Object.assign(cloneDeep$1(B),{id:R,name:O,position:G})});v(d[a].concat(E)),f(E.map(B=>document.getElementById(B.id))),C.current=E},redo:()=>P("redo"),undo:()=>P("undo"),save:()=>b&&b(schemasList2template(d,u.basePdf)),remove:()=>A(I().map($=>$.id)),esc:m,selectAll:()=>f(d[a].map($=>document.getElementById($.id)))})},[u,c,a,s,p,v,d,b,A,g,x,y,C,f,m]),w=reactExports.useCallback(()=>{destroyShortCuts()},[]);reactExports.useEffect(()=>(S(),w),[S,w])},getWithModifiedSize=(a,s,c,u)=>{const p=new DOMParser().parseFromString(a,"text/html"),v=A=>{(A.tagName==="SVG"||A.tagName==="svg")&&(A.setAttribute("width",c.toString()),A.setAttribute("height",c.toString())),Array.from(A.children).forEach(b=>v(b))};return Array.from(p.body.children).forEach(A=>v(A)),jsxRuntimeExports.jsx("div",{style:u,title:s,dangerouslySetInnerHTML:{__html:p.body.innerHTML}})},PluginIcon=a=>{var g;const{plugin:s,label:c,size:u,styles:d}=a,{token:p}=theme.useToken(),A=((g=reactExports.useContext(OptionsContext).icons)==null?void 0:g[s.propPanel.defaultSchema.type])??s.icon,b={...d,color:p.colorText,display:"flex",justifyContent:"center"};return A?u?getWithModifiedSize(A,c,u,b):jsxRuntimeExports.jsx("div",{style:b,title:c,dangerouslySetInnerHTML:{__html:A}}):jsxRuntimeExports.jsx("div",{style:{...d,overflow:"hidden",fontSize:10},title:c,children:c})},SelectableSortableItem=({isSelected:a,style:s,onSelect:c,onEdit:u,schema:d,schemas:p,onMouseEnter:v,onMouseLeave:A})=>{const{token:b}=theme.useToken(),g=reactExports.useContext(I18nContext),x=reactExports.useContext(PluginsRegistry),{setNodeRef:y,listeners:f,isDragging:m,isSorting:C,transform:S,transition:w}=useSortable({id:d.id}),I=useMountStatus(),P=m&&!I,$={...f,onClick:M=>c(d.id,M.shiftKey)},[T,E]=Object.entries(x).find(([M,_])=>(_==null?void 0:_.propPanel.defaultSchema.type)===d.type);let B;d.name?p.find(M=>d.name&&M.name===d.name&&M.id!==d.id)&&(B="is-danger"):B="is-warning";let R=g("edit");B==="is-warning"?R=g("plsInputName"):B==="is-danger"&&(R=g("fieldMustUniq"));const O=a?{background:b.colorPrimary,opacity:C||m?.5:1}:{};return jsxRuntimeExports.jsx(Item,{ref:y,onMouseEnter:v,onMouseLeave:A,onClick:()=>u(d.id),icon:E&&jsxRuntimeExports.jsx(PluginIcon,{plugin:E,label:T,size:20}),value:d.name,status:B,title:R,required:d.required,readOnly:d.readOnly,style:{...O,...s},dragging:m,sorting:C,transition:w,transform:S,fadeIn:P,listeners:$})},SelectableSortableContainer=a=>{const{token:s}=theme.useToken(),{schemas:c,onEdit:u,onSortEnd:d,hoveringSchemaId:p,onChangeHoveringSchemaId:v}=a,[A,b]=reactExports.useState([]),[g,x]=reactExports.useState(null),[y,f]=reactExports.useState(null),m=reactExports.useContext(PluginsRegistry),C=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:15}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),S=P=>A.map($=>$.id).includes(P),w=(P,$)=>{if($)if(S(P)){const T=A.filter(E=>E.id!==P);b(T)}else{const T=c.find(B=>B.id===P),E=A.concat(T);b(E)}else b([])},I=P=>{const $=typeof P=="string"?c.find(B=>B.id===P):P,[T,E]=Object.entries(m).find(([B,R])=>(R==null?void 0:R.propPanel.defaultSchema.type)===($==null?void 0:$.type));return E?jsxRuntimeExports.jsx(PluginIcon,{plugin:E,label:T,size:20,styles:{marginRight:"0.5rem"}}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})};return jsxRuntimeExports.jsx(DndContext,{sensors:C,collisionDetection:closestCorners,onDragStart:({active:P})=>{f(String(P.id)),x(c),S(String(P.id))?A.length>0&&d(A.reduce(($,T)=>T.id===String(P.id)?$:$.filter(E=>E!==T),c)):b([])},onDragEnd:({active:P,over:$})=>{const T=($==null?void 0:$.id)||"",E=c.map(R=>R.id).indexOf(String(P.id)),B=c.map(R=>R.id).indexOf(String(T));if(A.length){let R=[...c];R=arrayMove(R,E,B),R.splice(B+1,0,...A.filter(O=>O.id!==y)),d(R),b([])}else E!==B&&d(arrayMove(c,E,B));f(null)},onDragCancel:()=>{g&&d(g),f(null),x(null)},children:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{style:{height:"100%",overflowY:"auto"},children:jsxRuntimeExports.jsx(SortableContext,{items:c,strategy:verticalListSortingStrategy,children:jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",borderRadius:5},children:c.map(P=>jsxRuntimeExports.jsx(SelectableSortableItem,{style:{border:`1px solid ${P.id===p?s.colorPrimary:"transparent"}`},schema:P,schemas:c,isSelected:S(P.id)||y===P.id,onEdit:u,onSelect:w,onMouseEnter:()=>v(P.id),onMouseLeave:()=>v(null)},P.id))})})}),reactDomExports.createPortal(jsxRuntimeExports.jsx(DragOverlay,{adjustScale:!0,children:y?(()=>{const P=c.find($=>$.id===y);return P?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none"},children:jsxRuntimeExports.jsx(Item,{icon:I(y),value:P.name,required:P.required,readOnly:P.readOnly,style:{background:s.colorPrimary},dragOverlay:!0})}),jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none"},children:A.filter($=>$.id!==y).map($=>jsxRuntimeExports.jsx(Item,{icon:I($),value:$.name,required:$.required,readOnly:$.readOnly,style:{background:s.colorPrimary},dragOverlay:!0},$.id))})]}):null})():null}),document.body)]})})},{Text:Text$3}=Typography,{TextArea:TextArea$2}=Input$1,headHeight=40,ListView=a=>{const{schemas:s,onSortEnd:c,onEdit:u,size:d,hoveringSchemaId:p,onChangeHoveringSchemaId:v,changeSchemas:A}=a,{token:b}=theme.useToken(),g=reactExports.useContext(I18nContext),[x,y]=reactExports.useState(!1),[f,m]=reactExports.useState(""),C=getSidebarContentHeight(d.height),S=()=>{const I=f.split(`
|
775
775
|
`);I.length!==s.length?alert(g("errorBulkUpdateFieldName")):(A(I.map((P,$)=>({key:"name",value:P,schemaId:s[$].id}))),y(!1))},w=()=>{m(s.map(I=>I.name).join(`
|
776
776
|
`)),y(!0)};return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{style:{height:headHeight,display:"flex",alignItems:"center"},children:jsxRuntimeExports.jsx(Text$3,{strong:!0,style:{textAlign:"center",width:"100%"},children:g("fieldsList")})}),jsxRuntimeExports.jsx(Divider,{style:{marginTop:b.marginXS,marginBottom:b.marginXS}}),jsxRuntimeExports.jsxs("div",{style:{height:C-headHeight},children:[x?jsxRuntimeExports.jsx(TextArea$2,{wrap:"off",value:f,onChange:I=>m(I.target.value),style:{paddingLeft:30,height:C-headHeight,width:RIGHT_SIDEBAR_WIDTH-35,lineHeight:"2.75rem"}}):jsxRuntimeExports.jsx(SelectableSortableContainer,{schemas:s,hoveringSchemaId:p,onChangeHoveringSchemaId:v,onSortEnd:c,onEdit:u}),jsxRuntimeExports.jsx("div",{style:{paddingTop:"0.5rem",display:"flex",alignItems:"center",justifyContent:"flex-end"},children:x?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Button$1,{size:"small",type:"text",onClick:S,children:jsxRuntimeExports.jsxs("u",{children:[" ",g("commitBulkUpdateFieldName")]})}),jsxRuntimeExports.jsx("span",{style:{margin:"0 1rem"},children:"/"}),jsxRuntimeExports.jsx(Button$1,{size:"small",type:"text",onClick:()=>y(!1),children:jsxRuntimeExports.jsxs("u",{children:[" ",g("cancel")]})})]}):jsxRuntimeExports.jsx(Button$1,{size:"small",type:"text",onClick:w,children:jsxRuntimeExports.jsxs("u",{children:[" ",g("bulkUpdateFieldName")]})})})]})]})};var freeGlobal=typeof global=="object"&&global&&global.Object===Object&&global,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),Symbol$1=root.Symbol,objectProto$g=Object.prototype,hasOwnProperty$d=objectProto$g.hasOwnProperty,nativeObjectToString$1=objectProto$g.toString,symToStringTag$1=Symbol$1?Symbol$1.toStringTag:void 0;function getRawTag(a){var s=hasOwnProperty$d.call(a,symToStringTag$1),c=a[symToStringTag$1];try{a[symToStringTag$1]=void 0;var u=!0}catch{}var d=nativeObjectToString$1.call(a);return u&&(s?a[symToStringTag$1]=c:delete a[symToStringTag$1]),d}var objectProto$f=Object.prototype,nativeObjectToString=objectProto$f.toString;function objectToString(a){return nativeObjectToString.call(a)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$1?Symbol$1.toStringTag:void 0;function baseGetTag(a){return a==null?a===void 0?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(a)?getRawTag(a):objectToString(a)}function isObjectLike(a){return a!=null&&typeof a=="object"}var symbolTag$3="[object Symbol]";function isSymbol(a){return typeof a=="symbol"||isObjectLike(a)&&baseGetTag(a)==symbolTag$3}function arrayMap(a,s){for(var c=-1,u=a==null?0:a.length,d=Array(u);++c<u;)d[c]=s(a[c],c,a);return d}var isArray$2=Array.isArray,symbolProto$2=Symbol$1?Symbol$1.prototype:void 0,symbolToString=symbolProto$2?symbolProto$2.toString:void 0;function baseToString(a){if(typeof a=="string")return a;if(isArray$2(a))return arrayMap(a,baseToString)+"";if(isSymbol(a))return symbolToString?symbolToString.call(a):"";var s=a+"";return s=="0"&&1/a==-1/0?"-0":s}function isObject$3(a){var s=typeof a;return a!=null&&(s=="object"||s=="function")}function identity$1(a){return a}var asyncTag="[object AsyncFunction]",funcTag$2="[object Function]",genTag$1="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$2(a){if(!isObject$3(a))return!1;var s=baseGetTag(a);return s==funcTag$2||s==genTag$1||s==asyncTag||s==proxyTag}var coreJsData=root["__core-js_shared__"],maskSrcKey=function(){var a=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}();function isMasked(a){return!!maskSrcKey&&maskSrcKey in a}var funcProto$2=Function.prototype,funcToString$2=funcProto$2.toString;function toSource(a){if(a!=null){try{return funcToString$2.call(a)}catch{}try{return a+""}catch{}}return""}var reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto$1=Function.prototype,objectProto$e=Object.prototype,funcToString$1=funcProto$1.toString,hasOwnProperty$c=objectProto$e.hasOwnProperty,reIsNative=RegExp("^"+funcToString$1.call(hasOwnProperty$c).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(a){if(!isObject$3(a)||isMasked(a))return!1;var s=isFunction$2(a)?reIsNative:reIsHostCtor;return s.test(toSource(a))}function getValue$1(a,s){return a==null?void 0:a[s]}function getNative(a,s){var c=getValue$1(a,s);return baseIsNative(c)?c:void 0}var WeakMap$1=getNative(root,"WeakMap"),objectCreate=Object.create,baseCreate=function(){function a(){}return function(s){if(!isObject$3(s))return{};if(objectCreate)return objectCreate(s);a.prototype=s;var c=new a;return a.prototype=void 0,c}}();function apply(a,s,c){switch(c.length){case 0:return a.call(s);case 1:return a.call(s,c[0]);case 2:return a.call(s,c[0],c[1]);case 3:return a.call(s,c[0],c[1],c[2])}return a.apply(s,c)}function copyArray(a,s){var c=-1,u=a.length;for(s||(s=Array(u));++c<u;)s[c]=a[c];return s}var HOT_COUNT=800,HOT_SPAN=16,nativeNow=Date.now;function shortOut(a){var s=0,c=0;return function(){var u=nativeNow(),d=HOT_SPAN-(u-c);if(c=u,d>0){if(++s>=HOT_COUNT)return arguments[0]}else s=0;return a.apply(void 0,arguments)}}function constant(a){return function(){return a}}var defineProperty$4=function(){try{var a=getNative(Object,"defineProperty");return a({},"",{}),a}catch{}}(),baseSetToString=defineProperty$4?function(a,s){return defineProperty$4(a,"toString",{configurable:!0,enumerable:!1,value:constant(s),writable:!0})}:identity$1,setToString=shortOut(baseSetToString);function arrayEach(a,s){for(var c=-1,u=a==null?0:a.length;++c<u&&s(a[c],c,a)!==!1;);return a}var MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(a,s){var c=typeof a;return s=s??MAX_SAFE_INTEGER$1,!!s&&(c=="number"||c!="symbol"&&reIsUint.test(a))&&a>-1&&a%1==0&&a<s}function baseAssignValue(a,s,c){s=="__proto__"&&defineProperty$4?defineProperty$4(a,s,{configurable:!0,enumerable:!0,value:c,writable:!0}):a[s]=c}function eq(a,s){return a===s||a!==a&&s!==s}var objectProto$d=Object.prototype,hasOwnProperty$b=objectProto$d.hasOwnProperty;function assignValue(a,s,c){var u=a[s];(!(hasOwnProperty$b.call(a,s)&&eq(u,c))||c===void 0&&!(s in a))&&baseAssignValue(a,s,c)}function copyObject(a,s,c,u){var d=!c;c||(c={});for(var p=-1,v=s.length;++p<v;){var A=s[p],b=void 0;b===void 0&&(b=a[A]),d?baseAssignValue(c,A,b):assignValue(c,A,b)}return c}var nativeMax=Math.max;function overRest(a,s,c){return s=nativeMax(s===void 0?a.length-1:s,0),function(){for(var u=arguments,d=-1,p=nativeMax(u.length-s,0),v=Array(p);++d<p;)v[d]=u[s+d];d=-1;for(var A=Array(s+1);++d<s;)A[d]=u[d];return A[s]=c(v),apply(a,this,A)}}function baseRest(a,s){return setToString(overRest(a,s,identity$1),a+"")}var MAX_SAFE_INTEGER=9007199254740991;function isLength(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=MAX_SAFE_INTEGER}function isArrayLike(a){return a!=null&&isLength(a.length)&&!isFunction$2(a)}function isIterateeCall(a,s,c){if(!isObject$3(c))return!1;var u=typeof s;return(u=="number"?isArrayLike(c)&&isIndex(s,c.length):u=="string"&&s in c)?eq(c[s],a):!1}function createAssigner(a){return baseRest(function(s,c){var u=-1,d=c.length,p=d>1?c[d-1]:void 0,v=d>2?c[2]:void 0;for(p=a.length>3&&typeof p=="function"?(d--,p):void 0,v&&isIterateeCall(c[0],c[1],v)&&(p=d<3?void 0:p,d=1),s=Object(s);++u<d;){var A=c[u];A&&a(s,A,u,p)}return s})}var objectProto$c=Object.prototype;function isPrototype(a){var s=a&&a.constructor,c=typeof s=="function"&&s.prototype||objectProto$c;return a===c}function baseTimes(a,s){for(var c=-1,u=Array(a);++c<a;)u[c]=s(c);return u}var argsTag$3="[object Arguments]";function baseIsArguments(a){return isObjectLike(a)&&baseGetTag(a)==argsTag$3}var objectProto$b=Object.prototype,hasOwnProperty$a=objectProto$b.hasOwnProperty,propertyIsEnumerable$1=objectProto$b.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(a){return isObjectLike(a)&&hasOwnProperty$a.call(a,"callee")&&!propertyIsEnumerable$1.call(a,"callee")};function stubFalse(){return!1}var freeExports$2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&typeof module=="object"&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,Buffer$2=moduleExports$2?root.Buffer:void 0,nativeIsBuffer=Buffer$2?Buffer$2.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,argsTag$2="[object Arguments]",arrayTag$2="[object Array]",boolTag$3="[object Boolean]",dateTag$3="[object Date]",errorTag$2="[object Error]",funcTag$1="[object Function]",mapTag$5="[object Map]",numberTag$3="[object Number]",objectTag$4="[object Object]",regexpTag$3="[object RegExp]",setTag$5="[object Set]",stringTag$3="[object String]",weakMapTag$2="[object WeakMap]",arrayBufferTag$3="[object ArrayBuffer]",dataViewTag$4="[object DataView]",float32Tag$2="[object Float32Array]",float64Tag$2="[object Float64Array]",int8Tag$2="[object Int8Array]",int16Tag$2="[object Int16Array]",int32Tag$2="[object Int32Array]",uint8Tag$2="[object Uint8Array]",uint8ClampedTag$2="[object Uint8ClampedArray]",uint16Tag$2="[object Uint16Array]",uint32Tag$2="[object Uint32Array]",typedArrayTags={};typedArrayTags[float32Tag$2]=typedArrayTags[float64Tag$2]=typedArrayTags[int8Tag$2]=typedArrayTags[int16Tag$2]=typedArrayTags[int32Tag$2]=typedArrayTags[uint8Tag$2]=typedArrayTags[uint8ClampedTag$2]=typedArrayTags[uint16Tag$2]=typedArrayTags[uint32Tag$2]=!0,typedArrayTags[argsTag$2]=typedArrayTags[arrayTag$2]=typedArrayTags[arrayBufferTag$3]=typedArrayTags[boolTag$3]=typedArrayTags[dataViewTag$4]=typedArrayTags[dateTag$3]=typedArrayTags[errorTag$2]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag$5]=typedArrayTags[numberTag$3]=typedArrayTags[objectTag$4]=typedArrayTags[regexpTag$3]=typedArrayTags[setTag$5]=typedArrayTags[stringTag$3]=typedArrayTags[weakMapTag$2]=!1;function baseIsTypedArray(a){return isObjectLike(a)&&isLength(a.length)&&!!typedArrayTags[baseGetTag(a)]}function baseUnary(a){return function(s){return a(s)}}var freeExports$1=typeof exports=="object"&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&typeof module=="object"&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,freeProcess=moduleExports$1&&freeGlobal.process,nodeUtil=function(){try{var a=freeModule$1&&freeModule$1.require&&freeModule$1.require("util").types;return a||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch{}}(),nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,objectProto$a=Object.prototype,hasOwnProperty$9=objectProto$a.hasOwnProperty;function arrayLikeKeys(a,s){var c=isArray$2(a),u=!c&&isArguments(a),d=!c&&!u&&isBuffer(a),p=!c&&!u&&!d&&isTypedArray(a),v=c||u||d||p,A=v?baseTimes(a.length,String):[],b=A.length;for(var g in a)(s||hasOwnProperty$9.call(a,g))&&!(v&&(g=="length"||d&&(g=="offset"||g=="parent")||p&&(g=="buffer"||g=="byteLength"||g=="byteOffset")||isIndex(g,b)))&&A.push(g);return A}function overArg(a,s){return function(c){return a(s(c))}}var nativeKeys=overArg(Object.keys,Object),objectProto$9=Object.prototype,hasOwnProperty$8=objectProto$9.hasOwnProperty;function baseKeys(a){if(!isPrototype(a))return nativeKeys(a);var s=[];for(var c in Object(a))hasOwnProperty$8.call(a,c)&&c!="constructor"&&s.push(c);return s}function keys(a){return isArrayLike(a)?arrayLikeKeys(a):baseKeys(a)}function nativeKeysIn(a){var s=[];if(a!=null)for(var c in Object(a))s.push(c);return s}var objectProto$8=Object.prototype,hasOwnProperty$7=objectProto$8.hasOwnProperty;function baseKeysIn(a){if(!isObject$3(a))return nativeKeysIn(a);var s=isPrototype(a),c=[];for(var u in a)u=="constructor"&&(s||!hasOwnProperty$7.call(a,u))||c.push(u);return c}function keysIn(a){return isArrayLike(a)?arrayLikeKeys(a,!0):baseKeysIn(a)}var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey(a,s){if(isArray$2(a))return!1;var c=typeof a;return c=="number"||c=="symbol"||c=="boolean"||a==null||isSymbol(a)?!0:reIsPlainProp.test(a)||!reIsDeepProp.test(a)||s!=null&&a in Object(s)}var nativeCreate=getNative(Object,"create");function hashClear(){this.__data__=nativeCreate?nativeCreate(null):{},this.size=0}function hashDelete(a){var s=this.has(a)&&delete this.__data__[a];return this.size-=s?1:0,s}var HASH_UNDEFINED$2="__lodash_hash_undefined__",objectProto$7=Object.prototype,hasOwnProperty$6=objectProto$7.hasOwnProperty;function hashGet(a){var s=this.__data__;if(nativeCreate){var c=s[a];return c===HASH_UNDEFINED$2?void 0:c}return hasOwnProperty$6.call(s,a)?s[a]:void 0}var objectProto$6=Object.prototype,hasOwnProperty$5=objectProto$6.hasOwnProperty;function hashHas(a){var s=this.__data__;return nativeCreate?s[a]!==void 0:hasOwnProperty$5.call(s,a)}var HASH_UNDEFINED$1="__lodash_hash_undefined__";function hashSet(a,s){var c=this.__data__;return this.size+=this.has(a)?0:1,c[a]=nativeCreate&&s===void 0?HASH_UNDEFINED$1:s,this}function Hash(a){var s=-1,c=a==null?0:a.length;for(this.clear();++s<c;){var u=a[s];this.set(u[0],u[1])}}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet;function listCacheClear(){this.__data__=[],this.size=0}function assocIndexOf(a,s){for(var c=a.length;c--;)if(eq(a[c][0],s))return c;return-1}var arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(a){var s=this.__data__,c=assocIndexOf(s,a);if(c<0)return!1;var u=s.length-1;return c==u?s.pop():splice.call(s,c,1),--this.size,!0}function listCacheGet(a){var s=this.__data__,c=assocIndexOf(s,a);return c<0?void 0:s[c][1]}function listCacheHas(a){return assocIndexOf(this.__data__,a)>-1}function listCacheSet(a,s){var c=this.__data__,u=assocIndexOf(c,a);return u<0?(++this.size,c.push([a,s])):c[u][1]=s,this}function ListCache(a){var s=-1,c=a==null?0:a.length;for(this.clear();++s<c;){var u=a[s];this.set(u[0],u[1])}}ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;var Map$1=getNative(root,"Map");function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}function isKeyable(a){var s=typeof a;return s=="string"||s=="number"||s=="symbol"||s=="boolean"?a!=="__proto__":a===null}function getMapData(a,s){var c=a.__data__;return isKeyable(s)?c[typeof s=="string"?"string":"hash"]:c.map}function mapCacheDelete(a){var s=getMapData(this,a).delete(a);return this.size-=s?1:0,s}function mapCacheGet(a){return getMapData(this,a).get(a)}function mapCacheHas(a){return getMapData(this,a).has(a)}function mapCacheSet(a,s){var c=getMapData(this,a),u=c.size;return c.set(a,s),this.size+=c.size==u?0:1,this}function MapCache(a){var s=-1,c=a==null?0:a.length;for(this.clear();++s<c;){var u=a[s];this.set(u[0],u[1])}}MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var FUNC_ERROR_TEXT$1="Expected a function";function memoize(a,s){if(typeof a!="function"||s!=null&&typeof s!="function")throw new TypeError(FUNC_ERROR_TEXT$1);var c=function(){var u=arguments,d=s?s.apply(this,u):u[0],p=c.cache;if(p.has(d))return p.get(d);var v=a.apply(this,u);return c.cache=p.set(d,v)||p,v};return c.cache=new(memoize.Cache||MapCache),c}memoize.Cache=MapCache;var MAX_MEMOIZE_SIZE=500;function memoizeCapped(a){var s=memoize(a,function(u){return c.size===MAX_MEMOIZE_SIZE&&c.clear(),u}),c=s.cache;return s}var rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath=memoizeCapped(function(a){var s=[];return a.charCodeAt(0)===46&&s.push(""),a.replace(rePropName,function(c,u,d,p){s.push(d?p.replace(reEscapeChar,"$1"):u||c)}),s});function toString(a){return a==null?"":baseToString(a)}function castPath(a,s){return isArray$2(a)?a:isKey(a,s)?[a]:stringToPath(toString(a))}function toKey(a){if(typeof a=="string"||isSymbol(a))return a;var s=a+"";return s=="0"&&1/a==-1/0?"-0":s}function baseGet(a,s){s=castPath(s,a);for(var c=0,u=s.length;a!=null&&c<u;)a=a[toKey(s[c++])];return c&&c==u?a:void 0}function get(a,s,c){var u=a==null?void 0:baseGet(a,s);return u===void 0?c:u}function arrayPush(a,s){for(var c=-1,u=s.length,d=a.length;++c<u;)a[d+c]=s[c];return a}var getPrototype=overArg(Object.getPrototypeOf,Object),objectTag$3="[object Object]",funcProto=Function.prototype,objectProto$5=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$4=objectProto$5.hasOwnProperty,objectCtorString=funcToString.call(Object);function isPlainObject(a){if(!isObjectLike(a)||baseGetTag(a)!=objectTag$3)return!1;var s=getPrototype(a);if(s===null)return!0;var c=hasOwnProperty$4.call(s,"constructor")&&s.constructor;return typeof c=="function"&&c instanceof c&&funcToString.call(c)==objectCtorString}function baseSlice(a,s,c){var u=-1,d=a.length;s<0&&(s=-s>d?0:d+s),c=c>d?d:c,c<0&&(c+=d),d=s>c?0:c-s>>>0,s>>>=0;for(var p=Array(d);++u<d;)p[u]=a[u+s];return p}function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(a){var s=this.__data__,c=s.delete(a);return this.size=s.size,c}function stackGet(a){return this.__data__.get(a)}function stackHas(a){return this.__data__.has(a)}var LARGE_ARRAY_SIZE=200;function stackSet(a,s){var c=this.__data__;if(c instanceof ListCache){var u=c.__data__;if(!Map$1||u.length<LARGE_ARRAY_SIZE-1)return u.push([a,s]),this.size=++c.size,this;c=this.__data__=new MapCache(u)}return c.set(a,s),this.size=c.size,this}function Stack(a){var s=this.__data__=new ListCache(a);this.size=s.size}Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;var freeExports=typeof exports=="object"&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&typeof module=="object"&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,Buffer$1=moduleExports?root.Buffer:void 0,allocUnsafe=Buffer$1?Buffer$1.allocUnsafe:void 0;function cloneBuffer(a,s){if(s)return a.slice();var c=a.length,u=allocUnsafe?allocUnsafe(c):new a.constructor(c);return a.copy(u),u}function arrayFilter(a,s){for(var c=-1,u=a==null?0:a.length,d=0,p=[];++c<u;){var v=a[c];s(v,c,a)&&(p[d++]=v)}return p}function stubArray(){return[]}var objectProto$4=Object.prototype,propertyIsEnumerable=objectProto$4.propertyIsEnumerable,nativeGetSymbols$1=Object.getOwnPropertySymbols,getSymbols=nativeGetSymbols$1?function(a){return a==null?[]:(a=Object(a),arrayFilter(nativeGetSymbols$1(a),function(s){return propertyIsEnumerable.call(a,s)}))}:stubArray,nativeGetSymbols=Object.getOwnPropertySymbols,getSymbolsIn=nativeGetSymbols?function(a){for(var s=[];a;)arrayPush(s,getSymbols(a)),a=getPrototype(a);return s}:stubArray;function baseGetAllKeys(a,s,c){var u=s(a);return isArray$2(a)?u:arrayPush(u,c(a))}function getAllKeys(a){return baseGetAllKeys(a,keys,getSymbols)}function getAllKeysIn(a){return baseGetAllKeys(a,keysIn,getSymbolsIn)}var DataView$1=getNative(root,"DataView"),Promise$1=getNative(root,"Promise"),Set$1=getNative(root,"Set"),mapTag$4="[object Map]",objectTag$2="[object Object]",promiseTag="[object Promise]",setTag$4="[object Set]",weakMapTag$1="[object WeakMap]",dataViewTag$3="[object DataView]",dataViewCtorString=toSource(DataView$1),mapCtorString=toSource(Map$1),promiseCtorString=toSource(Promise$1),setCtorString=toSource(Set$1),weakMapCtorString=toSource(WeakMap$1),getTag=baseGetTag;(DataView$1&&getTag(new DataView$1(new ArrayBuffer(1)))!=dataViewTag$3||Map$1&&getTag(new Map$1)!=mapTag$4||Promise$1&&getTag(Promise$1.resolve())!=promiseTag||Set$1&&getTag(new Set$1)!=setTag$4||WeakMap$1&&getTag(new WeakMap$1)!=weakMapTag$1)&&(getTag=function(a){var s=baseGetTag(a),c=s==objectTag$2?a.constructor:void 0,u=c?toSource(c):"";if(u)switch(u){case dataViewCtorString:return dataViewTag$3;case mapCtorString:return mapTag$4;case promiseCtorString:return promiseTag;case setCtorString:return setTag$4;case weakMapCtorString:return weakMapTag$1}return s});var objectProto$3=Object.prototype,hasOwnProperty$3=objectProto$3.hasOwnProperty;function initCloneArray(a){var s=a.length,c=new a.constructor(s);return s&&typeof a[0]=="string"&&hasOwnProperty$3.call(a,"index")&&(c.index=a.index,c.input=a.input),c}var Uint8Array$1=root.Uint8Array;function cloneArrayBuffer(a){var s=new a.constructor(a.byteLength);return new Uint8Array$1(s).set(new Uint8Array$1(a)),s}function cloneDataView(a,s){var c=cloneArrayBuffer(a.buffer);return new a.constructor(c,a.byteOffset,a.byteLength)}var reFlags=/\w*$/;function cloneRegExp(a){var s=new a.constructor(a.source,reFlags.exec(a));return s.lastIndex=a.lastIndex,s}var symbolProto$1=Symbol$1?Symbol$1.prototype:void 0,symbolValueOf$1=symbolProto$1?symbolProto$1.valueOf:void 0;function cloneSymbol(a){return symbolValueOf$1?Object(symbolValueOf$1.call(a)):{}}function cloneTypedArray(a,s){var c=s?cloneArrayBuffer(a.buffer):a.buffer;return new a.constructor(c,a.byteOffset,a.length)}var boolTag$2="[object Boolean]",dateTag$2="[object Date]",mapTag$3="[object Map]",numberTag$2="[object Number]",regexpTag$2="[object RegExp]",setTag$3="[object Set]",stringTag$2="[object String]",symbolTag$2="[object Symbol]",arrayBufferTag$2="[object ArrayBuffer]",dataViewTag$2="[object DataView]",float32Tag$1="[object Float32Array]",float64Tag$1="[object Float64Array]",int8Tag$1="[object Int8Array]",int16Tag$1="[object Int16Array]",int32Tag$1="[object Int32Array]",uint8Tag$1="[object Uint8Array]",uint8ClampedTag$1="[object Uint8ClampedArray]",uint16Tag$1="[object Uint16Array]",uint32Tag$1="[object Uint32Array]";function initCloneByTag(a,s,c){var u=a.constructor;switch(s){case arrayBufferTag$2:return cloneArrayBuffer(a);case boolTag$2:case dateTag$2:return new u(+a);case dataViewTag$2:return cloneDataView(a);case float32Tag$1:case float64Tag$1:case int8Tag$1:case int16Tag$1:case int32Tag$1:case uint8Tag$1:case uint8ClampedTag$1:case uint16Tag$1:case uint32Tag$1:return cloneTypedArray(a,c);case mapTag$3:return new u;case numberTag$2:case stringTag$2:return new u(a);case regexpTag$2:return cloneRegExp(a);case setTag$3:return new u;case symbolTag$2:return cloneSymbol(a)}}function initCloneObject(a){return typeof a.constructor=="function"&&!isPrototype(a)?baseCreate(getPrototype(a)):{}}var mapTag$2="[object Map]";function baseIsMap(a){return isObjectLike(a)&&getTag(a)==mapTag$2}var nodeIsMap=nodeUtil&&nodeUtil.isMap,isMap=nodeIsMap?baseUnary(nodeIsMap):baseIsMap,setTag$2="[object Set]";function baseIsSet(a){return isObjectLike(a)&&getTag(a)==setTag$2}var nodeIsSet=nodeUtil&&nodeUtil.isSet,isSet=nodeIsSet?baseUnary(nodeIsSet):baseIsSet,CLONE_DEEP_FLAG$1=1,argsTag$1="[object Arguments]",arrayTag$1="[object Array]",boolTag$1="[object Boolean]",dateTag$1="[object Date]",errorTag$1="[object Error]",funcTag="[object Function]",genTag="[object GeneratorFunction]",mapTag$1="[object Map]",numberTag$1="[object Number]",objectTag$1="[object Object]",regexpTag$1="[object RegExp]",setTag$1="[object Set]",stringTag$1="[object String]",symbolTag$1="[object Symbol]",weakMapTag="[object WeakMap]",arrayBufferTag$1="[object ArrayBuffer]",dataViewTag$1="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",cloneableTags={};cloneableTags[argsTag$1]=cloneableTags[arrayTag$1]=cloneableTags[arrayBufferTag$1]=cloneableTags[dataViewTag$1]=cloneableTags[boolTag$1]=cloneableTags[dateTag$1]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[mapTag$1]=cloneableTags[numberTag$1]=cloneableTags[objectTag$1]=cloneableTags[regexpTag$1]=cloneableTags[setTag$1]=cloneableTags[stringTag$1]=cloneableTags[symbolTag$1]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag$1]=cloneableTags[funcTag]=cloneableTags[weakMapTag]=!1;function baseClone(a,s,c,u,d,p){var v,A=s&CLONE_DEEP_FLAG$1;if(v!==void 0)return v;if(!isObject$3(a))return a;var b=isArray$2(a);if(b)v=initCloneArray(a);else{var g=getTag(a),x=g==funcTag||g==genTag;if(isBuffer(a))return cloneBuffer(a,A);if(g==objectTag$1||g==argsTag$1||x&&!d)v=x?{}:initCloneObject(a);else{if(!cloneableTags[g])return d?a:{};v=initCloneByTag(a,g,A)}}p||(p=new Stack);var y=p.get(a);if(y)return y;p.set(a,v),isSet(a)?a.forEach(function(C){v.add(baseClone(C,s,c,C,a,p))}):isMap(a)&&a.forEach(function(C,S){v.set(S,baseClone(C,s,c,S,a,p))});var f=getAllKeys,m=b?void 0:f(a);return arrayEach(m||a,function(C,S){m&&(S=C,C=a[S]),assignValue(v,S,baseClone(C,s,c,S,a,p))}),v}var CLONE_DEEP_FLAG=1,CLONE_SYMBOLS_FLAG=4;function cloneDeep(a){return baseClone(a,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG)}var HASH_UNDEFINED="__lodash_hash_undefined__";function setCacheAdd(a){return this.__data__.set(a,HASH_UNDEFINED),this}function setCacheHas(a){return this.__data__.has(a)}function SetCache(a){var s=-1,c=a==null?0:a.length;for(this.__data__=new MapCache;++s<c;)this.add(a[s])}SetCache.prototype.add=SetCache.prototype.push=setCacheAdd,SetCache.prototype.has=setCacheHas;function arraySome(a,s){for(var c=-1,u=a==null?0:a.length;++c<u;)if(s(a[c],c,a))return!0;return!1}function cacheHas(a,s){return a.has(s)}var COMPARE_PARTIAL_FLAG$5=1,COMPARE_UNORDERED_FLAG$3=2;function equalArrays(a,s,c,u,d,p){var v=c&COMPARE_PARTIAL_FLAG$5,A=a.length,b=s.length;if(A!=b&&!(v&&b>A))return!1;var g=p.get(a),x=p.get(s);if(g&&x)return g==s&&x==a;var y=-1,f=!0,m=c&COMPARE_UNORDERED_FLAG$3?new SetCache:void 0;for(p.set(a,s),p.set(s,a);++y<A;){var C=a[y],S=s[y];if(u)var w=v?u(S,C,y,s,a,p):u(C,S,y,a,s,p);if(w!==void 0){if(w)continue;f=!1;break}if(m){if(!arraySome(s,function(I,P){if(!cacheHas(m,P)&&(C===I||d(C,I,c,u,p)))return m.push(P)})){f=!1;break}}else if(!(C===S||d(C,S,c,u,p))){f=!1;break}}return p.delete(a),p.delete(s),f}function mapToArray(a){var s=-1,c=Array(a.size);return a.forEach(function(u,d){c[++s]=[d,u]}),c}function setToArray(a){var s=-1,c=Array(a.size);return a.forEach(function(u){c[++s]=u}),c}var COMPARE_PARTIAL_FLAG$4=1,COMPARE_UNORDERED_FLAG$2=2,boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",mapTag="[object Map]",numberTag="[object Number]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",symbolTag="[object Symbol]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",symbolProto=Symbol$1?Symbol$1.prototype:void 0,symbolValueOf=symbolProto?symbolProto.valueOf:void 0;function equalByTag(a,s,c,u,d,p,v){switch(c){case dataViewTag:if(a.byteLength!=s.byteLength||a.byteOffset!=s.byteOffset)return!1;a=a.buffer,s=s.buffer;case arrayBufferTag:return!(a.byteLength!=s.byteLength||!p(new Uint8Array$1(a),new Uint8Array$1(s)));case boolTag:case dateTag:case numberTag:return eq(+a,+s);case errorTag:return a.name==s.name&&a.message==s.message;case regexpTag:case stringTag:return a==s+"";case mapTag:var A=mapToArray;case setTag:var b=u&COMPARE_PARTIAL_FLAG$4;if(A||(A=setToArray),a.size!=s.size&&!b)return!1;var g=v.get(a);if(g)return g==s;u|=COMPARE_UNORDERED_FLAG$2,v.set(a,s);var x=equalArrays(A(a),A(s),u,d,p,v);return v.delete(a),x;case symbolTag:if(symbolValueOf)return symbolValueOf.call(a)==symbolValueOf.call(s)}return!1}var COMPARE_PARTIAL_FLAG$3=1,objectProto$2=Object.prototype,hasOwnProperty$2=objectProto$2.hasOwnProperty;function equalObjects(a,s,c,u,d,p){var v=c&COMPARE_PARTIAL_FLAG$3,A=getAllKeys(a),b=A.length,g=getAllKeys(s),x=g.length;if(b!=x&&!v)return!1;for(var y=b;y--;){var f=A[y];if(!(v?f in s:hasOwnProperty$2.call(s,f)))return!1}var m=p.get(a),C=p.get(s);if(m&&C)return m==s&&C==a;var S=!0;p.set(a,s),p.set(s,a);for(var w=v;++y<b;){f=A[y];var I=a[f],P=s[f];if(u)var $=v?u(P,I,f,s,a,p):u(I,P,f,a,s,p);if(!($===void 0?I===P||d(I,P,c,u,p):$)){S=!1;break}w||(w=f=="constructor")}if(S&&!w){var T=a.constructor,E=s.constructor;T!=E&&"constructor"in a&&"constructor"in s&&!(typeof T=="function"&&T instanceof T&&typeof E=="function"&&E instanceof E)&&(S=!1)}return p.delete(a),p.delete(s),S}var COMPARE_PARTIAL_FLAG$2=1,argsTag="[object Arguments]",arrayTag="[object Array]",objectTag="[object Object]",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function baseIsEqualDeep(a,s,c,u,d,p){var v=isArray$2(a),A=isArray$2(s),b=v?arrayTag:getTag(a),g=A?arrayTag:getTag(s);b=b==argsTag?objectTag:b,g=g==argsTag?objectTag:g;var x=b==objectTag,y=g==objectTag,f=b==g;if(f&&isBuffer(a)){if(!isBuffer(s))return!1;v=!0,x=!1}if(f&&!x)return p||(p=new Stack),v||isTypedArray(a)?equalArrays(a,s,c,u,d,p):equalByTag(a,s,b,c,u,d,p);if(!(c&COMPARE_PARTIAL_FLAG$2)){var m=x&&hasOwnProperty$1.call(a,"__wrapped__"),C=y&&hasOwnProperty$1.call(s,"__wrapped__");if(m||C){var S=m?a.value():a,w=C?s.value():s;return p||(p=new Stack),d(S,w,c,u,p)}}return f?(p||(p=new Stack),equalObjects(a,s,c,u,d,p)):!1}function baseIsEqual(a,s,c,u,d){return a===s?!0:a==null||s==null||!isObjectLike(a)&&!isObjectLike(s)?a!==a&&s!==s:baseIsEqualDeep(a,s,c,u,baseIsEqual,d)}var COMPARE_PARTIAL_FLAG$1=1,COMPARE_UNORDERED_FLAG$1=2;function baseIsMatch(a,s,c,u){var d=c.length,p=d;if(a==null)return!p;for(a=Object(a);d--;){var v=c[d];if(v[2]?v[1]!==a[v[0]]:!(v[0]in a))return!1}for(;++d<p;){v=c[d];var A=v[0],b=a[A],g=v[1];if(v[2]){if(b===void 0&&!(A in a))return!1}else{var x=new Stack,y;if(!(y===void 0?baseIsEqual(g,b,COMPARE_PARTIAL_FLAG$1|COMPARE_UNORDERED_FLAG$1,u,x):y))return!1}}return!0}function isStrictComparable(a){return a===a&&!isObject$3(a)}function getMatchData(a){for(var s=keys(a),c=s.length;c--;){var u=s[c],d=a[u];s[c]=[u,d,isStrictComparable(d)]}return s}function matchesStrictComparable(a,s){return function(c){return c==null?!1:c[a]===s&&(s!==void 0||a in Object(c))}}function baseMatches(a){var s=getMatchData(a);return s.length==1&&s[0][2]?matchesStrictComparable(s[0][0],s[0][1]):function(c){return c===a||baseIsMatch(c,a,s)}}function baseHasIn(a,s){return a!=null&&s in Object(a)}function hasPath(a,s,c){s=castPath(s,a);for(var u=-1,d=s.length,p=!1;++u<d;){var v=toKey(s[u]);if(!(p=a!=null&&c(a,v)))break;a=a[v]}return p||++u!=d?p:(d=a==null?0:a.length,!!d&&isLength(d)&&isIndex(v,d)&&(isArray$2(a)||isArguments(a)))}function hasIn(a,s){return a!=null&&hasPath(a,s,baseHasIn)}var COMPARE_PARTIAL_FLAG=1,COMPARE_UNORDERED_FLAG=2;function baseMatchesProperty(a,s){return isKey(a)&&isStrictComparable(s)?matchesStrictComparable(toKey(a),s):function(c){var u=get(c,a);return u===void 0&&u===s?hasIn(c,a):baseIsEqual(s,u,COMPARE_PARTIAL_FLAG|COMPARE_UNORDERED_FLAG)}}function baseProperty(a){return function(s){return s==null?void 0:s[a]}}function basePropertyDeep(a){return function(s){return baseGet(s,a)}}function property(a){return isKey(a)?baseProperty(toKey(a)):basePropertyDeep(a)}function baseIteratee(a){return typeof a=="function"?a:a==null?identity$1:typeof a=="object"?isArray$2(a)?baseMatchesProperty(a[0],a[1]):baseMatches(a):property(a)}function createBaseFor(a){return function(s,c,u){for(var d=-1,p=Object(s),v=u(s),A=v.length;A--;){var b=v[++d];if(c(p[b],b,p)===!1)break}return s}}var baseFor=createBaseFor();function baseForOwn(a,s){return a&&baseFor(a,s,keys)}function createBaseEach(a,s){return function(c,u){if(c==null)return c;if(!isArrayLike(c))return a(c,u);for(var d=c.length,p=-1,v=Object(c);++p<d&&u(v[p],p,v)!==!1;);return c}}var baseEach=createBaseEach(baseForOwn);function assignMergeValue(a,s,c){(c!==void 0&&!eq(a[s],c)||c===void 0&&!(s in a))&&baseAssignValue(a,s,c)}function isArrayLikeObject(a){return isObjectLike(a)&&isArrayLike(a)}function safeGet$1(a,s){if(!(s==="constructor"&&typeof a[s]=="function")&&s!="__proto__")return a[s]}function toPlainObject(a){return copyObject(a,keysIn(a))}function baseMergeDeep(a,s,c,u,d,p,v){var A=safeGet$1(a,c),b=safeGet$1(s,c),g=v.get(b);if(g){assignMergeValue(a,c,g);return}var x=p?p(A,b,c+"",a,s,v):void 0,y=x===void 0;if(y){var f=isArray$2(b),m=!f&&isBuffer(b),C=!f&&!m&&isTypedArray(b);x=b,f||m||C?isArray$2(A)?x=A:isArrayLikeObject(A)?x=copyArray(A):m?(y=!1,x=cloneBuffer(b,!0)):C?(y=!1,x=cloneTypedArray(b,!0)):x=[]:isPlainObject(b)||isArguments(b)?(x=A,isArguments(A)?x=toPlainObject(A):(!isObject$3(A)||isFunction$2(A))&&(x=initCloneObject(b))):y=!1}y&&(v.set(b,x),d(x,b,u,p,v),v.delete(b)),assignMergeValue(a,c,x)}function baseMerge(a,s,c,u,d){a!==s&&baseFor(s,function(p,v){if(d||(d=new Stack),isObject$3(p))baseMergeDeep(a,s,v,c,baseMerge,u,d);else{var A=u?u(safeGet$1(a,v),p,v+"",a,s,d):void 0;A===void 0&&(A=p),assignMergeValue(a,v,A)}},keysIn)}createAssigner(function(a,s,c,u){baseMerge(a,s,c,u)});function last(a){var s=a==null?0:a.length;return s?a[s-1]:void 0}var objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function baseHas(a,s){return a!=null&&hasOwnProperty.call(a,s)}function has(a,s){return a!=null&&hasPath(a,s,baseHas)}function parent(a,s){return s.length<2?a:baseGet(a,baseSlice(s,0,-1))}function isMatch(a,s){return a===s||baseIsMatch(a,s,getMatchData(s))}function isUndefined$1(a){return a===void 0}createAssigner(function(a,s,c){baseMerge(a,s,c)});var FUNC_ERROR_TEXT="Expected a function";function negate(a){if(typeof a!="function")throw new TypeError(FUNC_ERROR_TEXT);return function(){var s=arguments;switch(s.length){case 0:return!a.call(this);case 1:return!a.call(this,s[0]);case 2:return!a.call(this,s[0],s[1]);case 3:return!a.call(this,s[0],s[1],s[2])}return!a.apply(this,s)}}function baseUnset(a,s){return s=castPath(s,a),a=parent(a,s),a==null||delete a[toKey(last(s))]}function baseSet(a,s,c,u){if(!isObject$3(a))return a;s=castPath(s,a);for(var d=-1,p=s.length,v=p-1,A=a;A!=null&&++d<p;){var b=toKey(s[d]),g=c;if(b==="__proto__"||b==="constructor"||b==="prototype")return a;if(d!=v){var x=A[b];g=void 0,g===void 0&&(g=isObject$3(x)?x:isIndex(s[d+1])?[]:{})}assignValue(A,b,g),A=A[b]}return a}function basePickBy(a,s,c){for(var u=-1,d=s.length,p={};++u<d;){var v=s[u],A=baseGet(a,v);c(A,v)&&baseSet(p,castPath(v,a),A)}return p}function pickBy(a,s){if(a==null)return{};var c=arrayMap(getAllKeysIn(a),function(u){return[u]});return s=baseIteratee(s),basePickBy(a,c,function(u,d){return s(u,d[0])})}function omitBy(a,s){return pickBy(a,negate(baseIteratee(s)))}function set(a,s,c){return a==null?a:baseSet(a,s,c)}function baseSome(a,s){var c;return baseEach(a,function(u,d,p){return c=s(u,d,p),!c}),!!c}function some$1(a,s,c){var u=isArray$2(a)?arraySome:baseSome;return c&&isIterateeCall(a,s,c)&&(s=void 0),u(a,baseIteratee(s))}function unset$1(a,s){return a==null?!0:baseUnset(a,s)}const __vite_import_meta_env__={},createStoreImpl=a=>{let s;const c=new Set,u=(x,y)=>{const f=typeof x=="function"?x(s):x;if(!Object.is(f,s)){const m=s;s=y??(typeof f!="object"||f===null)?f:Object.assign({},s,f),c.forEach(C=>C(s,m))}},d=()=>s,b={setState:u,getState:d,getInitialState:()=>g,subscribe:x=>(c.add(x),()=>c.delete(x)),destroy:()=>{(__vite_import_meta_env__?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),c.clear()}},g=s=a(u,d,b);return b},createStore$1=a=>a?createStoreImpl(a):createStoreImpl;var withSelector={exports:{}},withSelector_production={},shim={exports:{}},useSyncExternalStoreShim_production={};/**
|
777
777
|
* @license React
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@testing-library/jest-dom';
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@testing-library/jest-dom';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import type { SidebarProps } from '../../../../types.js';
|
3
|
-
declare const SelectableSortableContainer: (props: Pick<SidebarProps,
|
3
|
+
declare const SelectableSortableContainer: (props: Pick<SidebarProps, "schemas" | "onEdit" | "onSortEnd" | "hoveringSchemaId" | "onChangeHoveringSchemaId">) => React.JSX.Element;
|
4
4
|
export default SelectableSortableContainer;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { SidebarProps } from '../../../../types.js';
|
3
|
+
declare const ListView: (props: Pick<SidebarProps, "schemas" | "onSortEnd" | "onEdit" | "size" | "hoveringSchemaId" | "onChangeHoveringSchemaId" | "changeSchemas">) => React.JSX.Element;
|
4
|
+
export default ListView;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { PreviewProps, Size } from '@pdfme/common';
|
3
3
|
declare const Preview: ({ template, inputs, size, onChangeInput, }: Omit<PreviewProps, "domContainer"> & {
|
4
|
-
onChangeInput?: (
|
4
|
+
onChangeInput?: (args: {
|
5
5
|
index: number;
|
6
6
|
value: string;
|
7
7
|
name: string;
|
8
|
-
}) => void
|
8
|
+
}) => void;
|
9
9
|
size: Size;
|
10
10
|
}) => React.JSX.Element;
|
11
11
|
export default Preview;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Plugins, UIOptions } from '@pdfme/common';
|
2
|
+
export declare const I18nContext: import("react").Context<(key: keyof import("@pdfme/common").Dict, dict?: import("@pdfme/common").Dict) => string>;
|
3
|
+
export declare const FontContext: import("react").Context<Record<string, {
|
4
|
+
data: string | ArrayBuffer | Uint8Array;
|
5
|
+
fallback?: boolean | undefined;
|
6
|
+
subset?: boolean | undefined;
|
7
|
+
}>>;
|
8
|
+
export declare const PluginsRegistry: import("react").Context<Plugins>;
|
9
|
+
export declare const OptionsContext: import("react").Context<UIOptions>;
|
10
|
+
export declare const CacheContext: import("react").Context<Map<any, any>>;
|
@@ -4,9 +4,8 @@ export declare const set: <T extends object>(obj: T, path: string | string[], va
|
|
4
4
|
export declare const debounce: <T extends Function>(cb: T, wait?: number) => T;
|
5
5
|
export declare const round: (number: number, precision: number) => number;
|
6
6
|
export declare const flatten: <T>(arr: T[][]) => T[];
|
7
|
-
declare const esc = "esc";
|
8
7
|
export declare const initShortCuts: (arg: {
|
9
|
-
move: (command:
|
8
|
+
move: (command: "up" | "down" | "left" | "right", isShift: boolean) => void;
|
10
9
|
remove: () => void;
|
11
10
|
esc: () => void;
|
12
11
|
copy: () => void;
|
@@ -46,7 +45,7 @@ export declare const getUniqueSchemaName: (arg: {
|
|
46
45
|
stackUniqueSchemaNames: string[];
|
47
46
|
}) => string;
|
48
47
|
export declare const moveCommandToChangeSchemasArg: (props: {
|
49
|
-
command:
|
48
|
+
command: "up" | "down" | "left" | "right";
|
50
49
|
activeSchemas: SchemaForUI[];
|
51
50
|
isShift: boolean;
|
52
51
|
pageSize: Size;
|
@@ -73,4 +72,3 @@ export declare const changeSchemas: (args: {
|
|
73
72
|
commitSchemas: (newSchemas: SchemaForUI[]) => void;
|
74
73
|
}) => void;
|
75
74
|
export declare const getMaxZoom: () => number;
|
76
|
-
export {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/ui",
|
3
|
-
"version": "5.3.8-dev.
|
3
|
+
"version": "5.3.8-dev.56",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -54,6 +54,7 @@
|
|
54
54
|
"@pdfme/schemas": "file:../schemas",
|
55
55
|
"@testing-library/jest-dom": "^6.6.3",
|
56
56
|
"@testing-library/react": "^12.1.2",
|
57
|
+
"@types/jest": "^29.5.14",
|
57
58
|
"@types/react": "^17.0.52",
|
58
59
|
"@types/react-dom": "^17.0.18",
|
59
60
|
"@ungap/structured-clone": "^1.3.0",
|
package/src/helper.ts
CHANGED
@@ -17,13 +17,16 @@ import { DEFAULT_MAX_ZOOM, RULER_HEIGHT } from './constants.js';
|
|
17
17
|
import { OptionsContext } from './contexts.js';
|
18
18
|
|
19
19
|
// Create a simple mock for hotkeys to avoid TypeScript errors
|
20
|
-
const hotkeys = function
|
20
|
+
const hotkeys = function (
|
21
|
+
keys: string,
|
22
|
+
callback: (e: KeyboardEvent, handler: { shortcut: string }) => void
|
23
|
+
) {
|
21
24
|
return (hotkeysJs as any)(keys, callback);
|
22
25
|
};
|
23
26
|
|
24
27
|
// Add properties to the hotkeys function
|
25
28
|
(hotkeys as any).shift = false;
|
26
|
-
(hotkeys as any).unbind = function(keys: string) {
|
29
|
+
(hotkeys as any).unbind = function (keys: string) {
|
27
30
|
// Do nothing if hotkeysJs doesn't have unbind
|
28
31
|
if (typeof (hotkeysJs as any).unbind === 'function') {
|
29
32
|
(hotkeysJs as any).unbind(keys);
|
@@ -279,8 +282,10 @@ export const template2SchemasList = async (_template: Template) => {
|
|
279
282
|
}));
|
280
283
|
} else {
|
281
284
|
const b64BasePdf = await getB64BasePdf(basePdf);
|
282
|
-
//
|
283
|
-
|
285
|
+
// @ts-expect-error
|
286
|
+
const pdfArrayBuffer = b64toUint8Array(b64BasePdf) as ArrayBuffer;
|
287
|
+
|
288
|
+
pageSizes = await pdf2size(pdfArrayBuffer);
|
284
289
|
}
|
285
290
|
|
286
291
|
const ssl = schemasForUI.length;
|
@@ -491,4 +496,4 @@ export const getMaxZoom = () => {
|
|
491
496
|
const options = useContext(OptionsContext);
|
492
497
|
|
493
498
|
return options.maxZoom ? (options.maxZoom as number) / 100 : DEFAULT_MAX_ZOOM;
|
494
|
-
}
|
499
|
+
};
|
package/src/hooks.ts
CHANGED
@@ -66,11 +66,15 @@ export const useUIPreProcessor = ({ template, size, zoomLevel, maxZoom }: UIPreP
|
|
66
66
|
} else {
|
67
67
|
const _basePdf = await getB64BasePdf(basePdf);
|
68
68
|
|
69
|
+
const uint8Array = b64toUint8Array(_basePdf);
|
70
|
+
// Create a new ArrayBuffer copy to avoid detachment issues
|
71
|
+
const pdfArrayBuffer = new ArrayBuffer(uint8Array.byteLength);
|
72
|
+
new Uint8Array(pdfArrayBuffer).set(uint8Array);
|
73
|
+
|
69
74
|
const [_pages, imgBuffers] = await Promise.all([
|
70
|
-
pdf2size(
|
71
|
-
pdf2img(
|
75
|
+
pdf2size(pdfArrayBuffer),
|
76
|
+
pdf2img(pdfArrayBuffer.slice(), { scale: maxZoom }),
|
72
77
|
]);
|
73
|
-
|
74
78
|
_pageSizes = _pages;
|
75
79
|
paperWidth = _pageSizes[0].width * ZOOM;
|
76
80
|
paperHeight = _pageSizes[0].height * ZOOM;
|
@@ -92,7 +96,9 @@ export const useUIPreProcessor = ({ template, size, zoomLevel, maxZoom }: UIPreP
|
|
92
96
|
useEffect(() => {
|
93
97
|
init({ template, size })
|
94
98
|
.then(({ pageSizes, scale, backgrounds }) => {
|
95
|
-
setPageSizes(pageSizes)
|
99
|
+
setPageSizes(pageSizes);
|
100
|
+
setScale(scale);
|
101
|
+
setBackgrounds(backgrounds);
|
96
102
|
})
|
97
103
|
.catch((err: Error) => {
|
98
104
|
setError(err);
|
@@ -107,7 +113,9 @@ export const useUIPreProcessor = ({ template, size, zoomLevel, maxZoom }: UIPreP
|
|
107
113
|
error,
|
108
114
|
refresh: (template: Template) =>
|
109
115
|
init({ template, size }).then(({ pageSizes, scale, backgrounds }) => {
|
110
|
-
setPageSizes(pageSizes)
|
116
|
+
setPageSizes(pageSizes);
|
117
|
+
setScale(scale);
|
118
|
+
setBackgrounds(backgrounds);
|
111
119
|
}),
|
112
120
|
};
|
113
121
|
};
|
package/tsconfig.json
CHANGED
@@ -17,13 +17,11 @@
|
|
17
17
|
"moduleResolution": "nodenext",
|
18
18
|
"allowSyntheticDefaultImports": true,
|
19
19
|
"strict": true,
|
20
|
-
"types": [
|
21
|
-
"node",
|
22
|
-
"jest",
|
23
|
-
"@types/jest"
|
24
|
-
],
|
20
|
+
"types": ["jest"],
|
25
21
|
"typeRoots": [
|
26
|
-
"../node_modules/@types"
|
22
|
+
"../node_modules/@types",
|
23
|
+
"./node_modules/@types",
|
24
|
+
"../../node_modules/@types"
|
27
25
|
],
|
28
26
|
"sourceMap": true,
|
29
27
|
"baseUrl": ".",
|
@@ -39,12 +37,12 @@
|
|
39
37
|
},
|
40
38
|
"include": [
|
41
39
|
"src/**/*.ts",
|
42
|
-
"src/**/*.tsx"
|
40
|
+
"src/**/*.tsx",
|
41
|
+
"__tests__/**/*.ts",
|
42
|
+
"__tests__/**/*.tsx"
|
43
43
|
],
|
44
44
|
"exclude": [
|
45
45
|
"node_modules",
|
46
|
-
"dist"
|
47
|
-
"**/*.test.ts",
|
48
|
-
"**/*.spec.ts"
|
46
|
+
"dist"
|
49
47
|
]
|
50
48
|
}
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import type { SidebarProps } from '../../../../types.js';
|
3
|
-
declare const ListView: (props: Pick<SidebarProps, 'schemas' | 'onSortEnd' | 'onEdit' | 'size' | 'hoveringSchemaId' | 'onChangeHoveringSchemaId' | 'changeSchemas'>) => React.JSX.Element;
|
4
|
-
export default ListView;
|
package/dist/types/contexts.d.ts
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { Plugins, UIOptions } from '@pdfme/common';
|
3
|
-
export declare const I18nContext: import("react").Context<(key: "cancel" | "close" | "set" | "clear" | "field" | "fieldName" | "align" | "width" | "opacity" | "height" | "rotate" | "edit" | "required" | "editable" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "type" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "addPageAfter" | "removePage" | "removePageConfirm" | "validation.uniqueName" | "validation.hexColor" | "validation.dateTimeFormat" | "schemas.color" | "schemas.borderWidth" | "schemas.borderColor" | "schemas.backgroundColor" | "schemas.textColor" | "schemas.bgColor" | "schemas.horizontal" | "schemas.vertical" | "schemas.left" | "schemas.center" | "schemas.right" | "schemas.top" | "schemas.middle" | "schemas.bottom" | "schemas.padding" | "schemas.text.fontName" | "schemas.text.size" | "schemas.text.spacing" | "schemas.text.textAlign" | "schemas.text.verticalAlign" | "schemas.text.lineHeight" | "schemas.text.min" | "schemas.text.max" | "schemas.text.fit" | "schemas.text.dynamicFontSize" | "schemas.text.format" | "schemas.mvt.typingInstructions" | "schemas.mvt.sampleField" | "schemas.mvt.variablesSampleData" | "schemas.barcodes.barColor" | "schemas.barcodes.includetext" | "schemas.table.alternateBackgroundColor" | "schemas.table.tableStyle" | "schemas.table.showHead" | "schemas.table.headStyle" | "schemas.table.bodyStyle" | "schemas.table.columnStyle" | "schemas.date.format" | "schemas.date.locale" | "schemas.select.options" | "schemas.select.optionPlaceholder" | "schemas.radioGroup.groupName", dict?: {
|
4
|
-
cancel: string;
|
5
|
-
close: string;
|
6
|
-
set: string;
|
7
|
-
clear: string;
|
8
|
-
field: string;
|
9
|
-
fieldName: string;
|
10
|
-
align: string;
|
11
|
-
width: string;
|
12
|
-
opacity: string;
|
13
|
-
height: string;
|
14
|
-
rotate: string;
|
15
|
-
edit: string;
|
16
|
-
required: string;
|
17
|
-
editable: string;
|
18
|
-
plsInputName: string;
|
19
|
-
fieldMustUniq: string;
|
20
|
-
notUniq: string;
|
21
|
-
noKeyName: string;
|
22
|
-
fieldsList: string;
|
23
|
-
editField: string;
|
24
|
-
type: string;
|
25
|
-
errorOccurred: string;
|
26
|
-
errorBulkUpdateFieldName: string;
|
27
|
-
commitBulkUpdateFieldName: string;
|
28
|
-
bulkUpdateFieldName: string;
|
29
|
-
addPageAfter: string;
|
30
|
-
removePage: string;
|
31
|
-
removePageConfirm: string;
|
32
|
-
'validation.uniqueName': string;
|
33
|
-
'validation.hexColor': string;
|
34
|
-
'validation.dateTimeFormat': string;
|
35
|
-
'schemas.color': string;
|
36
|
-
'schemas.borderWidth': string;
|
37
|
-
'schemas.borderColor': string;
|
38
|
-
'schemas.backgroundColor': string;
|
39
|
-
'schemas.textColor': string;
|
40
|
-
'schemas.bgColor': string;
|
41
|
-
'schemas.horizontal': string;
|
42
|
-
'schemas.vertical': string;
|
43
|
-
'schemas.left': string;
|
44
|
-
'schemas.center': string;
|
45
|
-
'schemas.right': string;
|
46
|
-
'schemas.top': string;
|
47
|
-
'schemas.middle': string;
|
48
|
-
'schemas.bottom': string;
|
49
|
-
'schemas.padding': string;
|
50
|
-
'schemas.text.fontName': string;
|
51
|
-
'schemas.text.size': string;
|
52
|
-
'schemas.text.spacing': string;
|
53
|
-
'schemas.text.textAlign': string;
|
54
|
-
'schemas.text.verticalAlign': string;
|
55
|
-
'schemas.text.lineHeight': string;
|
56
|
-
'schemas.text.min': string;
|
57
|
-
'schemas.text.max': string;
|
58
|
-
'schemas.text.fit': string;
|
59
|
-
'schemas.text.dynamicFontSize': string;
|
60
|
-
'schemas.text.format': string;
|
61
|
-
'schemas.mvt.typingInstructions': string;
|
62
|
-
'schemas.mvt.sampleField': string;
|
63
|
-
'schemas.mvt.variablesSampleData': string;
|
64
|
-
'schemas.barcodes.barColor': string;
|
65
|
-
'schemas.barcodes.includetext': string;
|
66
|
-
'schemas.table.alternateBackgroundColor': string;
|
67
|
-
'schemas.table.tableStyle': string;
|
68
|
-
'schemas.table.showHead': string;
|
69
|
-
'schemas.table.headStyle': string;
|
70
|
-
'schemas.table.bodyStyle': string;
|
71
|
-
'schemas.table.columnStyle': string;
|
72
|
-
'schemas.date.format': string;
|
73
|
-
'schemas.date.locale': string;
|
74
|
-
'schemas.select.options': string;
|
75
|
-
'schemas.select.optionPlaceholder': string;
|
76
|
-
'schemas.radioGroup.groupName': string;
|
77
|
-
} | undefined) => string>;
|
78
|
-
export declare const FontContext: import("react").Context<Record<string, {
|
79
|
-
data: string | ArrayBuffer | Uint8Array;
|
80
|
-
fallback?: boolean | undefined;
|
81
|
-
subset?: boolean | undefined;
|
82
|
-
}>>;
|
83
|
-
export declare const PluginsRegistry: import("react").Context<Plugins>;
|
84
|
-
export declare const OptionsContext: import("react").Context<UIOptions>;
|
85
|
-
export declare const CacheContext: import("react").Context<Map<any, any>>;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/AlignWidget.d.ts
RENAMED
File without changes
|
File without changes
|
File without changes
|
/package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/index.d.ts
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|