PageSourceSearch

https://xn----7sbblivwnxcgmi.xn--p1ai/_next/static/chunks/9737.0a4792da4f73b0e9.js

js xn----7sbblivwnxcgmi.xn--p1ai collected 2026-10-05 00:40:48 UTC 269,890 bytes, 23 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9737],{27529:(e,t,i)=>{function n(e){let t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.category_slug&&t.set("category_slug",e.category_slug),e?.slug&&t.set("slug",e.slug);let i=t.toString();return`/api/products${i?`?${i}`:""}`}i.d(t,{Cn:()=>s,L$:()=>c,P1:()=>o,Ub:()=>a,_G:()=>l,iy:()=>r,sH:()=>n,xp:()=>d});let r="/api/gallery",a="/api/constructor/crosses",l="/api/constructor/flowers",s="/api/constructor/fonts",o="/api/constructor/image-proxy",c="/api/constructor/screen-mode";function d(e){let t=new URLSearchParams;e?.type&&t.set("type",e.type),e?.category_id!=null&&t.set("category_id",String(e.category_id)),e?.id!=null&&t.set("id",String(e.id));let i=t.toString();return`/api/engraving-images${i?`?${i}`:""}`}},34798:(e,t,i)=>{i.d(t,{GB:()=>l,Ie:()=>d,KE:()=>c,Kz:()=>s,M3:()=>a,MQ:()=>r,P9:()=>x,Pl:()=>o,Vs:()=>p,Wc:()=>u,Xx:()=>m,af:()=>n,qM:()=>h});let n="/icons/vk.png",r="/home-constructor-desktop.jpg",a="/home-constructor-mobile.jpg",l="/about-company-workshop.png",s="/retouch/before-01.jpg",o="/retouch/after-01.jpg",c=[{id:1,category:"restoration",before:"/retouch/before-01.jpg",after:"/retouch/after-01.jpg"},{id:2,category:"quality",before:"/retouch/before-02.jpg",after:"/retouch/after-02.jpg"},{id:3,category:"defects",before:"/retouch/before-03.jpg",after:"/retouch/after-03.jpg"}],d="https://s3.twcstorage.ru/master-granit-media/uploads/5f050fc2-bf90-4f4b-9485-adeeb033bc36.png",h=[{image:"/gold-leaf-engraving/step-01-outline.png",label:"Разметка эскиза"},{image:"/gold-leaf-engraving/step-02-hand-engraving.png",label:"Ручная гравировка"},{image:"/gold-leaf-engraving/step-03-machine-engraving.png",label:"Фрезерная обработка"},{image:"/gold-leaf-engraving/step-04-gold-leaf.png",label:"Нанесение золота"}],m="/gold-leaf-engraving/hero-angle.png",x="/gold-leaf-engraving/hero-front.png",u="/gold-leaf-engraving/process.mp4",p="/gold-leaf-engraving/example-video.mp4"},45160:(e,t,i)=>{i.d(t,{E:()=>s});var n=i(95155);i(12115);var r=i(12431),a=i(40980);let l=(0,r.F)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function s({className:e,variant:t,...i}){return(0,n.jsx)("div",{className:(0,a.cn)(l({variant:t}),e),...i})}},49737:(e,t,i)=>{i.r(t),i.d(t,{default:()=>tk});var n=i(95155),r=i(89239),a=i(63048),l=i(12115),s=i(27108),o=i(73714),c=i(6695),d=i(27529);async function h(e,t=d.L$){let i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image_url:e})});if(!i.ok)throw Error(`screen-mode API: HTTP ${i.status}`);let n=await i.json();if(!n.processed_image)throw Error("screen-mode API: пустой ответ");return n.processed_image}async function m(e,t=d.P1,i=d.L$){try{let{url:i,crossOrigin:r}=e.startsWith("data:")||e.startsWith("/")?{url:e,crossOrigin:!1}:e.startsWith("http://")||e.startsWith("https://")?{url:`${t}?url=${encodeURIComponent(e)}`,crossOrigin:!0}:{url:e,crossOrigin:!1};var n=await new Promise((e,t)=>{let n=new Image;r&&(n.crossOrigin="anonymous"),n.onload=()=>{let i=document.createElement("canvas"),r=n.naturalWidth||1,a=n.naturalHeight||1,l=Math.min(1,2e3/Math.max(r,a));i.width=Math.max(1,Math.round(r*l)),i.height=Math.max(1,Math.round(a*l));let s=i.getContext("2d");s?(s.drawImage(n,0,0,i.width,i.height),e(i)):t(Error("Canvas недоступен"))},n.onerror=()=>t(Error("Не удалось загрузить изображение")),n.src=i});let a=n.getContext("2d");if(!a)throw Error("Canvas недоступен");let l=a.getImageData(0,0,n.width,n.height);return!function(e){for(let t=0;t<e.length;t+=4){let i=e[t+3];if(0===i)continue;let n=e[t]/255,r=e[t+1]/255,a=e[t+2]/255,l=i/255,s=.299*n+.587*r+.114*a,o=1-(1-n)*.5,c=1-(1-r)*.5,d=1-(1-a)*.5;e[t]=255*o,e[t+1]=255*c,e[t+2]=255*d,e[t+3]=Math.pow(s,.7)*l*255}}(l.data),a.putImageData(l,0,0),n.toDataURL()}catch(e){console.warn("screen-mode (client):",e)}try{return await h(e,i)}catch(t){return console.error("screen-mode:",t),e}}async function x(e,t=1600){if("function"==typeof createImageBitmap)try{let i=await createImageBitmap(e);try{let e=Math.min(1,t/Math.max(i.width,i.height,1)),n=Math.max(1,Math.round(i.width*e)),r=Math.max(1,Math.round(i.height*e)),a=document.createElement("canvas");a.width=n,a.height=r;let l=a.getContext("2d");if(!l)throw Error("Canvas недоступен");return l.drawImage(i,0,0,n,r),a.toDataURL("image/jpeg",.92)}finally{i.close()}}catch{}let i=await new Promise((t,i)=>{let n=new FileReader;n.onload=()=>t(String(n.result||"")),n.onerror=()=>i(Error("Не удалось прочитать файл")),n.readAsDataURL(e)});if(!i)throw Error("Пустой файл изображения");try{let e=await new Promise((e,t)=>
1{let n=new Image;n.onload=()=>e(n),n.onerror=()=>t(Error("Не удалось декодировать изображение")),n.src=i}),n=Math.min(1,t/Math.max(e.naturalWidth,e.naturalHeight,1));if(n>=1)return i;let r=document.createElement("canvas");r.width=Math.max(1,Math.round(e.naturalWidth*n)),r.height=Math.max(1,Math.round(e.naturalHeight*n));let a=r.getContext("2d");if(!a)return i;return a.drawImage(e,0,0,r.width,r.height),r.toDataURL("image/jpeg",.92)}catch{return i}}var u=i(60529),p=i(33807),g=i(45160);let f=[{id:"400x800",label:"40 \xd7 80 см",widthMm:400,heightMm:800,pedestalWidthMm:500},{id:"450x900",label:"45 \xd7 90 см",widthMm:450,heightMm:900,pedestalWidthMm:500},{id:"500x1000",label:"50 \xd7 100 см",widthMm:500,heightMm:1e3,pedestalWidthMm:600},{id:"600x1200",label:"60 \xd7 120 см",widthMm:600,heightMm:1200,pedestalWidthMm:700}];function w(e){return e?Math.max(1,e.split("\n").length):1}function y(e){return`${Math.round(e)}`}function b(e){return new Intl.NumberFormat("ru-RU").format(e)+" ₽"}function v(e,t){return`${y(e)} \xd7 ${y(t)} мм`}function j(e,t){return f.find(i=>i.widthMm===e&&i.heightMm===t)}function N(e,t,i,n){if(!i||!n||i<=0||n<=0||e<=0||t<=0)return{widthPx:e,heightPx:t};let r=Math.min(e/i,t/n);return{widthPx:i*r,heightPx:n*r}}let M=({monumentWidthMm:e,monumentHeightMm:t,monumentSizeSlotLabel:i,onMonumentSizeChange:r,mmPerPx:a,selectedLayout:l,engravingItems:s,totalEngravingPrice:o,embedded:c=!1})=>{let d=j(e,t),h=d?.id??"custom";return(0,n.jsxs)("div",{className:c?"h-full":"flex-shrink-0 border-b border-white/10 bg-[#141414]",children:[!c&&(0,n.jsx)("div",{className:"px-3 pt-3 pb-2 border-b border-white/10",children:(0,n.jsx)("p",{className:"text-[10px] font-semibold text-white/40 uppercase tracking-widest",children:"Размеры и расчёт"})}),(0,n.jsxs)("div",{className:"p-3 space-y-3",children:[c&&(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Размеры и расчёт"}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:i?`Размер — ${i}`:"Размер памятника"}),(0,n.jsxs)("select",{value:h,onChange:e=>(e=>{if("custom"===e)return;let t=f.find(t=>t.id===e);t&&r(t.widthMm,t.heightMm)})(e.target.value),className:"mt-1 w-full h-9 rounded-md border border-white/10 bg-[#1e1e1e] px-2 text-sm text-white",children:[f.map(e=>(0,n.jsx)("option",{value:e.id,children:e.label},e.id)),!d&&(0,n.jsx)("option",{value:"custom",children:"Свой размер"})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Ширина, мм"}),(0,n.jsx)(u.p,{type:"number",min:100,max:5e3,value:e,onChange:e=>{let i=Number(e.target.value);i>0&&r(i,t)},className:"mt-1 h-9 bg-[#1e1e1e] border-white/10 text-white"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Высота, мм"}),(0,n.jsx)(u.p,{type:"number",min:100,max:5e3,value:t,onChange:t=>{let i=Number(t.target.value);i>0&&r(e,i)},className:"mt-1 h-9 bg-[#1e1e1e] border-white/10 text-white"})]})]}),(0,n.jsxs)("div",{className:"rounded-md bg-[#1a1a1a] border border-white/10 px-3 py-2 space-y-1.5 text-xs",children:[(0,n.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-white/50",children:"Памятник"}),(0,n.jsx)("span",{className:"text-white font-medium",children:v(e,t)})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-white/50",children:"Масштаб холста"}),(0,n.jsxs)("span",{className:"text-white/80",children:["1 px ≈ ",y(a)," мм"]})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-white/50",children:"Тариф"}),(0,n.jsxs)("span",{className:"text-white/80",children:[b(7e3)," / лист A4"]})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-white/50",children:"Минимум за элемент"}),(0,n.jsxs)("span",{className:"text-white/80",children:["от ",b(3500)]})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-white/50",children:"Текст"}),(0,n.jsxs)("span",{className:"text-white/80",children:[b(1e3)," / строка"]})]})]}),l&&(0,n.jsxs)("div",{className:"rounded-md border border-[#F39200]/40 bg-[#F39200]/10 px-3 py-2",children:[(0,n.jsx)("p",{className:"text-[10px] uppercase tracking-widest text-[#F39200]/80 mb-1",children:"Выбранный элемент"}
1),l.isTextPrice?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-sm",children:[(0,n.jsx)("span",{className:"text-white/70",children:"Строк"}),(0,n.jsx)("span",{className:"text-white font-medium",children:l.lineCount??1})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-sm mt-1",children:[(0,n.jsx)("span",{className:"text-white/70",children:"Стоимость текста"}),(0,n.jsx)("span",{className:"text-[#F39200] font-semibold",children:b(l.priceRub)})]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-sm",children:[(0,n.jsx)("span",{className:"text-white/70",children:"Размер на памятнике"}),(0,n.jsx)("span",{className:"text-white font-medium",children:v(l.widthMm,l.heightMm)})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-sm mt-1",children:[(0,n.jsx)("span",{className:"text-white/70",children:l.isFixedPrice?"Фиксированная цена":"Стоимость гравировки"}),(0,n.jsx)("span",{className:"text-[#F39200] font-semibold",children:b(l.priceRub)})]})]})]}),s.length>0&&(0,n.jsxs)("div",{className:"rounded-md bg-[#1a1a1a] border border-white/10 px-3 py-2",children:[(0,n.jsx)("p",{className:"text-[10px] uppercase tracking-widest text-white/40 mb-2",children:"Элементы на памятнике"}),(0,n.jsx)("div",{className:"space-y-1.5 max-h-28 overflow-y-auto scrollbar-site",children:s.map(e=>(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-xs",children:[(0,n.jsx)("span",{className:"text-white/60 truncate",children:e.label}),(0,n.jsx)("span",{className:"text-white/90 whitespace-nowrap",children:e.isTextPrice?`${e.lineCount??1} стр. \xb7 ${b(e.priceRub)}`:`${v(e.widthMm,e.heightMm)} \xb7 ${b(e.priceRub)}`})]},e.id))}),(0,n.jsxs)("div",{className:"mt-2 pt-2 border-t border-white/10 flex justify-between gap-2 text-sm",children:[(0,n.jsx)("span",{className:"text-white/70",children:"Итого"}),(0,n.jsx)("span",{className:"text-[#F39200] font-semibold",children:b(o)})]})]})]})]})};function S(e){if(!e||e.startsWith("data:")||e.startsWith("/")&&!e.startsWith("//"))return e;try{if(new URL(e,window.location.origin).origin===window.location.origin)return e}catch{}return`${d.P1}?url=${encodeURIComponent(e)}`}function k(e){if(e.startsWith("data:")||e.startsWith("/")&&!e.startsWith("//"))return!0;try{return new URL(e,window.location.origin).origin===window.location.origin}catch{return!1}}function C(e,t){if(!e||!t)return null;let i=S(t);for(let n of e.querySelectorAll("img[data-export-src]"))if(n.dataset.exportSrc===t&&n.complete&&!(n.naturalWidth<=0)){if(!k(t)&&!(n.currentSrc.includes("/api/constructor/image-proxy")||n.src===i))continue;return n}return null}async function z(e,t,i=1e4){let n=[...new Set(t.filter(Boolean))];if(!e||0===n.length)return;let r=Date.now()+i;for(;Date.now()<r;){if(n.every(t=>C(e,t)))return;await new Promise(e=>setTimeout(e,80))}}function $(e,t,i,n){let r=i/Math.max(e,1);return{scaleX:r,scaleY:n/Math.max(t,1),fontScale:r}}function F(e,t){let i=e.x+e.width/2,n=t.monuments.findIndex(e=>i>=e.x&&i<=e.x+e.width);return n>=0?n:0}function P(e,t,i){let n=i.width/Math.max(t.width,1),r=("text"===e.type||"epitaph"===e.type||"fio"===e.type||"dates"===e.type)&&!e.autoSize,a=Math.round(e.width*n),l=Math.round(e.height*n);return r?{x:Math.round(i.x+(e.x+e.width/2-t.x)*n-a/2),y:Math.round(i.y+(e.y+e.height/2-t.y)*n-l/2),width:a,height:l,fontScale:n}:{x:Math.round(i.x+(e.x-t.x)*n),y:Math.round(i.y+(e.y-t.y)*n),width:a,height:l,fontScale:n}}function E(e,t,i,n,r){var a,l,s;let o,c,d;if(t?.monuments?.length&&i?.monuments?.length){let n=F(e,t);return P(e,t.monuments[n]??t.monuments[0],i.monuments[n]??i.monuments[0])}return{...(a=e,l=n,s=r,o=("text"===a.type||"epitaph"===a.type||"fio"===a.type||"dates"===a.type)&&!a.autoSize,c=Math.round(a.width*l),d=Math.round(a.height*s),o?{x:Math.round((a.x+a.width/2)*l-c/2),y:Math.round((a.y+a.height/2)*s-d/2),width:c,height:d}:{x:Math.round(a.x*l),y:Math.round(a.y*s),width:c,height:d}),fontScale:n}}function I(e,t){let i=t?.threshold??12,n=t?.maxSpread??6,r=e.width,a=e.height,l=document.createElement("canvas");l.width=r,l.height=a;let s=l.getContext("2d");if(!s)return l;s.drawImage(e,0,0,r,a);let o=s.getImageData(0,0,r,a),c=o.data,d=e=>{let t=4*e,r=c[t],a=c[t+1],l=c[t+2],s=Math.max(r,a,l),o=Math.min(r,a,l);return s<=i&&s-o<=n},h=new Uint8Array(r*a),m=[];for(let e=0;e<r;e++)for(let t of[0,a-1]){let i=t*r+e;d(i)&&m.push(i)}for(let e=0;e<a;e++)for(let t of[0,r-1]){let i=e*r+t;d(i)&&m.push(i)}let x=0;for(;x<m.length;){let e=m[x++];if(h[e]||!d(e))continue;h[e]=1,c[4*e+3]=0;let t=e%r,i=e/r|0;t>0&&m.push(e-1),t<r-1&&m.push(e+1),i>0&&m.push(e-r),i<a-1&&m.push(e+r)}return s.putImageData(o,0,0),l}async function H(e){return e?new Promise(t=>{let i=new Image;i.crossOrigin="anonymous",i.onload=()=>{let e=document.createElement("canvas");
1e.width=i.naturalWidth||i.width,e.height=i.naturalHeight||i.height;let n=e.getContext("2d");n?(n.drawImage(i,0,0),t(e)):t(null)},i.onerror=()=>t(null),i.src=e}):null}async function A(e){return H(e)}async function R(e){return e?new Promise(t=>{let i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(I(i)),i.onerror=()=>t(null),i.src=e}):null}function W(e,t,i){if(i)return i;let n={widthMm:e,heightMm:t};return[n,{...n}]}function T(e){return"double"===e||"horizontal-double"===e||"mixed-double"===e}function D(e){return"horizontal"===e||"horizontal-double"===e}function L(e,t){return t||("horizontal-double"===e?[!0,!0]:"mixed-double"===e?[!1,!0]:[!1,!1])}function _(e,t){return e?t.heightMm:t.widthMm}function X(e,t){return e?t.widthMm:t.heightMm}function B(e,t){return T(e)&&1===t}let Y="#b0b0b0";function U(e,t,i){return D(e??"single")?{widthMm:i,heightMm:t}:{widthMm:t,heightMm:i}}function O(e,t,i,n,r,a,l){if(T(e??"single")){let s=L(e??"double",a),o=W(t,i,l),c=_(s[0],o[0]),d=_(s[1],o[1]),h=Math.max(r,J(s,o,n));return n+h+(c+d)/2}return Math.max(n,U(e,t,i).widthMm)}function J(e,t,i){return Math.max(0,(_(e[0],t[0])+_(e[1],t[1]))/2-i)}function G(e,t,i,n){return Math.max(e,J(t,i,n))}function V(e,t,i){return i+Math.max(X(e[0],t[0]),X(e[1],t[1]))}let q=16/9,K="/constructor/backgrounds/plitka.png",Z="/constructor/backgrounds/trava-lev.png",Q="/constructor/backgrounds/trava-rpaw.png",ee={src:"/constructor/scene-vase-cutout.png",previewFrames:["/constructor/scene-vase-preview-2.png","/constructor/scene-vase-preview-1.png"],aspect:283/478},et={src:"/constructor/scene-vase-red-cutout.png",previewFrames:["/constructor/scene-vase-red-preview-straight.png","/constructor/scene-vase-red-preview-tilted.png"],aspect:283/478},ei={src:"/constructor/scene-vase-gray-cutout.png",previewFrames:["/constructor/scene-vase-gray-preview-straight.png","/constructor/scene-vase-gray-preview-tilted.png"],aspect:283/478},en={src:"/constructor/scene-vase-silver-cutout.png",previewFrames:["/constructor/scene-vase-silver-preview-straight.png","/constructor/scene-vase-silver-preview-tilted.png"],aspect:283/478},er={src:"/constructor/scene-vase-white-cutout.png",previewFrames:["/constructor/scene-vase-white-preview-straight.png","/constructor/scene-vase-white-preview-tilted.png"],aspect:283/478},ea={black:ee,red:et,gray:ei,silver:en,white:er},el="/constructor/scene-lamp.png",es={src:"/constructor/scene-flowerbed.png",aspect:1024/430},eo={src:"/constructor/pedestal-test.png",widthMm:600,heightMm:Math.round(214.453125)};function ec(e){return Math.round(366*e/1024)}function ed(e=1200){return{width:e,height:Math.round(e/.72)}}function eh(e,t,i){var n;let r,a,{x:l,y:s,width:o,height:c,visualScale:d,origin:h}=i,m=Math.ceil(o),x=Math.ceil(c),u=o/d,p=c/d,g=t.width&&t.height&&t.height>0?t.width/t.height:u/Math.max(p,1),f=(n="bottom-left"===h?"left":"right",g>u/Math.max(p,1)?a=(r=u)/g:r=(a=p)*g,{x:"right"===n?u-r:0,y:p-a,width:r,height:a}),w="bottom-right"===h,y=document.createElement("canvas");y.width=m,y.height=x;let b=y.getContext("2d");if(!b)return;b.save(),b.beginPath(),b.rect(0,0,m,x),b.clip(),b.translate(w?m:0,x),b.scale(d,d),b.drawImage(t,w?f.x-u:f.x,f.y-p,f.width,f.height),b.restore();let v=e.canvas.width,j=e.canvas.height,N=Math.max(0,Math.floor(l)),M=Math.max(0,Math.floor(s)),S=Math.min(v,Math.ceil(l+o))-N,k=Math.min(j,Math.ceil(s+c))-M;if(S<=0||k<=0)return;let C=e.getImageData(N,M,S,k),z=b.getImageData(0,0,m,x),$=e.createImageData(S,k);for(let e=0;e<k;e++)for(let t=0;t<S;t++){let i=(e*S+t)*4,n=Math.floor(N+t-l),r=Math.floor(M+e-s),a=C.data[i],o=C.data[i+1],c=C.data[i+2];if(n<0||r<0||n>=m||r>=x){$.data[i]=a,$.data[i+1]=o,$.data[i+2]=c,$.data[i+3]=255;continue}let d=(r*m+n)*4,h=z.data[d],u=z.data[d+1],p=z.data[d+2],g=z.data[d+3]/255;if(g<=0)$.data[i]=a,$.data[i+1]=o,$.data[i+2]=c;else{let e=a*h/255,t=o*u/255,n=c*p/255;$.data[i]=Math.round((1-g)*a+g*e),$.data[i+1]=Math.round((1-g)*o+g*t),$.data[i+2]=Math.round((1-g)*c+g*n)}$.data[i+3]=255}e.putImageData($,N,M)}function em(e,t,i=!1){return i?e-t-.035*e:e-.18*e/2-t-.018*e}function ex(e){var t,i,n,r,a,l;let s=!0===e.omitPlitkaOffset,o=function(e,t,i,n,r,a=!1){let l=i*r,s=n*r;return{x:(e-l)/2,y:em(t,s,a),width:l,height:s}}(e.canvasW,e.canvasH,e.pedestalWidthMm,e.pedestalHeightMm,e.mmPerPx,s),c=o.height*((100-e.pedestalAnchorPct)/100+.028)+5*e.mmPerPx,d=(i=e.monumentWidthMm,i*e.mmPerPx),h=(n=e.monumentHeightMm,n*e.mmPerPx);if("horizontal"===e.monumentType){let e={x:o.x+(o.width-h)/2,y:o.y-d+c,width:h,height:d};return{pedestal:o,group:e,monuments:[e],dimensionRect:e,horizontal:!0,horizontalSlots:[!0,!1]}}if(T(e.monumentType)){let t=L(e.monumentType,e.monumentSlotHorizontal),i=W(e.monumentWidthMm,e.monumentHeightMm,e.monumentSlotSizes),n=(r=G(e.monumentGapMm,t,i,e.pedestalWidthMm),r*e.mmPerPx),o=(a=e.pedestalWidthMm,a*e.mmPerPx),d=(l=e.pedestalHeightMm,l*e.mmPerPx),h=em(e.canvasH,d,s),m=2*o+n,x=(e.canvasW-m)/2,u=[{x:x,y:h,width:o,height:d},{x:x+o+n,y:h,width:o,height:d}],p=u.map((n,r)=>{var a,l;let s,o;return a=t[r],s=(l=i[r]).widthMm*e.mmPerPx,o=l.heightMm*e.mmPerPx,a?{x:n.x+(n.width-o)/2,y:n.y-s+c,width:o,height:s}:{x:n.x+(n.width-s)/2,y:n.y-o+c,width:s,height:o}}),g=Math.max(p[0].height,p[1].height);return{pedestal:{x:x,y:h,width:m,height:d},pedestals:u,group:{x:x,y:h-g+c,width:m,height:g+d},monuments:p,dimensionRect:p[0],horizontal:t.every(Boolean),horizontalSlots:t}}if(e.combinedCatalogImage){let t=h+o.height,i=Math.max(d,o.width),n={x:(e.canvasW-i)/2,y:o.y+o.height-t+c,width:i,height:t};return{pedestal:o,group:n,monuments:[n],dimensionRect:n}}let m=(t=e.canvasW,d>o.width?Math.max(0,(t-d)/2):o.x+(o.width-d)/2),x={x:m,y:o.y-h+c,width:d,height:h};return{pedestal:o,group:x,monuments:[x],dimensionRect:x}}function eu(e){if(e.canvasW<=0||e.canvasH<=0)return 2;let t="studio"===e.sceneMode,i=!1!==e.showGroundLayers,n=i?.18*e.canvasH:0,r=Math.max(100,Math.max(0,e.canvasH-n)-e.canvasH*(!i&&t?.025:.05)),a=U(e.monumentType,e.monumentWidthMm,e.monumentHeightMm),l=.96*r/Math.max(T(e.monumentType??"single")?V(L(e.monumentType??"double",e.monumentSlotHorizontal),W(e.monumentWidthMm,e.monumentHeightMm,e.monumentSlotSizes),e.pedestalHeightMm):e.pedestalHeightMm+a.heightMm,1),s=e.monumentGapMm??50,o=O(e.monumentType,e.monumentWidthMm,e.monumentHeightMm,e.pedestalWidthMm,s,e.monumentSlotHorizontal,e.monumentSlotSizes),c=T(e.monumentType??"single"),d=e.canvasW*(c?.68:.42)/Math.max(o,1),h=e.mobile?1.28:1.08,m=t?.99:.96;return Math.min(3.24*Math.min(l,d)*h*m,l*m,d*m)}function ep(e,t,i){return{x:e.x+t,y:e.y+i,width:e.width,height:e.height}}function eg(e,t,i,n=!1){n?(e.save(),e.translate(i.x+i.width,i.y),e.scale(-1,1),e.drawImage(t,0,0,i.width,i.height),e.restore(
1)):e.drawImage(t,i.x,i.y,i.width,i.height)}function ef(e,t,i){let n=function(e,t,i){if(e<=0||t<=0||i<=0)return{x:0,y:0,width:e,height:t};if(i>e/t){let n=e/i;return{x:0,y:(t-n)/2,width:e,height:n}}let n=t*i;return{x:(e-n)/2,y:0,width:n,height:t}}(e,t,i);return{x:n.x,y:t-n.height,width:n.width,height:n.height}}function ew(e,t,i,n=!1,r=!1){if(!n){let n=t.width&&t.height&&t.height>0?t.width/t.height:i.width/Math.max(i.height,1),a=ef(i.width,i.height,n),l=i.x+a.x,s=i.y+a.y;e.save(),r?(e.translate(l+a.width,s),e.scale(-1,1),e.drawImage(t,0,0,a.width,a.height)):e.drawImage(t,l,s,a.width,a.height),e.restore();return}e.save(),e.beginPath(),e.rect(i.x,i.y,i.width,i.height),e.clip();let a=i.height,l=i.width,s=t.width&&t.height&&t.height>0?t.width/t.height:a/Math.max(l,1),o=ef(a,l,s);e.translate(i.x,i.y+i.height),e.rotate(-Math.PI/2),r?(e.translate(o.x+o.width,o.y),e.scale(-1,1),e.drawImage(t,0,0,o.width,o.height)):e.drawImage(t,o.x,o.y,o.width,o.height),e.restore()}function ey(e,t,i,n,r,a){let l,s,o,c;if(0===t.length)return[];let d=(s=Math.min(...(l=e.pedestals??[e.pedestal]).map(e=>e.x)),o=Math.max(...l.map(e=>e.x+e.width)),{x:s,y:c=Math.min(...l.map(e=>e.y)),width:o-s,height:Math.max(...l.map(e=>e.y+e.height))-c}),h=Math.max(8,.06*d.width),m=d.height*r,x=m*i,u=d.y+d.height;if(n&&n>0){let e=n*a;x>e&&(m=(x=e)/i)}return t.map(e=>{let t="left"===e?d.x-h-x:d.x+d.width+h;return n&&n>0&&("right"===e&&t+x>n-4&&(t=Math.max(4,n-4-x)),"left"===e&&t<4&&(t=4)),{x:t,y:u-m,width:x,height:m}})}function eb(e,t,i=ee.aspect,n){return ey(e,t,i,n,2.45,.24)}function ev(e,t,i=.62,n){return ey(e,t,i,n,1.85,.17)}function ej(e,t){return 50*(600===e&&1200===t)}function eN(e,t=es.aspect,i,n,r,a,l,s){if(null==i||i<=0)return[];let o=e.pedestals??[e.pedestal];return o.map((e,r)=>(function(e,t,i,n,r,a,l,s=!0,o=0){if(e.width<=0||e.height<=0||t<=0||i<=0)return null;let c=Math.max(1,i-ej(a,l)),d=e.width*(i/c),h=null!=n&&n>0?n:e.height,m=130/i*d,x=(0+o)/i*d,u=e.x+e.width,p=e.x,g=d+m,f=s?u-g+x:p-m/2+x,w=g/t,y=.11*e.height,b=e.height*(130/h),v=e.y+e.height-y-b;if(null!=r&&r>0&&v+w>r){let e=Math.max(1,r-v);w>e&&(g=(w=e)*t,f=s?u-g+x:p-m/2+x),v+w>r&&(v=Math.max(0,r-w))}return{x:f,y:v,width:g,height:w}})(e,t,i,n,a,l,s,1!==r||1===o.length,65*(1===r&&o.length>1))).filter(e=>null!=e)}function eM(e,t,i){let n=t.width&&t.height&&t.height>0?t.width/t.height:ee.aspect,r=i.width/Math.max(i.height,1),a=i.width,l=i.height,s=i.x,o=i.y;n>r?l=i.width/n:(a=i.height*n,s=i.x+(i.width-a)/2),o=i.y+i.height-l,e.drawImage(t,s,o,a,l)}async function eS(e,t,i,n){var r,a,l,s;let o=n.sceneMode??"outdoor",c=!n.sceneBackgroundSrc,d=c&&!n.sceneBackgroundSrc?n.sceneVaseSides??[]:[],h=c&&!n.sceneBackgroundSrc?n.sceneLampSides??[]:[],m=c&&!n.sceneBackgroundSrc&&n.sceneFlowerbed&&n.pedestalImageSrc,x=n.sceneVaseSrc??ee.src,u=n.sceneLampSrc??el,p=n.sceneFlowerbedSrc??es.src,g=n.loadImage,[f,w,y,b,v,j,N,M,S,k]=await Promise.all([g(K),g(Z),g(Q),n.sceneBackgroundSrc?g(n.sceneBackgroundSrc):Promise.resolve(null),g(n.monumentImageSrc),T(n.monumentType)&&n.monumentImage2Src?g(n.monumentImage2Src):Promise.resolve(null),n.pedestalImageSrc?g(n.pedestalImageSrc):Promise.resolve(null),d.length>0?g(x):Promise.resolve(null),h.length>0?g(u):Promise.resolve(null),m?g(p):Promise.resolve(null)]);!function(e,t,i,n,r,a="outdoor"){let l,s,o,c;if(n.full)return e.drawImage(n.full,0,0,t,i);let d=.18*i,h=(l=t*(.14+14*!!T(r)/100),s=.56*t,o=.38*i,{left:{x:-l,y:c=i-0*i-o,width:s,height:o,visualScale:1.45,origin:"bottom-left"},right:{x:t-s+l,y:c,width:s,height:o,visualScale:1.7,origin:"bottom-right"}});"studio"===a?(e.fillStyle=Y,e.fillRect(0,0,t,i),function(e,t,i,n=24){e.save(),e.strokeStyle="rgba(0, 0, 0, 0.07)",e.lineWidth=1;for(let r=0;r<=t;r+=n)e.beginPath(),e.moveTo(r+.5,0),e.lineTo(r+.5,i),e.stroke();for(let r=0;r<=i;r+=n)e.beginPath(),e.moveTo(0,r+.5),e.lineTo(t,r+.5),e.stroke();e.restore()}(e,t,i)):(e.fillStyle="#0a0a0a",e.fillRect(0,0,t,i)),n.plitka&&e.drawImage(n.plitka,0,i-d,t,d),n.travaLev&&eh(e,n.travaLev,h.left),n.travaRpaw&&eh(e,n.travaRpaw,h.right)}(e,t,i,{plitka:f,travaLev:w,travaRpaw:y,full:b},n.monumentType,b?"outdoor":o);let C=v&&v.width&&v.height?v.width/v.height:.75,z=j&&j.width&&j.height?j.width/j.height:C,$=ex({canvasW:t,canvasH:i,monumentType:n.monumentType,monumentGapMm:n.monumentGapMm,monumentWidthMm:n.monumentWidthMm,monumentHeightMm:n.monumentHeightMm,pedestalWidthMm:n.pedestalWidthMm,pedestalHeightMm:n.pedestalHeightMm,pedestalAnchorPct:n.pede
1stalAnchorPct,mmPerPx:n.mmPerPx,aspect1:C,aspect2:z,monumentSlotHorizontal:n.monumentSlotHorizontal,monumentSlotSizes:n.monumentSlotSizes,combinedCatalogImage:!n.pedestalImageSrc&&"single"===n.monumentType});if(N&&($.pedestals??[$.pedestal]).forEach((t,i)=>{eg(e,N,t,B(n.monumentType,i))}),k&&m&&eN($,k.width&&k.height&&k.height>0?k.width/k.height:es.aspect,(r=n.pedestalWidthMm,n.monumentType,n.monumentGapMm,r+ej(n.monumentWidthMm,n.monumentHeightMm)),n.pedestalHeightMm,t,i,n.monumentWidthMm,n.monumentHeightMm).forEach((t,i)=>{let r=B(n.monumentType,i);!function(e,t,i,n=!1,r=!1){let a=t.width&&t.height&&t.height>0?t.width/t.height:ee.aspect,l=i.width/Math.max(i.height,1),s=i.width,o=i.height,c=i.x,d=i.y;(a>l?o=i.width/a:(s=i.height*a,c=n?i.x+i.width-s:i.x+(i.width-s)/2),r)?(e.save(),e.translate(c+s,d),e.scale(-1,1),e.drawImage(t,0,0,s,o),e.restore()):e.drawImage(t,c,d,s,o)}(e,k,t,!r,r)}),v&&ew(e,v,$.monuments[0],$.horizontalSlots?.[0]??!!$.horizontal,n.monumentFlipHorizontal),j&&$.monuments[1]&&ew(e,j,$.monuments[1],$.horizontalSlots?.[1]??!!$.horizontal,n.monumentFlipHorizontal2),M&&d.length>0)for(let i of eb($,d,M.width&&M.height&&M.height>0?M.width/M.height:ee.aspect,t))eM(e,M,i);if(S&&h.length>0){let i=I(S);for(let n of ev($,h,i.width&&i.height&&i.height>0?i.width/i.height:.62,t))eM(e,i,n)}if("studio"===o&&!1!==n.showSceneDimensions&&!b&&($.dimensionRect||$.monuments[0])){let t,i,r,o,c,d=U(L(n.monumentType,n.monumentSlotHorizontal)[0]?"horizontal":n.monumentType,n.monumentWidthMm,n.monumentHeightMm);a=$.dimensionRect??$.monuments[0],l=d.widthMm,s=d.heightMm,t=Math.max(10,Math.min(18,.04*a.width)),i=Math.max(11,Math.min(16,.045*a.width)),r=(t,i,n,r)=>{let a=Math.atan2(r-i,n-t);e.beginPath(),e.moveTo(t,i),e.lineTo(n,r),e.stroke();let l=(t,i,n)=>{e.beginPath(),e.moveTo(t,i),e.lineTo(t-5*Math.cos(n-Math.PI/6),i-5*Math.sin(n-Math.PI/6)),e.moveTo(t,i),e.lineTo(t-5*Math.cos(n+Math.PI/6),i-5*Math.sin(n+Math.PI/6)),e.stroke()};l(t,i,a+Math.PI),l(n,r,a)},e.save(),e.strokeStyle="#3b7dd8",e.fillStyle="#3b7dd8",e.lineWidth=1.5,e.font=`600 ${i}px Arial, sans-serif`,e.textAlign="center",e.textBaseline="bottom",o=a.y-t,r(a.x,o,a.x+a.width,o),e.fillText(`${Math.round(l)} мм`,a.x+a.width/2,o-4),e.save(),e.textAlign="right",e.textBaseline="middle",r(c=a.x-t,a.y,c,a.y+a.height),e.translate(c-6,a.y+a.height/2),e.rotate(-Math.PI/2),e.fillText(`${Math.round(s)} мм`,0,0),e.restore(),e.restore()}return $}async function ek(e,t,i,n){var r;let a,l,s,o,c,d,h;e.fillStyle="#ffffff",e.fillRect(0,0,t,i);let m=n.loadImage,[x,u,p]=await Promise.all([m(n.monumentImageSrc),T(n.monumentType)&&n.monumentImage2Src?m(n.monumentImage2Src):Promise.resolve(null),n.pedestalImageSrc?m(n.pedestalImageSrc):Promise.resolve(null)]),g=x&&x.width&&x.height?x.width/x.height:.75,f=u&&u.width&&u.height?u.width/u.height:g,w=(r=ex({canvasW:t,canvasH:i,monumentType:n.monumentType,monumentGapMm:n.monumentGapMm,monumentWidthMm:n.monumentWidthMm,monumentHeightMm:n.monumentHeightMm,pedestalWidthMm:n.pedestalWidthMm,pedestalHeightMm:n.pedestalHeightMm,pedestalAnchorPct:n.pedestalAnchorPct,mmPerPx:n.mmPerPx,aspect1:g,aspect2:f,monumentSlotHorizontal:n.monumentSlotHorizontal,monumentSlotSizes:n.monumentSlotSizes,combinedCatalogImage:!n.pedestalImageSrc&&"single"===n.monumentType,omitPlitkaOffset:!0}),l=Math.min(...(a=[r.pedestal,...r.pedestals??[],...r.monuments]).map(e=>e.x)),s=Math.max(...a.map(e=>e.x+e.width)),o=Math.min(...a.map(e=>e.y)),c=Math.max(...a.map(e=>e.y+e.height)),d=(t-(s-l))/2-l,h=(i-(c-o))/2-o,{pedestal:ep(r.pedestal,d,h),pedestals:r.pedestals?.map(e=>ep(e,d,h)),monuments:r.monuments.map(e=>ep(e,d,h)),group:ep(r.group,d,h),dimensionRect:r.dimensionRect?ep(r.dimensionRect,d,h):void 0,horizontal:r.horizontal,horizontalSlots:r.horizontalSlots});return p&&(w.pedestals??[w.pedestal]).forEach((t,i)=>{eg(e,p,t,B(n.monumentType,i))}),x&&ew(e,x,w.monuments[0],w.horizontalSlots?.[0]??!!w.horizontal,n.monumentFlipHorizontal),u&&w.monuments[1]&&ew(e,u,w.monuments[1],w.horizontalSlots?.[1]??!!w.horizontal,n.monumentFlipHorizontal2),w}let eC={surname:"Иванов",name:"Иван",patronymic:"Иванович",birthDate:"12.04.1956",deathDate:"
102.06.2024"};function ez(e=eC){return`${function(e=eC){return`${e.surname}
2${e.name}
3${e.patronymic}`}(e)}
4${function(e=eC){return`${e.birthDate}-${e.deathDate}`}(e)}`}var e$=i(40980);function eF({config:e,selected:t=!1,onSelect:i,className:r}){let[a,s]=(0,l.useState)(!1),o=e.previewFrames,c=a?Math.min(1,o.length-1):0;(0,l.useEffect)(()=>{o.forEach(e=>{new Image().src=e})},[o]);let d=(0,n.jsx)("img",{src:o[c],alt:"",draggable:!1,className:"h-full w-full object-contain"});return i?(0,n.jsx)("button",{type:"button",onClick:i,onPointerEnter:()=>s(!0),onPointerLeave:()=>s(!1),className:(0,e$.cn)("flex h-24 flex-1 items-center justify-center rounded border p-1 transition-colors",t?"border-primary bg-primary/10":"border-white/10 bg-black/20 hover:border-primary/40",r),children:d}):(0,n.jsx)("div",{className:(0,e$.cn)("mx-auto h-24 w-full max-w-[96px]",r),onPointerEnter:()=>s(!0),onPointerLeave:()=>s(!1),children:d})}var eP=i(54713);let eE=[{title:"Короткие",items:["Помним. Любим. Скорбим.","Ты всегда в нашей памяти.","Спасибо за все.","Вечная память о тебе в сердцах близких.","Покойся с миром в Царствии Небесном.","Вечная память.","Помним, скорбим…","Опустела без тебя земля.","Любим и помним.","Память сильнее смерти.","Рождение – не начало, смерть – не конец."]},{title:"Двухстрочные",items:["Тому, кто дорог был при жизни,\nОт тех, кто любит и скорбит.","Живым тебя представить так легко,\nЧто в смерть твою поверить невозможно.","Навсегда сохраним в своих сердцах\nСвет и тепло родной души.","Одной звездой стало меньше на земле,\nОдной звездой стало больше на небе.","Из жизни ты ушел мгновенно,\nА боль осталась навсегда.","Любимые не умирают,\nЛишь рядом быть перестают.","Как хочется кричать от боли,\nЧто нет тебя на свете боле!","Как много нашего ушло с тобой,\nКак много твоего осталось с нами.","Отмеряя мгновенья, считая года,\nМы пришли ниоткуда и уйдем – в никуда…","Любим тебя, и в памяти\nНашей всегда ты жива."]}],eI=[{key:"_catalog",icon:"Milestone",label:"Каталог\nпамятников"},{key:"scene",icon:"Trees",label:"Сцена"},{key:"fio",icon:"User",label:"ФИО\nи даты"},{key:"photo",icon:"UserRound",label:"Портрет"},{key:"text",icon:"Type",label:"Текст"},{key:"imageCatalog",icon:"Images",label:"Картинки"},{key:"cross",icon:"Cross",label:"Крест"},{key:"epitaph",icon:"Quote",label:"Эпитафия"}],eH=[{key:"_catalog",title:"Каталог памятников",hint:"Выберите модель памятника"},{key:"fio",title:"ФИО и даты",hint:"Фамилия, имя, отчество и даты жизни"},{key:"photo",title:"Портрет",hint:"Фото или готовый портрет"},{key:"text",title:"Текст",hint:"Дополнительные надписи"},{key:"imageCatalog",title:"Картинки",hint:"Узоры и символы для гравировки"},{key:"cross",title:"Крест",hint:"Крест или символ веры"},{key:"epitaph",title:"Эпитафия",hint:"Прощальные слова"}],eA=({defaultTab:e="catalog",monumentImage:t,setMonumentImage:i,addTextElement:o,addEpitaphElement:c,addImageElement:h,addFIOElement:m,addDatesElement:x,applyInscriptionTemplate:f,handlePhotoUpload:w,photoInputRef:y,surname:b,setSurname:v,name:j,setName:N,patronymic:S,setPatronymic:k,selectedFont:C,setSelectedFont:z,birthDate:$,setBirthDate:F,deathDate:P,setDeathDate:E,selectedDateFont:I,setSelectedDateFont:H,catalogCategories:A,catalogProducts:R,selectedCategory:W,setSelectedCategory:D,isLoadingCatalog:_,loadCatalog:X,fonts:B,crosses:Y,isLoadingCrosses:U,loadCrosses:O,flowers:V,isLoadingFlowers:q,loadFlowers:K,layoutTool:Z,sceneTool:Q})=>{let ea,eo,ed,eh,em,ex,eu,ep,eg,ef,ew,ey,eb,ev,ej,eN,eM,eS,ek,eC=(0,s.Zp)(),[e$,eA]=(0,l.useState)(e),[eR,eW]=(0,l.useState)(null),[eT,eD]=(0,l.useState)([]),[eL,e_]=(0,l.useState)([]),[eX,eB]=(0,l.useState)(null),[eY,eU]=(0,l.useState)(!1),[eO,eJ]=(0,l.useState)(""),[eG,eV]=(0,l.useState)(""),[eq,eK]=(0,l.useState)("inline"),eZ=(0,l.useMemo)(()=>{let e=[...eI];return Z&&e.push({key:"layout",icon:"Ruler",label:"Размеры\nи расчёт"}),e},[Z]),eQ=l.useRef(null),e0=l.useRef(null),e1=(e,t,i="image",n)=>{let r=JSON.stringify({src:t,type:i,fixedPriceRub:n??null});e.dataTransfer.effectAllowed="copy",e.dataTransfer.setData("application/x-constructor-image",r),e.dataTransfer.setData("text/plain",r)},e2=e=>{let t=e.replace(/\D/g,"");return t.length<=2?t:t.length<=4?`${t.slice(0,2)}.${t.slice(2)}`:`${t.slice(0,2)}.${t.slice(2,4)}.${t.slice(4,8)}`},e5=!!(b||j||S),e4=!!($||P);(0,l.useEffect)(()=>{e&&eA(e)},[e]),(0,l.useEffect)(()=>{e3()},[]),(0,l.useEffect)(()=>{eA(e)},[e]);let e3=async()=>{try{let e=await fetch((0,d.xp)({type:"categories"}));if(e.ok){let t=await e.json();eD(t),t.length>0&&(eB(t[0].id),e8(t))}}catch(e){console.error("Error loading image categories:",e)}},e8=async e=>{eU(!0);try{let t=await Promise.all(e.map(async e=>{let t=await fetch((0,d.xp)({type:"images",category_id:e.id}));return t.ok?t.json():[]}));e_(t.flat())}catch(e){console.error("Error loading category images:",e)}finally{eU(!1)}};return(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#181818",color:"white"},children:(0,n.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,n.jsx)("div",{className:"flex flex-col items-center gap-1 pt-4 pb-2 bg-[#141414] border-r border-white/10 shrink-0",style:{width:"52px"},children:eZ.map(e=>(0,n.jsxs)(l.Fragment,{children:[Z&&"layout"===e.key&&(0,n.jsx)("div",{className:"w-8 border-t border-white/10 my-0.5"}),(0,n.jsxs)("button",{onClick:()=>{"_catalog"===e.key?(X(),eW(e=>"_catalog"===e?null:"_catalog")):eW(t=>t===e.key?null:e.key)},className:`w-10 h-10 flex flex-col items-center justify-center rounded transition-colors gap-0.5 ${eR===e.ke
4y?"bg-primary text-primary-foreground":"text-white/50 hover:text-white hover:bg-white/10"}`,title:e.label.replace("\n"," "),children:["_catalog"===e.key?(0,n.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 80 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flexShrink:0},children:[(0,n.jsx)("rect",{x:"0",y:"88",width:"80",height:"12",rx:"1",fill:"currentColor"}),(0,n.jsx)("rect",{x:"8",y:"78",width:"64",height:"12",rx:"1",fill:"currentColor"}),(0,n.jsx)("path",{d:"M20 78 L20 30 Q20 6 40 6 Q60 6 60 30 L60 78 Z",fill:"currentColor"})]}):"cross"===e.key?(0,n.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 90 160",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flexShrink:0},children:[(0,n.jsx)("rect",{x:"38",y:"0",width:"14",height:"160",fill:"currentColor"}),(0,n.jsx)("rect",{x:"28",y:"8",width:"34",height:"14",fill:"currentColor"}),(0,n.jsx)("rect",{x:"0",y:"44",width:"90",height:"14",fill:"currentColor"}),(0,n.jsx)("polygon",{points:"10,98 10,112 38,118 38,106",fill:"currentColor"}),(0,n.jsx)("polygon",{points:"52,106 52,118 80,112 80,98",fill:"currentColor"})]}):(0,n.jsx)(a.A,{name:e.icon,size:17}),(0,n.jsx)("span",{className:"text-[7px] leading-tight text-center whitespace-pre",children:e.label})]}),"_catalog"===e.key&&(0,n.jsx)("div",{className:"w-8 border-t border-white/10 my-0.5"},"sep")]},e.key))}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto scrollbar-site min-h-0 bg-[#181818]",children:[!eR&&(0,n.jsxs)("div",{className:"flex h-full flex-col overflow-y-auto scrollbar-site p-4",children:[(0,n.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-white/45",children:"Как собрать макет"}),(0,n.jsx)("p",{className:"mt-1.5 mb-4 text-[11px] leading-relaxed text-white/30",children:"Идите по шагам сверху вниз — нажмите на пункт или выберите иконку слева."}),(0,n.jsx)("ol",{className:"space-y-2",children:eH.map((e,t)=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>{var t;"_catalog"===(t=e.key)&&X(),eW(t)},className:"flex w-full items-start gap-3 rounded-lg border border-white/[0.06] bg-white/[0.02] px-3 py-2.5 text-left transition-colors hover:border-primary/40 hover:bg-primary/5",children:[(0,n.jsx)("span",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary/15 font-oswald text-[10px] font-bold text-primary",children:t+1}),(0,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("span",{className:"block text-xs font-medium text-white/85",children:e.title}),(0,n.jsx)("span",{className:"mt-0.5 block text-[10px] leading-snug text-white/40",children:e.hint})]})]})},e.key))})]}),"layout"===eR&&Z&&(0,n.jsx)(M,{...Z,embedded:!0}),"scene"===eR&&Q&&(0,n.jsxs)("div",{className:"p-3 space-y-4",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Сцена"}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Тип фона"}),(0,n.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[{id:"studio",label:"Каталог (серый)"},{id:"outdoor",label:"На месте (тёмный)"}].map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>Q.setSceneMode(e.id),className:`rounded px-2.5 py-1.5 text-[11px] border transition-colors ${Q.sceneMode===e.id?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/55 hover:border-white/25 hover:text-white"}`,children:e.label},e.id))}),"studio"===Q.sceneMode&&(0,n.jsxs)("label",{className:"mt-2 flex items-center gap-2 text-[11px] text-white/55 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:Q.showSceneDimensions,onChange:e=>Q.setShowSceneDimensions(e.target.checked),className:"rounded border-white/20"}),"Показать размерные линии"]}),(0,n.jsx)("p",{className:"mt-1.5 text-[10px] text-white/35",children:"Каталог — серый фон, сетка и размерные линии. Внизу — плитка и трава."})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Тип компоновки"}),(0,n.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[{id:"single",label:"Одиночный"},{id:"double",label:"Двойной"},{id:"horizontal",label:"Горизонтальный"},{id:"horizontal-double",label:"Гориз. двойной"},{id:"mixed-double",label:"Смешанный"}].map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>Q.setMonumentType(e.id),className:`rounded px-2.5 py-1.5 text-[11px] border transition-colors ${Q.monumentType===e.id?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/55 hover:border-white/25 hover:text-white"}`,children:e.label},e.id))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Отражение памятника"}),(0,n.jsxs)("button",{type:"button",onClick:Q.toggleMonumentFlip,className:`mt-1.5 w-full flex items-center justify-center gap-2 rounded px-2.5 py-2 text-[11px] border transition-colors ${(T(Q.monumentType)&&1===Q.activeMonumentSlot?Q.monumentFlipHorizontal2:Q.monumentFlipHorizontal)?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/55 hover:border-white/25 hover:text-white"}`,children:[(0,n.jsx)(a.A,{name:"FlipHorizontal",size:16}),(T(Q.monumentType)&&1===Q.activeMonumentSlot?Q.monumentFlipHorizontal2:Q.monumentFlipHorizontal)?"Отзеркалено":"Отзеркалить"]}),T(Q.monumentType)&&(0,n.jsx)("p",{className:"mt-1 text-[10px] text-white/35",children:"Отражение применяется к выбранной подставке (левая / правая)."})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:T(Q.monumentType)?"Памятники на подставки":"Памятник на подставку"}),T(Q.monumentType)&&(0,n.jsx)("div",{className:"mt-1.5 flex gap-1",children:[{slot:0,label:"Левая"},{slot:1,label:"Правая"}].map(({slot:e,label:t})=>(0,n.jsxs)("button",{type:"button",onClick:()=>Q.toggleMonumentSlotHorizontal(e),className:`flex-1 rounded px-2 py-1.5 text-[11px] border transition-colors ${Q.monumentSlotHorizontal[e]?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/55 hover:border-white/25 hover:text-white"}`,children:[t,": ",Q.monumentSlotHorizontal[e]?"гориз.":"верт."]},`orient-${e}`))}),T(Q.monumentType)&&(0,n.jsx)("div",{className:"mt-1.5 flex gap-1",children:[{slot:0,label:"Левая подставка",image:Q.monumentImage},{slot:1,label:"Правая подставка",image:Q.monumentImage2}].map(({slot:e,label:t,image:i})=>(0,n.jsxs)("button",{type:"button",onClick:()=>Q.setActiveMonumentSlot(e),className:`flex-1 rounded px-2 py-1.5 text-[11px] border transition-colors ${Q.activeMonumentSlot===e?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/55 hover:border-white/25 hover:text-white"}`,children:[(0,n.jsx)("span",{className:"block",children:t}),(0,n.jsx)("span",{className:"block text-[9px] opacity-70 mt-0.5",children:i?"Выбран":"Пусто"})]},e))}),T(Q.monumentType)&&(0,n.jsx)("p",{className:"mt-1 text-[10px] text-white/35",children:"Кнопки \xabЛевая / Правая\xbb переключают вертикальную или горизонтальную ориентацию на подставке."}),T(Q.monumentType)&&(0,n.jsx)("p",{className:"mt-1.5 text-[10px] text-white/35",children:"Выберите подставку, затем модель из каталога. После первого памятника автоматически переключится на правую подставку."}),(0,n.jsx)("div",{className:"mt-1.5 grid grid-cols-2 gap-1.5 max-h-44 overflow-y-auto scrollbar-site",children:Q.c
4atalogProducts.filter(e=>e.category_id===Q.selectedCategory&&(0,eP.me)(e)).map(e=>{let t=(0,eP.me)(e),i=T(Q.monumentType)?0===Q.activeMonumentSlot?Q.monumentImage===t:Q.monumentImage2===t:Q.monumentImage===t;return(0,n.jsx)("button",{type:"button",onClick:()=>Q.selectMonumentFromCatalog(t),className:`aspect-[3/4] rounded border overflow-hidden bg-[repeating-conic-gradient(#2a2a2a_0%_25%,#1a1a1a_0%_50%)] bg-[length:10px_10px] ${i?"border-primary ring-1 ring-primary/30":"border-white/10 hover:border-primary/40"}`,children:(0,n.jsx)("img",{src:t,alt:e.name,className:"h-full w-full object-contain p-1"})},e.id)})}),T(Q.monumentType)&&Q.monumentImage2&&(0,n.jsx)("button",{type:"button",onClick:()=>Q.setMonumentImage2(null),className:"mt-2 text-[10px] text-white/45 hover:text-white/70 transition-colors",children:"Убрать памятник с правой подставки"})]}),(0,n.jsxs)("div",{className:"space-y-2 border-t border-white/10 pt-3",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Фон сцены (1920\xd71080)"}),(0,n.jsx)("input",{ref:e0,type:"file",accept:"image/png,image/webp,image/jpeg",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(!t)return;let i=new FileReader;i.onload=()=>Q.setSceneBackgroundImage(i.result),i.readAsDataURL(t),e.target.value=""}}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)(r.$,{type:"button",variant:"outline",className:"h-8 flex-1 text-xs",onClick:()=>e0.current?.click(),children:[(0,n.jsx)(a.A,{name:"Upload",size:14,className:"mr-1"}),"Загрузить фон"]}),Q.sceneBackgroundImage&&(0,n.jsx)(r.$,{type:"button",variant:"ghost",className:"h-8 text-xs text-white/50",onClick:()=>Q.setSceneBackgroundImage(null),children:"Убрать"})]}),Q.sceneBackgroundImage&&(0,n.jsx)("div",{className:"rounded border border-white/10 bg-black/30 p-2",children:(0,n.jsx)("img",{src:Q.sceneBackgroundImage,alt:"Фон сцены",className:"mx-auto max-h-16 w-full object-cover rounded"})}),(0,n.jsx)("p",{className:"text-[10px] text-white/35",children:"Свой фон заменяет белый/тёмный режим. Иначе — плитка и трава внизу."})]}),T(Q.monumentType)&&(eo=(ea=L(Q.monumentType,Q.monumentSlotHorizontal)).some(Boolean),ed=J(ea,Q.monumentSlotSizes,Q.pedestalWidthMm),eh=G(Q.monumentGapMm,ea,Q.monumentSlotSizes,Q.pedestalWidthMm),em=Math.max(Q.monumentGapMm,ed),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{className:"text-xs text-white/60",children:[eo||ed>0?"Зазор между подставками":"Зазор между памятниками",": ",eh," мм",ed>0&&(0,n.jsxs)("span",{className:"text-white/40",children:[" (мин. ",ed,")"]})]}),(0,n.jsx)("input",{type:"range",min:ed,max:eo?1200:300,step:5,value:em,onChange:e=>Q.setMonumentGapMm(Number(e.target.value)),className:"mt-1 w-full"})]})),(0,n.jsxs)("div",{className:"space-y-2 border-t border-white/10 pt-3",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Подставка (постамент)"}),(0,n.jsx)("input",{ref:eQ,type:"file",accept:"image/png,image/webp,image/jpeg",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(!t)return;let i=new FileReader;i.onload=()=>Q.setPedestalImage(i.result),i.readAsDataURL(t),e.target.value=""}}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)(r.$,{type:"button",variant:"outline",className:"h-8 flex-1 text-xs",onClick:()=>eQ.current?.click(),children:[(0,n.jsx)(a.A,{name:"Upload",size:14,className:"mr-1"}),"Выбрать PNG"]}),Q.pedestalImage&&(0,n.jsx)(r.$,{type:"button",variant:"ghost",className:"h-8 text-xs text-white/50",onClick:()=>Q.setPedestalImage(null),children:"Убрать"})]}),Q.pedestalImage&&(0,n.jsx)("div",{className:"rounded border border-white/10 bg-black/30 p-2",children:(0,n.jsx)("img",{src:Q.pedestalImage,alt:"Подставка",className:"mx-auto max-h-20 object-contain"})}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-[10px] text-white/45",children:"Ширина, мм"}),(0,n.jsx)(u.p,{type:"number",min:100,max:3e3,value:Q.pedestalWidthMm,onChange:e=>{let t=Number(e.target.value)||500;Q.setPedestalWidthMm(t),Q.setPedestalHeightMm(ec(t))},className:"mt-1 h-8 bg-[#1e1e1e] border-white/10 text-white text-xs"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-[10px] text-white/45",children:"Высота, мм"}),(0,n.jsx)(u.p,{type:"number",min:50,max:1e3,value:Q.pedestalHeightMm,onChange:e=>Q.setPedestalHeightMm(Number(e.target.value)||150),className:"mt-1 h-8 bg-[#1e1e1e] border-white/10 text-white text-xs"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{className:"text-[10px] text-white/45",children:["Точка крепления подставки: ",Q.pedestalAnchorPct,"%"]}),(0,n.jsx)("input",{type:"range",min:80,max:100,step:1,value:Q.pedestalAnchorPct,onChange:e=>Q.setPedestalAnchorPct(Number(e.target.value)),className:"mt-1 w-full"})]})]}),(0,n.jsxs)("div",{className:"space-y-2 border-t border-white/10 pt-3",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Цветник у подставки"}),(0,n.jsx)("p",{className:"text-[10px] text-white/40 leading-snug",children:"Гранитная рамка с декоративной засыпкой перед подставкой. Нужна отдельная подставка."}
4),(0,n.jsx)("button",{type:"button",disabled:!!Q.sceneBackgroundImage||!Q.pedestalImage,onClick:()=>Q.setSceneFlowerbed(!Q.sceneFlowerbed),className:`w-full rounded border px-2 py-2 text-xs transition-colors ${Q.sceneFlowerbed?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/70 hover:border-primary/40"} disabled:opacity-40 disabled:pointer-events-none`,children:Q.sceneFlowerbed?"Цветник включён":"Добавить цветник"}),Q.sceneFlowerbed&&(0,n.jsx)("div",{className:"rounded border border-white/10 bg-black/30 p-2",children:(0,n.jsx)("img",{src:es.src,alt:"Цветник",className:"mx-auto max-h-20 object-contain"})})]}),(0,n.jsxs)("div",{className:"space-y-2 border-t border-white/10 pt-3",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Ваза на плитке"}),(0,n.jsx)("p",{className:"text-[10px] text-white/40 leading-snug",children:"Слева или справа от подставки на плитке. Не работает при своём фоне сцены."}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{type:"button",disabled:!!Q.sceneBackgroundImage,onClick:()=>Q.setSceneVaseLeft(!Q.sceneVaseLeft),className:`flex-1 rounded border px-2 py-2 text-xs transition-colors ${Q.sceneVaseLeft?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/70 hover:border-primary/40"} disabled:opacity-40 disabled:pointer-events-none`,children:"Слева"}),(0,n.jsx)("button",{type:"button",disabled:!!Q.sceneBackgroundImage,onClick:()=>Q.setSceneVaseRight(!Q.sceneVaseRight),className:`flex-1 rounded border px-2 py-2 text-xs transition-colors ${Q.sceneVaseRight?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/70 hover:border-primary/40"} disabled:opacity-40 disabled:pointer-events-none`,children:"Справа"})]}),(0,n.jsx)("div",{className:"rounded border border-white/10 bg-black/30 p-2",children:(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:[(0,n.jsx)(eF,{config:ee,selected:"black"===Q.sceneVaseVariant,onSelect:()=>Q.setSceneVaseVariant("black")}),(0,n.jsx)(eF,{config:et,selected:"red"===Q.sceneVaseVariant,onSelect:()=>Q.setSceneVaseVariant("red")}),(0,n.jsx)(eF,{config:ei,selected:"gray"===Q.sceneVaseVariant,onSelect:()=>Q.setSceneVaseVariant("gray")}),(0,n.jsx)(eF,{config:en,selected:"silver"===Q.sceneVaseVariant,onSelect:()=>Q.setSceneVaseVariant("silver")}),(0,n.jsx)(eF,{config:er,selected:"white"===Q.sceneVaseVariant,onSelect:()=>Q.setSceneVaseVariant("white")})]})})]}),(0,n.jsxs)("div",{className:"space-y-2 border-t border-white/10 pt-3",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Лампадка на плитке"}),(0,n.jsx)("p",{className:"text-[10px] text-white/40 leading-snug",children:"Слева или справа от подставки. Не работает при своём фоне сцены."}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{type:"button",disabled:!!Q.sceneBackgroundImage,onClick:()=>Q.setSceneLampLeft(!Q.sceneLampLeft),className:`flex-1 rounded border px-2 py-2 text-xs transition-colors ${Q.sceneLampLeft?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/70 hover:border-primary/40"} disabled:opacity-40 disabled:pointer-events-none`,children:"Слева"}),(0,n.jsx)("button",{type:"button",disabled:!!Q.sceneBackgroundImage,onClick:()=>Q.setSceneLampRight(!Q.sceneLampRight),className:`flex-1 rounded border px-2 py-2 text-xs transition-colors ${Q.sceneLampRight?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/70 hover:border-primary/40"} disabled:opacity-40 disabled:pointer-events-none`,children:"Справа"})]}),(Q.sceneLampLeft||Q.sceneLampRight)&&(0,n.jsx)("div",{className:"rounded border border-white/10 bg-black/30 p-2",children:(0,n.jsx)("img",{src:el,alt:"Лампадка",className:"mx-auto max-h-24 object-contain"})})]})]}),"fio"===eR&&(0,n.jsxs)("div",{className:"p-3 space-y-3 overflow-y-auto scrollbar-site max-h-full",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"ФИО и даты"}),(0,n.jsxs)("button",{type:"button",onClick:f,className:"w-full rounded-lg border border-primary/40 bg-primary/10 p-2.5 text-left transition-colors hover:bg-primary/15 hover:border-primary/60",children:[(0,n.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-primary",children:"Готовый шаблон"}),(0,n.jsx)("span",{className:"mt-1 flex flex-col items-center text-center leading-[1.05]",children:ez().split("\n").map((e,t)=>(0,n.jsx)("span",{className:3===t?"text-xs text-white/80":"text-sm text-white",children:e},t))})]}),(0,n.jsx)("p",{className:"text-[10px] text-white/40",children:"ФИО"}),(ex=B.find(e=>
4e.id===C),ep=(eu=[b,j,S].filter(Boolean)).length>0?eu:["Фамилия","Имя","Отчество"],(0,n.jsx)("div",{className:"rounded-lg bg-black/40 border border-white/10 flex flex-col items-center justify-center py-3 px-4 min-h-[64px]",children:ep.map((e,t)=>(0,n.jsx)("span",{className:"text-white text-sm text-center leading-tight",style:{fontFamily:ex?.style,fontWeight:ex?.weight,opacity:0===eu.length?.3:1},children:e},t))})),(0,n.jsx)(u.p,{placeholder:"Фамилия",value:b,onChange:e=>v(e.target.value),className:"bg-white/5 border-white/10 text-white placeholder:text-white/30 h-8 text-xs"}),(0,n.jsx)(u.p,{placeholder:"Имя",value:j,onChange:e=>N(e.target.value),className:"bg-white/5 border-white/10 text-white placeholder:text-white/30 h-8 text-xs"}),(0,n.jsx)(u.p,{placeholder:"Отчество",value:S,onChange:e=>k(e.target.value),className:"bg-white/5 border-white/10 text-white placeholder:text-white/30 h-8 text-xs"}),(0,n.jsx)("p",{className:"text-[10px] text-white/40 pt-1",children:"Шрифт ФИО"}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-1",children:B.map(e=>(0,n.jsxs)("button",{onClick:()=>z(e.id),className:`px-2 py-1.5 rounded border text-left transition-all ${C===e.id?"border-primary bg-primary/10 text-primary":"border-white/10 hover:border-primary/50 text-white/70"}`,children:[(0,n.jsx)("div",{className:"text-[9px] text-white/40 truncate",children:e.name}),(0,n.jsx)("div",{className:"text-xs truncate",style:{fontFamily:e.style,fontWeight:e.weight},children:e.example.slice(0,8)})]},e.id))}),(0,n.jsxs)("div",{className:"border-t border-white/10 pt-3 space-y-2",children:[(0,n.jsx)("p",{className:"text-[10px] text-white/40",children:"Даты жизни"}),(eg=B.find(e=>e.id===I),ef=$||"15.03.1950",ew=P||"07.11.2024",ey=!$&&!P,eb="inline"===eq?`${ef} – ${ew}`:"stacked"===eq?`${ef}
5${ew}`:`${ef}
6      ${ew}`,ev="offset"===eq?"left":"center",(0,n.jsx)("div",{className:"rounded-lg bg-black/40 border border-white/10 flex items-center justify-center py-4 px-4 min-h-[64px]",children:(0,n.jsx)("span",{className:"text-white text-base whitespace-pre",style:{fontFamily:eg?.style,fontWeight:eg?.weight,opacity:ey?.3:1,lineHeight:1.3,textAlign:ev,display:"block"},children:eb})})),(0,n.jsx)("p",{className:"text-[10px] text-white/40 pt-1",children:"Расположение"}),(ej=B.find(e=>e.id===I),eN=$||"15.03.1950",eM=P||"07.11.2024",eS=[{key:"inline",label:"В строку",preview:`${eN} – ${eM}`,align:"center"},{key:"stacked",label:"Столбцом",preview:`${eN}
7${eM}`,align:"center"},{key:"offset",label:"Со сдвигом",preview:`${eN}
8      ${eM}`,align:"left"}],(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2 -mx-3",children:eS.map(e=>{let t=eq===e.key;return(0,n.jsxs)("button",{onClick:()=>eK(e.key),className:"flex flex-col items-center gap-2 py-3 px-2 transition-all group",children:[(0,n.jsx)("div",{className:`rounded-md w-full flex items-center justify-center min-h-[56px] transition-all overflow-hidden ${"inline"===e.key?"px-1 py-2":"px-2 py-3"} ${t?"bg-primary/15 ring-2 ring-primary":"bg-black/60 hover:bg-black/80"}`,children:(0,n.jsx)("span",{className:`text-white ${"inline"===e.key?"whitespace-nowrap":"whitespace-pre"}`,style:{fontFamily:ej?.style,fontWeight:ej?.weight,fontSize:"inline"===e.key?"7.5px":"11px",lineHeight:1.2,textAlign:e.align,display:"block",width:"100%"},children:e.preview})}),(0,n.jsx)("span",{className:`text-[10px] text-center leading-tight transition-colors ${t?"text-primary":"text-white/50 group-hover:text-white/80"}`,children:e.label})]},e.key)})})),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(p.J,{className:"text-[10px] text-white/40",children:"Дата рождения"}),(0,n.jsx)(u.p,{placeholder:"01.01.1950",value:$,inputMode:"numeric",maxLength:10,onChange:e=>F(e2(e.target.value)),className:"bg-white/5 border-white/10 text-white placeholder:text-white/30 h-8 text-xs"})]}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(p.J,{className:"text-[10px] text-white/40",children:"Дата смерти"}),(0,n.jsx)(u.p,{placeholder:"01.01.2020",value:P,inputMode:"numeric",maxLength:10,onChange:e=>E(e2(e.target.value)),className:"bg-white/5 border-white/10 text-white placeholder:text-white/30 h-8 text-xs"})]}),(0,n.jsx)("p",{className:"text-[10px] text-white/40 pt-1",children:"Шрифт дат"}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-1",children:B.map(e=>(0,n.jsxs)("button",{onClick:()=>H(e.id),className:`px-2 py-1.5 rounded border text-left transition-all ${I===e.id?"border-primary bg-primary/10 text-primary":"border-white/10 hover:border-primary/50 text-white/70"}`,children:[(0,n.jsx)("div",{className:"text-[9px] text-white/40 truncate",children:e.name}),(0,n.jsx)("div",{className:"text-xs truncate",style:{fontFamily:e.style,fontWeight:e.weight},children:"01.01—01.01"})]},e.id))})]}),(0,n.jsxs)(r.$,{className:"w-full h-8 text-xs",onClick:()=>{e5&&m(),e4&&x(eq)},disabled:!e5&&!e4,children:[(0,n.jsx)(a.A,{name:"Plus",size:14,className:"mr-1"}),e5&&e4?"Добавить ФИО и даты":e5?"Добавить ФИО":"Добавить даты"]})]}),"epitaph"===eR&&(0,n.jsxs)("div",{className:"p-3 space-y-3",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider mb-3",children:"Эпитафии"}),eE.map(e=>(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-white/40",children:e.title}),e.items.map((t,i)=>(0,n.jsx)("button",{onClick:()=>c(t),className:"w-full text-left px-2 py-2 rounded border border-white/10 hover:border-primary transition-all bg-white/5 hover:bg-primary/10",children:(0,n.jsx)("p",{className:"text-xs italic text-white/70 whitespace-pre-line",children:t})},`${e.title}-${i}`))]},e.title)),(0,n.jsx)("p",{className:"text-[10px] text-white/30 pt-1",children:"После добавления можно отредактировать"})]}),"text"===eR&&(0,n.jsxs)("div",{className:"p-3 space-y-3",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Текст"}),(0,n.jsx)("p",{className:"text-[10px] text-[#F39200]/90",children:"1 000 ₽ за каждую строку"}),(0,n.jsx)("textarea",{placeholder:"Введите текст...",value:eO,onCh
8ange:e=>eJ(e.target.value),rows:4,className:"w-full bg-white/5 border border-white/10 rounded text-white placeholder:text-white/30 text-sm p-2 resize-none focus:outline-none focus:border-primary"}),(0,n.jsx)("p",{className:"text-[10px] text-white/40",children:"Шрифт"}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-1",children:B.map(e=>(0,n.jsxs)("button",{onClick:()=>eV(e.fullStyle),className:`px-2 py-1.5 rounded border text-left transition-all ${eG===e.fullStyle?"border-primary bg-primary/10 text-primary":"border-white/10 hover:border-primary/50 text-white/70"}`,children:[(0,n.jsx)("div",{className:"text-[9px] text-white/40 truncate",children:e.name}),(0,n.jsx)("div",{className:"text-xs truncate",style:{fontFamily:e.style,fontWeight:e.weight},children:e.example.slice(0,8)})]},e.id))}),(0,n.jsxs)(r.$,{className:"w-full h-8 text-xs",onClick:()=>{o(eO||void 0,eG||void 0),eJ(""),eV("")},children:[(0,n.jsx)(a.A,{name:"Plus",size:14,className:"mr-1"})," Добавить текст"]})]}),"photo"===eR&&(0,n.jsxs)("div",{className:"p-3 space-y-3",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Портреты"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs text-white/40 mb-1.5",children:"Мужские"}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-1.5",children:[(0,n.jsx)("button",{onClick:()=>h("/constructor/portraits/male-01.jpg","image"),draggable:!0,onDragStart:e=>e1(e,"/constructor/portraits/male-01.jpg","image"),className:"relative overflow-hidden rounded border-2 border-white/10 hover:border-primary transition-all aspect-[3/4] bg-black",children:(0,n.jsx)("img",{src:"/constructor/portraits/male-01.jpg",alt:"Мужской портрет",className:"w-full h-full object-cover"})}),(0,n.jsx)("button",{onClick:()=>h("/constructor/portraits/male-02.jpg","image"),draggable:!0,onDragStart:e=>e1(e,"/constructor/portraits/male-02.jpg","image"),className:"relative overflow-hidden rounded border-2 border-white/10 hover:border-primary transition-all aspect-[3/4] bg-black",children:(0,n.jsx)("img",{src:"/constructor/portraits/male-02.jpg",alt:"Мужской портрет контур",className:"w-full h-full object-cover"})})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs text-white/40 mb-1.5",children:"Женские"}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-1.5",children:[(0,n.jsx)("button",{onClick:()=>h("/constructor/portraits/female-01.jpg","image"),draggable:!0,onDragStart:e=>e1(e,"/constructor/portraits/female-01.jpg","image"),className:"relative overflow-hidden rounded border-2 border-white/10 hover:border-primary transition-all aspect-[3/4] bg-black",children:(0,n.jsx)("img",{src:"/constructor/portraits/female-01.jpg",alt:"Женский портрет",className:"w-full h-full object-cover"})}),(0,n.jsx)("button",{onClick:()=>h("/constructor/portraits/female-02.jpg","image"),draggable:!0,onDragStart:e=>e1(e,"/constructor/portraits/female-02.jpg","image"),className:"relative overflow-hidden rounded border-2 border-white/10 hover:border-primary transition-all aspect-[3/4] bg-black",children:(0,n.jsx)("img",{src:"/constructor/portraits/female-02.jpg",alt:"Женский портрет контур",className:"w-full h-full object-cover"})})]})]}),(0,n.jsx)("input",{ref:y,type:"file",accept:"image/*",onChange:w,className:"hidden",id:"photo-upload"}),(0,n.jsxs)(r.$,{onClick:()=>y.current?.click(),className:"w-full h-8 text-xs mt-2",children:[(0,n.jsx)(a.A,{name:"Upload",size:14,className:"mr-1"})," Загрузить свой портрет"]}),(0,n.jsxs)("div",{className:"mt-1 p-2 bg-white/5 rounded text-[10px] text-white/30 leading-relaxed",children:[(0,n.jsx)(a.A,{name:"Info",size:10,className:"inline mr-1 align-text-top"}),"Или"," ",(0,n.jsx)("button",{type:"button",onClick:()=>{eC("/"),setTimeout(()=>document.getElementById("retouch")?.scrollIntoView({behavior:"smooth"}),100)},className:"text-primary hover:underline",children:"закажите ретушь"})," ","у профессионалов:"," ",(0,n.jsx)("a",{href:"tel:+79960681168",className:"text-primary hover:underline whitespace-nowrap",children:"+7 (996) 068-11-68"})]})]}),"cross"===eR&&(0,n.jsxs)("div",{className:"p-3 space-y-2",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider mb-3",children:"Кресты"}),(0,n.jsx)("p",{className:"text-[10px] text-white/35 -mt-2 mb-2",children:"Клик или перетащите на макет"}),U?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"})}):Y.length>0?(0,n.jsx)("div",{className:"grid grid-cols-2 gap-1.5",children:Y.map(e=>(0,n.jsxs)("button",{onClick:()=>h(e.image_url,"cross",{fixedPriceRub:e.price_rub??null}),draggable:!0,onDragStart:t=>e1(t,e.image_url,"cross",e.price_rub??null),className:"aspect-square rounded border border-white/10 hover:border-primary transition-all p-2 bg-white/5 hover:bg-primary/10 flex flex-col",children:[(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("img",{src:e.image_url,alt:e.name,className:"w-full h-full object-contain"})}),(0,n.jsx)("div",{className:"text-[9px] text-center mt-1 text-white/40 truncate",children:e.name}),null!=e.price_rub&&(0,n.jsxs)("div",{className:"text-[9px] text-center text-[#F39200] font-medium",children:[e.price_rub.toLocaleStr
8ing("ru-RU")," ₽"]})]},e.id))}):(0,n.jsx)("p",{className:"text-xs text-white/30 text-center py-4",children:"Кресты не найдены"})]}),"flower"===eR&&(0,n.jsxs)("div",{className:"p-3 space-y-2",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider mb-3",children:"Цветы"}),(0,n.jsx)("p",{className:"text-[10px] text-white/35 -mt-2 mb-2",children:"Клик или перетащите на макет"}),q?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"})}):V.length>0?(0,n.jsx)("div",{className:"grid grid-cols-2 gap-1.5",children:V.map(e=>(0,n.jsxs)("button",{onClick:()=>h(e.image_url,"flower"),draggable:!0,onDragStart:t=>e1(t,e.image_url,"flower"),className:"aspect-square rounded border border-white/10 hover:border-primary transition-all p-2 bg-white/5 hover:bg-primary/10 flex flex-col",children:[(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("img",{src:e.image_url,alt:e.name,className:"w-full h-full object-contain"})}),(0,n.jsx)("div",{className:"text-[9px] text-center mt-1 text-white/40 truncate",children:e.name})]},e.id))}):(0,n.jsx)("p",{className:"text-xs text-white/30 text-center py-4",children:"Цветы не найдены"})]}),"_catalog"===eR&&(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 pt-3 pb-2 shrink-0",children:[(0,n.jsx)(a.A,{name:"Milestone",size:14,className:"text-white/50"}),(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider",children:"Каталог памятников"})]}),Q&&T(Q.monumentType)&&(0,n.jsxs)("div",{className:"px-3 pb-2 shrink-0 space-y-1.5",children:[(0,n.jsx)("div",{className:"flex gap-1",children:[{slot:0,label:"Левая"},{slot:1,label:"Правая"}].map(({slot:e,label:t})=>(0,n.jsxs)("button",{type:"button",onClick:()=>Q.setActiveMonumentSlot(e),className:`flex-1 rounded px-2 py-1 text-[10px] border transition-colors ${Q.activeMonumentSlot===e?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/55 hover:border-white/25 hover:text-white"}`,children:[t," подставка"]},e))}),(0,n.jsx)("p",{className:"text-[10px] text-white/35",children:"Выберите подставку, затем модель — памятник встанет на неё."})]}),_?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):A.length>0?(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 px-3 pb-3",children:[(0,n.jsx)("div",{className:"flex flex-wrap gap-1 shrink-0 mb-3 bg-white/5 rounded-lg p-1",children:A.map(e=>{let t=R.filter(t=>t.category_id===e.id&&(0,eP.me)(t)).length;return(0,n.jsxs)("button",{onClick:()=>D(e.id),className:`flex-1 min-w-[80px] px-2 py-1.5 rounded text-xs font-medium transition-all flex items-center justify-center gap-1 ${W===e.id?"bg-primary text-primary-foreground":"text-white/50 hover:text-white hover:bg-white/10"}`,children:[(0,n.jsx)("span",{className:"truncate",children:e.name}),(0,n.jsx)(g.E,{variant:"secondary",className:"ml-1 h-4 text-[10px] px-1 shrink-0",children:t})]},e.id)})}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto scrollbar-site min-h-0",children:(ek=R.filter(e=>e.category_id===W&&(0,eP.me)(e))).length>0?(0,n.jsx)("div",{className:"grid grid-cols-2 gap-2 pb-2",children:ek.map(e=>{let r=(0,eP.me)(e),l=Q&&T(Q.monumentType)?Q.monumentImage===r||Q.monumentImage2===r:t===r;return(0,n.jsxs)("button",{onClick:()=>Q?.selectMonumentFromCatalog?.(r)??i(r),className:`relative aspect-[3/4] rounded-lg overflow-hidden border-2 transition-all bg-[repeating-conic-gradient(#2a2a2a_0%_25%,#1a1a1a_0%_50%)] bg-[length:10px_10px] ${l?"border-primary ring-2 ring-primary/20":"border-border hover:border-primary/50"}`,children:[(0,n.jsx)("img",{src:r,alt:e.name,className:"w-full h-full object-contain p-2"}),(0,n.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/90 to-transparent text-white text-xs p-2 text-center",children:(0,n.jsx)("div",{className:"font-medium",children:e.name})}),l&&(0,n.jsx)("div",{className:"absolute top-2 right-2 bg-primary rounded-full p-1",children:(0,n.jsx)(a.A,{name:"Check",size:12,className:"text-primary-foreground"})})]},e.id)})}):(0,n.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:(0,n.jsx)("p",{className:"text-sm",children:"Нет памятников в этой категории"})})})]}):(0,n.jsxs)("div",{className:"text-center py-12 text-muted-foreground px-3",children:[(0,n.jsx)(a.A,{name:"Package",size:48,className:"mx-auto mb-4 opacity-20"}),(0,n.jsx)("p",{className:"text-sm font-medium",children:"Каталог пуст"})]})]}),"imageCatalog"===eR&&(0,n.jsxs)("div",{className:"p-3 space-y-2",children:[(0,n.jsx)("p",{className:"text-xs font-semibold text-white/60 uppercase tracking-wider mb-3",children:"Каталог изображений"}),(0,n.jsx)("p",{className:"text-[10px] text-white/35 -mt-2 mb-2",children:"Клик или перетащите на макет"}),eY?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):eT.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"grid grid-cols-3 gap-1 bg-white/5 rounded-lg p-1 shrink-0",children:eT.map(e=>{let t=eL.filter(t=>t.category_id===e.id).length;return(0,n.jsxs)("button",{onClick:()=>eB(e.id),className:`px-1.5 py-1.5 rounded text-xs font-medium transition-all flex items-center justify-center gap-1 w-full ${eX===e.id?"bg-primary text-primary-foreground":"text-white/50 hover:text-white hover:bg-white/10"}`,children:[(0,n.jsx)("span",{className:"truncate",children:e.name}),(0,n.jsx)("span",{className:"shrink-0 bg-white/20 rounded-full text-[10px] px-1 leading-4",children:t})]},e.id)})}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2 pb-2",children:[eL.filter(e=>e.category_id===eX).map(e=>(0,n.jsxs)("button",{onClick:()=>h(e.image_url,"image"),draggable:!0,onDragStart:t=>e1(t,e.image_url,"image"),className:"rounded border-2 border-white/10 hover:border-primary transition-all bg-black/40 hover:bg-primary/5 overflow-hidden flex flex-col",children:[(0,n.jsx)("div",{className:"flex items-center justify-center p-2",style:{height:"90px"},children:(0,n.jsx)("img",{src:e.image_url,alt:e.name,className:"max-w-full max-h-full object-contain"})}),(0,n.jsx)("div",{className:"bg-black/60 text-white text-[9px] px-1 py-1 text-center truncate w-full",children:e.name})]},e.id)),0===eL.filter(e=>e.category_id===eX).length&&(0,n.jsx)("p",{className:"col-span-2 text-xs text-white/40 text-center py-6",children:"Нет изображений"})]})]}):(0,n.jsx)("p",{className:"text-xs text-white/30 text-center py-4",children:"Категории не найдены"})]})]})]})})};function eR({imageUrl:e,containerWidth:t,containerHeight:i,isContain:s,brushSize:o,hardness:c=60,onSave:d,onCancel:h}){let m=(0,l.useRef)(null),x=(0,l.useRef)(null),u=(0,l.useRef)(null),p=(0,l.useRef)(!1),g=(0,l.useRef)(null),[f,w]=(0,l.useState)(!1),[y,b]=(0,l.useState)({x:0,y:0,w:t,h:i});(0,l.useEffect)(()=>{let n=m.current;if(!n)return;let r=n.getContext("2d",{willReadFrequently:!0});if(!r)return;u.current=r;let a=e.startsWith("data:"),l=e.startsWith("/")&&!e.startsWith("//"),o=S(e),c=new Image;a||l||(c.crossOrigin="anonymous"),c.onload=()=>{var e,a;let l,o,d;
8b(s?(e=c.naturalWidth,l=Math.min(t/e,i/(a=c.naturalHeight)),{x:(t-(o=e*l))/2,y:(i-(d=a*l))/2,w:o,h:d}):{x:0,y:0,w:t,h:i}),n.width=c.naturalWidth,n.height=c.naturalHeight,r.clearRect(0,0,n.width,n.height),r.globalCompositeOperation="source-over",r.drawImage(c,0,0),w(!0)},c.onerror=()=>{console.error("[InlineEraser] не удалось загрузить изображение",e),w(!1)},c.src=o},[e,t,i,s]),(0,l.useEffect)(()=>{let e=x.current;e&&(e.width=Math.round(y.w),e.height=Math.round(y.h))},[y]);let v=(0,l.useCallback)((e,t)=>{let i=x.current;if(!i)return;let n=i.getContext("2d");n&&(n.clearRect(0,0,i.width,i.height),n.beginPath(),n.arc(e,t,o/2+1,0,2*Math.PI),n.strokeStyle="rgba(0,0,0,0.85)",n.lineWidth=1,n.stroke(),n.beginPath(),n.arc(e,t,o/2,0,2*Math.PI),n.strokeStyle="rgba(255,255,255,0.95)",n.lineWidth=1.5,n.stroke())},[o]),j=(0,l.useCallback)(()=>{let e=x.current;if(!e)return;let t=e.getContext("2d");t?.clearRect(0,0,e.width,e.height)},[]),N=(0,l.useCallback)((e,t)=>{let i=x.current;if(!i)return{x:0,y:0};let n=i.getBoundingClientRect(),r=i.width/n.width,a=i.height/n.height;return{x:(e-n.left)*r,y:(t-n.top)*a}},[]),M=(0,l.useCallback)((e,t)=>{let i=m.current;if(!i)return{x:0,y:0};let n=i.getBoundingClientRect();return{x:(e-n.left)/n.width*i.width,y:(t-n.top)/n.height*i.height}},[]),k=(0,l.useCallback)(()=>{let e=m.current;return e&&0!==y.w?o/2*(e.width/y.w):o/2},[o,y.w]),C=(0,l.useCallback)((e,t)=>{let i=u.current;if(!i)return;let n=k(),r=.7+(1-Math.min(Math.max(c/100,0),1))*4.5,a=i.createRadialGradient(e,t,0,e,t,n);for(let e=0;e<=8;e++){let t=e/8,i=Math.pow(1-t,r);a.addColorStop(t,`rgba(0,0,0,${i})`)}i.globalCompositeOperation="destination-out",i.fillStyle=a,i.beginPath(),i.arc(e,t,n,0,2*Math.PI),i.fill()},[k,c]),z=(0,l.useCallback)((e,t)=>{if(!g.current)return void C(e,t);let{x:i,y:n}=g.current,r=Math.max(Math.ceil(Math.sqrt((e-i)**2+(t-n)**2)/2),1);for(let a=0;a<=r;a++){let l=a/r;C(i+(e-i)*l,n+(t-n)*l)}},[C]),$=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),p.current=!0;let{x:t,y:i}=M(e.clientX,e.clientY);g.current={x:t,y:i},C(t,i)},[M,C]),F=(0,l.useCallback)(e=>{e.preventDefault();let t=N(e.clientX,e.clientY);if(v(t.x,t.y),!p.current)return;let{x:i,y:n}=M(e.clientX,e.clientY);z(i,n),g.current={x:i,y:n}},[N,v,M,z]),P=(0,l.useCallback)(e=>{e.preventDefault(),p.current=!1,g.current=null},[]),E=(0,l.useCallback)(()=>{p.current=!1,g.current=null,j()},[j]),I=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=e.touches[0];p.current=!0;let{x:i,y:n}=M(t.clientX,t.clientY);g.current={x:i,y:n},C(i,n)},[M,C]),H=(0,l.useCallback)(e=>{if(e.preventDefault(),!p.current)return;let t=e.touches[0],{x:i,y:n}=M(t.clientX,t.clientY);z(i,n),g.current={x:i,y:n}},[M,z]),A=(0,l.useCallback)(e=>{e.preventDefault(),p.current=!1,g.current=null},[]),R=(0,l.useCallback)(()=>{let e=m.current;e&&d(e.toDataURL("image/png"))},[d]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("canvas",{ref:m,style:{position:"absolute",left:y.x,top:y.y,width:y.w,height:y.h,touchAction:"none",zIndex:50,opacity:+!!f}}),(0,n.jsx)("canvas",{ref:x,style:{position:"absolute",left:y.x,top:y.y,width:y.w,height:y.h,cursor:"none",touchAction:"none",zIndex:51},onMouseDown:$,onMouseMove:F,onMouseUp:P,onMouseLeave:E,onTouchStart:I,onTouchMove:H,onTouchEnd:A}),(0,n.jsxs)("div",{style:{position:"absolute",bottom:-44,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:8,zIndex:100,whiteSpace:"nowrap"},onMouseDown:e=>e.stopPropagation(),children:[(0,n.jsxs)(r.$,{size:"sm",variant:"outline",onClick:h,className:"bg-black/80 border-white/20 text-white hover:bg-black/90 h-8 text-xs px-3",children:[(0,n.jsx)(a.A,{name:"X",size:14,className:"mr-1"}),"Отмена"]}),(0,n.jsxs)(r.$,{size:"sm",onClick:R,className:"bg-primary h-8 text-xs px-3",children:[(0,n.jsx)(a.A,{name:"Check",size:14,className:"mr-1"}),"Готово"]})]})]})}var eW=i(47650);let eT="#2d2d2d",eD="#00bfff",eL=[1,2,5,10,20,25,50,100,200,250,500,1e3];function e_(e,t,i){let n=i.getBoundingClientRect();return n.width<=0||n.height<=0?{x:0,y:0}:{x:(e-n.left)/n.width*i.offsetWidth,y:(t-n.top)/n.height*i.offsetHeight}}function eX({guides:e,previewGuide:t,onMoveStart:i,onRemove:r}){return(0,n.jsxs)("div",{className:"absolute inset-0 pointer-events-none overflow-visible",style:{zIndex:50},children:[e.map(e=>(0,n.jsx)("div",{className:"absolute pointer-events-auto",style:"h"===e.axis?{top:e.pos,left:0,right:0,height:0,cursor:"ns-resize"}:{left:e.pos,top:0,bottom:0,width:0,cursor:"ew-resize"},onMouseDown:t=>{t.stopPropagation(),t.preventDefault(),i(e.id,e.axis)},onDoubleClick:t=>{t.stopPropagation(),r(e.id)},children:(0,n.jsx)("div",{className:"absolute",style:"h"===e.axis?{left:0,right:0,top:-1,height:2,background:eD,boxShadow:`0 0 4px ${eD}`}:{top:0,bottom:0,left:-1,width:2,background:eD,boxShadow:`0 0 4px ${eD}`}})},e.id)),t&&(0,n.jsx)("div",{className:"absolute pointer-events-none",style:"h"===t.axis?{top:t.pos,left:0,right:0,height:1,background:eD,opacity:.7}:{left:t.pos,top:0,bottom:0,width:1,background:eD,opacity:.7}})]})}function eB({enabled:e,canvasRef:t,zoom:i,mmPerPx:r,children:a}){let s=(0,l.useRef)(null),o=(0,l.useRef)(null),c=(0,l.useRef)(null),[d,h]=(0,l.useState)({w:0,h:0}),[m,x]=(0,l.useState)({w:0,h:0}),[u,p]=(0,l.useState)(null),[g,f]=(0,l.useState)([]),[w,y]=(0,l.useState)(null),[b,v]=(0,l.useState)(null),[j,N]=(0,l.useState)(null),M=(0,l.useId)(),S=(0,l.useCallback)(()=>{let e=t.current;if(!e)return;let i=e.offsetWidth,n=e.offsetHeight;if(i<=0||n<=0)return;let r=e.getBoundingClientRect();x({w:i,h:n}),h({w:Math.max(1,Math.round(r.width)),h:Math.max(1,Math.round(r.height))})},[t]);(0,l.useLayoutEffect)(()=>{e?p(t.current):p(null)},[e,t,m.w,m.h]),(0,l.useEffect)(()=>
8{if(!e)return;S();let i=t.current;if(!i)return;let n=new ResizeObserver(S);n.observe(i),c.current&&n.observe(c.current),window.addEventListener("resize",S);let r=requestAnimationFrame(()=>{S(),requestAnimationFrame(S)});return()=>{cancelAnimationFrame(r),n.disconnect(),window.removeEventListener("resize",S)}},[t,S,i,e]),(0,l.useEffect)(()=>{if(!e)return;let t=s.current,i=o.current;if(!t||!i||d.w<=0||d.h<=0)return;let n=window.devicePixelRatio||1;for(let{ref:e,w:t,h:i,axis:a}of[{ref:s,w:d.w,h:22,axis:"h"},{ref:o,w:22,h:d.h,axis:"v"}]){let l=e.current;l.width=Math.floor(t*n),l.height=Math.floor(i*n),l.style.width=`${t}px`,l.style.height=`${i}px`;let s=l.getContext("2d");s.setTransform(n,0,0,n,0,0),function(e,t,i,n,r,a){let l=null!=r&&r>0,s=l?n*r:n,o=function(e,t,i=55){let n=e/Math.max(t/i,1);for(let e of eL)if(e>=n)return e;return eL[eL.length-1]}(s,i),c=o/(o>=100?5:10);e.fillStyle=eT,"h"===t?e.fillRect(0,0,i,22):e.fillRect(0,0,22,i),e.strokeStyle="#8a8a8a",e.fillStyle="#c8c8c8",e.font="9px system-ui, sans-serif",e.textBaseline="top";for(let n=0;n<=s+.01*c;n+=c){let r=(s>0?n/s:0)*i,a=Math.abs(n%o)<.01*c||0===n,l=a?18:8.1;if(e.beginPath(),"h"===t?(e.moveTo(r+.5,22),e.lineTo(r+.5,22-l)):(e.moveTo(22,r+.5),e.lineTo(22-l,r+.5)),e.stroke(),a){let i=String(Math.round(n));"h"===t?e.fillText(i,r+3,3):(e.save(),e.translate(3,r+3),e.fillText(i,0,0),e.restore())}}if(null!=a&&n>0){let n=(l?a*r:a)/s*i;e.fillStyle="#F39200","h"===t?e.fillRect(n-1,0,2,22):e.fillRect(0,n-1,22,2)}}(s,a,"h"===a?t:i,"h"===a?m.w:m.h,r,"h"===a?w?.x??null:w?.y??null)}},[e,d,m,r,w]),(0,l.useEffect)(()=>{if(!e)return;let i=t.current;if(!i)return;let n=e=>{y(e_(e.clientX,e.clientY,i))},r=()=>y(null);return i.addEventListener("mousemove",n),i.addEventListener("mouseleave",r),()=>{i.removeEventListener("mousemove",n),i.removeEventListener("mouseleave",r)}},[e,t,m.w,m.h]);let k=(0,l.useCallback)((e,t)=>{let i="h"===e?m.h:m.w;t<0||t>i||f(i=>[...i,{id:`${M}-${Date.now()}`,axis:e,pos:Math.round(t)}])},[m.h,m.w,M]),C=(0,l.useCallback)((e,t,i)=>{let n="h"===i?m.h:m.w;t<-8||t>n+8?f(t=>t.filter(t=>t.id!==e)):f(i=>i.map(i=>i.id===e?{...i,pos:Math.round(Math.max(0,Math.min(n,t)))}:i))},[m.h,m.w]);(0,l.useEffect)(()=>{if(!b)return;let e=e=>{let i=t.current;if(!i)return;let{x:n,y:r}=e_(e.clientX,e.clientY,i);"create"===b.kind?N({axis:b.axis,pos:"h"===b.axis?r:n}):C(b.id,"h"===b.axis?r:n,b.axis)},i=e=>{let i=t.current;if(!i)return;let{x:n,y:r}=e_(e.clientX,e.clientY,i);"create"===b.kind&&k(b.axis,"h"===b.axis?r:n),v(null),N(null)};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",i),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",i)}},[b,t,k,C]);let z=r?"мм":"px",$=d.w>0&&d.h>0;return e?(0,n.jsxs)("div",{ref:c,className:"relative flex flex-1 flex-col w-full min-h-0 self-stretch overflow-visible",children:[(0,n.jsx)("div",{className:"relative flex flex-1 flex-col w-full min-h-0",children:a}),u&&(0,eW.createPortal)((0,n.jsx)(eX,{guides:g,previewGuide:j,onMoveStart:(e,t)=>v({kind:"move",id:e,axis:t}),onRemove:e=>f(t=>t.filter(t=>t.id!==e))}),u),$&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"absolute z-[100] shrink-0 cursor-pointer hover:bg-[#3a3a3a] transition-colors",style:{top:0,left:0,width:22,height:22,background:eT},title:"Двойной клик — очистить направляющие",onDoubleClick:()=>f([])}),(0,n.jsx)("canvas",{ref:s,className:"absolute top-0 z-[100] cursor-row-resize",style:{left:22,height:22,width:d.w},onMouseDown:e=>{e.preventDefault(),v({kind:"create",axis:"h"})}}),(0,n.jsx)("canvas",{ref:o,className:"absolute left-0 z-[100] cursor-col-resize",style:{top:22,width:22,height:d.h},onMouseDown:e=>{e.preventDefault(),v({kind:"create",axis:"v"})}})]}),w&&$&&(0,n.jsx)("div",{className:"absolute z-[120] pointer-events-none rounded bg-black/75 px-2 py-1 text-[10px] text-white/90 font-mono border border-white/10",style:{to
8p:22+d.h-28,left:30},children:r?`${Math.round(w.x*r)} \xd7 ${Math.round(w.y*r)} мм`:`${Math.round(w.x)} \xd7 ${Math.round(w.y)} px`}),(0,n.jsxs)("p",{className:(0,e$.cn)("pointer-events-none absolute z-[120] text-[10px] text-white/50",$?"block":"hidden"),style:{top:4,left:28},children:["Перетащите с линейки — направляющая \xb7 Двойной клик — удалить \xb7 Угол — очистить все \xb7 ",z]})]}):(0,n.jsx)(n.Fragment,{children:a})}function eY({enabled:e,onToggle:t,className:i}){return(0,l.useEffect)(()=>{let e=e=>{e.ctrlKey&&"r"===e.key.toLowerCase()&&(e.preventDefault(),t())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]),(0,n.jsxs)("button",{type:"button",onClick:t,className:(0,e$.cn)("flex h-8 items-center gap-1.5 rounded px-2 text-[11px] transition-colors",e?"bg-[#F39200]/90 font-medium text-black hover:bg-[#F39200]":"bg-black/70 text-white/70 hover:bg-black/90 hover:text-white",i),title:"Линейки (Ctrl+R)",children:[(0,n.jsx)(a.A,{name:"Ruler",size:14}),"Линейки"]})}function eU(e,t,i){return e>=i.x&&e<=i.x+i.width&&t>=i.y&&t<=i.y+i.height}function eO(e,t,i){let n=Math.max(0,Math.min(e.x,t-e.width)),r=Math.max(0,Math.min(e.y,i-e.height));return{...e,x:n,y:r}}function eJ(e,t,i){let n=i.getBoundingClientRect();return{x:(e-n.left)/n.width*i.offsetWidth,y:(t-n.top)/n.height*i.offsetHeight}}function eG(e,t,i,n,r=!1){let a=i-e,l=n-t;if(r){let e=Math.max(Math.abs(a),Math.abs(l));a=Math.sign(a||1)*e,l=Math.sign(l||1)*e}return{x:Math.max(0,a>=0?e:e+a),y:Math.max(0,l>=0?t:t+l),width:Math.abs(a),height:Math.abs(l)}}function eV(e,t,i){let n=Math.min(e.x,t),r=Math.min(e.y,i),a=Math.min(e.width,t-n),l=Math.min(e.height,i-r);return{x:n,y:r,width:a,height:l}}function eq({enabled:e,onToggle:t,className:i}){return(0,l.useEffect)(()=>{let e=e=>{if("m"===e.key.toLowerCase()&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let i=e.target?.tagName;"INPUT"===i||"TEXTAREA"===i||e.target?.isContentEditable||(e.preventDefault(),t())}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]),(0,n.jsxs)("button",{type:"button",onClick:t,className:(0,e$.cn)("flex h-8 items-center gap-1.5 rounded px-2 text-[11px] transition-colors",e?"bg-[#F39200]/90 font-medium text-black hover:bg-[#F39200]":"bg-black/70 text-white/70 hover:bg-black/90 hover:text-white",i),title:"Прямоугольное выделение (M)",children:[(0,n.jsx)(a.A,{name:"SquareDashed",size:14}),"Выделение"]})}function eK({rect:e,draggable:t=!1,isDragging:i=!1,onMoveStart:r}){if(!e||e.width<1||e.height<1)return null;let a=t&&!i;return(0,n.jsx)("div",{className:(0,e$.cn)("absolute z-[70]",a?"pointer-events-auto cursor-move":"pointer-events-none"),style:{left:e.x,top:e.y,width:e.width,height:e.height},onMouseDown:e=>{a&&r?.(e)},children:(0,n.jsx)("div",{className:"absolute inset-0 border border-dashed border-white bg-sky-400/10",style:{boxShadow:"inset 0 0 0 1px rgba(0,0,0,0.65)"}})})}function eZ({enabled:e,rect:t,mmPerPx:i,canvasRef:r,onApply:a}){let s=null!=i&&i>0,[o,c]=(0,l.useState)(s?"mm":"px"),[d,h]=(0,l.useState)(""),[m,x]=(0,l.useState)("");(0,l.useEffect)(()=>{s||c("px")},[s]),(0,l.useEffect)(()=>{if(!t){h(""),x("");return}"mm"===o&&s?(h(String(Math.round(t.width*i))),x(String(Math.round(t.height*i)))):(h(String(Math.round(t.width))),x(String(Math.round(t.height))))},[t,o,s,i]);let u=(0,l.useCallback)(()=>{let e=Number(d.replace(",",".")),n=Number(m.replace(",","."));if(!Number.isFinite(e)||!Number.isFinite(n)||e<=0||n<=0)return;let l="mm"===o&&s?e/i:e,c="mm"===o&&s?n/i:n,h=r.current;if(!h)return;let x=eV({x:t?t.x:Math.max(0,(h.offsetWidth-l)/2),y:t?t.y:Math.max(0,(h.offsetHeight-c)/2),width:l,height:c},h.offsetWidth,h.offsetHeight);x.width>=1&&x.height>=1&&a(x)},[d,m,o,s,i,r,t,a]);return e?(0,n.jsxs)("div",{className:"absolute top-12 right-2 z-40 w-[220px] rounded-lg border border-white/15 bg-black/85 p-2.5 shadow-xl backdrop-blur-sm",children:[(0,n.jsx)("p",{className:"mb-2 text-[10px] font-medium uppercase tracking-wide text-white/50",children:"Размер выделения"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("label",{className:"flex flex-1 flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"text-[9px] text-white/40",children:"Ширина"}),(0,n.jsx)("input",{type:"number",min:1,step:1,value:d,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),u())},placeholder:"—",className:"h-7 w-full rounded border border-white/15 bg-white/5 px-2 text-[11px] text-white outline-none focus:border-primary/60"})]}),(0,n.jsx)("span",{className:"mt-4 text-white/30",children:"\xd7"}),(0,n.jsxs)("label",{className:"flex flex-1 flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"text-[9px] text-white/40",children:"Высота"}),(0,n.jsx)("input",{type:"number",min:1,step:1,value:m,onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),u())},placeholder:"—",className:"h-7 w-full rounded border border-white/15 bg-white/5 px-2 text-[11px] text-white outline-none focus:border-primary/60"})]})]}),(0,n.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s?(0,n.jsxs)("div",{className:"flex rounded border border-white/10 p-0.5 text-[10px]",children:[(0,n.jsx)("button",{type:"button",onClick:()=>c("mm"),className:(0,e$.cn)("rounded px-2 py-0.5 transition-colors","mm"===o?"bg-primary text-black":"text-white/50 hover:text-white"),children:"мм"}),(0,n.jsx)("button",{type:"button",onClick:()=>c("px"),className:(0,e$.cn)("rounded px-2 py-0.5 transition-colors","px"===o?"bg-primary text-black":"text-white/50 hover:text-white"),children:"px"})]}):(0,n.jsx)("span",{className:"text-[10px] text-white/35",children:"px"}),(0,n.jsx)("button",{type:"button",onClick:u,className:"rounded bg-primary px-2.5 py-1 text-[10px] font-medium text-black hover:bg-primary/90",children:t?"Применить":"Создать"})]}),t&&(0,n.jsx)("p",{className:"mt-1.5 text-[9px] text-white/30",children:function(e,t){let i=Math.round(e.width),n=Math.round(e.height);if(t&&t>0){let r=Math.round(e.width*t),a=Math.round(e.height*t);return`${i} \xd7 ${n} px \xb7 ${r} \xd7 ${a} мм`}return`${i} \xd7 ${n} px`}(t,i)})]}):null}function eQ({src:e,rect:t,flipHorizontal:i}){let r=(0,l.useRef)(null);return(0,l.useEffect)(()=>
8{if(!r.current||t.width<=0||t.height<=0)return;let n=!1,a=[S(e),e],l=0,s=()=>{if(n||l>=a.length)return;let e=new Image;0===l&&(e.crossOrigin="anonymous");let o=a[l];e.onload=()=>(e=>{if(n||!r.current)return;let a=Math.max(1,Math.round(t.width)),l=Math.max(1,Math.round(t.height));r.current.width=a,r.current.height=l;let s=r.current.getContext("2d");s&&(s.clearRect(0,0,a,l),ew(s,e,{x:0,y:0,width:a,height:l},!0,i))})(e),e.onerror=()=>{l+=1,s()},e.src=o};return s(),()=>{n=!0}},[e,t.width,t.height,i]),(0,n.jsx)("canvas",{ref:r,"data-export-src":e,"aria-label":"Памятник",style:{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,zIndex:3,pointerEvents:"none",userSelect:"none"}})}function e0({monRect:e,widthMm:t,heightMm:i,compact:r=!1}){let a=r?Math.max(22,Math.min(30,.07*e.width)):Math.max(14,Math.min(24,.05*e.width)),l=Math.max(11,Math.min(16,.045*e.width)),s="#3b7dd8",o=e.y-a,c=r?e.x+e.width+a:e.x-a,d=r?o+l+2:o-6;return(0,n.jsx)("svg",{className:"absolute inset-0 overflow-visible pointer-events-none",style:{zIndex:6},"aria-hidden":!0,children:(0,n.jsxs)("g",{stroke:s,fill:s,strokeWidth:1.5,children:[(0,n.jsx)("line",{x1:e.x,y1:o,x2:e.x+e.width,y2:o}),(0,n.jsx)("polygon",{points:`${e.x},${o} ${e.x+5},${o-5} ${e.x+5},${o+5}`}),(0,n.jsx)("polygon",{points:`${e.x+e.width},${o} ${e.x+e.width-5},${o-5} ${e.x+e.width-5},${o+5}`}),(0,n.jsxs)("text",{x:e.x+e.width/2,y:d,textAnchor:"middle",fontSize:l,fontWeight:600,fill:s,stroke:"none",children:[Math.round(t)," мм"]}),(0,n.jsx)("line",{x1:c,y1:e.y,x2:c,y2:e.y+e.height}),(0,n.jsx)("polygon",{points:`${c},${e.y} ${c-5},${e.y+5} ${c+5},${e.y+5}`}),(0,n.jsx)("polygon",{points:`${c},${e.y+e.height} ${c-5},${e.y+e.height-5} ${c+5},${e.y+e.height-5}`}),(0,n.jsxs)("text",{x:r?c+8:c-8,y:e.y+e.height/2,textAnchor:"middle",fontSize:l,fontWeight:600,fill:s,stroke:"none",transform:`rotate(-90 ${r?c+8:c-8} ${e.y+e.height/2})`,children:[Math.round(i)," мм"]})]})})}function e1(e,t=.75){let[i,n]=(0,l.useState)(t);return(0,l.useEffect)(()=>{if(!e)return;let t=new Image;t.crossOrigin="anonymous",t.onload=()=>{t.naturalWidth>0&&t.naturalHeight>0&&n(t.naturalWidth/t.naturalHeight)},t.src=e},[e]),i}function e2({monumentType:e,sceneBackgroundImage:t,sceneMode:i="outdoor"}){let r=14*!!T(e),a=Math.round(14.000000000000002),l=a+r,s=Math.round(38),o=Math.round(0);return t?(0,n.jsx)("img",{src:t,alt:"",draggable:!1,className:"absolute inset-0 h-full w-full object-cover",style:{zIndex:0,pointerEvents:"none",userSelect:"none"}}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{style:{position:"absolute",inset:0,zIndex:0,pointerEvents:"none",background:"studio"===i?Y:"#0a0a0a",backgroundImage:"studio"===i?"linear-gradient(to right, rgba(0,0,0,0.07) 1px, transparent 1px), linear-gradient(to bottom, rgba(0,0,0,0.07) 1px, transparent 1px)":void 0,backgroundSize:"studio"===i?"24px 24px":void 0}}),(0,n.jsx)("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"18%",zIndex:0,pointerEvents:"none",overflow:"hidden"},children:(0,n.jsx)("img",{src:K,alt:"",draggable:!1,style:{position:"absolute",bottom:0,left:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"bottom center",userSelect:"none"}})}),(0,n.jsx)("div",{style:{position:"absolute",bottom:`${o}%`,left:`-${l}%`,width:`${42+a}%`,height:`${s}%`,zIndex:1,pointerEvents:"none",overflow:"hidden"},children:(0,n.jsx)("img",{src:Z,alt:"",draggable:!1,style:{position:"absolute",bottom:0,left:0,width:"68.96551724137932%",height:"68.96551724137932%",objectFit:"contain",objectPosition:"bottom left",transform:"scale(1.45)",transformOrigin:"bottom left",mixBlendMode:"multiply",userSelect:"none"}})}),(0,n.jsx)("div",{style:{position:"absolute",bottom:`${o}%`,right:`-${l}%`,width:`${42+a}%`,height:`${s}%`,zIndex:1,pointerEvents:"none",overflow:"hidden"},children:(0,n.jsx)("img",{src:Q,alt:"",draggable:!1,style:{position:"absolute",bottom:0,right:0,width:"68.96551724137932%",height:"68.96551724137932%",objectFit:"contain",objectPosition:"bottom right",transform:"scale(1.7)",transformOrigin:"bottom right",mixBlendMode:"multiply",userSelect:"none"}})})]})}function e5({canvasWidth:e,canvasHeight:t,monumentImage:i,monumentImage2:r,monumentType:a="single",monumentGapMm:s=50,monumentSlotHorizontal:o,monumentSlotSizes:c,monumentWidthMm:d=600,monumentHeightMm:h=1200,pede
8stalImage:m,sceneBackgroundImage:x,pedestalWidthMm:u=eo.widthMm,pedestalHeightMm:p=150,pedestalAnchorPct:g=95,mmPerPx:f=2,sceneMode:w="outdoor",showSceneDimensions:y=!0,compactSceneDimensions:b=!1,monumentFlipHorizontal:v=!1,monumentFlipHorizontal2:j=!1,sceneVaseSides:N=[],sceneVaseSrc:M=ee.src,sceneLampSides:k=[],sceneLampSrc:C=el,sceneFlowerbed:z=!1,sceneFlowerbedSrc:$=es.src}){let F=(0,l.useRef)(null),[P,E]=(0,l.useState)({w:e,h:t}),I=e1(i),W=e1(r),T=e1(M),D=e1(C),[_,X]=(0,l.useState)(null),[Y,O]=(0,l.useState)(null),[J,G]=(0,l.useState)(null);(0,l.useEffect)(()=>{let e=!1;return A(M??ee.src).then(t=>{!e&&t&&X(t.toDataURL("image/png"))}),()=>{e=!0}},[M]),(0,l.useEffect)(()=>{let e=!1;return R(C??el).then(t=>{!e&&t&&O(t.toDataURL("image/png"))}),()=>{e=!0}},[C]),(0,l.useEffect)(()=>{if(!z)return void G(null);let e=!1;return H($??es.src).then(t=>{!e&&t&&G(t.toDataURL("image/png"))}),()=>{e=!0}},[z,$]),(0,l.useLayoutEffect)(()=>{let e=F.current?.parentElement;if(!e)return;let t=()=>{let t=Math.round(e.offsetWidth),i=Math.round(e.offsetHeight);t>0&&i>0&&E(e=>e.w===t&&e.h===i?e:{w:t,h:i})};t();let i=new ResizeObserver(t);return i.observe(e),()=>i.disconnect()},[e,t]);let V=(0,l.useMemo)(()=>eu({canvasW:P.w,canvasH:P.h,monumentHeightMm:h,monumentWidthMm:d,pedestalHeightMm:p,pedestalWidthMm:u,monumentType:a,monumentGapMm:s,monumentSlotHorizontal:o,monumentSlotSizes:c,sceneMode:w,showGroundLayers:!x}),[P.w,P.h,h,d,p,u,a,s,w,x,o,c]),q=(0,l.useMemo)(()=>P.w<=0||P.h<=0||V<=0?null:ex({canvasW:P.w,canvasH:P.h,monumentType:a,monumentGapMm:s,monumentWidthMm:d,monumentHeightMm:h,pedestalWidthMm:u,pedestalHeightMm:p,pedestalAnchorPct:g,mmPerPx:V,aspect1:I,aspect2:W,monumentSlotHorizontal:o,monumentSlotSizes:c,combinedCatalogImage:!m&&"single"===a}),[P.w,P.h,a,s,d,h,u,p,g,V,I,W,m,o,c]),K=!x,Z=K&&z&&!!m,Q=e1(Z?$:null,es.aspect),et=(0,l.useMemo)(()=>u+ej(d,h),[u,a,s,d,h]),ei=(0,l.useMemo)(()=>q&&Z?eN(q,Q||es.aspect,et,p,P.w,P.h,d,h):[],[q,Z,Q,et,p,P.w,P.h,d,h]),en=(0,l.useMemo)(()=>q&&K&&0!==N.length?eb(q,N,T||ee.aspect,P.w):[],[q,K,N,T,P.w]),er=(0,l.useMemo)(()=>q&&K&&0!==k.length?ev(q,k,D||.62,P.w):[],[q,K,k,D,P.w]),ea=(0,l.useMemo)(()=>U((q?.horizontalSlots??L(a,o))[0]?"horizontal":a,d,h),[q?.horizontalSlots,a,o,d,h]);return(0,n.jsxs)("div",{ref:F,className:"absolute inset-0 pointer-events-none overflow-hidden",children:[(0,n.jsx)(e2,{monumentType:a,sceneBackgroundImage:x,sceneMode:x?"outdoor":w}),q&&(0,n.jsxs)(n.Fragment,{children:[m?(q.pedestals??[q.pedestal]).map((e,t)=>{let i=B(a,t);return(0,n.jsx)("img",{src:m,alt:"",draggable:!1,style:{position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,zIndex:2,pointerEvents:"none",objectFit:"fill",objectPosition:"bottom center",transform:i?"scaleX(-1)":void 0,transformOrigin:"center center",userSelect:"none"}},t)}):null,ei.map((e,t)=>{let i=B(a,t);return(0,n.jsx)("img",{src:J??$??es.src,alt:"",draggable:!1,style:{position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,zIndex:3,pointerEvents:"none",objectFit:"contain",objectPosition:i?"top left":"top right",transform:i?"scaleX(-1)":void 0,transformOrigin:"center center",filter:"contrast(1.08)",userSelect:"none"}},`flowerbed-${t}`)}),_&&en.map((e,t)=>(0,n.jsx)("img",{src:_,alt:"",draggable:!1,style:{position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,zIndex:4,pointerEvents:"none",objectFit:"contain",objectPosition:"bottom center",filter:"drop-shadow(0 4px 10px rgba(0,0,0,0.45)) contrast(1.08)",userSelect:"none"}},`vase-${t}`)),er.map((e,t)=>(0,n.jsx)("img",{src:Y??C??el,alt:"",draggable:!1,style:{position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,zIndex:4,pointerEvents:"none",objectFit:"contain",objectPosition:"bottom center",filter:"drop-shadow(0 4px 10px rgba(0,0,0,0.45)) contrast(1.08)",userSelect:"none"}},`lamp-${t}`)),q.monuments.map((e,t)=>{let a=0===t?i:r;if(!a)return null;let l=q.horizontalSlots?.[t]??!!q.horizontal,s=0===t?v:j;return l?(0,n.jsx)(eQ,{src:a,rect:e,flipHorizontal:s},t):(0,n.jsx)("div",{style:{position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,zIndex:3,pointerEvents:"none"},children:(0,n.jsx)("img",{src:S(a),"data-export-src":a,alt:0===t?"Памятник":"Памятник 2",draggable:!1,
8crossOrigin:"anonymous",onError:e=>{let t=e.currentTarget;t.src!==a&&(t.src=a)},style:{width:"100%",height:"100%",objectFit:"contain",objectPosition:"bottom center",transform:s?"scaleX(-1)":void 0,transformOrigin:"center center",userSelect:"none"}})},t)}),"studio"===w&&y&&!x&&(q.dimensionRect||q.monuments[0])&&(0,n.jsx)(e0,{monRect:q.dimensionRect??q.monuments[0],widthMm:ea.widthMm,heightMm:ea.heightMm,compact:b})]})]})}let e4=[{id:"nw",leftPct:0,topPct:0,cursor:"nwse-resize"},{id:"n",leftPct:50,topPct:0,cursor:"ns-resize"},{id:"ne",leftPct:100,topPct:0,cursor:"nesw-resize"},{id:"e",leftPct:100,topPct:50,cursor:"ew-resize"},{id:"se",leftPct:100,topPct:100,cursor:"nwse-resize"},{id:"s",leftPct:50,topPct:100,cursor:"ns-resize"},{id:"sw",leftPct:0,topPct:100,cursor:"nesw-resize"},{id:"w",leftPct:0,topPct:50,cursor:"ew-resize"}],e3=(e,t,i,n)=>{let r=Math.min(i/e,n/t),a=e*r,l=t*r;return{w:a,h:l,x:(i-a)/2,y:(n-l)/2}},e8=(e,t="")=>(0,e$.cn)("resize-none bg-transparent border-none outline-none whitespace-pre-wrap",e?"block max-w-none shrink-0":"w-full h-full break-words",t),e6=e=>({whiteSpace:"pre-wrap",wordBreak:e?"normal":"break-word",overflowWrap:e?"normal":"break-word",boxSizing:"border-box"}),e9={width:8,height:8,boxShadow:"0 0 0 1px rgba(0,0,0,0.4)"},e7=({src:e,alt:t,flipHorizontal:i,isSelected:r,containerWidth:a,containerHeight:s,onResizeMouseDown:o,onResizeTouchStart:c,onRotateMouseDown:d,onRotateTouchStart:h,onFitToContent:m})=>{let x=(0,l.useRef)(null),u=(0,l.useRef)(!1),[p,g]=(0,l.useState)({w:a,h:s,x:0,y:0}),f=(0,l.useCallback)((e,t,i,n)=>{g(e3(e,t,i,n))},[]);return(0,l.useEffect)(()=>{x.current?f(x.current.w,x.current.h,a,s):g({w:a,h:s,x:0,y:0})},[a,s,f]),(0,l.useEffect)(()=>{u.current=!1,x.current=null,g({w:a,h:s,x:0,y:0})},[e,a,s]),(0,n.jsxs)("div",{className:"relative w-full h-full",children:[(0,n.jsx)("img",{src:e,alt:t,className:"block w-full h-full select-none",style:{objectFit:"contain",objectPosition:"center center",transform:i?"scaleX(-1)":"none",pointerEvents:"none"},draggable:!1,onLoad:e=>{let t=e.currentTarget;if(x.current={w:t.naturalWidth,h:t.naturalHeight},f(t.naturalWidth,t.naturalHeight,a,s),!m||u.current)return;let{w:i,h:n}=x.current,r=e3(i,n,a,s),l=r.w<a-.5||r.h<s-.5;u.current=!0,l?m({width:r.w,height:r.h,offsetX:r.x,offsetY:r.y,naturalWidth:i,naturalHeight:n}):i>0&&n>0&&m({width:a,height:s,offsetX:0,offsetY:0,naturalWidth:i,naturalHeight:n})}}),r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"absolute pointer-events-none",style:{left:p.x,top:p.y,width:p.w,height:p.h,border:"1.5px solid white",boxShadow:"0 0 0 1px rgba(0,0,0,0.25)"}}),e4.map(({id:e,leftPct:t,topPct:i,cursor:r})=>(0,n.jsx)("div",{className:"absolute bg-white touch-none",style:{...e9,left:p.x+p.w*t/100,top:p.y+p.h*i/100,transform:"translate(-50%, -50%)",cursor:r},onMouseDown:t=>{t.stopPropagation(),o(t,e)},onTouchStart:t=>{t.stopPropagation(),c(t,e)}},e)),(0,n.jsxs)("div",{className:"absolute touch-none",style:{left:p.x+p.w/2,top:p.y-28,transform:"translateX(-50%)",height:28,width:0,zIndex:2},children:[(0,n.jsx)("div",{className:"absolute left-1/2 top-0 -translate-x-1/2 bg-white pointer-events-none",style:{width:1,height:28,boxShadow:"0 0 0 0.5px rgba(0,0,0,0.3)"}}),(0,n.jsx)("div",{className:"absolute left-1/2 top-0 bg-white cursor-grab active:cursor-grabbing",style:{...e9,transform:"translate(-50%, -50%)"},onMouseDown:e=>{e.stopPropagation(),d(e)},onTouchStart:e=>{e.stopPropagation(),h(e)}})]})]})]})},te=({canvasRef:e,monumentImage:t,elements:i,selectedElement:r,setSelectedElement:s,rotateMode:o,handleMouseDown:c,handleTouchStart:d,handleDoubleClick:h,handleSingleClick:m,handleMouseMove:x,handleMouseUp:u,handleTouchMove:p,handleTouchEnd:g,handleResizeMouseDown:f,handleResizeTouchStart:w,handleRotateMouseDown:y,handleRotateTouchStart:b,toggleRotateMode:v,setElements:j,saveDesign:N,sendForCalculation:M,exportDesign:S,exportDesignAsPNG:k,isSaving:C,importDesign:z,importInputRef:$,inlineEditingId:F,handleInlineTextChange:P,handleInlineEditBlur:E,canvasZoom:I,onCanvasDoubleClick:H,onCanvasTouchStart:A,canvasPan:R,onCanvasMouseDown:W,updateElement:T,onPrintOrder:D,topOffset:L=48,inline
8EraserElementId:_,onStartInlineErase:X,onStopInlineErase:B,onSaveInlineErase:U,inlineEraserBrushSize:O=40,onChangeInlineEraserBrushSize:J,inlineEraserHardness:G=80,onZoomChange:V,onCanvasDragOver:q,onCanvasDrop:K,canvasAspectRatio:Z=.75,layoutOverlay:Q,onFitImageContent:ee,monumentType:et="single",monumentImage2:ei=null,monumentGapMm:en=50,monumentSlotHorizontal:er,monumentSlotSizes:ea,pedestalImage:el=null,pedestalWidthMm:es=eo.widthMm,pedestalHeightMm:ec=150,pedestalAnchorPct:ed=95,monumentWidthMm:eh=600,monumentHeightMm:em=1200,sceneBackgroundImage:ex=null,sceneMode:eu="studio",showSceneDimensions:ep=!0,monumentFlipHorizontal:eg=!1,monumentFlipHorizontal2:ef=!1,sceneVaseSides:ew=[],sceneVaseSrc:ey=null,sceneLampSides:eb=[],sceneLampSrc:ev=null,sceneFlowerbed:ej=!1,sceneFlowerbedSrc:eN=null,mobileSceneCrop:eM=null,sceneCanvasWidth:eS=0,sceneCanvasHeight:ek=0,bottomChromePx:eC})=>{let[ez,eF]=(0,l.useState)(null),[eP,eE]=(0,l.useState)(!1),[eI,eH]=(0,l.useState)(!1),{activeRect:eA,isDragging:eW,startCreate:eT,startMove:eD,clearSelection:eL,updateSelection:e_}=function(e,t){let[i,n]=(0,l.useState)(null),[r,a]=(0,l.useState)(null),s=(0,l.useCallback)(()=>{n(null),a(null)},[]),o=(0,l.useCallback)(r=>{let l=e.current;if(!t||!l)return!1;let{x:s,y:o}=eJ(r.clientX,r.clientY,l);return!(i&&eU(s,o,i))&&(n(null),a({kind:"create",startX:s,startY:o,currentX:s,currentY:o,square:r.shiftKey}),r.preventDefault(),r.stopPropagation(),!0)},[e,t,i]),c=(0,l.useCallback)(n=>{let r=e.current;if(!t||!r||!i)return!1;let{x:l,y:s}=eJ(n.clientX,n.clientY,r);return!!eU(l,s,i)&&(a({kind:"move",origin:i,startX:l,startY:s,currentX:l,currentY:s}),n.preventDefault(),n.stopPropagation(),!0)},[e,t,i]);(0,l.useEffect)(()=>{if(!r)return;let t=t=>{let i=e.current;if(!i)return;let{x:n,y:r}=eJ(t.clientX,t.clientY,i);a(e=>e?"create"===e.kind?{...e,currentX:n,currentY:r,square:t.shiftKey}:{...e,currentX:n,currentY:r}:null)},i=t=>{let i=e.current;if(!i)return;let{x:l,y:s}=eJ(t.clientX,t.clientY,i);if("move"===r.kind){let e=l-r.startX,t=s-r.startY,o=eO({...r.origin,x:r.origin.x+e,y:r.origin.y+t},i.offsetWidth,i.offsetHeight);a(null),n(o);return}let o=eV(eG(r.startX,r.startY,l,s,r.square||t.shiftKey),i.offsetWidth,i.offsetHeight);a(null),o.width>=2&&o.height>=2&&n(o)};return window.addEventListener("mousemove",t),window.addEventListener("mouseup",i),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",i)}},[r,e]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&s()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,s]);let d=(()=>{if(!r)return i;let t=e.current?.offsetWidth??1/0,n=e.current?.offsetHeight??1/0;if("move"===r.kind){let e=r.currentX-r.startX,i=r.currentY-r.startY;return eO({...r.origin,x:r.origin.x+e,y:r.origin.y+i},t,n)}return eV(eG(r.startX,r.startY,r.currentX,r.currentY,r.square),t,n)})();return{selection:i,activeRect:d,isDragging:null!=r,startCreate:o,startMove:c,clearSelection:s,updateSelection:(0,l.useCallback)(e=>{a(null),n(e)},[])}}(e,eI),eX=(0,l.useRef)(ez),eQ=(0,l.useRef)(null),[e0,e1]=(0,l.useState)({w:0,h:0}),e2=(0,l.useRef)(null),[e4,e3]=(0,l.useState)(1),[e9,te]=(0,l.useState)(null),[tt,ti]=(0,l.useState)(window.innerWidth<1024);(0,l.useEffect)(()=>{let e=()=>ti(window.innerWidth<1024);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,l.useEffect)(()=>{tt&&(eE(!1),eH(!1),eL())},[tt,eL]);let tn=(0,l.useMemo)(()=>eS>0&&ek>0?{w:eS,h:ek}:e0.w>0&&e0.h>0?e0:{w:0,h:0},[eS,ek,e0]);(0,l.useEffect)(()=>{eX.current=ez},[ez]),(0,l.useLayoutEffect)(()=>{if(eS>0&&ek>0)return;let t=null,i=0,n=()=>{let r=e.current;if(!r){i=requestAnimationFrame(n);return}let a=()=>{let e=Math.round(r.offsetWidth);if(e<=0)return;let t=Math.round(tt?e/Z:r.offsetHeight);t>0&&e1(i=>i.w===e&&i.h===t?i:{w:e,h:t})};a(),(t=new ResizeObserver(a)).observe(r)};return n(),()=>{cancelAnimationFrame(i),t?.disconnect()}},[Z,e,tt,eM,eS,ek]),(0,l.useLayoutEffect)(()=>{if(!tt||!eM){e3(1),te(null);return}let e=e2.current;if(!e)return;let t=()=>{let t=e.closest("[data-constructor-stage]")??e.parentElement?.parentElement??e.parentElement,i=t?.clientWidth||e.clientWidth,n=t?.clientHeight??0;if(i<=0||eM.cropWidth<=0)return;let r=tn.w>0?tn.w:i,a=tn.h>0?tn.h:n,l=eM.cropLeft,s=eM.cropTop,o=eM.cropWidth,c=eM.cropHeight,d=eM.fitMode??"contain",h=eM.fitScale??1;if("contain"===d&&n>0&&c>
80){let e=i/n,t=o/Math.max(c,1);if(t<e-.001){let t=Math.min(r,c*e);l=Math.max(0,Math.min(l+o/2-t/2,r-t)),o=Math.max(o,t)}else t>e+.001&&a>0&&s+(c=Math.max(c,Math.min(a,o/e)))>a&&(s=Math.max(0,a-c))}let m=i/o,x=n>0&&c>0?n/c:m,u=("cover"===d?Math.max(m,x):Math.min(m,x))*h;e3(e=>.001>Math.abs(e-u)?e:u),te(e=>e&&.5>Math.abs(e.cropLeft-l)&&.5>Math.abs(e.cropTop-s)&&.5>Math.abs(e.cropWidth-o)&&.5>Math.abs(e.cropHeight-c)?e:{cropLeft:l,cropTop:s,cropWidth:o,cropHeight:c})};t();let i=new ResizeObserver(t),n=e.closest("[data-constructor-stage]");return n?i.observe(n):e.parentElement?i.observe(e.parentElement):i.observe(e),()=>i.disconnect()},[tt,eM?.cropWidth,eM?.cropHeight,eM?.cropLeft,eM?.cropTop,eM?.fitMode,eM?.fitScale,tn.w,tn.h]),(0,l.useEffect)(()=>{F||eF(null)},[F]),(0,l.useEffect)(()=>{if(!eQ.current){let e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.top="0",e.style.visibility="hidden",e.style.whiteSpace="pre",e.style.pointerEvents="none",document.body.appendChild(e),eQ.current=e}return()=>{eQ.current?.remove(),eQ.current=null}},[]);let tr=(0,l.useCallback)((e,t)=>{let i=eX.current,n=eQ.current;if(!i||i.id!==e||!n)return;let r=((e,t,i)=>{let n=window.getComputedStyle(e);i.style.font=n.font,i.style.letterSpacing=n.letterSpacing,i.style.fontFeatureSettings=n.fontFeatureSettings,i.style.fontVariantLigatures=n.fontVariantLigatures,i.style.fontStyle=n.fontStyle;let r=0;for(let e of t.split("\n"))i.textContent=e.length>0?e:"\xa0",r=Math.max(r,i.getBoundingClientRect().width);return Math.ceil(r)})(t,t.value,n)+20,a=Math.max(i.minWidth,r);t.style.maxWidth="none",t.style.width=`${a}px`,t.style.height="0px";let l=Math.max(i.minHeight,t.scrollHeight);t.style.height=`${l}px`,eF(t=>t&&t.id===e&&(t.width!==a||t.height!==l)?{...t,width:a,height:l}:t)},[]),ta=(0,l.useCallback)(e=>{let t=eX.current;E(t?.id===e?{width:t.width,height:t.height}:void 0)},[E]),tl=(0,l.useCallback)((e,t,i)=>{P(e.id,t,i),e.autoSize&&F===e.id&&tr(e.id,i)},[P,F,tr]),ts=(0,l.useCallback)(e=>t=>{t&&F===e.id&&e.autoSize&&tr(e.id,t)},[F,tr]);(0,l.useLayoutEffect)(()=>{if(!F||!ez)return;let e=i.find(e=>e.id===F);if(!e?.autoSize)return;let t=document.querySelector(`[data-inline-edit="${F}"]`);t&&tr(F,t)},[F,ez?.id,ez?.width,i,tr]);let to="studio"===eu&&!ex,tc=eC??(tt?52:44),td=null!=eC?`calc(100vh - ${L}px - ${tc}px - env(safe-area-inset-bottom, 0px))`:`calc(100vh - ${L}px - ${tc}px)`,th=`min(100%, calc((100vh - ${L}px) * 0.9 * ${Z}))`,tm=tt&&null!=eM,tx=e9??eM,tu=tx?Math.round(tx.cropHeight*e4):0,tp=`scale(${I}) translate(${R.x/I}px, ${R.y/I}px)`,tg=tx?`scale(${e4}) translate(-${tx.cropLeft}px, -${tx.cropTop}px)`:"",tf=tm?{width:tn.w>0?tn.w:"100%",height:tn.h>0?tn.h:void 0,flexShrink:0}:tt?{width:"100%",aspectRatio:String(Z),maxHeight:td}:{width:th,aspectRatio:String(Z),maxHeight:td};return(0,n.jsxs)("div",{className:(0,e$.cn)("flex flex-col items-center w-full relative",tt?"justify-center flex-1 min-h-0 h-full self-stretch":to?"justify-center flex-1 min-h-0 h-full":"justify-start flex-1 min-h-0 h-full"),style:to?{backgroundColor:Y}:void 0,children:[(0,n.jsxs)("div",{className:"absolute top-2 right-2 z-40 hidden lg:flex items-center gap-1.5",children:[(0,n.jsx)(eq,{enabled:eI,onToggle:()=>{eH(e=>(e&&eL(),!e))}}),(0,n.jsx)(eY,{enabled:eP,onToggle:()=>eE(e=>!e)})]}),(0,n.jsx)(eZ,{enabled:eI,rect:eA,mmPerPx:Q?.mmPerPx,canvasRef:e,onApply:e_}),(0,n.jsx)(eB,{enabled:eP,onToggle:()=>eE(e=>!e),canvasRef:e,zoom:I,pan:R,mmPerPx:Q?.mmPerPx,children:(0,n.jsx)("div",{ref:e2,className:(0,e$.cn)(tm?"overflow-hidden flex-shrink-0 w-full":"w-full",!tm&&to?"flex flex-1 min-h-0 h-full items-center justify-center":""),style:tm?{width:"100%",height:tu,maxWidth:"100%",maxHeight:td}:void 0,children:(0,n.jsxs)("div",{ref:e,className:(0,e$.cn)("relative overflow-hidden touch-none select-none",ex||"outdoor"===eu?"bg-[#0a0a0a]":""),style:{...ex||"outdoor"===eu?{}:{backgroundColor:Y},transform:tm?`${tg} ${tp}`:tp,transformOrigin:tm?"top left":"top center",cursor:eI?"crosshair":I>1?"move":"default",transition:"none",...tf},onMouseMove:x,onMouseUp:u,onMouseLeave:u,onTouchMove:p,onTouchEnd:g,onTouchStart:A,onDoubleClick:H,onContextMenu:e=>e.preventDefault(),onDragOver:q,onDrop:K,onMouseDown:e=>{if(eI){s(null),eT(e);return}(e.target===e.currentTarget||"IMG"===e.target.tagName)&&(s(null),W(e))},children:[(0,n.jsx)(e5,{canvasWidth:tn.w,canvasHeight:tn.h,monumentImage:t,monumentImage2:ei,monumentType:et,monumentGapMm:en,monumentSlotHorizontal:er,monumentSlotSizes:ea,monumentWidthMm:eh,monumentHeightMm:em,pedestalImage:el,sceneBackgroun
8dImage:ex,pedestalWidthMm:es,pedestalHeightMm:ec,pedestalAnchorPct:ed,mmPerPx:tn.w>0&&tn.h>0&&Q?.sceneMmPerPx?Q.sceneMmPerPx:0,sceneMode:eu,showSceneDimensions:ep,compactSceneDimensions:tt,monumentFlipHorizontal:eg,monumentFlipHorizontal2:ef,sceneVaseSides:ew,sceneVaseSrc:ey,sceneLampSides:eb,sceneLampSrc:ev,sceneFlowerbed:ej,sceneFlowerbedSrc:eN}),(0,n.jsx)(eK,{rect:eA,mmPerPx:Q?.mmPerPx,draggable:eI&&null!=eA,isDragging:eW,onMoveStart:eD}),Q&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"absolute top-2 left-2 pointer-events-none z-[5] hidden lg:block",children:(0,n.jsxs)("div",{className:"rounded bg-black/70 border border-white/20 px-2 py-1 text-[10px] text-white/90 font-medium",children:["↕ ",Math.round(Q.monumentHeightMm)," мм"]})}),(0,n.jsx)("div",{className:"absolute bottom-2 right-2 pointer-events-none z-[5] hidden lg:block",children:(0,n.jsxs)("div",{className:"rounded bg-black/70 border border-white/20 px-2 py-1 text-[10px] text-white/90 font-medium",children:["↔ ",Math.round(Q.monumentWidthMm)," мм"]})})]}),i.map(e=>{var t,i;let s,x,u=["image","cross","flower"].includes(e.type);return(0,n.jsxs)("div",{className:`absolute cursor-move touch-none ${r===e.id&&!u?"ring-2 ring-inset ring-primary":""}`,style:{zIndex:4,left:e.x,top:e.y,width:e.autoSize&&F===e.id&&ez?.id===e.id?ez.width:e.autoSize?"auto":e.width,height:e.autoSize&&F===e.id&&ez?.id===e.id?ez.height:e.autoSize?"auto":e.height,transform:`rotate(${e.rotation||0}deg)`,minWidth:e.autoSize?"50px":void 0,minHeight:e.autoSize?"30px":void 0},onMouseDown:t=>{F!==e.id&&c(t,e.id)},onTouchStart:t=>{F!==e.id&&d(t,e.id)},onClick:()=>m(e.id),onDoubleClick:t=>{t.stopPropagation();let i=t.currentTarget,n=Math.max(50,i.offsetWidth),r=Math.max(30,i.offsetHeight);eF({id:e.id,width:n,height:r,minWidth:n,minHeight:r}),h(e.id)},children:["text"===e.type&&(0,n.jsx)("div",{className:`w-full h-full flex items-start justify-center p-1 ${F===e.id?"overflow-visible":"overflow-hidden"}`,children:F===e.id?(0,n.jsx)("textarea",{"data-inline-edit":e.id,autoFocus:!0,value:e.content||"",onChange:t=>tl(e,t.target.value,t.target),onBlur:()=>ta(e.id),ref:ts(e),onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),className:e8(e.autoSize),wrap:e.autoSize?"off":"soft",style:{fontSize:`${e.fontSize}px`,color:e.color,textShadow:"2px 2px 4px rgba(0,0,0,0.8)",fontFamily:e.fontFamily?.includes("|custom|")?e.fontFamily?.split("|")[0]:e.fontFamily?.split("|")[0]||"serif",fontWeight:e.fontFamily?.includes("|custom|")?"normal":e.fontFamily?.split("|")[1]||"bold",fontStyle:e.italic?"italic":"normal",lineHeight:e.lineHeight||1.2,letterSpacing:e.letterSpacing?`${e.letterSpacing}px`:"normal",textAlign:e.textAlign||"center",...e6(e.autoSize),overflow:e.autoSize?"hidden":"auto"}}):(0,n.jsx)("div",{className:"select-none",style:{fontSize:`${e.fontSize}px`,color:e.color,textShadow:"2px 2px 4px rgba(0,0,0,0.8)",fontFamily:e.fontFamily?.includes("|custom|")?e.fontFamily?.split("|")[0]:e.fontFamily?.split("|")[0]||"serif",fontWeight:e.fontFamily?.includes("|custom|")?"normal":e.fontFamily?.split("|")[1]||"bold",fontStyle:e.italic?"italic":"normal",lineHeight:e.lineHeight||1.2,letterSpacing:e.letterSpacing?`${e.letterSpacing}px`:"normal",textAlign:e.textAlign||"center",whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"visible",width:"100%",display:"block",margin:0,padding:0},children:e.content})}),"epitaph"===e.type&&(0,n.jsx)("div",{className:`w-full h-full flex items-start justify-center p-1 ${F===e.id?"overflow-visible":"overflow-hidden"}`,children:F===e.id?(0,n.jsx)("textarea",{"data-inline-edit":e.id,autoFocus:!0,value:e.content||"",onChange:t=>tl(e,t.target.value,t.target),onBlur:()=>ta(e.id),ref:ts(e),onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),className:e8(e.autoSize,"italic"),wrap:e.autoSize?"off":"soft",style:{fontSize:`${e.fontSize}px`,color:e.color,textShadow:"2px 2px 4px rgba(0,0,0,0.8)",fontFamily:e.fontFamily?.split("|")[0]||"serif",fontWeight:e.fontFamily?.split("|")[1]||"400",fontStyle:e.italic?"italic":"normal",lineHeight:e.lineHeight||1.4,letterSpacing:e.letterSpacing?`${e.letterSpacing}px`:"normal",textAlign:e.textAlign||"center",...e6(e.autoSize),overflow:e.autoSize?"hidden":"auto"}}):(0,n.jsx)("div",{className:"select-none italic",style:{fontSize:`${e.fontSize}px`,color:e.color,textShadow:"2px 2px 4px rgba(0,0,0,0.8)",fontFamily:e.fontFamily?.split("|")[0]||"serif",fontWeight:e.fontFamily?.split("|")[1]||"400",fontStyle:e.italic?"italic":"normal",lineHeight:e.lineHeight||1.4,letterSpacing:e.letterSpacing?`${e.letterSpacing}px`:"normal",textAlign:e.textAlign||"center",whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"visible",width:"100%",display:"block",margin:0,padding:0},children:e.content})}),"fio"===e.type&&(0,n.jsx)("div",{className:`w-full h-full flex items-start justify-center ${F===e.id?"overflow-visible":""}`,children:F===e.id?(0,n.jsx)("textarea",{"data-inline-edit":e.id,autoFocus:!0,value:e.content||"",onChange:t=>tl(e,t.target.value,t.target),onBlur:()=>ta(e.id),ref:ts(e),onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),className:e8(e.autoSize),wrap:e.autoSize?"off":"soft",style:{fontSize:`${e.fontSize}px`,color:e.color,textShadow:"2px 2px 4px rgba(0,0,0,0.8)",fontFamily:e.fontFamily?.split("|")[0]||"serif",fontWeight:e.fontFamily?.includes("|custom|")?"normal":e.fontFamily?.split("|")[1]||"400",fontStyle:e.italic?"italic":"normal",lineHeight:e.lineHeight||1.05,letterSpacing:e.letterSpacing?`${e.letterSpacing}px`:"normal",textAlign:e.textAlign||"center",fontFeatureSettings:e.fontFamily?.includes("|custom|")?"'ss01', 'calt', 'swsh', 'liga', 'dlig'":"normal",fontVariantLigatures:e.fontFamily?.includes("|custom|")?"common-ligatures discretionary-ligatures":"normal",...e6(e.autoSize),overflow:e.autoSize?"hidden":"auto"}}):(0,n.jsx)("div",{className:"select-none",style:{fontSize:`${e.fontSize}px`,color:e.color,textShadow:"2px 2px 4px rgba(0,0,0,0.8)",fontFamily:e.fontFamily?.split("|")[0]||"serif",fontWeight:e.fontFamily?.includes("|custom|")?"normal":e.fontFamily?.split("|")[1]||"400",fontStyle:e.italic?"italic":"normal",lineHeight:e.lineHeight||1.05,letterSpacing:e.letterSpacing?`${e.letterSpacing}px`:"normal",textAlign:e.textAlign||"center",whiteSpace:"pre-wrap",overflow:"visible",width:"100%",display:"block",margin:0,padding:0},children:(t=e.content||"",(i=e.initialScale)&&1!==i?t.split("\n").map((e,t)=>{let r=e.split(/\s+/);return(0,n.jsxs)(l.Fragment,{children:[t>0&&(0,n.jsx)("br",{}),r.map((e,t)=>{if(!e)return null;let r=e[0],a=e.slice(1);return(0,n.jsxs)(l.Fragment,{children:[t>0&&" ",(0,n.jsx)("span",{style:{fontSize:`${i}em`,lineHeight:1},children:r}),a]},t)})]},t)}):t)})}),"dates"===e.type&&(0,n.jsx)("div",{className:`w-full h-full flex items-start justify-center ${F===e.id?"overflow-visible":""}`,children:F===e.id?(0,n.jsx)("textarea",{"data-inline-edit":e.id,autoFocus:!0,value:e.content||"",onChange:t=>tl(e,t.target.value,t.target),onBlur:()=>ta(e.id),ref:ts(e),onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),className:e8(e.autoSize),wrap:e.autoSize?"off":"soft",style:{fontSize:`${e.fontSize}px`,color:e.color,textShadow:"2px 2px 4px rgba(0,0,0,0.8)",fontFamily:e.fontFamily?.split("|")[0]||"serif",fontWeight:e.fontFamily?.split("|")[1]||"400",fontStyle:e.italic?"italic":"normal",lineHeight:e.lineHeight||1.2,letterSpacing:e.letterSpacing?`${e.letterSpacing}px`:"0.05em",textAlign:e.textAlign||"center",...e6(e.autoSize),overflow:e.autoSize?"hidden":"auto"}}):(0,n.jsx)("div",{className:"select-none",style:{fontSize:`${e.fontSize}px`,color:e.color,textShadow:"2px 2px 4px rgba(0,0,0,0.8)",fontFamily:e.fontFamily?.split("|")[0]||"serif",fontWeight:e.fontFamily?.split("|")[1]||"400",fontStyle:e.italic?"italic":"normal",lineHeight:e.lineHeight||1.2,letterSpacing:e.letterSpacing?`${e.letterSpacing}px`:"0.05em",textAlign:e.textAlign||"center",whiteSpace:"pre-wrap",overflow:"visible",width:"100%",display:"block",margin:0,padding:0},children:e.content})}),"photo"===e.type&&e.src&&_!==e.id&&(0,n.jsx)("img",{src:e.screenMode&&e.processedSrc?e.processedSrc:e.src,alt:"Фотография",className:"w-full h-full object-cover select-none",draggable:!1}),("image"===e.type||"cross"===e.type||"flower"===e.type)&&e.src&&_!==e.id&&(0,n.jsx)(e7,{src:e.screenMode&&e.processedSrc?e.processedSrc:e.src,alt:e.type,flipHorizontal:e.flipHorizontal,isSelected:r===e.id,containerWidth:e.width,containerHeight:e.height,onResizeMouseDown:(t,i)=>f(t,e.id,i),onResizeTouchStart:(t,i)=>w(t,e.id,i),onRotateMouseDown:t=>y(t,e.id),onRotateTouchStart:t=>b(t,e.id),onFitToContent:ee?t=>ee(e.id,t):void 0}),_===e.id&&("image"===e.type||"cross"===e.type||"flower"===e.type||"photo"===e.type)&&e.src&&(0,n.jsx)(eR,{imageUrl:e.processedSrc||e.src,containerWidth:e.width,containerHeight:e.height,isContain:"photo"!==e.type,zoom:I,brushSize:O,hardness:G,onSave:e=>U?.(e),onCancel:()=>B?.()}),r===e.id&&!u&&F!==e.id&&(0,n.jsx)("div",{className:`absolute bottom-0 right-0 w-4 h-4 bg-primary rounded-full hover:scale-125 transition-transform touch-none flex items-center justify-center shadow-lg border-2 border-background ${o?"cursor-grab":"cursor-nwse-resize"}`,style:{transform:"translate(50%, 50%)"},onMouseDown:t=>f(t,e.id),onTouchStart:t=>w(t,e.id),onDoubleClick:e=>{e.stopPropagation(),v()},title:o?"Режим вращения (двойной клик для масштабирования)":"Режим масштабирования (двойной клик для вращения)",children:o&&(0,n.jsx)(a.A,{name:"RotateCw",size:8,className:"text-primary-foreground"})}),Q&&r===e.id&&("image"===(s=e.type)||"photo"===s||"cross"===s||"flower"===s)&&"number"==typeof e.width&&"number"==typeof e.height&&(0,n.jsx)("div",{className:"absolute left-1/2 top-full mt-1 -translate-x-1/2 pointer-events-none z-30 whitespace-nowrap",children:(0,n.jsxs)("div",{className:"rounded bg-[#F39200] text-black text-[10px] font-semibold px-2 py-0.5 
8shadow-lg",children:[(x=Q.getElementSizeMm?.(e)??{widthMm:e.width*Q.mmPerPx,heightMm:e.height*Q.mmPerPx},(0,n.jsxs)(n.Fragment,{children:[Math.round(x.widthMm)," \xd7 ",Math.round(x.heightMm)," мм"]})),Q.getElementPrice&&(0,n.jsxs)(n.Fragment,{children:[" \xb7 ",Math.round(Q.getElementPrice(e)).toLocaleString("ru-RU")," ₽"]})]})})]},e.id)})]})})})]})},tt=({selectedEl:e,updateElement:t,deleteElement:i,fonts:s,onEditImage:o,eraserBrushSize:c=40,onEraserBrushSizeChange:d,eraserHardness:h=80,onEraserHardnessChange:m,layoutInfo:x=null})=>{let[g,f]=(0,l.useState)(!1);return(0,n.jsxs)("div",{className:"constructor-panel flex flex-col h-full bg-[#181818] text-white overflow-y-auto scrollbar-site",children:[(0,n.jsx)("div",{className:"px-3 pt-3 pb-2 border-b border-white/10 flex-shrink-0",children:(0,n.jsx)("p",{className:"text-[10px] font-semibold text-white/40 uppercase tracking-widest",children:"Свойства"})}),(0,n.jsxs)("div",{className:"p-3 flex-1",children:[!e&&(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-40 text-center",children:[(0,n.jsx)(a.A,{name:"MousePointer2",size:28,className:"text-white/20 mb-2"}),(0,n.jsx)("p",{className:"text-xs text-white/40",children:"Выберите элемент на холсте"})]}),e&&(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("div",{children:(0,n.jsxs)(p.J,{children:["Тип: ","text"===e.type?"Текст":"epitaph"===e.type?"Эпитафия":"fio"===e.type?"ФИО":"dates"===e.type?"Даты":"photo"===e.type?"Фотография":"cross"===e.type?"Крест":"flower"===e.type?"Цветок":"Изображение"]})}),"text"===e.type&&(0,n.jsxs)("div",{className:"rounded-md border border-[#F39200]/30 bg-[#F39200]/10 px-3 py-2 space-y-1",children:[(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-xs",children:[(0,n.jsx)("span",{className:"text-white/60",children:"Строк"}),(0,n.jsx)("span",{className:"text-white font-medium",children:w(e.content)})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-xs",children:[(0,n.jsx)("span",{className:"text-white/60",children:"Тариф"}),(0,n.jsxs)("span",{className:"text-white/80",children:[1e3.toLocaleString("ru-RU")," ₽ / строка"]})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-xs",children:[(0,n.jsx)("span",{className:"text-white/60",children:"Стоимость"}),(0,n.jsxs)("span",{className:"text-[#F39200] font-semibold",children:[(1e3*w(e.content)).toLocaleString("ru-RU")," ₽"]})]})]}),x&&("image"===e.type||"photo"===e.type||"cross"===e.type||"flower"===e.type)&&(0,n.jsxs)("div",{className:"rounded-md border border-[#F39200]/30 bg-[#F39200]/10 px-3 py-2 space-y-1",children:[(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-xs",children:[(0,n.jsx)("span",{className:"text-white/60",children:"На памятнике"}),(0,n.jsxs)("span",{className:"text-white font-medium",children:[Math.round(x.widthMm)," \xd7 ",Math.round(x.heightMm)," мм"]})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-2 text-xs",children:[(0,n.jsx)("span",{className:"text-white/60",children:x.isFixedPrice?"Фиксированная цена":"Стоимость"}),(0,n.jsxs)("span",{className:"text-[#F39200] font-semibold",children:[x.priceRub.toLocaleString("ru-RU")," ₽"]})]})]}),("text"===e.type||"epitaph"===e.type||"fio"===e.type||"dates"===e.type)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{children:"Текст"}),(0,n.jsx)(u.p,{value:e.content||"",onChange:i=>t(e.id,{content:i.target.value}),className:"mt-1"})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{children:["Размер шрифта: ",Math.round(e.fontSize||24),"px"]}),(0,n.jsx)("input",{type:"range",min:"12",max:"72",value:Math.round(e.fontSize||24),onChange:i=>t(e.id,{fontSize:parseInt(i.target.value)}),className:"w-full mt-1"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{children:"Цвет"}),(0,n.jsx)("div",{className:"flex gap-2 mt-1",children:[{name:"Золото",value:"#C9A84C"},{name:"Серебро",value:"#C0C0C0"},{name:"Белый",value:"#FFFFFF"}].map(i=>(0,n.jsx)("button",{title:i.name,onClick:()=>t(e.id,{color:i.value}),className:`w-10 h-10 rounded border-2 transition-all ${e.color===i.value?"border-primary scale-110":"border-muted-foreground
8/30"}`,style:{backgroundColor:i.value}},i.value))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{children:"Выравнивание"}),(0,n.jsx)("div",{className:"flex gap-2 mt-1",children:[{value:"left",icon:"AlignLeft",title:"По левому краю"},{value:"center",icon:"AlignCenter",title:"По центру"},{value:"right",icon:"AlignRight",title:"По правому краю"}].map(i=>(0,n.jsx)("button",{type:"button",title:i.title,onClick:()=>t(e.id,{textAlign:i.value}),className:`flex-1 h-9 rounded border flex items-center justify-center transition-all ${(e.textAlign||"center")===i.value?"border-primary bg-primary/20 text-primary":"border-white/15 text-white/50 hover:border-white/30 hover:text-white"}`,children:(0,n.jsx)(a.A,{name:i.icon,size:16})},i.value))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{children:"Шрифт"}),(0,n.jsx)("div",{className:"space-y-2 mt-2 max-h-48 overflow-y-auto scrollbar-site",children:s.map(i=>(0,n.jsxs)("button",{onClick:()=>t(e.id,{fontFamily:i.fullStyle}),className:`w-full text-left p-2 rounded border transition-all ${e.fontFamily===i.fullStyle?"border-primary bg-primary/10":"border-border hover:border-primary/50"}`,children:[(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:i.name}),(0,n.jsx)("div",{className:"text-sm",style:{fontFamily:i.style,fontWeight:i.weight},children:i.example})]},i.id))})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{children:["Между строками (Фамилия↔Имя): ",e.lineHeight?.toFixed(1)||"1.2"]}),(0,n.jsx)("input",{type:"range",min:"0.8",max:"2.5",step:"0.1",value:e.lineHeight||1.2,onChange:i=>t(e.id,{lineHeight:parseFloat(i.target.value)}),className:"w-full mt-1"}),(0,n.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[(0,n.jsx)("span",{children:"Узко"}),(0,n.jsx)("span",{children:"Широко"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{children:["Между буквами: ",e.letterSpacing?.toFixed(1)||"0","px"]}),(0,n.jsx)("input",{type:"range",min:"-2",max:"10",step:"0.5",value:e.letterSpacing||0,onChange:i=>t(e.id,{letterSpacing:parseFloat(i.target.value)}),className:"w-full mt-1"}),(0,n.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[(0,n.jsx)("span",{children:"Сжато"}),(0,n.jsx)("span",{children:"Разрежено"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{children:"Курсив"}),(0,n.jsxs)(r.$,{onClick:()=>t(e.id,{italic:!e.italic}),variant:e.italic?"default":"outline",className:"w-full mt-2",children:[(0,n.jsx)(a.A,{name:e.italic?"Check":"Italic",size:18,className:"mr-2"}),e.italic?"Включен":"Выключен"]})]})]}),"image"===e.type||"cross"===e.type||"flower"===e.type||"photo"===e.type?(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{children:["Размер: ",Math.round(e.width),"px"]}),(0,n.jsx)("input",{type:"range",min:"30",max:"500",value:Math.round(e.width),onChange:i=>{let n=parseInt(i.target.value,10),r=e.height/e.width;t(e.id,{width:n,height:Math.round(n*r)})},className:"w-full mt-1"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{children:["Ширина: ",Math.round(e.width),"px"]}),(0,n.jsx)("input",{type:"range",min:"50",max:"500",value:Math.round(e.width),onChange:i=>t(e.id,{width:parseInt(i.target.value,10)}),className:"w-full mt-1"})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{children:["Высота: ",Math.round(e.height),"px"]}),(0,n.jsx)("input",{type:"range",min:"30",max:"400",value:Math.round(e.height),onChange:i=>t(e.id,{height:parseInt(i.target.value,10)}),className:"w-full mt-1"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{children:["Поворот: ",Math.round(e.rotation||0),"\xb0"]}),(0,n.jsx)("input",{type:"range",min:"-180",max:"180",value:Math.round(e.rotation||0),onChange:i=>t(e.id,{rotation:parseInt(i.target.value)}),className:"w-full mt-1"}),(0,n.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[(0,n.jsx)("span",{children:"← Влево"}),(0,n.jsx)("span",{children:"Вправо →"})]})]}),"fio"===e.type&&(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{children:["Размер первой буквы: ",e.initialScale?.toFixed(1)||"1.0","x"]}),(0,n.jsx)("input",{type:"range",min:"1.0",max:"2.0",step:"0.1",value:e.initialScale||1,onChange:i=>t(e.id,{initialScale:parseFloat(i.target.value)}),className:"w-full mt-1"}),(0,n.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[(0,n.jsx)("span",{children:"Обычный"}),(0,n.jsx)("span",{children:"Увеличенный"})]})]}),("image"===e.type||"cross"===e.type||"flower"===e.type)&&(0,n.jsx)("div",{children:(0,n.jsxs)(r.$,{onClick:()=>t(e.id,{flipHorizontal:!e.flipHorizontal}),variant:e.flipHorizontal?"default":"outline",className:"w-full",children:[(0,n.jsx)(a.A,{name:e.flipHorizontal?"Check":"FlipHorizontal",size:18,className:"mr-2"}),e.flipHorizontal?"Отзеркалено":"Отзеркалить"]})}),("photo"===e.type||"image"===e.type||"cross"===e.type||"flower"===e.type)&&e.src&&(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)(r.$,{onClick:()=>{o?.(e.id)},variant:"outline",className:"w-full",children:[(0,n.jsx)(a.A,{name:"Eraser",size:18,className:"mr-2"}),"Редактировать с ластиком"]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Уберите лишний фон вручную"}),(0,n.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{className:"text-xs",children:["Размер кисти: ",c,"px"]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,n.jsx)("div",{className:"w-2 h-2 rounded-full border border-muted-foreground flex-shrink-0"}),(0,n.jsx)("input",{type:"range",min:5,max:150,value:c,onChange:e=>d?.(Number(e.target.value)),className:"flex-1 constructor-range"}),(0,n.jsx)("div",{className:"w-4 h-4 rounded-full border border-muted-foreground flex-shrink-0"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{className:"text-xs",children:["Жёсткость: ",h,"%"]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,n.jsx)("div",{className:"w-3 h-3 rounded-full bg-muted-foreground
8/40 flex-shrink-0",style:{filter:"blur(1px)"}}),(0,n.jsx)("input",{type:"range",min:0,max:100,value:h,onChange:e=>m?.(Number(e.target.value)),className:"flex-1 constructor-range"}),(0,n.jsx)("div",{className:"w-3 h-3 rounded-full bg-muted-foreground flex-shrink-0"})]})]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{children:'Режим "Экран"'}),(0,n.jsx)(r.$,{onClick:async()=>{f(!0),await t(e.id,{screenMode:!e.screenMode}),f(!1)},variant:e.screenMode?"default":"outline",className:"w-full mt-2",disabled:g,children:g?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.A,{name:"Loader2",size:18,className:"mr-2 animate-spin"}),"Обработка..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.A,{name:e.screenMode?"Check":"Circle",size:18,className:"mr-2"}),e.screenMode?"Включен":"Выключен"]})}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Убирает черный цвет с фотографии"})]})]}),(0,n.jsxs)(r.$,{variant:"destructive",className:"w-full",onClick:()=>i(e.id),children:[(0,n.jsx)(a.A,{name:"Trash2",size:18,className:"mr-2"}),"Удалить элемент"]})]})]})]})};var ti=i(81477);let tn=({isOpen:e,onClose:t,editingElement:i,setEditingElement:s,onApply:o,fonts:c=[]})=>{(0,l.useEffect)(()=>{if(e){let e=window.innerWidth-document.documentElement.clientWidth;return document.body.style.overflow="hidden",document.body.style.paddingRight=`${e}px`,()=>{document.body.style.overflow="",document.body.style.paddingRight=""}}},[e]);let d=(0,l.useCallback)(()=>{i&&o({content:i.content,fontSize:i.fontSize,color:i.color,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,textAlign:i.textAlign,italic:i.italic,fontFamily:i.fontFamily})},[i,o]),h=(0,l.useCallback)(()=>{i&&o({content:i.content,fontSize:i.fontSize,color:i.color,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,textAlign:i.textAlign,italic:i.italic,fontFamily:i.fontFamily}),t(),s(null)},[i,o,t,s]);return e&&i?(0,n.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-end sm:items-center justify-center z-50",style:{paddingBottom:"40px"},onClick:e=>{e.target===e.currentTarget&&h()},children:(0,n.jsx)(ti.Zp,{className:"w-full max-w-lg sm:my-4 rounded-b-none sm:rounded-b-lg flex flex-col",style:{maxHeight:"calc(100vh - 80px)"},children:(0,n.jsxs)(ti.Wu,{className:"p-3 flex flex-col min-h-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center pb-2 border-b mb-2 flex-shrink-0",children:[(0,n.jsx)("h2",{className:"text-base font-bold",children:"Редактор текста"}),(0,n.jsx)("button",{onClick:h,className:"text-muted-foreground hover:text-foreground",children:(0,n.jsx)(a.A,{name:"X",size:20})})]}),(0,n.jsx)("div",{className:"relative bg-black/90 rounded-lg border border-border p-2 min-h-[90px] mb-2 flex-shrink-0",children:(0,n.jsx)("textarea",{autoFocus:!0,value:i.content||"",onChange:e=>s({...i,content:e.target.value}),className:"w-full min-h-[70px] resize-none bg-transparent border-none outline-none",placeholder:"Введите текст...",style:{fontSize:`${Math.min(i.fontSize||24,36)}px`,color:i.color||"#FFFFFF",fontFamily:i.fontFamily?.split("|")[0]||"serif",fontWeight:i.fontFamily?.split("|")[1]||"400",fontStyle:i.italic?"italic":"normal",lineHeight:i.lineHeight||1.2,letterSpacing:i.letterSpacing?`${i.letterSpacing}px`:"normal",textAlign:i.textAlign||"center",textShadow:"2px 2px 4px rgba(0,0,0,0.8)",whiteSpace:"pre-wrap",wordBreak:"keep-all",overflowWrap:"normal",touchAction:"manipulation"}})}),(0,n.jsxs)("div",{className:"constructor-panel flex-1 overflow-y-auto space-y-2 min-h-0",children:[(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{className:"text-xs text-muted-foreground",children:["Размер: ",(0,n.jsxs)("span",{className:"text-primary",children:[Math.round(i.fontSize||24),"px"]})]}),(0,n.jsx)("input",{type:"range",min:"12",max:"72",value:Math.round(i.fontSize||24),onChange:e=>s({...i,fontSize:parseInt(e.target.value)}),className:"w-full h-1.5 mt-1"})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{className:"text-xs text-muted-foreground",children:["Между строк: ",(0,n.jsx)("span",{className:"text-primary",children:i.lineHeight?.toFixed(1)||"1.2"})]}),(0,n.jsx)("input",{type:"range",min:"0.8",max:"2.5",step:"0.1",value:i.lineHeight||1.2,onChange:e=>s({...i,lineHeight:parseFloat(e.target.value)}),className:"w-full h-1.5 mt-1"})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)(p.J,{className:"text-xs text-muted-foreground",children:["Между букв: ",(0,n.jsxs)("span",{className:"text-primary",children:[i.letterSpacing?.toFixed(1)||"0","px"]})]}),(0,n.jsx)("input",{type:"range",min:"-2",max:"10",step:"0.5",value:i.letterSpacing||0,onChange:e=>s({...i,letterSpacing:parseFloat(e.target.value)}),className:"w-full h-1.5 mt-1"})]}),(0,n.jsxs)("div",{className:"flex flex-col justify-end",children:[(0,n.jsx)(p.J,{className:"text-xs text-muted-foreground mb-1",children:"Курсив и выравнивание"}),(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsx)("button",{onClick:()=>s({...i,italic:!i.italic}),className:`flex-1 h-7 rounded border text-xs flex items-center justify-center transition-all ${i.italic?"bg-primary text-primary-foreground border-primary":"border-border hover:bg-muted"}`,children:(0,n.jsx)(a.A,{name:"Italic",size:13})}),["left","center","right"].map(e=>(0,n.jsx)("button",{onClick:()=>s({...i,textAlign:e}),className:`flex-1 h-7 rounded border text-xs flex items-center justify-center transition-all ${(i.textAlign||"center")===e?"bg-primary text-primary-foreground border-primary":"border-border hover:bg-muted"}
8`,children:(0,n.jsx)(a.A,{name:"left"===e?"AlignLeft":"center"===e?"AlignCenter":"AlignRight",size:13})},e))]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-muted-foreground",children:"Цвет текста"}),(0,n.jsxs)("div",{className:"flex gap-1.5 mt-1",children:[[{name:"Золото",value:"#C9A84C"},{name:"Серебро",value:"#C0C0C0"},{name:"Белый",value:"#FFFFFF"}].map(e=>(0,n.jsx)("button",{title:e.name,onClick:()=>s({...i,color:e.value}),className:`w-8 h-8 rounded-lg border-2 transition-all ${i.color===e.value?"border-primary scale-110":"border-muted-foreground/30"}`,style:{backgroundColor:e.value}},e.value)),(0,n.jsx)("input",{type:"color",value:i.color||"#FFFFFF",onChange:e=>s({...i,color:e.target.value}),className:"w-8 h-8 rounded-lg border-2 cursor-pointer",title:"Свой цвет"})]})]}),c.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-muted-foreground",children:"Шрифт"}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-1 mt-1",children:c.map(e=>(0,n.jsxs)("button",{onClick:()=>s({...i,fontFamily:e.fullStyle}),className:`text-left px-2 py-1 rounded transition-all border ${i.fontFamily===e.fullStyle?"border-primary bg-primary/10":"border-border hover:bg-muted"}`,children:[(0,n.jsx)("div",{className:"text-[9px] text-muted-foreground leading-tight truncate",children:e.name}),(0,n.jsx)("div",{className:"text-sm text-foreground truncate",style:{fontFamily:e.style,fontWeight:e.weight},children:e.example})]},e.id))})]})]}),(0,n.jsxs)("div",{className:"flex gap-2 pt-2 flex-shrink-0",children:[(0,n.jsxs)(r.$,{className:"flex-1 h-10 font-semibold",onClick:d,children:[(0,n.jsx)(a.A,{name:"Check",size:16,className:"mr-1.5"}),"Применить"]}),(0,n.jsx)(r.$,{variant:"outline",onClick:h,className:"h-10 px-4",children:"Отмена"})]})]})})}):null},tr="--constructor-vv-bottom",ta=0;function tl(){let[e,t]=(0,l.useState)(0);return(0,l.useEffect)(()=>{let e=window.visualViewport;if(!e)return;ta+=1;let i=()=>{let i=Math.max(0,Math.round((document.documentElement.clientHeight||window.innerHeight)-e.height-e.offsetTop));document.documentElement.style.setProperty(tr,`${i}px`),t(e=>e===i?e:i)};return i(),e.addEventListener("resize",i),e.addEventListener("scroll",i),window.addEventListener("resize",i),()=>{e.removeEventListener("resize",i),e.removeEventListener("scroll",i),window.removeEventListener("resize",i),0===(ta=Math.max(0,ta-1))&&document.documentElement.style.removeProperty(tr)}},[]),e}function ts(e){return e>0?`${e}px`:"0px"}let to=({onAddText:e,onAddImage:t,onDelete:i,onRotateToggle:s,rotateMode:o,hasSelection:c,onOpenEraser:d,canErase:h,selectedEl:m,updateElement:x,deleteElement:u,fonts:p,uxMode:g="legacy",onClearSelection:f})=>{let[w,y]=(0,l.useState)(null),[b,v]=(0,l.useState)(!1),[j,N]=(0,l.useState)(""),M="bottom-tabs"===g,S=ts(tl()),k=M?`calc(56px + env(safe-area-inset-bottom, 0px) + ${S})`:S,C=M?`calc(56px + 48px + env(safe-area-inset-bottom, 0px) + ${S})`:`calc(2.5rem + ${S})`;if(!m||window.innerWidth>=1024)return null;let z=["text","epitaph","fio","dates"].includes(m.type),$=["image","cross","flower","photo"].includes(m.type),F=e=>{"rotate"===e&&"rotate"!==w&&N((m.rotation||0).toString()),y(w===e?null:e)};return(0,n.jsxs)(n.Fragment,{children:[z&&"fonts"===w&&p&&(0,n.jsxs)("div",{className:"constructor-panel fixed left-0 right-0 bg-[#1a1a1a] backdrop-blur-sm border-t border-white/10 px-2 py-1.5 z-[76] max-h-36 overflow-y-auto scrollbar-site",style:{bottom:C},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,n.jsx)("span",{className:"text-[10px] text-white/60",children:"Шрифт"}),(0,n.jsx)(r.$,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>y(null),children:(0,n.jsx)(a.A,{name:"X",size:10})})]}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-1",children:p.map(e=>(0,n.jsxs)("button",{onClick:()=>{m&&x&&x(m.id,{fontFamily:e.fullStyle})},className:`px-1.5 py-1 rounded border transition-all ${m.fontFamily===e.fullStyle?"border-primary bg-primary/10":"border-border hover:border-primary/50"}`,children:[(0,n.jsx)("div",{className:"text-[9px] text-muted-foreground truncate",children:e.name}),(0,n.jsx)("div",{className:"text-xs truncate",style:{fontFamily:e.style,fontWeight:e.weight},children:e.example})]},e.id))})]}),z&&"size"===w&&(0,n.jsxs)("div",{className:"constructor-panel fixed left-0 right-0 bg-[#1a1a1a] backdrop-blur-sm border-t border-white/10 px-3 py-1.5 z-[76]",style:{bottom:C},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,n.jsxs)("span",{className:"text-[10px] text-white/60",children:["Размер: ",Math.round(m.fontSize||24),"px"]}),(0,n.jsx)(r.$,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>y(null),children:(0,n.jsx)(a.A,{name:"X",size:10})})]}),(0,n.jsx)("input",{type:"range",min:"8",max:"30",value:Math.round(m?.fontSize||24),onChange:e=>{m&&x&&x(m.id,{fontSize:parseInt(e.target.value)})},className:"w-full mb-1"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("span",{className:"text-[10px] text-white/60 whitespace-nowrap",children:["Строки: ",m.lineHeight||1.2]}),(0,n.jsx)("input",{type:"range",min:"0.4",max:"3",step:"0.1",value:m?.lineHeight||1.2,onChange:e=>{m&&x&&x(m.id,{lineHeight:parseFloat(e.target.value)})},className:"w-full"})]})]}),z&&"color"===w&&(0,n.jsxs)("div",{className:"constructor-panel fixed left-0 right-0 bg-[#1a1a1a] backdrop-blur-sm border-t border-white/10 px-3 py-1.5 z-[76]",style:{bottom:C},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,n.jsx)("span",{className:"text-[10px] text-white/60",children:"Цвет текста"}),(0,n.jsx)(r.$,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>y(null),children:(0,n.jsx)(a.A,{name:"X",size:10})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"flex gap-1.5",children:["#FFFFFF","#000000","#FFD700","#C0C0C0","#8B4513","#4A4A4A"].map(e=>(0,n.jsx)("button",{onClick:()=>{m&&x&&(x(m.id,{color:e}),y(null))},className:`w-7 h-7 rounded-lg border-2 flex-shrink-0 ${m.color===e?"border-primary ring-2 ring-primary/20":"border-border"}`,style:{backgroundColor:e}},e))}),(0,n.jsx)("input",{type:"color",value:m?.color||"#FFFFFF",onChange:e=>{m&&x&&x(m.id,{color:e.target.value})},className:"w-8 h-7 rounded border flex-shrink-0"})]})]}),z&&"align"===w&&(0,n.jsxs)("div",{className:"constructor-panel fixed left-0 right-0 bg-[#1a1a1a] backdrop-blur-sm border-t border-white/10 px-3 py-1.5 z-[76]",style:{bottom:C},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,n.jsx)("span",{className:"text-[10px] text-white/60",children:"Выравнивание"}),(0,n.jsx)(r.$,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>y(null),children:(0,n.jsx)(a.A,{name:"X",size:10})})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(r.$,{variant:m?.textAlign==="left"?"default":"outline",onClick:()=>{m&&x&&(x(m.id,{textAlign:"left"}),y(null))},className:"flex-1 h-8",children:(0,n.jsx)(a.A,{name:"AlignLeft",size:16})}),(0,n.jsx)(r.$,{variant:m?.textAlign!=="center"&&m?.textAlign?"outline":"default",onClick:()=>{m&&x&&(x(m.id,{textAlign:"center"}),y(null))},className:"flex-1 h-8",children:(0,n.jsx)(a.A,{name:"AlignCenter",size:16})}),(0,n.jsx)(r.$,{variant:m?.textAlign==="right"?"default":"outline",onClick:()=>{m&&x&&(x(m.id,{textAlign:"right"}),y(null))},className:"flex-1 h-8",children:(0,n.jsx)(a.A,{name:"AlignRight",size:16})})]})]}),"rotate"===w&&(0,n.jsxs)("div",{className:"constructor-panel fixed left-0 right-0 bg-[#1a1a1a] backdrop-blur-sm border-t border-white/10 px-3 py-1.5 z-[76]",style:{bottom:C},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,n.jsx)("span",{className:"text-[10px] text-white/60",children:"Поворот"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("span",{className:"text-sm font-bold text-white",children:[m.rotation||0,"\xb0"]}),(0,n.jsx)(r.$,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>y(null),children:(0,n.jsx)(a.A,{name:"X",size:10})})]})]}),(0,n.jsx)("div",{className:"slider-wrapper-mobile",children:(0,n.jsxs)("div",{className:"track-mobile",children:[(0,n.jsx)("input",{type:"range",min:"-180",max:"180",value:m?.rotation||0,onChange:e=>{if(m&&x){let t=parseInt(e.target.value);x(m.id,{rotation:t}),N(t.toString())}}
8,className:"rotation-slider-mobile"}),(0,n.jsx)("div",{className:"ticks-mobile",style:{transform:`translateX(calc(-50% - ${1.333*(m.rotation||0)}px))`},children:Array.from({length:361},(e,t)=>{let i=t-180;return(0,n.jsx)("div",{className:`tick-mobile ${i%45==0?"big":""}`},t)})})]})})]}),$&&"imageSize"===w&&(0,n.jsxs)("div",{className:"constructor-panel fixed left-0 right-0 bg-[#1a1a1a] backdrop-blur-sm border-t border-white/10 px-3 py-1.5 z-[76]",style:{bottom:C},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,n.jsx)("span",{className:"text-[10px] text-white/60",children:"Размер изображения"}),(0,n.jsx)(r.$,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>y(null),children:(0,n.jsx)(a.A,{name:"X",size:10})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("label",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:["Ширина: ",m?.width||100,"px"]}),(0,n.jsx)("input",{type:"range",min:"50",max:"400",value:m?.width||100,onChange:e=>{if(m&&x){let t=parseInt(e.target.value),i=m.height/m.width;x(m.id,{width:t,height:Math.round(t*i)})}},className:"w-full"})]})]}),(0,n.jsx)("div",{className:`fixed inset-x-0 bg-black/90 backdrop-blur-sm border-t border-white/10 px-2 z-[75] lg:hidden ${M?"h-12 py-0":"py-0.5 pb-[max(2px,env(safe-area-inset-bottom))]"}`,style:{bottom:k},children:(0,n.jsxs)("div",{className:`flex items-center justify-around gap-0.5 h-full ${M?"":"pr-14"}`,children:[M&&f&&(0,n.jsxs)("button",{type:"button",onClick:()=>{y(null),f()},className:"flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors text-primary",children:[(0,n.jsx)(a.A,{name:"Check",size:16}),(0,n.jsx)("span",{className:"text-[9px]",children:"Готово"})]}),z&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{onClick:()=>F("fonts"),className:`flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors ${"fonts"===w?"text-primary":"text-white/70"}`,children:[(0,n.jsx)(a.A,{name:"Type",size:16}),(0,n.jsx)("span",{className:"text-[9px]",children:"Шрифт"})]}),(0,n.jsxs)("button",{onClick:()=>F("size"),className:`flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors ${"size"===w?"text-primary":"text-white/70"}`,children:[(0,n.jsx)("span",{className:"text-sm font-bold leading-4",children:"Aa"}),(0,n.jsx)("span",{className:"text-[9px]",children:"Размер"})]}),(0,n.jsxs)("button",{onClick:()=>F("color"),className:`flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors ${"color"===w?"text-primary":"text-white/70"}`,children:[(0,n.jsx)("div",{className:"w-4 h-4 rounded-full border-2 border-current",style:{backgroundColor:m.color||"#FFFFFF"}}),(0,n.jsx)("span",{className:"text-[9px]",children:"Цвет"})]}),(0,n.jsxs)("button",{onClick:()=>F("align"),className:`flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors ${"align"===w?"text-primary":"text-white/70"}`,children:[(0,n.jsx)(a.A,{name:"AlignCenter",size:16}),(0,n.jsx)("span",{className:"text-[9px]",children:"Выравн."})]})]}),$&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),console.log("\uD83D\uDDB1️\uD83D\uDDB1️\uD83D\uDDB1️ КЛИК НА ЛАСТИК!!! \uD83D\uDDB1️\uD83D\uDDB1️\uD83D\uDDB1️"),console.log("selectedEl:",m),console.log("selectedEl?.id:",m?.id),console.log("selectedEl?.src:",m?.src),console.log("onOpenEraser функция:",typeof d),d?(console.log("✅ Вызываем onOpenEraser"),d()):console.error("❌ onOpenEraser отсутствует!")},className:"flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors text-red-400",children:[(0,n.jsx)(a.A,{name:"Eraser",size:16}),(0,n.jsx)("span",{className:"text-[9px]",children:"Ластик"})]}),(0,n.jsxs)("button",{onClick:()=>x?.(m.id,{flipHorizontal:!m.flipHorizontal}),className:`flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors ${m.flipHorizontal?"text-primary":"text-white/70"}`,children:[(0,n.jsx)(a.A,{name:"FlipHorizontal",size:16}),(0,n.jsx)("span",{className:"text-[9px]",children:"Зеркало"})]}),(0,n.jsxs)("button",{onClick:()=>F("imageSize"),className:`flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors ${"imageSize"===w?"text-primary":"text-white/70"}`,children:[(0,n.jsx)(a.A,{name:"Scaling",size:16}),(0,n.jsx)("span",{className:"text-[9px]",children:"Размер"})]}),(0,n.jsxs)("button",{disabled:b,onClick:async()=>{m&&x&&(v(!0),await x(m.id,{screenMode:!m.screenMode}),v(!1))},className:`flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors ${m.screenMode?"text-primary":"text-white/70"} ${b?"opacity-50":""}`,children:[(0,n.jsx)(a.A,{name:b?"Loader2":"Layers",size:16,className:b?"animate-spin":""}),(0,n.jsx)("span",{className:"text-[9px]",children:"Экран"})]})]}),(0,n.jsxs)("button",{onClick:()=>F("rotate"),className:`flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors ${"rotate"===w?"text-primary":"text-white/70"}`,children:[(0,n.jsx)(a.A,{name:"RotateCw",size:16}),(0,n.jsx)("span",{className:"text-[9px]",children:"Поворот"})]}),(0,n.jsxs)("button",{onClick:()=>{u&&confirm("Удалить этот элемент?")&&(u(m.id),y(null))},className:"flex flex-col items-center gap-0 px-2 py-1 rounded-lg transition-colors text-white/70 hover:text-red-400",children:[(0,n.jsx)(a.A,{name:"Trash2",size:16}),(0,n.jsx)("span",{className:"text-[9px]",children:"Удалить"})]})]})})]})},tc=[{key:"_catalog",icon:"Milestone",label:"Каталог\nпамятников"},{key:"monumentSize",icon:"Ruler",label:"Размер\nпамятника"},{key:"fio",icon:"User",label:"ФИО\nи даты"},{key:"photo",icon:"UserRound",label:"Портрет"},{key:"text",icon:"Type",label:"Текст"},{key:"imageCatalog",icon:"Images",label:"Картинки"},{key:"cross",icon:"Cross",label:"Крест"},{key:"epitaph",icon:"Quote",label:"Эпитафия"}],td=[{key:"_catalog",icon:"Milestone",label:"Каталог"},{key:"photo",icon:"UserRound",label:"Портрет"},{key:"text",icon:"Type",label:"Текст"},{key:"cross",icon:"Cross",label:"Крест"},{key:"more",icon:"MoreHorizontal",label:"Ещё"}],th=[{key:"monumentSize",icon:"Ruler",label:"Размер\nпамятника"},{key:"fio",icon:"User",label:"ФИО\nи даты"},{key:"imageCatalog",icon:"Images",label:"Картинки"},{key:"epitaph",icon:"Quote",label:"Эпитафия"}],tm=({addTextElement:e,addEpitaphElement:t,addFIOElement:i,addDatesElement:s,applyInscriptionTemplate:o,handlePhotoUpload:c,photoInputRef:h,surname:m,setSurname:w,name:y,setName:b,patronymic:N,setPatronymic:M,selectedFont:S,setSelectedFont:k,birthDate:C,setBirthDate:z,deathDate:$,setDeathDate:F,selectedDateFont:P,setSelectedDateFont:E,fonts:I,crosses:H,isLoadingCrosses:A,flowers:R,isLoadingFlowers:W,addImageElement:T,monumentImage:D,setMonumentImage:L,catalogCategories:_,catalogProducts:X,selectedCategory:B,setSelectedCategory:Y,isLoadingCatalog:U,loadCatalog:O,uxMode:J="legacy",hasSelection:G=!1,onClearSelection:V,registerCloseHandler:q,monumentWidthMm:K=500,monumentHeightMm:Z=1e3,onMonumentSizeChange:Q,scenePedestal:ea=!0,onScenePedestalChange:el,sceneFlowerbed:es=!1,onSceneFlowerbedChange:eo,canToggleFlowerbed:ec=!0,sceneVaseLeft:ed=!1,sceneVaseRight:eh=!1,onSceneVaseLeftChange:em,onSceneVaseRightChange:ex,sceneVaseVariant:eu="black",onSceneVaseVariantChange:ep,sceneLampLeft:eg=!1,sceneLampRight:ef=!1,onSceneLampLeftChange:ew,onSceneLampRightChange:ey,canToggleSceneProps:eb=!0})=>{let ev,ej,eN,eM,eS,ek,eC,e$,eI,eH,eA,eR,eT,eD=(e,t)=>{let i=e.replace(/\D/g,"");return i.length<=2?i:i.length<=4?`${i.slice(0,2)}.${i.slice(2)}`:`${i.slice(0,2)}.${i.slice(2,4)}.${i.slice(4,8)}`},[eL,e_]=(0,l.useState)(null),[eX,eB]=(0,l.useState)("inline"),[eY,eU]=(0,l.useState)(""),[eO,eJ]=(0,l.useState)(""),[eG,eV]=(0,l.useState)([]),[eq,eK]=(0,l.useState)([]),[eZ,eQ]=(0,l.useState)(null),[e0,e1]=(0,l.useState)(!1),e2=(0,l.useRef)(null),e5=(0,l.useRef)(null),[e4,e3]=(0,l.useState)(!1),e8=async e=>{let t=e.target.files?.[0];if(e.target&&(e.target.value=""),e5.current&&(e5.current.value=""),t){e3(!0);try{let e=await x(t);if(!e)return;await Promise.resolve(T(e,"image")),tg()}catch(e){console.error("Ошибка загрузки изображения",e)}finally{e3(!1)}}},e6=async e=>{e3(!0);try{await Promise.resolve(c(e)),tg()}catch{}finally{e3(!1),e2.current&&(e2.current.value="")}},[e9,e7]=(0,l.useState)(()=>window.innerWidth<1024);(0,l.useEffect)(()=>{let e=()=>e7(window.innerWidth<1024);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,l.useEffect)(()=>{(async()=>{try{let e=await fetch((0,d.xp)({type:"categories"}));if(!e.ok)return;let t=await e.json();if(eV(t),t.length>0){eQ(t[0].id),e1(!0);let e=await Promise.all(t.map(async e=>{let t=await fetch((0,d.xp)({type:"images",category_id:e.id}));return t.ok?t.json():[]}));eK(e.flat()),e1(!1)}}catch(e){console.error(e)}})()},[]);let[te,tt]=(0,l.useState)(65),ti=(0,l.useRef)(null),tn=(0,l.useRef)(65),tr="bottom-tabs"===J,ta=ts(tl()),to=tr?`calc(56px + env(safe-area-inset-bottom, 0px) + ${ta})`:ta,tm=tr?`min(92dvh, calc(100dvh - 48px - 56px - env(safe-area-inset-bottom, 0px) - ${ta}))`:`min(92dvh, calc(100dvh - 48px - ${ta}))`,[tx,tu]=(0,l.useState)(!1);(0,l.useEffect)(()=>{tu(!0)},[]);let tp=e=>{G&&V&&V(),"_catalog"===e&&O(),e_(t=>(t!==e&&tt(65),t===e?null:e))},tg=()=>{e_(null),tt(65)};(0,l.useEffect)(()=>
8{if(q)return q(()=>!!eL&&(tg(),!0)),()=>q(null)},[eL,q]),(0,l.useEffect)(()=>{tr&&G&&(e_(null),tt(65))},[tr,G]);let tf=!!(m||y||N),tw=!!(C||$),ty=(e,t=18)=>{if("_catalog"===e)return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 80 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flexShrink:0},children:[(0,n.jsx)("rect",{x:"0",y:"88",width:"80",height:"12",rx:"1",fill:"currentColor"}),(0,n.jsx)("rect",{x:"8",y:"78",width:"64",height:"12",rx:"1",fill:"currentColor"}),(0,n.jsx)("path",{d:"M20 78 L20 30 Q20 6 40 6 Q60 6 60 30 L60 78 Z",fill:"currentColor"})]});if("cross"===e)return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 90 160",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flexShrink:0},children:[(0,n.jsx)("rect",{x:"38",y:"0",width:"14",height:"160",fill:"currentColor"}),(0,n.jsx)("rect",{x:"28",y:"8",width:"34",height:"14",fill:"currentColor"}),(0,n.jsx)("rect",{x:"0",y:"44",width:"90",height:"14",fill:"currentColor"}),(0,n.jsx)("polygon",{points:"10,98 10,112 38,118 38,106",fill:"currentColor"}),(0,n.jsx)("polygon",{points:"52,106 52,118 80,112 80,98",fill:"currentColor"})]});if("monumentSize"===e)return(0,n.jsx)(a.A,{name:"Ruler",size:t});let i=[...tc,...td,...th].find(t=>t.key===e);return(0,n.jsx)(a.A,{name:i?.icon||"Circle",size:t})};if(!e9)return null;let tb="more"===eL?null:eL,tv=tr?(0,n.jsx)("div",{"data-constructor-tabbar":"true",className:"lg:hidden fixed inset-x-0 z-[80] bg-[#1a1a1a] border-t border-white/10",style:{bottom:ta,paddingBottom:"max(0px, env(safe-area-inset-bottom))"},children:(0,n.jsx)("div",{className:"flex items-stretch justify-around h-14",children:td.map(e=>{let t=eL===e.key||"more"===e.key&&("fio"===eL||"imageCatalog"===eL||"epitaph"===eL||"more"===eL||"monumentSize"===eL);return(0,n.jsxs)("button",{type:"button",onClick:()=>tp(e.key),className:`flex-1 min-h-[44px] min-w-[44px] flex flex-col items-center justify-center gap-0.5 transition-colors ${t?"text-primary":"text-white/55"}`,children:[ty(e.key,20),(0,n.jsx)("span",{className:"text-[10px] leading-none",children:e.label})]},e.key||"more")})})}):null,tj=tv&&tx?(0,eW.createPortal)(tv,document.body):tv;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{ref:e2,id:"mobile-portrait-upload",type:"file",accept:"image/*,image/jpeg,image/png,image/webp",onChange:e=>{e6(e)},className:"fixed opacity-0 pointer-events-none",style:{width:1,height:1,left:-9999,top:0},tabIndex:-1}),(0,n.jsx)("input",{ref:e5,id:"mobile-custom-image-upload",type:"file",accept:"image/*,image/jpeg,image/png,image/webp",onChange:e=>{e8(e)},className:"fixed opacity-0 pointer-events-none",style:{width:1,height:1,left:-9999,top:0},tabIndex:-1}),!tr&&(0,n.jsx)("div",{className:"lg:hidden fixed left-0 z-40 flex flex-col items-center gap-1 pt-4 pb-2 bg-[#1a1a1a] border-r border-white/10 shadow-lg",style:{top:"48px",bottom:ta,width:"48px"},children:tc.map((e,t)=>(0,n.jsxs)(l.Fragment,{children:[(0,n.jsxs)("button",{onClick:()=>tp(e.key),className:`w-10 h-10 flex flex-col items-center justify-center rounded transition-colors gap-0.5 ${eL===e.key?"bg-primary text-primary-foreground":"text-white/50 hover:text-white hover:bg-white/10"}`,title:e.label,children:[ty(e.key,18),(0,n.jsx)("span",{className:"text-[7px] leading-tight text-center whitespace-pre-wrap",children:e.label})]}),0===t&&(0,n.jsx)("div",{className:"w-8 border-t border-white/10 my-0.5"})]},e.key))}),tj,(tb||"more"===eL)&&(0,n.jsx)("div",{className:"lg:hidden fixed inset-0 z-40 bg-black/40",style:{top:"48px",bottom:to},onClick:tg}),tr&&"more"===eL&&(0,n.jsxs)("div",{className:"lg:hidden fixed left-0 right-0 z-[70] bg-[#1e1e1e] border-t border-white/10 rounded-t-2xl shadow-2xl flex flex-col",style:{bottom:to,maxHeight:tm},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 pt-3 pb-1 shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"Ещё"}),(0,n.jsx)("button",{type:"button",onClick:tg,className:"min-h-[44px] min-w-[44px] flex items-center justify-center text-white/40 hover:text-white",children:(0,n.jsx)(a.A,{name:"X",size:16})})]}),(0,n.jsxs)("div",{className:"overflow-y-auto overscroll-contain px-3 pb-3 scrollbar-site",children:[(0,n.jsx)("div",{className:"grid grid-cols-2 gap-2",children:th.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>tp(e.key),className:"min-h-[64px] flex flex-col items-center justify-center gap-1 rounded-xl bg-white/5 text-white/80 hover:bg-white/10 px-2",children:[ty(e.ke
8y,22),(0,n.jsx)("span",{className:"text-[11px] text-center whitespace-pre-wrap leading-tight",children:e.label}),"monumentSize"===e.key&&(0,n.jsx)("span",{className:"text-[10px] text-white/45",children:j(K,Z)?.label??v(K,Z)})]},e.key))}),el&&(0,n.jsx)("div",{className:"mt-3 rounded-xl border border-white/10 bg-white/[0.03] p-2.5 space-y-1.5",children:(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"text-sm font-medium text-white",children:"Подставка"}),(0,n.jsx)("p",{className:"text-[11px] text-white/45 leading-snug",children:"Выкл. — стела крупнее на экране"})]}),(0,n.jsx)("button",{type:"button",role:"switch","aria-checked":ea,onClick:()=>el(!ea),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${ea?"bg-primary":"bg-white/15"}`,children:(0,n.jsx)("span",{className:`absolute top-0.5 left-0.5 h-6 w-6 rounded-full bg-white shadow transition-transform ${ea?"translate-x-5":"translate-x-0"}`})})]})}),eo&&(0,n.jsxs)("div",{className:"mt-3 rounded-xl border border-white/10 bg-white/[0.03] p-2.5 space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"text-sm font-medium text-white",children:"Цветник"}),(0,n.jsx)("p",{className:"text-[11px] text-white/45 leading-snug",children:"Рамка с засыпкой перед подставкой"})]}),(0,n.jsx)("button",{type:"button",role:"switch","aria-checked":es,disabled:!ec,onClick:()=>eo(!es),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors disabled:opacity-40 disabled:pointer-events-none ${es?"bg-primary":"bg-white/15"}`,children:(0,n.jsx)("span",{className:`absolute top-0.5 left-0.5 h-6 w-6 rounded-full bg-white shadow transition-transform ${es?"translate-x-5":"translate-x-0"}`})})]}),!ec&&(0,n.jsx)("p",{className:"text-[10px] text-amber-400/80 leading-snug",children:"Нужна подставка и стандартная сцена (без своего фона)."})]}),(em||ex)&&(0,n.jsxs)("div",{className:"mt-3 rounded-xl border border-white/10 bg-white/[0.03] p-2.5 space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"text-sm font-medium text-white",children:"Ваза"}),(0,n.jsx)("p",{className:"text-[11px] text-white/45 leading-snug",children:"Слева / справа от подставки"})]}),(0,n.jsxs)("div",{className:"flex gap-1.5 shrink-0",children:[(0,n.jsx)("button",{type:"button",disabled:!eb||!em,onClick:()=>em?.(!ed),className:`min-h-[40px] min-w-[56px] rounded-lg border px-2 text-xs transition-colors disabled:opacity-40 disabled:pointer-events-none ${ed?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/70"}`,children:"Л"}),(0,n.jsx)("button",{type:"button",disabled:!eb||!ex,onClick:()=>ex?.(!eh),className:`min-h-[40px] min-w-[56px] rounded-lg border px-2 text-xs transition-colors disabled:opacity-40 disabled:pointer-events-none ${eh?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/70"}`,children:"П"})]})]}),ep&&(0,n.jsx)("div",{className:"flex gap-1.5 overflow-x-auto pb-0.5 -mx-0.5 px-0.5",children:[{variant:"black",config:ee},{variant:"red",config:et},{variant:"gray",config:ei},{variant:"silver",config:en},{variant:"white",config:er}].map(({variant:e,config:t})=>(0,n.jsx)(eF,{config:t,selected:eu===e,onSelect:()=>ep(e),className:"h-14 w-14 shrink-0 flex-none"},e))}),!eb&&(0,n.jsx)("p",{className:"text-[10px] text-amber-400/80 leading-snug",children:"Недоступно при своём фоне сцены."})]}),(ew||ey)&&(0,n.jsxs)("div",{className:"mt-3 rounded-xl border border-white/10 bg-white/[0.03] p-2.5 space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"text-sm font-medium text-white",children:"Лампада"}),(0,n.jsx)("p",{className:"text-[11px] text-white/45 leading-snug",children:"Слева / справа от подставки"})]}),(0,n.jsxs)("div",{className:"flex gap-1.5 shrink-0",children:[(0,n.jsx)("button",{type:"button",disabled:!eb||!ew,onClick:()=>ew?.(!eg),className:`min-h-[40px] min-w-[56px] rounded-lg border px-2 text-xs transition-colors disabled:opacity-40 disabled:pointer-events-none ${eg?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/70"}`,children:"Л"}),(0,n.jsx)("button",{type:"button",disabled:!eb||!ey,onClick:()=>ey?.(!ef),className:`min-h-[40px] min-w-[56px] rounded-lg border px-2 text-xs transition-colors disabled:opacity-40 disabled:pointer-events-none ${ef?"border-primary bg-primary/15 text-primary":"border-white/10 text-white/70"}`,children:"П"})]})]}),!eb&&(0,n.jsx)("p",{className:"text-[10px] text-amber-400/80 leading-snug",children:"Недоступно при своём фоне сцены."})]})]})]}),tb&&(0,n.jsxs)("div",{className:"lg:hidden fixed left-0 right-0 z-[70] bg-[#1e1e1e] border-t border-white/10 rounded-t-2xl shadow-2xl flex flex-col",style:{bottom:to,height:`${te}vh`,maxHeight:tm,transition:null!==ti.current?"none":"height 0.25s ease"},children:[(0,n.jsx)("div",{className:"flex items-center justify-center pt-3 pb-1 touch-none cursor-grab active:cursor-grabbing",onTouchStart:e=>{ti.current=e.touches[0].clientY,tn.current=te},onTouchMove:e=>{if(null===ti.current)return;let t=ti.current-e.touches[0].clientY;tt(Math.min(tr?85:92,Math.max(25,tn.current+t/window.innerHeight*100)))},onTouchEnd:()=>{ti.current=null,tt(e=>e<35?(tg(),65):e<55?40:e<75?65:tr?82:90)},children:(0,n.jsx)("div",{className:"w-12 h-1.5 rounded-full bg-white/30"})}),"_catalog"===eL&&(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"Каталог памятников"}),(0,n.jsx)("button",{onClick:tg,className:"text-white/40 hover:text-white",children:(0,n.jsx)(a.A,{name:"X",size:16})})]}),U?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):_.length>0?(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-4",children:[(0,n.jsx)("div",{className:"flex flex-wrap gap-1 shrink-0 mb-3 bg-white/5 rounded-lg p-1",children:_.map(e=>{let t=X.filter(t=>t.category_id===e.id&&(0,eP.me)(t)).length;return(0,n.jsxs)("button",{onClick:()=>Y(e.id),className:`flex-1 min-w-[80px] px-2 py-1.5 rounded text-xs font-medium transition-all flex items-center justify-center gap-1 ${B===e.id?"bg-primary text-primary-foreground":"text-white/50 hover:text-white hover:bg-white/10"}`,children:[(0,n.jsx)("span",{className:"truncate",children:e.name}),(0,n.jsx)(g.E,{variant:"secondary",className:"ml-1 h-4 text-[10px] px-1 shrink-0",children:t})]},e.id)})}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto scrollbar-site min-h-0",children:(ev=X.filter(e=>e.category_id===B&&(0,eP.me)(e))).length>0?(0,n.jsx)("div",{className:"grid grid-cols-2 gap-2 pb-2",children:ev.map(e=>{let t=(0,eP.me)(e);return(0,n.jsxs)("button",{onClick:()=>{L(t),tg()},className:`relative aspect-[3/4] rounded-lg overflow-hidden border-2 transition-all bg-black/40 ${D===t?"border-primary ring-2 ring-primary/20":"border-white/10 hover:border-primary/50"}`,children:[(0,n.jsx)("img",{src:t,alt:e.name,className:"w-full h-full object-contain p-2"}),(0,n.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/90 to-transparent text-white text-xs p-2 text-center",children:(0,n.jsx)("div",{className:"font-medium",children:e.name})}),D===t&&(0,n.jsx)("div",{className:"absolute top-2 right-2 bg-primary rounded-full p-1",children:(0,n.jsx)(a.A,{name:"Check",size:12,className:"text-primary-foreground"})})]},e.id)})}):(0,n.jsx)("div",{className:"text-center py-8 text-white/30",children:(0,n.jsx)("p",{className:"text-sm",children:"Нет памятников в этой категории"})})})]}):(0,n.jsxs)("div",{className:"text-center py-12 text-white/30 px-3",children:[(0,n.jsx)(a.A,{name:"Package",size:48,className:"mx-auto mb-4 opacity-20"}),(0,n.jsx)("p",{className:"text-sm font-medium",children:"Каталог пуст"})]})]}),"monumentSize"===eL&&(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"Размер памятника"}),(0,n.jsxs)("p",{className:"text-[11px] text-white/45 mt-0.5",children:["Сейчас: ",j(K,Z)?.label??v(K,Z)]})]}),(0,n.jsx)("button",{type:"button",onClick:tg,className:"text-white/40 hover:text-white min-h-[44px] min-w-[44px] flex items-center justify-center",children:(0,n.jsx)(a.A,{name:"X",size:16})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto scrollbar-site px-4 pb-5 space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-[11px] uppercase tracking-wider text-white/40 mb-2",children:"Выберите размер"}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-2",children:f.map(e=>{let t=j(K,Z)?.id===e.id;return(0,n.jsxs)("button",{type:"button",onClick:()=>{Q?.(e.widthMm,e.heightMm)},className:`min-h-[72px] rounded-xl border px-3 py-3 text-left transition-colors ${t?"border-primary bg-primary/20 text-white":"border-white/10 bg-white/5 text-white/80 hover:bg-white/10"}`,children:[(0,n.jsx)("span",{className:"block text-base font-semibold leading-tight",children:e.label}),(0,n.jsx)("span",{className:"block text-[11px] text-white/45 mt-1",children:v(e.widthMm,e.heightMm)})]},e.id)})})]}),(0,n.jsxs)("div",{className:"rounded-xl border border-white/10 bg-white/[0.03] p-3 space-y-3",children:[(0,n.jsx)("p",{className:"text-[11px] uppercase tracking-wider text-white/40",children:"Свой размер"}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Ширина, мм"}),(0,n.jsx)(u.p,{type:"number",inputMode:"numeric",min:100,max:5e3,value:K,onChange:e=>{let t=Number(e.target.value);t>0&&Q?.(t,Z)},className:"mt-1 h-11 bg-[#1e1e1e] border-white/10 text-white text-base"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(p.J,{className:"text-xs text-white/60",children:"Высота, мм"}),(0,n.jsx)(u.p,{type:"number",inputMode:"numeric",min:100,max:5e3,value:Z,onChange:e=>{let t=Number(e.target.value);t>0&&Q?.(K,t)},className:"mt-1 h-11 bg-[#1e1e1e] border-white/10 text-white text-base"})]})]})]}),(0,n.jsx)("p",{className:"text-[11px] text-white/35 leading-relaxed",children:"Размер меняет габариты стелы на сцене и подписи \xabмм\xbb. Типовые размеры подставляют подходящую подставку."})]})]}),"fio"===eL&&(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"ФИО и даты"}),(0,n.jsx)("button",{onClick:tg,className:"text-white/40 hover:text-white",children:(0,n.jsx)(a.A,{name:"X",size:16})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto scrollbar-site px-4 pb-2 space-y-4 min-h-0",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>{o(),tg()},className:"w-full rounded-lg border border-primary/40 bg-primary/10 p-3 text-left transition-colors hover:bg-primary/15",children:[(0,n.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-primary",children:"Готовый шаблон"}),(0,n.jsx)("span",{className:"mt-1 flex flex-col items-center text-center leading-[1.05]",children:ez().split("\n").map((e,t)=>(0,n.jsx)("span",{className:3===t?"text-xs text-white/80":"text-sm text-white",children:e},t))})]}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("p",{className:"text-xs text-white/50",children:"ФИО"}),(0,n.jsx)("div",{className:"rounded-lg bg-black/40 border border-white/20 flex flex-col items-center justify-center py-3 px-4 min-h-[64px]",children:(ej=I.find(e=>
8e.id===S),((eN=[m,y,N].filter(Boolean)).length>0?eN:["Фамилия","Имя","Отчество"]).map((e,t)=>(0,n.jsx)("span",{className:"text-white text-base text-center leading-tight",style:{fontFamily:ej?.style,fontWeight:ej?.weight,opacity:0===eN.length?.3:1},children:e},t)))}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(u.p,{placeholder:"Фамилия",value:m,onChange:e=>w(e.target.value),className:"bg-white/5 border-white/10 text-white placeholder:text-white/30"}),(0,n.jsx)(u.p,{placeholder:"Имя",value:y,onChange:e=>b(e.target.value),className:"bg-white/5 border-white/10 text-white placeholder:text-white/30"}),(0,n.jsx)(u.p,{placeholder:"Отчество",value:N,onChange:e=>M(e.target.value),className:"bg-white/5 border-white/10 text-white placeholder:text-white/30"})]}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/50",children:"Шрифт ФИО"}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-1.5",children:I.map(e=>(0,n.jsxs)("button",{onClick:()=>k(e.id),className:`px-2 py-1.5 rounded border text-left transition-all ${S===e.id?"border-primary bg-primary/10 text-primary":"border-white/10 hover:border-primary/50 text-white/70"}`,children:[(0,n.jsx)("div",{className:"text-[9px] text-white/40 truncate",children:e.name}),(0,n.jsx)("div",{className:"text-xs truncate",style:{fontFamily:e.style,fontWeight:e.weight},children:e.example.slice(0,8)})]},e.id))})]})]}),(0,n.jsxs)("div",{className:"border-t border-white/10 pt-4 space-y-3",children:[(0,n.jsx)("p",{className:"text-xs text-white/50",children:"Даты жизни"}),(0,n.jsx)("div",{className:"rounded-lg bg-black/40 border border-white/20 flex items-center justify-center py-3 px-4 min-h-[64px]",children:(eM=I.find(e=>e.id===P),eS=C||"15.03.1950",ek=$||"07.11.2024",eC=!C&&!$,e$="inline"===eX?`${eS} – ${ek}`:"stacked"===eX?`${eS}
9${ek}`:`${eS}
10      ${ek}`,eI="offset"===eX?"left":"center",(0,n.jsx)("span",{className:"text-white text-base whitespace-pre",style:{fontFamily:eM?.style,fontWeight:eM?.weight,opacity:eC?.3:1,lineHeight:1.3,textAlign:eI,display:"block"},children:e$}))}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/50",children:"Дата рождения"}),(0,n.jsx)(u.p,{placeholder:"01.01.1950",value:C,onChange:e=>z(eD(e.target.value,C)),inputMode:"numeric",maxLength:10,className:"bg-white/5 border-white/10 text-white placeholder:text-white/30"})]}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/50",children:"Дата смерти"}),(0,n.jsx)(u.p,{placeholder:"01.01.2024",value:$,onChange:e=>F(eD(e.target.value,$)),inputMode:"numeric",maxLength:10,className:"bg-white/5 border-white/10 text-white placeholder:text-white/30"})]})]}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/50",children:"Шрифт дат"}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-1.5",children:I.map(e=>(0,n.jsxs)("button",{onClick:()=>E(e.id),className:`px-2 py-1.5 rounded border text-left transition-all ${P===e.id?"border-primary bg-primary/10 text-primary":"border-white/10 hover:border-primary/50 text-white/70"}`,children:[(0,n.jsx)("div",{className:"text-[9px] text-white/40 truncate",children:e.name}),(0,n.jsx)("div",{className:"text-xs truncate",style:{fontFamily:e.style,fontWeight:e.weight},children:"1950–2024"})]},e.id))})]}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/50",children:"Расположение"}),(eH=I.find(e=>e.id===P),eA=C||"15.03.1950",eR=$||"07.11.2024",eT=[{key:"inline",label:"В строку",preview:`${eA} – ${eR}`,align:"center"},{key:"stacked",label:"Столбцом",preview:`${eA}
11${eR}`,align:"center"},{key:"offset",label:"Со сдвигом",preview:`${eA}
12      ${eR}`,align:"left"}],(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2",children:eT.map(e=>{let t=eX===e.key;return(0,n.jsxs)("button",{onClick:()=>eB(e.key),className:`flex flex-col items-center gap-1.5 p-2 rounded border transition-all ${t?"border-primary bg-primary/15 ring-1 ring-primary":"border-white/10 hover:border-primary/60 hover:bg-primary/10"}`,children:[(0,n.jsx)("div",{className:`rounded w-full flex items-center justify-center py-2 px-1 min-h-[40px] ${t?"bg-black/60":"bg-black/50"}`,children:(0,n.jsx)("span",{className:`text-white leading-tight whitespace-pre ${"inline"===e.key?"whitespace-nowrap":"whitespace-pre"}`,style:{fontFamily:eH?.style,fontWeight:eH?.weight,fontSize:"inline"===e.key?"6px":"9px",textAlign:e.align,display:"block",width:"100%",lineHeight:1.3},children:e.preview})}),(0,n.jsx)("span",{className:`text-[10px] text-center leading-tight ${t?"text-primary":"text-white/50"}`,children:e.label})]},e.key)})}))]})]})]}),(0,n.jsx)("div",{className:"px-4 pb-4 flex-shrink-0",children:(0,n.jsxs)(r.$,{className:"w-full",onClick:()=>{tf&&i(),tw&&s(eX),tg()},disabled:!tf&&!tw,children:[(0,n.jsx)(a.A,{name:"Plus",size:16,className:"mr-2"}),tf&&tw?"Добавить ФИО и даты":tf?"Добавить ФИО":"Добавить даты"]})})]}),"epitaph"===eL&&(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"Эпитафия"}),(0,n.jsx)("p",{className:"text-xs text-white/40",children:"Выберите готовый текст или добавьте свой"})]}),(0,n.jsx)("button",{onClick:tg,className:"text-white/40 hover:text-white",children:(0,n.jsx)(a.A,{name:"X",size:16})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto scrollbar-site px-4 pb-4 space-y-3",children:[eE.map(e=>(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-white/40",children:e.title}),e.items.map((i,r)=>(0,n.jsx)("button",{onClick:()=>{t(i),tg()},className:"w-full text-left px-3 py-2.5 rounded-lg border border-white/10 hover:border-primary/50 hover:bg-primary/5 transition-all",children:(0,n.jsx)("p",{className:"text-sm italic text-white/70 whitespace-pre-line",children:i})},`${e.title}-${r}`))]},e.title)),(0,n.jsxs)(r.$,{variant:"outline",className:"w-full border-white/20 text-white hover:bg-white/10",onClick:()=>{t(),tg()},children:[(0,n.jsx)(a.A,{name:"Edit3",size:16,className:"mr-2"}),"Написать свою эпитафию"]})]})]}),"text"===eL&&(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"Свободный текст"}),(0,n.jsx)("button",{onClick:tg,className:"text-white/40 hover:text-white",children:(0,n.jsx)(a.A,{name:"X",size:16})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto scrollbar-site px-4 pt-1 pb-2 space-y-3 min-h-0",children:[(0,n.jsx)("textarea",{placeholder:"Введите текст...",value:eY,onChange:e=>eU(e.target.value),rows:3,className:"w-full bg-white/5 border border-white/10 rounded text-white placeholder:text-white/30 text-sm p-2 resize-none focus:outline-none focus:border-primary"}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(p.J,{className:"text-xs text-white/50",children:"Шрифт"}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-1.5",children:I.map(e=>(0,n.jsxs)("button",{onClick:()=>eJ(e.fullStyle),className:`px-2 py-1.5 rounded border text-left transition-all ${eO===e.fullStyle?"border-primary bg-primary/10 text-primary":"border-white/10 hover:border-primary/50 text-white/70"}`,children:[(0,n.jsx)("div",{className:"text-[9px] text-white/40 truncate",children:e.name}),(0,n.jsx)("div",{className:"text-xs truncate",style:{fontFamily:e.style,fontWeight:e.weight},children:e.example.slice(0,8)})]},e.id))})]})]}),(0,n.jsx)("div",{className:"px-4 pb-4 flex-shrink-0",children:(0,n.jsxs)(r.$,{className:"w-full",onClick:()=>{e(eY||void 0,eO||void 0),eU(""),tg()},children:[(0,n.jsx)(a.A,{name:"Plus",size:16,className:"mr-2"}),"Добавить текст"]})})]}),"photo"===eL&&(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"Портрет"}),(0,n.jsx)("p",{className:"text-xs text-white/40",children:"Загрузите фото или выберите шаблон"})]}),(0,n.jsx)("button",{onClick:tg,className:"text-white/40 hover:text-white",children:(0,n.jsx)(a.A,{name:"X",size:16})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto scrollbar-site px-4 pb-4 space-y-3",children:[(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("p",{className:"text-[10px] text-white/40 text-center",children:"Мужские"}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-1",children:["/constructor/portraits/male-01.jpg","/constructor/portraits/male-02.jpg"].map((e,t)=>(0,n.jsx)("button",{onClick:()=>{T(e,"image"),tg()},className:"aspect-[3/4] rounded overflow-hidden border-2 border-white/10 hover:border-primary transition-all",children:(0,n.jsx)("img",{src:e,alt:"Портрет",className:"w-full h-full object-cover"})},t))})]}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("p",{className:"text-[10px] text-white/40 text-center",children:"Женские"}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-1",children:["/constructor/portraits/female-01.jpg","/constructor/portraits/female-02.jpg"].map((e,t)=>(0,n.jsx)("button",{onClick:()=>{T(e,"image"),tg()},className:"aspect-[3/4] rounded overflow-hidden border-2 border-white/10 hover:border-primary transition-all",children:(0,n.jsx)("img",{src:e,alt:"Портрет",className:"w-full h-full object-cover"})},t))})]})]}),(0,n.jsxs)(r.$,{className:"w-full min-h-[44px]",type:"button",disabled:e4,onClick:()=>e2.current?.click(),children:[(0,n.jsx)(a.A,{name:"Upload",size:16,className:"mr-2"}),e4?"Загрузка…":"Загрузить свой портрет"]}),(0,n.jsxs)("div",{className:"p-2 bg-white/5 rounded text-[10px] text-white/40 leading-relaxed",children:[(0,n.jsx)(a.A,{name:"Info",size:10,
12className:"inline mr-1 align-text-top"}),"Ретушь у профессионалов:"," ",(0,n.jsx)("a",{href:"tel:+79960681168",className:"text-primary hover:underline whitespace-nowrap",children:"+7 (996) 068-11-68"})]})]})]}),"cross"===eL&&(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"Кресты"}),(0,n.jsx)("button",{onClick:tg,className:"text-white/40 hover:text-white",children:(0,n.jsx)(a.A,{name:"X",size:16})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto scrollbar-site px-4 pb-4",children:A?(0,n.jsx)("div",{className:"flex justify-center py-8",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):H.length>0?(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2",children:H.map(e=>(0,n.jsxs)("button",{onClick:()=>{T(e.image_url,"cross",{fixedPriceRub:e.price_rub??null}),tg()},className:"aspect-square rounded border-2 border-white/10 hover:border-primary transition-all p-2 bg-white/5 hover:bg-primary/5 flex flex-col",children:[(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("img",{src:e.image_url,alt:e.name,className:"w-full h-full object-contain"})}),(0,n.jsx)("div",{className:"text-[9px] text-center mt-1 text-white/40 truncate",children:e.name})]},e.id))}):(0,n.jsx)("p",{className:"text-sm text-white/40 text-center py-6",children:"Кресты не найдены"})})]}),"imageCatalog"===eL&&(0,n.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"Каталог изображений"}),(0,n.jsx)("button",{onClick:tg,className:"text-white/40 hover:text-white",children:(0,n.jsx)(a.A,{name:"X",size:16})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto scrollbar-site px-4 pb-4 space-y-3",children:[e0?(0,n.jsx)("div",{className:"flex justify-center py-8",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):eG.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"grid grid-cols-3 gap-1 bg-white/5 rounded-lg p-1",children:eG.map(e=>{let t=eq.filter(t=>t.category_id===e.id).length;return(0,n.jsxs)("button",{onClick:()=>eQ(e.id),className:`px-1.5 py-1.5 rounded text-xs font-medium transition-all flex items-center justify-center gap-1 w-full ${eZ===e.id?"bg-primary text-primary-foreground":"text-white/50 hover:text-white hover:bg-white/10"}`,children:[(0,n.jsx)("span",{className:"truncate max-w-[60px]",children:e.name}),(0,n.jsx)("span",{className:"shrink-0 bg-white/20 rounded-full text-[10px] px-1 leading-4",children:t})]},e.id)})}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2 pb-2",children:[eq.filter(e=>e.category_id===eZ).map(e=>(0,n.jsxs)("button",{onClick:()=>{T(e.image_url,"image"),tg()},className:"rounded border-2 border-white/10 hover:border-primary transition-all bg-black/40 hover:bg-primary/5 overflow-hidden flex flex-col",children:[(0,n.jsx)("div",{className:"flex items-center justify-center p-2",style:{height:"110px"},children:(0,n.jsx)("img",{src:e.image_url,alt:e.name,className:"max-w-full max-h-full object-contain"})}),(0,n.jsx)("div",{className:"bg-black/60 text-white text-[9px] px-1 py-1 text-center truncate w-full",children:e.name})]},e.id)),0===eq.filter(e=>e.category_id===eZ).length&&(0,n.jsx)("p",{className:"col-span-3 text-sm text-white/40 text-center py-6",children:"Нет изображений"})]})]}):(0,n.jsx)("p",{className:"text-sm text-white/40 text-center py-6",children:"Категории не найдены"}),(0,n.jsx)("div",{className:"pt-2 border-t border-white/10 space-y-2",children:(0,n.jsxs)(r.$,{type:"button",className:"w-full min-h-[44px]",disabled:e4,onClick:()=>e5.current?.click(),children:[(0,n.jsx)(a.A,{name:"Upload",size:16,className:"mr-2"}),e4?"Загрузка…":"Загрузить своё изображение"]})})]})]})]})]})};var tx=i(42763);function tu({isOpen:e,onClose:t,imageUrl:i,onSave:s}){let o=(0,l.useRef)(null),c=(0,l.useRef)(null),h=(0,l.useRef)(null),[m,x]=(0,l.useState)(20),[u,p]=(0,l.useState)(.1),[g,f]=(0,l.useState)(!1),[w,y]=(0,l.useState)(!1),b=(0,l.useRef)(null);(0,l.useEffect)(()=>{h.current&&(h.current.style.display=g?"block":"none")},[g]),(0,l.useEffect)(()=>{let e=()=>{w&&(y(!1),b.current=null)};return window.addEventListener("mouseup",e),window.addEventListener("touchend",e),()=>{window.removeEventListener("mouseup",e),window.removeEventListener("touchend",e)}},[w]),(0,l.useEffect)(()=>
12{if(!e||!i)return;f(!1),y(!1),b.current=null;let t=()=>{let e=o.current;if(!e)return!1;let t=e.getContext("2d",{willReadFrequently:!0});return!!t&&(c.current=t,v(i,e,t),!0)};if(!t()){let e=setTimeout(t,150);return()=>clearTimeout(e)}},[e,i]);let v=(e,t,i)=>{let n=e.startsWith("data:"),r=n?e:`${d.P1}?url=${encodeURIComponent(e)}`,a=new Image;n||(a.crossOrigin="anonymous"),a.onload=()=>{let e=Math.min(1e3/a.width,700/a.height,1);t.width=Math.floor(a.width*e),t.height=Math.floor(a.height*e),t.style.width="100%",t.style.height="auto",i.globalCompositeOperation="source-over",i.drawImage(a,0,0,t.width,t.height)},a.src=r},j=e=>{let t=o.current;if(!t)return{x:0,y:0};let i=e.touches[0],n=t.getBoundingClientRect();return{x:(i.clientX-n.left)/n.width*t.width,y:(i.clientY-n.top)/n.height*t.height}},N=(e,t)=>{let i=c.current;if(!i)return;let n=m/2,r=.7+(1-Math.min(Math.max(u,0),1))*4.5,a=i.createRadialGradient(e,t,0,e,t,n);for(let e=0;e<=8;e++){let t=e/8,i=Math.pow(1-t,r);a.addColorStop(t,`rgba(0,0,0,${i})`)}i.globalCompositeOperation="destination-out",i.fillStyle=a,i.beginPath(),i.arc(e,t,n,0,2*Math.PI),i.fill()};return(0,n.jsx)(tx.lG,{open:e,onOpenChange:t,children:(0,n.jsxs)(tx.Cf,{className:"w-[95vw] max-w-5xl max-h-[92vh] overflow-y-auto p-3 sm:p-6",children:[(0,n.jsx)(tx.c7,{children:(0,n.jsx)(tx.L3,{className:"text-sm sm:text-base",children:"Редактор — Ластик"})}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"constructor-panel flex flex-col gap-2 p-3 bg-secondary rounded-lg",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)(r.$,{variant:g?"default":"outline",size:"sm",onClick:()=>f(!g),className:"shrink-0",children:[(0,n.jsx)(a.A,{name:"Eraser",size:16,className:"mr-1"}),"Ластик ",g?"ВКЛ":"ВЫКЛ"]}),(0,n.jsx)(r.$,{variant:"outline",size:"sm",onClick:()=>{let e=o.current,t=c.current;e&&t&&i&&v(i,e,t)},className:"shrink-0 ml-auto",children:(0,n.jsx)(a.A,{name:"RotateCcw",size:16})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("span",{className:"text-xs whitespace-nowrap w-24 shrink-0",children:["Размер: ",m,"px"]}),(0,n.jsx)("input",{type:"range",min:"5",max:"100",step:"5",value:m,onChange:e=>x(parseInt(e.target.value)),className:"flex-1 min-w-0"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("span",{className:"text-xs whitespace-nowrap w-24 shrink-0",children:["Жёсткость: ",Math.round(100*u),"%"]}),(0,n.jsx)("input",{type:"range",min:"0",max:"100",step:"1",value:100*u,onChange:e=>p(parseInt(e.target.value)/100),className:"flex-1 min-w-0"})]})]}),(0,n.jsx)("div",{className:"relative bg-muted/20 rounded-lg p-1 flex items-center justify-center w-full",children:(0,n.jsx)("canvas",{ref:o,onMouseDown:e=>{if(!g)return;let{x:t,y:i}=(e=>{let t=o.current;if(!t)return{x:0,y:0};let i=t.getBoundingClientRect();return{x:(e.clientX-i.left)/i.width*t.width,y:(e.clientY-i.top)/i.height*t.height}})(e);y(!0),b.current={x:t,y:i},N(t,i)},onMouseMove:e=>{let t=o.current;if(!t)return;let i=t.getBoundingClientRect(),n=(e.clientX-i.left)/i.width*t.width,r=(e.clientY-i.top)/i.height*t.height;if(h.current&&g){let e=i.left+n/t.width*i.width,a=i.top+r/t.height*i.height;h.current.style.left=`${e}px`,h.current.style.top=`${a}px`,h.current.style.display="block"}if(w){if(b.current){let e=b.current.x,t=b.current.y,i=Math.max(Math.ceil(Math.sqrt((n-e)**2+(r-t)**2)/2),1);for(let a=0;a<=i;a++){let l=a/i;N(e+(n-e)*l,t+(r-t)*l)}}b.current={x:n,y:r}}},onMouseUp:()=>{y(!1),b.current=null},onMouseLeave:()=>{y(!1),h.current&&(h.current.style.display="none")},onMouseEnter:e=>{let t=o.current;if(!t||!h.current||!g)return;let i=t.getBoundingClientRect(),n=(e.clientX-i.left)/i.width*t.width,r=(e.clientY-i.top)/i.height*t.height,a=i.left+n/t.width*i.width,l=i.top+r/t.height*i.height;h.current.style.left=`${a}px`,h.current.style.top=`${l}px`,h.current.style.display="block"},onTouchStart:e=>{if(!g)return;e.preventDefault();let{x:t,y:i}=j(e),n=e.touches[0];y(!0),b.current={x:t,y:i},N(t,i),h.current&&(h.current.style.left=`${n.clientX}px`,h.current.style.top=`${n.clientY}px`,h.current.style.display="block")},onTouchMove:e=>{if(!w||!g)return;e.preventDefault();let{x:t,y:i}=j(e),n=e.touches[0];if(h.current&&(h.current.style.left=`${n.clientX}px`,h.current.style.top=`${n.clientY}px`),b.current){let e=b.current.x,n=b.current.y,r=Math.max(Math.ceil(Math.sqrt((t-e)**2+(i-n)**2)/2),1);for(let a=0;a<=r;a++){let l=a/r;N(e+(t-e)*l,n+(i-n)*l)}}b.current={x:t,y:i}},onTouchEnd:()=>{y(!1),b.current=null,h.current&&(h.current.style.display="none")},style:{cursor:g?"none":"default",touchAction:"none",display:"block",maxWidth:"100%",height:"auto",border:"2px s
12olid rgba(255,255,255,0.1)",borderRadius:"4px"}})}),(0,n.jsx)("div",{ref:h,style:{position:"fixed",pointerEvents:"none",border:"2px solid rgba(255,255,255,0.9)",borderRadius:"50%",width:`${m}px`,height:`${m}px`,transform:"translate(-50%, -50%)",display:"none",zIndex:999999,boxShadow:"0 0 0 1px rgba(0,0,0,0.8), inset 0 0 0 1px rgba(255,255,255,0.3)",background:"rgba(255,255,255,0.05)"}}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[(0,n.jsx)(r.$,{variant:"outline",onClick:t,children:"Отмена"}),(0,n.jsxs)(r.$,{onClick:()=>{o.current&&(s(o.current.toDataURL("image/png")),t())},children:[(0,n.jsx)(a.A,{name:"Check",size:18,className:"mr-2"}),"Сохранить изменения"]})]})]})]})})}let tp={text:"Текст",image:"Изображение",cross:"Крест",flower:"Цветок",epitaph:"Эпитафия",fio:"ФИО",dates:"Даты",photo:"Портрет"},tg={text:"Type",image:"Image",cross:"Cross",flower:"Flower2",epitaph:"Quote",fio:"User",dates:"Calendar",photo:"Camera"},tf=({elements:e,selectedElement:t,setSelectedElement:i,onMoveUp:r,onMoveDown:l,onMoveToFront:s,onMoveToBack:o,onDelete:c})=>{let d=[...e].reverse();return(0,n.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-white/10 flex items-center gap-2",children:[(0,n.jsx)(a.A,{name:"Layers",size:14,className:"text-white/50"}),(0,n.jsx)("span",{className:"text-xs font-semibold text-white/70 uppercase tracking-wider",children:"Слои"}),(0,n.jsx)("span",{className:"ml-auto text-xs text-white/30",children:e.length})]}),0===e.length&&(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-xs text-white/30 text-center px-4",children:"Добавьте элементы на макет"}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto scrollbar-site",children:d.map((d,h)=>{let m=e.length-1-h,x=t===d.id,u=m===e.length-1,p=0===m;return(0,n.jsxs)("div",{onClick:()=>i(d.id),className:`group flex items-center gap-2 px-2 py-1.5 cursor-pointer border-b border-white/5 transition-colors ${x?"bg-primary/20 border-l-2 border-l-primary":"hover:bg-white/5"}`,children:[(0,n.jsx)("div",{className:"w-7 h-7 flex-shrink-0 rounded overflow-hidden bg-white/5 flex items-center justify-center",children:("image"===d.type||"cross"===d.type||"flower"===d.type||"photo"===d.type)&&(d.processedSrc||d.src)?(0,n.jsx)("img",{src:d.processedSrc||d.src,alt:"",className:"w-full h-full object-contain"}):(0,n.jsx)(a.A,{name:tg[d.type],fallback:"Square",size:14,className:x?"text-primary":"text-white/40"})}),(0,n.jsx)("span",{className:`flex-1 text-xs truncate ${x?"text-white":"text-white/60"}`,children:function(e){if(("fio"===e.type||"text"===e.type||"epitaph"===e.type||"dates"===e.type)&&e.content&&e.content.trim()){let t=e.content.replace(/\n/g," ").trim();return t.length>22?t.slice(0,22)+"…":t}return tp[e.type]??e.type}(d)}),(0,n.jsxs)("div",{className:`flex items-center gap-0.5 transition-opacity ${x?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:[(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),s(d.id)},disabled:u,title:"На передний план",className:"p-1 rounded hover:bg-white/10 text-white/50 hover:text-white disabled:opacity-20 disabled:cursor-default",children:(0,n.jsx)(a.A,{name:"ChevronsUp",size:12})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),r(d.id)},disabled:u,title:"Выше",className:"p-1 rounded hover:bg-white/10 text-white/50 hover:text-white disabled:opacity-20 disabled:cursor-default",children:(0,n.jsx)(a.A,{name:"ChevronUp",size:12})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),l(d.id)},disabled:p,title:"Ниже",className:"p-1 rounded hover:bg-white/10 text-white/50 hover:text-white disabled:opacity-20 disabled:cursor-default",children:(0,n.jsx)(a.A,{name:"ChevronDown",size:12})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),o(d.id)},disabled:p,title:"На задний план",className:"p-1 rounded hover:bg-white/10 text-white/50 hover:text-white disabled:opacity-20 disabled:cursor-default",children:(0,n.jsx)(a.A,{name:"ChevronsDown",size:12})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),c(d.id)},title:"Удалить",className:"p-1 rounded hover:bg-red-500/20 text-white/30 hover:text-red-400",children:(0,n.jsx)(a.A,{name:"Trash2",size:12})})]})]},d.id)})})]})};var tw=i(84675),ty=i(34798);let tb=[{id:1,name:"Одиночные"}],tv=[{id:-1,name:"G490",category_id:1,category_name:"Одиночные",image_url:ty.Ie,constructor_image_url:ty.Ie},{id:-2,name:"Тюльпан",category_id:1,category_name:"Одиночные",image_url:"https://s3.twcstorage.ru/master-granit-media/products/1783ae033de3f7fa.jpg",constructor_image_url:"https://s3.twcstorage.ru/master-granit-media/products/1783ae033de3f7fa.jpg"},{id:-3,name:"Элегант",category_id:1,category_name:"Одиночные",image_url:"https://s3.twcstorage.ru/master-granit-media/products/e243581175a094b9.jpg",constructor_image_url:"https://s3.twcstorage.ru/master-granit-media/products/e243581175a094b9.jpg"},{id:-4,name:"V3",category_id:1,category_name:"Одиночные",image_url:"https://s3.twcstorage.ru/master-granit-media/products/c15ee930521cffd2.jpg",constructor_image_url:"https://s3.twcstorage.ru/master-granit-media/products/c15ee930521cffd2.jpg"}],tj=e=>"image"===e||"photo"===e||"cross"===e||"flower"===e,tN=e=>tj(e)||"text"===e,tM={image:"Изображение",photo:"Фотография",cross:"Крест",flower:"Цветок"},tS=(e,t,i,n)=>{let{width:r,height:a,elemX:l,elemY:s,handle:o}
12=t,c=N(r,a,e.naturalWidth,e.naturalHeight),d=e.naturalWidth&&e.naturalHeight?e.naturalWidth/e.naturalHeight:c.widthPx/c.heightPx,h=(r-c.widthPx)/2,m=(a-c.heightPx)/2;return((e,t,i,n,r,a,l,s)=>{let o=s&&s>0?s:n/r,c=n,d=r,h=a,m=l;switch(e){case"se":d=(c=Math.max(30,n+(Math.abs(t)>Math.abs(i)?t:i*o)))/o;break;case"sw":d=(c=Math.max(30,n+(Math.abs(-t)>Math.abs(i)?-t:i*o)))/o,h=a+n-c;break;case"ne":m=l+r-(d=(c=Math.max(30,n+(Math.abs(t)>Math.abs(-i)?t:-i*o)))/o);break;case"nw":d=(c=Math.max(30,n+(Math.abs(-t)>Math.abs(-i)?-t:-i*o)))/o,h=a+n-c,m=l+r-d;break;case"e":m=l+(r-(d=(c=Math.max(30,n+t))/o))/2;break;case"w":d=(c=Math.max(30,n-t))/o,h=a+n-c,m=l+(r-d)/2;break;case"n":h=a+(n-(c=(d=Math.max(30,r-i))*o))/2,m=l+r-d;break;case"s":h=a+(n-(c=(d=Math.max(30,r+i))*o))/2}return{width:Math.round(c),height:Math.round(d),x:Math.round(h),y:Math.round(m)}})(o,i,n,c.widthPx,c.heightPx,l+h,s+m,d)},tk=({initialImage:e=null,initialMonument:t=null,mobileUx:i="bottom-tabs"})=>{let h=(0,s.Zp)(),u=(0,l.useRef)(null),{toast:p}=(0,c.dj)(),[g,f]=(0,l.useState)(!1),y=(0,l.useRef)(null),b="bottom-tabs"===i;(0,l.useEffect)(()=>{f(!!localStorage.getItem("auth_token"))},[]);let[v,M]=(0,l.useState)([]),[I,H]=(0,l.useState)(ty.Ie),[A,R]=(0,l.useState)([{widthMm:500,heightMm:1e3},{widthMm:500,heightMm:1e3}]),X=A[0].widthMm,B=A[0].heightMm,[J,K]=(0,l.useState)(0),[Z,Q]=(0,l.useState)(0),[et,ei]=(0,l.useState)(.5),[en,er]=(0,l.useState)(.5),[eh,em]=(0,l.useState)(null),[ep,eg]=(0,l.useState)(!0),[ef,ew]=(0,l.useState)(!1),[ey,eM]=(0,l.useState)("black"),[e$,eF]=(0,l.useState)(!1),[eP,eE]=(0,l.useState)(!0),[eI,eH]=(0,l.useState)(!1),[eR,eW]=(0,l.useState)("studio"),[eT,eD]=(0,l.useState)(!0),[eL,e_]=(0,l.useState)(eo.src),[eX,eB]=(0,l.useState)(eo.widthMm),[eY,eU]=(0,l.useState)(eo.heightMm),[eO,eJ]=(0,l.useState)(95),[eG,eV]=(0,l.useState)("single"),[eq,eK]=(0,l.useState)(null),[eZ,eQ]=(0,l.useState)(50),[e0,e1]=(0,l.useState)([!1,!1]),[e2,e5]=(0,l.useState)(0),e4=A[e2],[e3,e8]=(0,l.useState)(!1),[e6,e9]=(0,l.useState)(!1);(0,l.useEffect)(()=>{!eL&&eI&&eH(!1)},[eL,eI]);let e7=(0,l.useCallback)(()=>{T(eG)&&1===e2?e9(e=>!e):e8(e=>!e)},[eG,e2]),ti=(0,l.useCallback)(e=>{let t=L(e);if(eV(e),e1(t),!T(e)){eK(null),e5(0);return}t.some(Boolean)&&eQ(e=>G(e,t,A,eX)),e5(+!!I)},[I,A,eX]),tr=(0,l.useCallback)(e=>{e1(t=>{let i=0===e?[!t[0],t[1]]:[t[0],!t[1]];return eV(i[0]&&i[1]?"horizontal-double":!i[0]&&i[1]||i[0]&&!i[1]?"mixed-double":"double"),eQ(e=>G(e,i,A,eX)),i})},[A,eX]),ta=(0,l.useCallback)(e=>{T(eG)?0===e2?(H(e),e5(1)):eK(e):H(e)},[eG,e2]);(0,l.useEffect)(()=>{let e=new Image;e.crossOrigin="anonymous",e.onload=()=>{e.naturalWidth>0&&e.naturalHeight>0&&ei(e.naturalWidth/e.naturalHeight)},e.src=I},[I]),(0,l.useEffect)(()=>{if(!eq)return;let e=new Image;e.crossOrigin="anonymous",e.onload=()=>{e.naturalWidth>0&&e.naturalHeight>0&&er(e.naturalWidth/e.naturalHeight)},e.src=eq},[eq]),(0,l.useEffect)(()=>{if(!T(eG))return;let e=L(eG,e0);eQ(t=>G(t,e,A,eX))},[eG,e0,A,eX]);let[tl,ts]=(0,l.useState)([]),[tc,td]=(0,l.useState)(!1),[th,tx]=(0,l.useState)(!1),tp=(0,l.useRef)({past:[],future:[]}),tg=(0,l.useRef)([]);(0,l.useEffect)(()=>{tg.current=tl},[tl]);let tk=(0,l.useCallback)(e=>{let t="function"==typeof e?e(tg.current):e;tg.current=t,ts(t)},[]),tC=(0,l.useCallback)(e=>{let t=tg.current,i="function"==typeof e?e(t):e;tp.current.past=[...tp.current.past,t].slice(-50),tp.current.future=[],tg.current=i,ts(i),td(!0),tx(!1);try{localStorage.setItem("constructor_design",JSON.stringify(i))}catch(e){}},[]),tz=(0,l.useCallback)(()=>{let e=tg.current;tp.current.past=[...tp.current.past,e].slice(-50),tp.current.future=[],td(tp.current.past.length>0),tx(!1);try{localStorage.setItem("constructor_design",JSON.stringify(e))}catch(e){}},[]),t$=(0,l.useCallback)(()=>{let{past:e,future:t}=tp.current;if(0===e.length)return;let i=e[e.length-1];tp.current.past=e.slice(0,-1),tp.current.future=[tg.current,...t],tg.current=i,ts(i),td(tp.current.past.length>0),tx(!0);try{localStorage.setItem("constructor_design",JSON.stringify(i))}catch(e){}},[]),tF=(0,l.useCallback)(()=>{let{past:e,future:t}=tp.current;if(0===t.length)return;let i=t[0];tp.current.past=[...e,tg.current],tp.current.future=t.slice(1),tg.current=i,ts(i),td(!0),tx(tp.current.future.length>0);try{localStorage.setItem("constructor_design",JSON.stringify(i))}catch(e){}},[]),tP=(0,l.useRef)(!1),tE=(0,l.useRef)(!1),tI=(0,l.useRef)(!1),[tH,tA]=(0,l.useState)(null),[tR,tW]=(0,l.useState)(!1),[tT,tD]=(0,l.useState)(!1),[tL,t_]=(0,l.useState)(!1),[tX,tB]=(0,l.useState)(!1),[tY,tU]=(0,l.useState)({x:0,y:0}),[tO,tJ]=(0,l.useState)({x:0,y:0,width:0,height:0,fontSize:0,elemX:0,elemY:0,handle:"se"}
12),[tG,tV]=(0,l.useState)({x:0,y:0,rotation:0,centerX:0,centerY:0}),[tq,tK]=(0,l.useState)(""),[tZ,tQ]=(0,l.useState)(""),[t0,t1]=(0,l.useState)(""),[t2,t5]=(0,l.useState)("font1"),[t4,t3]=(0,l.useState)(""),[t8,t6]=(0,l.useState)(""),[t9,t7]=(0,l.useState)(!1),[ie,it]=(0,l.useState)(window.innerWidth<1024);(0,l.useEffect)(()=>{let e=()=>it(window.innerWidth<1024);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let[ii,ir]=(0,l.useState)(null),[ia,il]=(0,l.useState)(null),[is,io]=(0,l.useState)("font1"),ic=(0,l.useRef)(null),id=(0,l.useRef)(null),[ih,im]=(0,l.useState)(null),[ix,iu]=(0,l.useState)(null),[ip,ig]=(0,l.useState)([]),[iw,iy]=(0,l.useState)([]),[ib,iv]=(0,l.useState)(null),[ij,iN]=(0,l.useState)(!1),[iM,iS]=(0,l.useState)([]),[ik,iC]=(0,l.useState)(!1),[iz,i$]=(0,l.useState)([]),[iF,iP]=(0,l.useState)(!1),[iE,iI]=(0,l.useState)([]),[iH,iA]=(0,l.useState)(1),[iR,iW]=(0,l.useState)(null),[iT,iD]=(0,l.useState)({x:0,y:0}),[iL,i_]=(0,l.useState)(!1),[iX,iB]=(0,l.useState)({x:0,y:0}),[iY,iU]=(0,l.useState)(!1),[iO,iJ]=(0,l.useState)(null),[iG,iV]=(0,l.useState)(null),[iq,iK]=(0,l.useState)(40),[iZ,iQ]=(0,l.useState)(60),i0=(0,l.useRef)(null),i1=(0,l.useRef)(null),[i2,i5]=(0,l.useState)(!1),[i4,i3]=(0,l.useState)(!1);(0,l.useEffect)(()=>{document.title="Конструктор памятников | Мастер Гранит"},[]),(0,l.useEffect)(()=>{let e=e=>{if((e.ctrlKey||e.metaKey)&&"z"===e.key&&!e.shiftKey){let t=document.activeElement;t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable)||(e.preventDefault(),t$())}if((e.ctrlKey||e.metaKey)&&("y"===e.key||"z"===e.key&&e.shiftKey)){let t=document.activeElement;t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable)||(e.preventDefault(),tF())}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t$,tF]);let i8=async()=>{iN(!0);try{let e=await fetch((0,d.sH)({type:"categories"})),t=e.ok?await e.json():[],i=await fetch((0,d.sH)()),n=i.ok?await i.json():[],r=Array.isArray(n)?n.filter(e=>e.image_url||e.constructor_image_url):[];if(0===r.length){ig(tb),iy(tv),iv(tb[0]?.id??null);return}let a=new Map;t.forEach(e=>{a.set(e.id,e.name)});let l=r.map(e=>({id:e.id,name:e.name,category_id:e.category_id||0,category_name:e.category_name||a.get(e.category_id??0)||"Без категории",image_url:e.image_url??null,constructor_image_url:e.constructor_image_url??null})),s=Array.isArray(t)&&t.length>0?t.map(e=>({id:e.id,name:e.name})):Array.from(new Map(l.map(e=>[e.category_id,{id:e.category_id,name:e.category_name}])).values());ig(s),iy(l),s.length>0&&iv(s[0].id)}catch(e){console.error("Error loading catalog:",e),ig(tb),iy(tv),iv(tb[0]?.id??null),p({title:"Каталог из демо-набора",description:"База недоступна — показаны примеры памятников"})}finally{iN(!1)}},i6=async()=>{iC(!0);try{let e=await fetch(d.Ub);if(e.ok){let t=await e.json();iS(t)}else iS([])}catch(e){console.error("Error loading crosses:",e),iS([])}finally{iC(!1)}},i9=async()=>{iP(!0);try{let e=await fetch(d._G);if(e.ok){let t=await e.json();i$(t)}else i$([])}catch(e){console.error("Error loading flowers:",e),i$([])}finally{iP(!1)}},i7=async()=>{try{let e=await fetch(d.Cn);if(e.ok){let t=await e.json();iI(t),t.forEach(e=>{let t=`font-face-${e.filename}`;if(!document.getElementById(t)){let i=document.createElement("style");i.id=t,i.innerHTML=`
13              @font-face {
14                font-family: '${e.name}';
15                src: url('${e.url}') format('truetype');
16                font-weight: normal;
17                font-style: normal;
18              }
19            `,document.head.appendChild(i)}})}}catch(e){console.error("Error loading custom fonts:",e)}};(0,l.useEffect)(()=>{i8(),i6(),i9()},[]),(0,l.useEffect)(()=>{if(!u.current)return;let e=new ResizeObserver(e=>{let t=e[0];if(!t)return;let i=t.contentRect.width,n=t.contentRect.height;if(0===i||0===n)return;let r=i0.current;if(r&&(Math.abs(r.width-i)>1||Math.abs(r.height-n)>1)){let e=i/r.width,t=n/r.height;tk(i=>i.map(i=>({...i,x:i.x*e,y:i.y*t,width:i.width*e,height:i.height*t,fontSize:i.fontSize?Math.round(i.fontSize*e):i.fontSize})))}i0.current={width:i,height:n}});e.observe(u.current);let t=u.current.offsetWidth,i=u.current.offsetHeight;return t>0&&i>0&&(i0.current={width:t,height:i}),()=>e.disconnect()},[]);let ne=[{id:"font1",name:"№ 1/1а",style:"Playfair Display",weight:"400",example:"Фамилия Имя Отчество",fullStyle:"Playfair Display|400"},{id:"font2",name:"№ 2/2а",style:"Playfair Display",weight:"700",example:"Фамилия Имя Отчество",fullStyle:"Playfair Display|700"},{id:"font3",name:"№ 3",style:"Cormorant Garamond",weight:"400",example:"Фамилия Имя Отчество",fullStyle:"Cormorant Garamond|400"},{id:"font4",name:"№ 4",style:"Cormorant Garamond",weight:"700",example:"Фамилия Имя Отчество",fullStyle:"Cormorant Garamond|700"},{id:"font5",name:"№ 3а",style:"EB Garamond",weight:"400",example:"Фамилия Имя Отчество",fullStyle:"EB Garamond|400"},{id:"font6",name:"Иск 1/1а",style:"Dancing Script",weight:"400",example:"Фамилия Имя Отчество",fullStyle:"Dancing Script|400"},{id:"font7",name:"Иск 2/2а",style:"Great Vibes",weight:"400",example:"Фамилия Имя Отчество",fullStyle:"Great Vibes|400"},{id:"font8",name:"Иск 3/3а",style:"Allura",weight:"400",example:"Фамилия Имя Отчество",fullStyle:"Allura|400"},{id:"font9",name:"№ Cinzel",style:"Cinzel",weight:"700",example:"Фамилия Имя Отчество",fullStyle:"Cinzel|700"},...iE.map((e,t)=>({id:`custom-${t}`,name:e.name,style:e.name,weight:"400",example:"Фамилия Имя Отчество",fullStyle:`${e.name}|custom|${e.url}`}))],nt=()=>{let e=u.current;if(!e)return{x:50,y:50,centerX:100,centerY:150,width:200,height:300};let t=e.offsetWidth,i=e.offsetHeight;if(t<=0||i<=0)return{x:50,y:50,centerX:100,centerY:150,width:200,height:300};let n=eu({canvasW:t,canvasH:i,monumentHeightMm:B,monumentWidthMm:X,pede
19stalHeightMm:eY,pedestalWidthMm:eX,monumentType:eG,monumentGapMm:eZ,monumentSlotHorizontal:e0,monumentSlotSizes:A,sceneMode:eR,showGroundLayers:!eh}),r=ex({canvasW:t,canvasH:i,monumentType:eG,monumentGapMm:eZ,monumentWidthMm:X,monumentHeightMm:B,pedestalWidthMm:eX,pedestalHeightMm:eY,pedestalAnchorPct:eO,mmPerPx:n,aspect1:et,aspect2:en,monumentSlotHorizontal:e0,monumentSlotSizes:A,combinedCatalogImage:!eL&&"single"===eG}).group;return{x:Math.round(r.x+.08*r.width),y:Math.round(r.y+.08*r.height),centerX:Math.round(r.x+r.width/2),centerY:Math.round(r.y+r.height/2),width:r.width,height:r.height}},ni=(e,t)=>{let i=nt(),n=Date.now().toString(),r={id:n,type:"text",x:i.x,y:i.y,width:200,height:40,content:e||"Текст",fontSize:24,color:"#FFFFFF",rotation:0,autoSize:!0,fontFamily:t};tC(e=>[...e,r]),tA(n)},nn=async(e,t,i)=>{let n=100,r=100,a=0,l=0;await new Promise(t=>{let i=new Image;e.startsWith("data:")||(i.crossOrigin="anonymous"),i.onload=()=>{a=i.naturalWidth,l=i.naturalHeight;let e=a/Math.max(l,1);e<1?n=Math.round((r=150)*e):e>1?r=Math.round((n=150)/e):(n=100,r=100),t()},i.onerror=()=>t(),i.src=e});let s=u.current?.offsetWidth??0,o=u.current?.offsetHeight??0,c=nt(),d=i?.x!=null?i.x-n/2:c.centerX-n/2,h=i?.y!=null?i.y-r/2:c.centerY-r/2,m=s>0?Math.max(0,Math.min(d,s-n)):d,x=o>0?Math.max(0,Math.min(h,o-r)):h,p=Date.now().toString(),g={id:p,type:t,x:m,y:x,width:n,height:r,src:e,rotation:0,screenMode:!1,processedSrc:e,..."cross"===t&&i?.fixedPriceRub!=null?{fixedPriceRub:i.fixedPriceRub}:{},...a>0&&l>0?{naturalWidth:a,naturalHeight:l}:{}};tC(e=>[...e,g]),tA(p),nd(e).then(e=>{tk(t=>t.map(t=>t.id===p?{...t,screenMode:!0,processedSrc:e}:t))})};(0,l.useEffect)(()=>{t&&H(decodeURIComponent(t)),e&&nn(decodeURIComponent(e),"image"),i7()},[e,t]);let nr=(0,l.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"},[]),na=(0,l.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData("application/x-constructor-image")||e.dataTransfer.getData("text/plain");if(t)try{let i=JSON.parse(t);
19if(!i.src)return;let n=u.current;if(!n)return;let r=n.getBoundingClientRect(),a=n.offsetWidth>0?n.offsetWidth/r.width:1,l=n.offsetHeight>0?n.offsetHeight/r.height:1,s=(e.clientX-r.left)*a,o=(e.clientY-r.top)*l;nn(i.src,i.type??"image",{x:s,y:o,fixedPriceRub:i.fixedPriceRub??null})}catch(e){console.error("DnD payload parse error:",e)}},[nn]),nl=e=>{let t=nt(),i=Date.now().toString(),n={id:i,type:"epitaph",x:t.x,y:Math.round(t.y+.55*t.height),width:300,height:60,content:e||"Вечная память",fontSize:18,color:"#FFFFFF",rotation:0,autoSize:!0};tC(e=>[...e,n]),tA(i)},ns=()=>{if(!tq&&!tZ&&!t0)return;let e=`${tq}
20${tZ}
21${t0}`.trim(),t=ne.find(e=>e.id===t2),i=nt(),n=Date.now().toString(),r={id:n,type:"fio",x:Math.round(i.centerX-100),y:Math.round(i.y+.12*i.height),width:200,height:90,content:e,fontSize:28,color:"#FFFFFF",rotation:0,fontFamily:t?.fullStyle||"serif",autoSize:!0,lineHeight:1.05};tC(e=>[...e,r]),tA(n),tK(""),tQ(""),t1("")},no=(e="inline")=>{let t;if(!t4&&!t8)return;let i=ne.find(e=>e.id===is),n=i?.fullStyle||"serif",r="center",a=1.4;if("inline"===e)t=`${t4} – ${t8}`.trim();else if("stacked"===e)t=`${t4}
22${t8}`.trim(),a=1.6;else{let e=t4||"",i=t8||"";t=`${e}
23      ${i}
23`.trim(),r="left",a=1.6}let l=nt(),s=Date.now().toString(),o={id:s,type:"dates",x:Math.round(l.centerX-125),y:Math.round(l.y+.72*l.height),width:250,height:40,content:t,fontSize:20,color:"#FFFFFF",rotation:0,fontFamily:n,autoSize:!0,textAlign:r,lineHeight:a};tC(e=>[...e,o]),tA(s),t3(""),t6("")},nc=(0,l.useCallback)(()=>{tK(eC.surname),tQ(eC.name),t1(eC.patronymic),t3(eC.birthDate),t6(eC.deathDate);let e=ne.find(e=>e.id===t2),t=nt(),i=`${Date.now()}-inscription-template`,n=Math.round(117.60000000000001),r={id:i,type:"fio",x:Math.round(t.centerX-120),y:Math.round(t.centerY-n/2),width:240,height:n,content:ez(eC),fontSize:28,color:"#FFFFFF",rotation:0,fontFamily:e?.fullStyle||"serif",autoSize:!0,lineHeight:1.05,textAlign:"center"};tC(e=>[...e,r]),tA(i)},[ne,t2,tC]),nd=m,nh=async e=>{let t=e.target.files?.[0];if(e.target&&(e.target.value=""),ic.current&&(ic.current.value=""),t)try{let e=await x(t);if(!e)throw Error("Пустое изображение");let i=await new Promise((t,i)=>{let n=new Image;n.onload=()=>{let e=n.naturalWidth/Math.max(n.naturalHeight,1);e>=1?t({w:200,h:Math.round(200/e),nw:n.naturalWidth,nh:n.naturalHeight}):t({w:Math.round(200*e),h:200,nw:n.naturalWidth,nh:n.naturalHeight})},n.onerror=()=>i(Error("Не удалось декодировать изображение. Попробуйте JPG или PNG.")),n.src=e}),n=u.current?.offsetWidth??0,r=u.current?.offsetHeight??0,a=nt(),l=a.centerX-i.w/2,s=a.centerY-i.h/2,o=n>0?Math.max(0,Math.min(l,n-i.w)):l,c=r>0?Math.max(0,Math.min(s,r-i.h)):s,d=Date.now().toString(),h={id:d,type:"photo",x:o,y:c,width:i.w,height:i.h,src:e,rotation:0,screenMode:!1,processedSrc:e,naturalWidth:i.nw,naturalHeight:i.nh};tC(e=>[...e,h]),tA(d),nd(e).then(e=>{tk(t=>t.map(t=>t.id===d?{...t,screenMode:!0,processedSrc:e}:t))})}catch(e){throw console.error("Ошибка обработки загруженного фото",e),p({title:"Не удалось загрузить фото",description:e instanceof Error?e.message:"Попробуйте JPG или PNG",variant:"destructive"}),e}},nm=async(e,t)=>{let i=tl.find(t=>t.id===e);if(!i)return;if("screenMode"in t&&("photo"===i.type||"image"===i.type||"cross"===i.type||"flower"===i.type)&&i.src){if(!0===t.screenMode){if(i.processedSrc)tC(t=>t.map(t=>t.id===e?{...t,screenMode:!0}:t));else{let t=await nd(i.src);tC(i=>i.map(i=>i.id===e?{...i,screenMode:!0,processedSrc:t}:i))}return}else if(!1===t.screenMode)return void tC(t=>t.map(t=>t.id===e?{...t,screenMode:!1,processedSrc:void 0}:t))}let n={...t};"number"==typeof n.fontSize&&(n.fontSize=Math.round(n.fontSize)),tC(t=>t.map(t=>t.id===e?{...t,...n}:t))},nx=e=>{tC(t=>t.filter(t=>t.id!==e)),tH===e&&tA(null)};(0,l.useEffect)(()=>{let e=e=>{let t=document.activeElement;t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable)||(("Delete"===e.key||"Backspace"===e.key)&&tH&&(e.preventDefault(),nx(tH)),"Escape"===e.key&&(il(null),tA(null)))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[tH]);let nu=e=>{let t=tl.find(t=>t.id===e);t&&t.src&&iV(e)},np=async e=>{if(!iO)return;let t=tl.find(e=>e.id===iO);if(t?.screenMode){let t=await nd(e);tC(i=>i.map(i=>i.id===iO?{...i,src:e,processedSrc:t,screenMode:!0}:i))}else tC(t=>t.map(t=>t.id===iO?{...t,src:e,processedSrc:void 0}:t));p({title:"Изображение обновлено",description:"Отредактированное изображение применено"})},ng=async e=>{if(!iG)return;let t=tl.find(e=>e.id===iG);if(t?.screenMode){let t=await nd(e);tC(i=>i.map(i=>i.id===iG?{...i,src:e,processedSrc:t,screenMode:!0}:i))}else tC(t=>t.map(t=>t.id===iG?{...t,src:e,processedSrc:void 0}:t));iV(null)},nf=(0,l.useMemo)(()=>{if(!iO)return"";let e=tl.find(e=>e.id===iO);return e?.src||""},[iO,tl]),nw=async()=>{if(!i2){if(0===tl.length)return void p({title:"Пустой дизайн",description:"Добавьте элементы на памятник",variant:"destructive"});i5(!0);try{p({title:"Создание PNG...",description:"Встраиваем данные в изображение"});let e={monumentImage:I,elements:tl,timestamp:Date.now(),version:"1.0"},t=await nM();if(!t)throw Error("Не удалось создать превью");
23let i=t.split(",")[1],n=atob(i),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);let a=JSON.stringify(e),l=nb(r,"workflow",a),s=new Blob([Uint8Array.from(l)],{type:"image/png"}),o=new Date,c=`${o.getDate().toString().padStart(2,"0")}.${(o.getMonth()+1).toString().padStart(2,"0")}.${o.getFullYear()}`,d=`проект_${c}.png`;if(/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)&&navigator.canShare&&navigator.canShare({files:[new File([s],d)]}))try{await navigator.share({files:[new File([s],d,{type:"image/png"})],title:"Эскиз памятника",text:"Нажмите \xabСохранить изображение\xbb чтобы добавить в галерею"});return}catch(e){if(e instanceof Error&&"AbortError"===e.name)return}let h=URL.createObjectURL(s),m=document.createElement("a");m.href=h,m.download=d,m.style.display="none",document.body.appendChild(m),m.click(),setTimeout(()=>{document.body.contains(m)&&document.body.removeChild(m),URL.revokeObjectURL(h)},3e3),p({title:"Проект сохранён",description:"PNG файл скачан на устройство"})}catch(e){console.error("❌ Export error:",e),p({title:"Ошибка экспорта PNG",description:String(e),variant:"destructive"})}finally{i5(!1)}}},ny=async()=>{if(!i2){if(0===tl.length)return void p({title:"Пустой дизайн",description:"Добавьте элементы на памятник",variant:"destructive"});i5(!0);try{p({title:"Создание JPG...",description:"Экспортируем изображение без сжатия"});let e=await nM();if(!e)throw Error("Не удалось создать превью");let t=new Image;await new Promise((i,n)=>{t.onload=()=>i(),t.onerror=n,t.src=e});let i=document.createElement("canvas");i.width=t.width,i.height=t.height;let n=i.getContext("2d");n.fillStyle="#000000",n.fillRect(0,0,i.width,i.height),n.drawImage(t,0,0);let r=Math.max(16,Math.round(.028*i.width));n.save(),n.font=`bold ${r}px Arial`,n.fillStyle="rgba(255, 255, 255, 0.18)",n.textAlign="center",n.textBaseline="middle";let a=-Math.PI/6,l=.35*i.width,s=.18*i.height;for(let e=-2;e<8;e++)for(let t=-1;t<5;t++){let i=t*l+(e%2==0?0:l/2),r=e*s;n.save(),n.translate(i,r),n.rotate(a),n.fillText("мастер-гранит.рф",0,0),n.restore()}n.restore();let o=i.toDataURL("image/jpeg",1).split(",")[1],c=atob(o),d=new Uint8Array(c.length);for(let e=0;e<c.length;e++)d[e]=c.charCodeAt(e);let h=new Blob([d],{type:"image/jpeg"}),m=new Date,x=`${m.getDate().toString().padStart(2,"0")}.${(m.getMonth()+1).toString().padStart(2,"0")}.${m.getFullYear()}`,u=`проект_${x}.jpg`;if(/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)&&navigator.canShare&&navigator.canShare({files:[new File([h],u)]}))try{await navigator.share({files:[new File([h],u,{type:"image/jpeg"})],title:"Эскиз памятника",text:"Нажмите \xabСохранить изображение\xbb чтобы добавить в галерею"});return}catch(e){if(e instanceof Error&&"AbortError"===e.name)return}let g=URL.createObjectURL(h),f=document.createElement("a");f.href=g,f.download=u,f.style.display="none",document.body.appendChild(f),f.click(),setTimeout(()=>{document.body.contains(f)&&document.body.removeChild(f),URL.revokeObjectURL(g)},3e3),p({title:"JPG сохранён",description:"Файл скачан на устройство"})}catch(e){console.error("❌ Export JPG error:",e),p({title:"Ошибка экспорта JPG",description:String(e),variant:"destructive"})}finally{i5(!1)}}},nb=(e,t,i)=>{e.slice(0,8);let n=-1;for(let t=8;t<e.length-4;t++)if(73===e[t]&&69===e[t+1]&&78===e[t+2]&&68===e[t+3]){n=t-4;break}if(-1===n)return console.warn("IEND chunk не найден, возвращаем оригинал"),e;let r=new TextEncoder().encode(t),a=new TextEncoder().encode(i),l=new Uint8Array(r.length+1+a.length);l.set(r,0),l[r.length]=0,l.set(a,r.length+1);let s=l.length,o=new Uint8Array(4);new DataView(o.buffer).setUint32(0,s,!1);let c=new Uint8Array([116,69,88,116]),d=new Uint8Array(c.length+l.length);d.set(c,0),d.set(l,c.length);let h=nv(d),m=new Uint8Array(4);new DataView(m.buffer).setUint32(0,h,!1);let x=new Uint8Array(e.length+o.length+c.length+l.length+m.length);x.set(e.slice(0,n),0);let u=n;return x.set(o,u),u+=o.length,x.set(c,u),u+=c.length,x.set(l,u),u
23+=l.length,x.set(m,u),u+=m.length,x.set(e.slice(n),u),x},nv=e=>{let t=0xffffffff;for(let i=0;i<e.length;i++){t^=e[i];for(let e=0;e<8;e++)t=t>>>1^0xedb88320&-(1&t)}return(0xffffffff^t)>>>0},nj=async()=>{if(0===tl.length)return void p({title:"Пустой дизайн",description:"Добавьте элементы на памятник",variant:"destructive"});try{console.log("\uD83D\uDCE6 Начинаем экспорт дизайна");let e={monumentImage:I,elements:tl,timestamp:Date.now(),version:"1.0"},t=JSON.stringify(e,null,2);console.log("\uD83D\uDCC4 JSON создан, размер:",t.length);let i=new Blob([t],{type:"application/json"}),n=URL.createObjectURL(i),r=Date.now(),a=`monument_${r}`;console.log("\uD83D\uDCBE Попытка скачать JSON файл:",`${a}.json`);let l=document.createElement("a");l.href=n,l.download=`${a}.json`,l.style.display="none",document.body.appendChild(l);try{l.click(),console.log("✅ JSON: click() вызван")}catch(t){console.error("❌ Ошибка click():",t);let e=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});l.dispatchEvent(e),console.log("✅ JSON: dispatchEvent() вызван")}setTimeout(()=>{document.body.removeChild(l),URL.revokeObjectURL(n),console.log("\uD83E\uDDF9 JSON: элемент удален из DOM")},1e3),p({title:"Файл готов к загрузке",description:`${a}.json`}),console.log("\uD83C\uDF89 Экспорт завершен")}catch(e){console.error("❌ Export error:",e),p({title:"Ошибка экспорта",description:String(e),variant:"destructive"})}},nN=e=>{let t=e.target.files?.[0];if(!t)return;console.log("\uD83D\uDCC1 Загружаем файл:",t.name,t.type,t.size);let i=t.name.toLowerCase();if(i.endsWith(".png")){console.log("\uD83D\uDDBC️ Обнаружен PNG, ищем метаданные...");let i=new FileReader;i.onload=async e=>{try{let t=e.target?.result,i=new Uint8Array(t),n=((e,t)=>{let i=8;for(;i<e.length&&!(i+4>e.length);){let n=new DataView(e.buffer,e.byteOffset+i).getUint32(0,!1);if((i+=4)+4>e.length)break;let r=String.fromCharCode(e[i],e[i+1],e[i+2],e[i+3]);if(i+=4,"IEND"===r)break;
23if("tEXt"===r&&i+n<=e.length){let r=e.slice(i,i+n),a=-1;for(let e=0;e<r.length;e++)if(0===r[e]){a=e;break}if(-1!==a&&new TextDecoder().decode(r.slice(0,a))===t){let e=new TextDecoder().decode(r.slice(a+1));return console.log(`✅ Найден tEXt chunk "${t}", размер:`,e.length),e}}i+=n+4}return console.warn(`tEXt chunk "${t}" не найден`),null})(i,"workflow");if(!n)return void p({title:"Метаданные не найдены",description:"Это обычное изображение без workflow данных",variant:"destructive"});let r=JSON.parse(n);if(!r.monumentImage||!r.elements)throw Error("Неверный формат данных");console.log("✅ Workflow данные извлечены из PNG, элементов:",r.elements.length),H(r.monumentImage),tp.current={past:[],future:[]},tg.current=r.elements,ts(r.elements),td(!1),tx(!1),tA(null),p({title:"Workflow загружен из PNG",description:`Восстановлено ${r.elements.length} элементов`})}catch(e){console.error("❌ Ошибка чтения PNG метаданных:",e),p({title:"Ошибка чтения PNG",description:"Не удалось извлечь workflow данные",variant:"destructive"})}},i.readAsArrayBuffer(t),e.target&&(e.target.value="");return}if(!i.endsWith(".json")){p({title:"Неверный формат",description:"Выберите JSON или PNG файл",variant:"destructive"}),e.target&&(e.target.value="");return}let n=new FileReader;n.onload=e=>{try{let t=e.target?.result;console.log("\uD83D\uDCC4 Содержимое файла загружено, размер:",t.length);let i=JSON.parse(t);if(!i.monumentImage||!i.elements)throw Error("Неверный формат файла");console.log("✅ JSON валиден, элементов:",i.elements.length),H(i.monumentImage),tp.current={past:[],future:[]},tg.current=i.elements,ts(i.elements),td(!1),tx(!1),tA(null),p({title:"Шаблон загружен",description:`Восстановлено ${i.elements.length} элементов`})}catch(e){console.error("❌ Ошибка парсинга JSON:",e),p({title:"Ошибка импорта",description:"Не удалось прочитать файл. Проверьте формат",variant:"destructive"})}},n.onerror=()=>{console.error("❌ Ошибка чтения файла"),p({title:"Ошибка чтения",description:"Не удалось прочитать файл",variant:"destructive"})},n.readAsText(t),e.target&&(e.target.value="")},nM=async(e=!1)=>{if(!u.current)return null;try{await nC(tl);let t=ed(1200),i=e?t.width:1920,n=e?t.height:Math.round(i/q),r=document.createElement("canvas");r.width=i,r.height=n;let a=r.getContext("2d");if(!a)return null;let l=[I,T(eG)&&eq?eq:null].filter(e=>!!e);await z(u.current,l);let s=nE.w>0?nE.w:u.current.offsetWidth,o=nE.h>0?nE.h:Math.round(s/q),c=eu({canvasW:s,canvasH:o,monumentHeightMm:B,monumentWidthMm:X,pede
23stalHeightMm:eY,pedestalWidthMm:eX,monumentType:eG,monumentGapMm:eZ,monumentSlotHorizontal:e0,monumentSlotSizes:A,mobile:ie,sceneMode:eR,showGroundLayers:!eh}),d=e?ex({canvasW:s,canvasH:o,monumentType:eG,monumentGapMm:eZ,monumentWidthMm:X,monumentHeightMm:B,pedestalWidthMm:eX,pedestalHeightMm:eY,pedestalAnchorPct:eO,mmPerPx:c,aspect1:et,aspect2:en,monumentSlotHorizontal:e0,monumentSlotSizes:A,combinedCatalogImage:!eL&&"single"===eG}):null,h=d??ex({canvasW:s,canvasH:o,monumentType:eG,monumentGapMm:eZ,monumentWidthMm:X,monumentHeightMm:B,pedestalWidthMm:eX,pedestalHeightMm:eY,pedestalAnchorPct:eO,mmPerPx:c,aspect1:et,aspect2:en,monumentSlotHorizontal:e0,monumentSlotSizes:A,combinedCatalogImage:!eL&&"single"===eG}),m=e?function(e){if(e.canvasW<=0||e.canvasH<=0)return 2;let t=.035*e.canvasW,i=.035*e.canvasH,n=Math.max(100,e.canvasW-2*t),r=Math.max(100,e.canvasH-2*i),a=U(e.monumentType,e.monumentWidthMm,e.monumentHeightMm),l=.96*r/Math.max(T(e.monumentType??"single")?V(L(e.monumentType??"double",e.monumentSlotHorizontal),W(e.monumentWidthMm,e.monumentHeightMm,e.monumentSlotSizes),e.pedestalHeightMm):e.pedestalHeightMm+a.heightMm,1),s=e.monumentGapMm??50;return Math.min(l,.94*n/Math.max(O(e.monumentType,e.monumentWidthMm,e.monumentHeightMm,e.pedestalWidthMm,s,e.monumentSlotHorizontal,e.monumentSlotSizes),1))}
23({canvasW:i,canvasH:n,monumentHeightMm:B,monumentWidthMm:X,pedestalHeightMm:eY,pedestalWidthMm:eX,monumentType:eG,monumentGapMm:eZ,monumentSlotHorizontal:e0,monumentSlotSizes:A}):eu({canvasW:i,canvasH:n,monumentHeightMm:B,monumentWidthMm:X,pedestalHeightMm:eY,pedestalWidthMm:eX,monumentType:eG,monumentGapMm:eZ,sceneMode:eR,showGroundLayers:!eh}),x=ex({canvasW:i,canvasH:n,monumentType:eG,monumentGapMm:eZ,monumentWidthMm:X,monumentHeightMm:B,pedestalWidthMm:eX,pedestalHeightMm:eY,pedestalAnchorPct:eO,mmPerPx:m,aspect1:et,aspect2:en,monumentSlotHorizontal:e0,monumentSlotSizes:A,combinedCatalogImage:!eL&&"single"===eG}),p={monumentType:eG,monumentGapMm:eZ,monumentWidthMm:X,monumentHeightMm:B,mmPerPx:m,pedestalWidthMm:eX,pedestalHeightMm:eY,pedestalAnchorPct:eO,monumentSlotHorizontal:e0,monumentSlotSizes:A,monumentImageSrc:I,monumentImage2Src:eq,monumentFlipHorizontal:e3,monumentFlipHorizontal2:e6,pedestalImageSrc:eL,loadImage:nz,sceneVaseSides:nA,sceneVaseSrc:nR.src,sceneLampSides:nW,sceneLampSrc:el,sceneFlowerbed:eI,sceneFlowerbedSrc:es.src},g=null;e?g=await ek(a,i,n,p):await eS(a,i,n,{...p,sceneBackgroundSrc:eh,sceneMode:eR,showSceneDimensions:eT});let{scaleX:f,scaleY:w,fontScale:y}=$(s,o,i,n);for(let t of tl){let i,n,r,l;a.save();let s=y;if(e&&g&&d){let e=F(t,d),a=d.monuments[e]??d.monuments[0],o=g.monuments[e]??g.monuments[0],c=P(t,a,o);i=c.x,n=c.y,r=c.width,l=c.height,s=c.fontScale}else{let e=E(t,h,x,f,w);i=e.x,n=e.y,r=e.width,l=e.height,s=e.fontScale}if("text"===t.type||"epitaph"===t.type||"fio"===t.type||"dates"===t.type){let e,o=t.fontFamily?.split("|")||["serif","400"],c=o[0],d="custom"===o[1];e=d?"normal":"text"===t.type?o[1]||"bold":o[1]||"400";let h=(t.fontSize||24)*s,m=t.italic?"italic":"normal";a.font=`${m} ${e} ${h}px "${c}"`,a.fillStyle=t.color||"#FFFFFF",d&&(a.fontVariantLigatures="common-ligatures discretionary-ligatures",a.fontFeatureSettings="'ss01', 'calt', 'swsh', 'liga', 'dlig'"),t.letterSpacing?a.letterSpacing=`${t.letterSpacing*s}px`:a.letterSpacing="0px",a.shadowColor="rgba(0,0,0,0.8)",a.shadowBlur=4*s,a.shadowOffsetX=2*s,a.shadowOffsetY=2*s;let x=t.content||"";"dates"===t.type&&(x=x.toUpperCase());let u=1.2;"fio"===t.type?u=d?1.6:1.05:"epitaph"===t.type&&(u=1.4);let p=t.lineHeight||u,g=h*p,f="fio"!==t.type?4*s:0,w=r-2*f,y=x.split("\n"),b=[],v=t.autoSize?1/0:w;y.forEach(e=>{if(""===e.trim())b.push("");else{let t=nS(a,e,v);b.push(...t)}});let j=t.textAlign||"center",N=w;t.autoSize&&(N=Math.max(...b.map(e=>a.measureText(e).width)));let M=b.map(e=>{let t=a.measureText(e).width,n=i;
23return"center"===j?n=i+f+(N-t)/2:"right"===j&&(n=i+f+N-t),{x:n,width:t}});if(t.rotation){let e=i+r/2,s=n+l/2;a.translate(e,s),a.rotate(t.rotation*Math.PI/180),a.translate(-e,-s)}a.textBaseline="top";let S=t.initialScale||1;b.forEach((i,r)=>{let l=Math.round(n+f+r*g),s=Math.round(M[r].x);"fio"===t.type&&S>1&&i.length>0?i.split(/\s+/).forEach((t,i)=>{if(i>0){let e=a.measureText(" ").width;s+=e}if(t.length>0){let i=t[0],n=t.slice(1),r=a.font,o=h*S;a.font=`${m} ${e} ${o}px "${c}"`,a.fillText(i,s,l);let d=a.measureText(i).width;s+=d,a.font=r,a.fillText(n,s,l);let x=a.measureText(n).width;s+=x}}):a.fillText(i,s,l)}),a.shadowColor="transparent",a.shadowBlur=0,a.shadowOffsetX=0,a.shadowOffsetY=0}else if("image"===t.type||"cross"===t.type||"flower"===t.type||"photo"===t.type){let e=t.screenMode&&t.processedSrc?t.processedSrc:t.src;if(e){let s=await nz(e);if(s){if(t.rotation){let e=i+r/2,s=n+l/2;a.translate(e,s),a.rotate(t.rotation*Math.PI/180),a.translate(-e,-s)}if("photo"===t.type){let e=s.width/s.height,o=r/l,c=r,d=l,h=i,m=n;e>o?(c=l*e,h=i-(c-r)/2):(d=r/e,m=n-(d-l)/2),a.save(),a.rect(i,n,r,l),a.clip(),t.flipHorizontal?(a.translate(h+c,m),a.scale(-1,1),a.drawImage(s,0,0,c,d)):a.drawImage(s,h,m,c,d),a.restore()}else{let e=s.width/s.height,o=r/l,c=r,d=l,h=i,m=n;e>o?(d=r/e,m=n+(l-d)/2):(c=l*e,h=i+(r-c)/2),t.flipHorizontal?(a.translate(h+c,m),a.scale(-1,1),a.drawImage(s,0,0,c,d)):a.drawImage(s,h,m,c,d)}}}}a.restore()}if(e&&g&&d){let e=tl.map(e=>{let t=F(e,d),i=d.monuments[t]??d.monuments[0],n=g.monuments[t]??g.monuments[0],r=P(e,i,n);return{x:r.x,y:r.y,width:r.width,height:r.height}}),t=function(e,t,i,n=[]){let r=[e.pedestal,...e.pedestals??[],...e.monuments,...n],a=Math.min(...r.map(e=>e.x)),l=Math.max(...r.map(e=>e.x+e.width)),s=Math.min(...r.map(e=>e.y)),o=Math.max(...r.map(e=>e.y+e.height)),c=Math.max(12,.035*Math.max(l-a,o-s)),d=Math.max(0,Math.floor(a-c)),h=Math.max(0,Math.floor(s-c));return{x:d,y:h,width:Math.max(1,Math.min(t,Math.ceil(l+c))-d),height:Math.max(1,Math.min(i,Math.ceil(o+c))-h)}}(g,i,n,e);return(function(e,t,i=1200){let{width:n,height:r}=ed(i),a=document.createElement("canvas");a.width=n,a.height=r;let l=a.getContext("2d");if(!l)return a;l.fillStyle="#ffffff",l.fillRect(0,0,n,r);let s=.035*n,o=n-2*s,c=r-2*s,d=Math.min(o/Math.max(t.width,1),c/Math.max(t.height,1)),h=t.width*d,m=t.height*d,x=(n-h)/2;return l.drawImage(e,t.x,t.y,t.width,t.height,x,(r-m)/2,h,m),a})(r,t).toDataURL("image/png")}return r.toDataURL("image/png")}catch(e){return console.error("Preview creation error:",e),null}},nS=(e,t,i)=>{let n=t.split(" "),r=[],a="";for(let t=0;t<n.length;t++){let l=a?a+" "+n[t]:n[t];e.measureText(l).width>i&&""!==a?(r.push(a),a=n[t]):a=l}return a&&r.push(a),r},nk=(e,t,i)=>Promise.race([e,new Promise(e=>setTimeout(()=>e(i),t))]),nC=async e=>{let t=new Map;if(e.forEach(e=>{if(e.fontFamily&&("text"===e.type||"epitaph"===e.type||"fio"===e.type||"dates"===e.type)){let i=e.fontFamily.split("|"),n=i[0],r=i[1],a=i[2];"custom"===r&&a?t.set(n,a):t.set(n,"")}}),0===t.size)return;let i=new Set;e.forEach(e=>{if(e.fontFamily&&("text"===e.type||"epitaph"===e.type||"fio"===e.type||"dates"===e.type)){let t=e.fontFamily.split("|"),n=t[0],r="custom"===t[1]?"normal":t[1]||"400",a=e.italic?"italic":"normal";i.add(`${a}|${r}|${n}`)}});let n=Array.from(t).map(async([e,t])=>{try{if(t){let i=new FontFace(e,`url(${t})`,{featureSettings:"'ss01', 'calt', 'swsh', 'liga', 'dlig'"});await nk(i.load(),5e3,void 0),document.fonts.add(i)}else{let t=Array.from(i).filter(t=>t.endsWith(`|${e}`)).map(t=>{let[i,n]=t.split("|");return`${i} ${n} 24px "${e}"`});0===t.length&&t.push(`400 24px "${e}"`),await nk(Promise.all(t.map(e=>document.fonts.load(e))),5e3,[])}}catch(t){console.warn(`Font load failed ${e}:`,t)}});await Promise.all(n)},nz=async e=>{let t=(e,t=!1)=>new Promise(i=>{let n=new Image;t&&(n.crossOrigin="anonymous"),n.onload=()=>i(n),n.onerror=()=>i(null),n.src=e}),i=e=>new Promise(t=>{let i=new FileReader;i.onloadend=()=>t(i.result),i.onerror=()=>t(null),i.readAsDataURL(e)}),n=C(u.current,e);if(n)return n;if(e.startsWith("data:"))return nk(t(e),1e4,null);let r=S(e);if(k(e)){try{let n=new AbortController,r=setTimeout(()=>n.abort(),15e3),a=await fetch(e,{signal:n.signal});if(clearTimeout(r),a.ok){let e=await a.blob(),n=await i(e);if(n){let e=await nk(t(n),1e4,null);if(e)return e}}}catch{}return nk(t(r),1e4,null)}try{let e=new AbortController,n=setTimeout(()=>e.abort(),2e4),a=await fetch(r,{signal:e.signal});if(clearTimeout(n),!a.ok||!(a.headers.get("content-type")??"").startsWith("image/"))return nk(t(r,!0),1e4,null);let l=await a.blob(),s=await i(l);if(!s)return null;return nk(t(s),1e4,null)}catch{return nk(t(r,!0),1e4,null)}},n$=async()=>
23{if(!i4){i3(!0);try{p({title:"Подготовка эскиза...",description:"Пожалуйста, подождите"});let e=await nM(!0);if(!e)return void p({title:"Ошибка",description:"Не удалось создать превью эскиза",variant:"destructive"});(0,tw.LB)(e),h("/print-order")}catch(e){console.error("Print order error:",e),p({title:"Ошибка",description:"Не удалось открыть форму заказа",variant:"destructive"})}finally{i3(!1)}}},nF=async()=>{if(!i2){if(0===tl.length)return void p({title:"Пустой дизайн",description:"Добавьте элементы на памятник перед отправкой",variant:"destructive"});i5(!0);try{if(p({title:"Создание изображения...",description:"Пожалуйста, подождите"}),!u.current)throw Error("Canvas не найден");await nC(tl);let e=u.current,t=nE.w>0?nE.w:e.offsetWidth,i=nE.h>0?nE.h:Math.round(t/q),n=Math.round(1920/q),r=document.createElement("canvas");r.width=1920,r.height=n;let a=r.getContext("2d");if(!a)throw Error("Не удалось создать контекст Canvas");let l=eu({canvasW:1920,canvasH:n,monumentHeightMm:B,monumentWidthMm:X,pede
23stalHeightMm:eY,pedestalWidthMm:eX,monumentType:eG,monumentGapMm:eZ,sceneMode:eR,showGroundLayers:!eh}),s=eu({canvasW:t,canvasH:i,monumentHeightMm:B,monumentWidthMm:X,pedestalHeightMm:eY,pedestalWidthMm:eX,monumentType:eG,monumentGapMm:eZ,monumentSlotHorizontal:e0,monumentSlotSizes:A,mobile:ie,sceneMode:eR,showGroundLayers:!eh}),o={monumentType:eG,monumentGapMm:eZ,monumentWidthMm:X,monumentHeightMm:B,pedestalWidthMm:eX,pedestalHeightMm:eY,pedestalAnchorPct:eO,aspect1:et,aspect2:en,monumentSlotHorizontal:e0,monumentSlotSizes:A,combinedCatalogImage:!eL&&"single"===eG},c=ex({canvasW:t,canvasH:i,mmPerPx:s,...o}),d=ex({canvasW:1920,canvasH:n,mmPerPx:l,...o});console.log("\uD83D\uDCE5 Загружаем сцену и памятник:",I),await eS(a,1920,n,{monumentType:eG,monumentGapMm:eZ,monumentWidthMm:X,monumentHeightMm:B,mmPerPx:l,pedestalWidthMm:eX,pedestalHeightMm:eY,pedestalAnchorPct:eO,monumentSlotHorizontal:e0,monumentSlotSizes:A,monumentImageSrc:I,monumentImage2Src:eq,monumentFlipHorizontal:e3,monumentFlipHorizontal2:e6,pedestalImageSrc:eL,sceneBackgroundSrc:eh,sceneMode:eR,showSceneDimensions:eT,sceneVaseSides:nA,sceneVaseSrc:nR.src,sceneLampSides:nW,sceneLampSrc:el,sceneFlowerbed:eI,sceneFlowerbedSrc:es.src,loadImage:nz});let{scaleX:h,scaleY:m,fontScale:x}=$(t,i,1920,n);for(let e of(console.log("\uD83D\uDD0D Параметры (экспорт):",{screen:`${t.toFixed(0)}x${i.toFixed(0)}`,export:`1920x${n}`,scaleX:h.toFixed(3),scaleY:m.toFixed(3)}),tl)){a.save();let{x:t,y:i,width:n,height:r,fontScale:l}=E(e,c,d,h,m);if("text"===e.type||"epitaph"===e.type||"fio"===e.type||"dates"===e.type){let s,o=e.fontFamily?.split("|")||["serif","400"],c=o[0],d="custom"===o[1];s=d?"normal":"text"===e.type?o[1]||"bold":o[1]||"400";let h=(e.fontSize||24)*l,m=e.italic?"italic":"normal";a.font=`${m} ${s} ${h}px "${c}"`,a.fillStyle=e.color||"#FFFFFF",d&&(a.fontVariantLigatures="common-ligatures discretionary-ligatures",a.fontFeatureSettings="'ss01', 'calt', 'swsh', 'liga', 'dlig'"),e.letterSpacing?a.letterSpacing=`${e.letterSpacing*l}px`:a.letterSpacing="0px";let x=1.2;"fio"===e.type?x=d?1.6:1.05:"epitaph"===e.type&&(x=1.4);let u=e.lineHeight||x,p=h*u,g="fio"!==e.type?4*l:0,f=n-2*g,w=e.content||"";"dates"===e.type&&(w=w.toUpperCase());let y=w.split("\n"),b=[],v=e.autoSize?1/0:f;y.forEach(e=>{if(""===e.trim())b.push("");else{let t=nS(a,e,v);b.push(...t)}});let j=e.textAlign||"center",N=Math.max(...b.map(e=>a.measureText(e).width),1),M=e.autoSize?N:f,S=b.map(e=>{let i=a.measureText(e).width,n=t;
23return"center"===j?n=t+g+(M-i)/2:"right"===j&&(n=t+g+M-i),{x:n,width:i}});if(a.textBaseline="top",e.rotation){let l=t+n/2,s=i+r/2;a.translate(l,s),a.rotate(e.rotation*Math.PI/180),a.translate(-l,-s)}a.shadowColor="rgba(0,0,0,0.8)",a.shadowBlur=4*l,a.shadowOffsetX=2*l,a.shadowOffsetY=2*l;let k=e.initialScale||1;b.forEach((t,n)=>{let r=Math.round(i+g+n*p),l=Math.round(S[n].x);"fio"===e.type&&k>1&&t.length>0?t.split(/\s+/).forEach((e,t)=>{if(t>0){let e=a.measureText(" ").width;l+=e}if(e.length>0){let t=e[0],i=e.slice(1),n=a.font,o=h*k;a.font=`${m} ${s} ${o}px "${c}"`,a.fillText(t,l,r);let d=a.measureText(t).width;l+=d,a.font=n,a.fillText(i,l,r);let x=a.measureText(i).width;l+=x}}):a.fillText(t,l,r)}),a.shadowColor="transparent",a.shadowBlur=0,a.shadowOffsetX=0,a.shadowOffsetY=0}else if("image"===e.type||"cross"===e.type||"flower"===e.type||"photo"===e.type){let l=e.screenMode&&e.processedSrc?e.processedSrc:e.src;if(l){let s=await nz(l);if(s){if(e.rotation){let l=t+n/2,s=i+r/2;a.translate(l,s),a.rotate(e.rotation*Math.PI/180),a.translate(-l,-s)}if("photo"===e.type){let l=s.width/s.height,o=n/r,c=n,d=r,h=t,m=i;l>o?(c=r*l,h=t-(c-n)/2):(d=n/l,m=i-(d-r)/2),a.save(),a.rect(t,i,n,r),a.clip(),e.flipHorizontal?(a.translate(h+c,m),a.scale(-1,1),a.drawImage(s,0,0,c,d)):a.drawImage(s,h,m,c,d),a.restore()}else{let l=s.width/s.height,o=n/r,c=n,d=r,h=t,m=i;l>o?(d=n/l,m=i+(r-d)/2):(c=r*l,h=t+(n-c)/2),e.flipHorizontal?(a.translate(h+c,m),a.scale(-1,1),a.drawImage(s,0,0,c,d)):a.drawImage(s,h,m,c,d)}}}}a.restore()}console.log("\uD83C\uDFA8 Конвертируем canvas в PNG...");let g=r.toDataURL("image/png"),f=`monument_design_${Date.now()}.png`;console.log("\uD83D\uDCBE Скачиваем файл:",f);let w=document.createElement("a");w.href=g,w.download=f,w.click(),console.log("✅ PNG успешно создан и скачан"),p({title:"Изображение сохранено!",description:`PNG файл (1920x${n}px) скачан на устройство`})}catch(e){console.error("❌ Ошибка создания изображения:",e),p({title:"Ошибка создания изображения",description:e instanceof Error?e.message:"Попробуйте ещё раз",variant:"destructive"})}finally{i5(!1)}}},nP=tl.find(e=>e.id===tH),nE=(0,l.useMemo)(()=>{if(ie)return{w:960,h:960/q};let e=J>0?J:960,t=Z>0?Z:e/q;return{w:e,h:t}},[ie,J,Z]),nI=(0,l.useMemo)(()=>eu({canvasW:nE.w,canvasH:nE.h,monumentHeightMm:B,monumentWidthMm:X,pede
23stalHeightMm:eY,pedestalWidthMm:eX,monumentType:eG,monumentGapMm:eZ,monumentSlotHorizontal:e0,monumentSlotSizes:A,mobile:ie,sceneMode:eR,showGroundLayers:!eh}),[nE.w,nE.h,B,X,eY,eX,eG,eZ,e0,A,ie,eR,eh]),nH=(0,l.useMemo)(()=>nE.w<=0||nE.h<=0?null:ex({canvasW:nE.w,canvasH:nE.h,monumentType:eG,monumentGapMm:eZ,monumentWidthMm:X,monumentHeightMm:B,pedestalWidthMm:eX,pedestalHeightMm:eY,pedestalAnchorPct:eO,mmPerPx:nI,aspect1:et,aspect2:en,monumentSlotHorizontal:e0,monumentSlotSizes:A,combinedCatalogImage:!eL&&"single"===eG}),[nE.w,nE.h,eG,eZ,X,B,eX,eY,eO,nI,et,en,e0,A,eL]),nA=(0,l.useMemo)(()=>{let e=[];return ep&&e.push("left"),ef&&e.push("right"),e},[ep,ef]),nR=(0,l.useMemo)(()=>(function(e="black"){return ea[e]})(ey),[ey]),nW=(0,l.useMemo)(()=>{let e=[];return e$&&e.push("left"),eP&&e.push("right"),e},[e$,eP]),nT=(0,l.useMemo)(()=>ie&&nH&&!(nE.h<=0)?function(e,t,i,n){let r=n?.includePedestal!==!1,a=(n?.vaseSides?.length??0)>0||(n?.lampSides?.length??0)>0,l=!r&&!a&&!n?.includeFlowerbed,s=!a&&!n?.includeFlowerbed,o=r?[i.pedestal,...i.pedestals??[],...i.monuments]:[...i.monuments],c=Math.min(...o.map(e=>e.x)),d=Math.max(...o.map(e=>e.x+e.width)),h=Math.min(...o.map(e=>e.y)),m=Math.max(...o.map(e=>e.y+e.height)),x=d-c,u=Math.max(l?12:s?10:14,x*(l?.06:s?.035:.05)),p=Math.max(l?56:s?52:64,(m-h)*(l?.06:s?.05:.07)),g=t*(n?.includeFlowerbed?.02:l?.035:s?r?.032:.022:.045),f=Math.max(20,.035*t),w=(c+d)/2,y=Math.min(e,Math.max(160,x+2*Math.max(u,l||s?28:32))),b=w-y/2;b<0&&(y=Math.min(y,2*w),b=w-y/2),b+y>e&&(y=Math.min(y,(e-w)*2),b=w-y/2);let v=(b=Math.max(0,Math.min(b,e-y)))+y,j=Math.max(0,h-p),N=Math.min(t,(r?Math.max(m,i.pedestal.y+i.pedestal.height):m)+g);if(n?.includeFlowerbed){var M,S;let r=n.pedestalWidthMm??n.monumentWidthMm??500,a=n.flowerbedWidthMm??(M=r,S=n.monumentWidthMm,M+ej(S,n.monumentHeightMm)),l=eN(i,es.aspect,a,n.pedestalHeightMm,e,t,n.monumentWidthMm,n.monumentHeightMm);N=l.length>0?Math.min(t,Math.max(N,Math.max(...l.map(e=>e.y+e.height))+f)):Math.min(t,Math.max(N,m+.55*(x/es.aspect)+f))}for(let r of[...eb(i,n?.vaseSides??[],n?.vaseAspect??ee.aspect,e),...ev(i,n?.lampSides??[],n?.lampAspect??.62,e)])b=Math.max(0,Math.min(b,r.x-10)),v=Math.min(e,Math.max(v,r.x+r.width+10)),j=Math.max(0,Math.min(j,r.y-10)),N=Math.min(t,Math.max(N,r.y+r.height+10));let k=Math.max(160,v-b),C=Math.max(180,N-j);return{cropTop:j,cropLeft:b,cropWidth:k,cropHeight:C,viewportHeight:C,fitMode:l?"cover":"contain",fitScale:l?.8:1}}(nE.w,nE.h,nH,{includeFlowerbed:eI,includePedestal:!!eL,pedestalWidthMm:eX,pedestalHeightMm:eY,monumentWidthMm:e4.widthMm,monumentHeightMm:e4.heightMm,vaseSides:nA,lampSides:nW,vaseAspect:nR.aspect}):null,[ie,nH,nE.w,nE.h,eI,eL,eX,eY,e4.widthMm,e4.heightMm,nA,nW,nR.aspect]),nD=(0,l.useCallback)(e=>{let t=nH?.monuments[e];if(!t?.width||t.width<=0)return nI;let i=L(eG,e0),n=A[e]??A[0];return _(i[e]??!1,n)/t.width},[nH,eG,e0,A,nI]),nL=(0,l.useMemo)(()=>nD(e2),[nD,e2]),n_=(0,l.useCallback)(e=>{var t,i,n,r;if("text"===e.type){let t=w(e.content);return{widthMm:0,heightMm:0,priceRub:1e3*w(e.content),isFixedPrice:!0,lineCount:t,isTextPrice:!0}}let a=nD(nH?F(e,nH):0),{widthMm:l,heightMm:s}=function(e,t,i,n,r,a="contain"){if("cover"===a)return{widthMm:e*i,heightMm:t*i};let{widthPx:l,heightPx:s}=N(e,t,n,r);return{widthMm:l*i,heightMm:s*i}}(e.width,e.height,a,e.naturalWidth,e.naturalHeight,"photo"===e.type?"cover":"contain"),o="cross"===e.type&&null!=e.fixedPriceRub,c=(t=e.type,i=l,n=s,r=e.fixedPriceRub,"cross"===t&&null!=r?r:Math.max(3500,Math.round(i*n/62370*7e3)));return{widthMm:l,heightMm:s,priceRub:c,isFixedPrice:o}},[nD,nH]),nX=(0,l.useMemo)(()=>nP&&tN(nP.type)?n_(nP):null,[nP,n_]),nB=(0,l.useMemo)(()=>tl.filter(e=>tN(e.type)).map(e=>{let t=n_(e);return{id:e.id,label:"text"===e.type?"Текст":tM[e.type],...t}}),[tl,n_]),nY=(0,l.useMemo)(()=>nB.reduce((e,t)=>e+t.priceRub,0),[nB]),nU=(0,l.useMemo)(()=>({monumentWidthMm:e4.widthMm,monumentHeightMm:e4.heightMm,mmPerPx:nL,sceneMmPerPx:nI,getElementPrice:e=>n_(e).priceRub,getElementSizeMm:e=>({widthMm:n_(e).widthMm,heightMm:n_(e).heightMm})}),[e4,nL,nI,n_]),nO=(0,l.useCallback)((e,t)=>{tk(i=>i.map(i=>
23i.id!==e?i:i.naturalWidth===t.naturalWidth&&i.naturalHeight===t.naturalHeight&&.5>Math.abs(i.width-t.width)&&.5>Math.abs(i.height-t.height)&&0===t.offsetX&&0===t.offsetY?i.naturalWidth?i:{...i,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight}:{...i,x:Math.round(i.x+t.offsetX),y:Math.round(i.y+t.offsetY),width:Math.round(t.width),height:Math.round(t.height),naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight}))},[]);(0,l.useEffect)(()=>{let e=null,t=0,i=()=>{let n=u.current;if(!n){t=requestAnimationFrame(i);return}let r=()=>{if(ie){K(960),Q(960/q);return}let e=Math.round(n.offsetWidth),t=Math.round(n.offsetHeight);e>0&&K(e),t>0&&Q(t)};r(),(e=new ResizeObserver(r)).observe(n)};return i(),()=>{cancelAnimationFrame(t),e?.disconnect()}},[ie,48,q]);let nJ=(0,l.useCallback)((e,t)=>{let i=T(eG)?e2:0;if(R(n=>{let r=[...n];return r[i]={widthMm:e,heightMm:t},r}),0===i){let i=j(e,t);i&&(eB(i.pedestalWidthMm),eU(ec(i.pedestalWidthMm)))}D(eG)&&ti("single")},[ti,eG,e2]);return(0,n.jsxs)("div",{className:"h-screen w-screen bg-[#111] text-foreground flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"fixed left-0 right-0 top-0 h-12 flex-shrink-0 bg-[#1a1a1a] flex items-center px-3 gap-1 z-50",children:[(0,n.jsxs)(r.$,{variant:"ghost",size:"sm",onClick:()=>{if(b){if(y.current?.())return;if(tH)return void tA(null)}h(b?"/constructor":"/")},className:"h-8 px-2 text-white/70 hover:text-white hover:bg-white/10",children:[(0,n.jsx)(a.A,{name:"ArrowLeft",size:16,className:"mr-1"}),(0,n.jsx)("span",{className:"text-xs",children:"Назад"})]}),(0,n.jsx)("div",{className:"w-px h-5 bg-white/10 mx-1"}),(0,n.jsx)(r.$,{variant:"ghost",size:"sm",onClick:t$,disabled:!tc,title:"Отменить (Ctrl+Z)",className:"h-8 w-8 p-0 flex-shrink-0 text-white/70 hover:text-white hover:bg-white/10 disabled:opacity-30",children:(0,n.jsx)(a.A,{name:"Undo2",size:15})}),(0,n.jsx)(r.$,{variant:"ghost",size:"sm",onClick:tF,disabled:!th,title:"Вернуть (Ctrl+Y)",className:"h-8 w-8 p-0 flex-shrink-0 text-white/70 hover:text-white hover:bg-white/10 disabled:opacity-30",children:(0,n.jsx)(a.A,{name:"Redo2",size:15})}),(0,n.jsx)("div",{className:"w-px h-5 bg-white/10 mx-1"}),(0,n.jsx)("span",{className:"text-xs font-semibold text-primary tracking-widest uppercase hidden sm:block",children:"Конструктор"}),(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)(s.N_,{to:o.C_,className:"hidden sm:inline text-[10px] text-white/40 hover:text-white/70 mr-2 shrink-0",children:"Правовая информация"}),(0,n.jsxs)(r.$,{variant:"ghost",size:"sm",onClick:nj,title:"Сохранить проект",className:"h-8 px-2 sm:px-3 flex-shrink-0 text-white/70 hover:text-white hover:bg-white/10 text-xs gap-1.5",children:[(0,n.jsx)(a.A,{name:"Save",size:14}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Сохранить проект"})]}),(0,n.jsxs)(r.$,{variant:"ghost",size:"sm",onClick:nw,disabled:i2,title:"Скачать PNG (с метаданными проекта)",className:"h-8 px-2 sm:px-3 flex-shrink-0 text-white/70 hover:text-white hover:bg-white/10 text-xs gap-1.5",children:[(0,n.jsx)(a.A,{name:"Image",size:14}),(0,n.jsx)("span",{className:"hidden sm:inline",children:i2?"Создаю...":"Скачать PNG"})]}),(0,n.jsxs)(r.$,{variant:"ghost",size:"sm",onClick:ny,disabled:i2,title:"Скачать JPG (максимальное качество)",className:"h-8 px-2 sm:px-3 flex-shrink-0 text-white/70 hover:text-white hover:bg-white/10 text-xs gap-1.5",children:[(0,n.jsx)(a.A,{name:"FileImage",size:14}),(0,n.jsx)("span",{className:"hidden sm:inline",children:i2?"Создаю...":"Скачать JPG"})]}),(0,n.jsxs)("label",{className:"cursor-pointer flex-shrink-0",title:"Загрузить эскиз",children:[(0,n.jsx)("input",{ref:id,type:"file",accept:".json,.png",onChange:nN,className:"hidden"}),(0,n.jsxs)("div",{className:"h-8 px-2 sm:px-3 inline-flex items-center gap-1.5 text-xs text-white/70 hover:text-white hover:bg-white/10 rounded-md transition-colors cursor-pointer",children:[(0,n.jsx)(a.A,{name:"Upload",size:14}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Загрузить эскиз"})]})]}),g&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"w-px h-5 bg-white/10 mx-1 flex-shrink-0"}),(0,n.jsxs)(r.$,{size:"sm",onClick:n$,disabled:i4,className:"h-8 px-2 sm:px-3 flex-shrink-0 text-xs gap-1.5",children:[(0,n.jsx)(a.A,{name:"FileText",size:14}),(0,n.jsx)("span",{className:"hidden sm:inline",children:i4?"Подготовка...":"Оформить заказ"})]})]})]}),(0,n.jsxs)("div",{className:"flex overflow-hidden fixed right-0",style:{to
23p:48,left:b?"0":ie?"48px":"0",bottom:b?tH?"calc(56px + 48px + env(safe-area-inset-bottom, 0px) + var(--constructor-vv-bottom, 0px))":"calc(56px + env(safe-area-inset-bottom, 0px) + var(--constructor-vv-bottom, 0px))":0},children:[(0,n.jsx)("div",{className:"hidden lg:flex flex-shrink-0 w-[380px] border-r border-white/10 bg-[#181818] flex-col overflow-hidden",children:(0,n.jsx)(eA,{monumentImage:I,setMonumentImage:ta,addTextElement:ni,addEpitaphElement:nl,addImageElement:nn,addFIOElement:ns,addDatesElement:no,applyInscriptionTemplate:nc,handlePhotoUpload:nh,photoInputRef:ic,surname:tq,setSurname:tK,name:tZ,setName:tQ,patronymic:t0,setPatronymic:t1,selectedFont:t2,setSelectedFont:t5,birthDate:t4,setBirthDate:t3,deathDate:t8,setDeathDate:t6,selectedDateFont:is,setSelectedDateFont:io,catalogCategories:ip,catalogProducts:iw,selectedCategory:ib,setSelectedCategory:iv,isLoadingCatalog:ij,loadCatalog:i8,fonts:ne,crosses:iM,isLoadingCrosses:ik,loadCrosses:i6,flowers:iz,isLoadingFlowers:iF,loadFlowers:i9,layoutTool:{monumentWidthMm:e4.widthMm,monumentHeightMm:e4.heightMm,monumentSizeSlotLabel:T(eG)?0===e2?"Левая подставка":"Правая подставка":void 0,onMonumentSizeChange:nJ,mmPerPx:nL,selectedLayout:nX,engravingItems:nB,totalEngravingPrice:nY},sceneTool:{monumentType:eG,setMonumentType:ti,activeMonumentSlot:e2,setActiveMonumentSlot:e5,selectMonumentFromCatalog:ta,monumentImage2:eq,setMonumentImage2:eK,monumentGapMm:eZ,setMonumentGapMm:eQ,monumentSlotHorizontal:e0,toggleMonumentSlotHorizontal:tr,monumentSlotSizes:A,pedestalImage:eL,setPedestalImage:e_,pedestalWidthMm:eX,setPedestalWidthMm:eB,pedestalHeightMm:eY,setPedestalHeightMm:eU,pedestalAnchorPct:eO,setPedestalAnchorPct:eJ,sceneBackgroundImage:eh,setSceneBackgroundImage:em,sceneMode:eR,setSceneMode:eW,showSceneDimensions:eT,setShowSceneDimensions:eD,catalogProducts:iw,selectedCategory:ib,setSelectedCategory:iv,monumentImage:I,monumentFlipHorizontal:e3,monumentFlipHorizontal2:e6,toggleMonumentFlip:e7,sceneVaseLeft:ep,setSceneVaseLeft:eg,sceneVaseRight:ef,setSceneVaseRight:ew,sceneVaseVariant:ey,setSceneVaseVariant:eM,sceneLampLeft:e$,setSceneLampLeft:eF,sceneLampRight:eP,setSceneLampRight:eE,sceneFlowerbed:eI,setSceneFlowerbed:eH}})}),(0,n.jsxs)("div",{className:`flex-1 min-w-0 flex flex-col relative ${"studio"===eR&&!eh?"":"bg-[#111]"}`,style:"studio"!==eR||eh?void 0:{backgroundColor:Y},children:[(0,n.jsx)("div",{"data-constructor-stage":!0,className:`flex-1 flex justify-center overflow-hidden min-h-0 w-full ${ie||"studio"===eR&&!eh?"items-stretch":"items-start"}`,style:"studio"!==eR||eh?void 0:{backgroundColor:Y},children:(0,n.jsx)(te,{canvasRef:u,monumentImage:I,elements:tl,selectedElement:tH,setSelectedElement:tA,rotateMode:tX,handleMouseDown:(e,t)=>{e.stopPropagation(),tA(t),tP.current=!0,tW(!0);let i=tl.find(e=>e.id===t);if(!i||!u.current)return;let n=u.current.getBoundingClientRect(),r=(e.clientX-n.left-n.width/2)/iH-iT.x/iH+n.width/2,a=(e.clientY-n.top-n.height/2)/iH-iT.y/iH+n.height/2;tU({x:r-i.x,y:a-i.y})},handleTouchStart:(e,t)=>{e.stopPropagation(),tA(t);let i=tl.find(e=>e.id===t);if(!i)return;if(2===e.touches.length){let t=e.touches[0],n=e.touches[1];im({angle:Math.atan2(n.clientY-t.clientY,n.clientX-t.clientX)*(180/Math.PI),rotation:i.rotation||0}),iu({distance:Math.sqrt(Math.pow(n.clientX-t.clientX,2)+Math.pow(n.clientY-t.clientY,2)),width:i.width,height:i.height,fontSize:i.fontSize||24});return}if(!u.current)return;tP.current=!0,tW(!0);let n=e.touches[0],r=u.current.getBoundingClientRect(),a=(n.clientX-r.left-r.width/2)/iH-iT.x/iH+r.width/2,l=(n.clientY-r.top-r.height/2)/iH-iT.y/iH+r.height/2;tU({x:a-i.x,y:l-i.y})},handleDoubleClick:e=>{let t=tl.find(t=>t.id===e);t&&["text","epitaph","fio","dates"].includes(t.type)&&(i1.current=tg.current.map(e=>({...e})),tA(e),il(e))},handleSingleClick:e=>{},handleMouseMove:e=>{if(u.current){if(iL&&!tH)return void iD({x:e.clientX-iX.x,y:e.clientY-iX.y});if(tH){if(tL){let t=u.current.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top,r=i-tG.centerX,a=180/Math.PI*Math.atan2(n-tG.centerY,r),l=tG.x-tG.centerX,s=180/Math.PI*Math.atan2(tG.y-tG.centerY,l),o=tG.rotation+(a-s)/3;tk(e=>e.map(e=>e.id===tH?{...e,rotation:Math.round(o)}:e))}else if(tT){let t=(e.clientX-tO.x)/iH,i=(e.clientY-tO.y)/iH,n=tl.find(e=>e.id===tH);if(n&&("text"===n.type||"epitaph"===n.type||"fio"===n.type||"dates"===n.type)){let e=Math.max(50,tO.width+t),n=Math.max(30,tO.height+i),r=Math.min(e/tO.width,n/tO.height),a=Math.max(8,Math.min(72,Math.round(tO.fontSize*r)));tk(t=>t.map(t=>
23t.id===tH?{...t,width:e,height:n,fontSize:a}:t))}else if(n&&tj(n.type)){let e=tS(n,tO,t,i);tk(t=>t.map(t=>t.id===tH?{...t,width:e.width,height:e.height,x:e.x,y:e.y}:t))}else{let e=Math.max(50,tO.width+t),n=Math.max(30,tO.height+i);tk(t=>t.map(t=>t.id===tH?{...t,width:e,height:n}:t))}}else if(tR){let t=u.current.getBoundingClientRect(),i=(e.clientX-t.left-t.width/2)/iH-iT.x/iH+t.width/2,n=(e.clientY-t.top-t.height/2)/iH-iT.y/iH+t.height/2,r=i-tY.x,a=n-tY.y,l=t.width/iH,s=t.height/iH;tk(e=>e.map(e=>e.id===tH?{...e,x:Math.max(-l,Math.min(r,2*l)),y:Math.max(-s,Math.min(a,2*s))}:e))}}}},handleMouseUp:()=>{(tP.current||tE.current||tI.current)&&tz(),tP.current=!1,tE.current=!1,tI.current=!1,tW(!1),tD(!1),t_(!1),i_(!1)},handleTouchMove:e=>{if(!u.current)return;if(2===e.touches.length&&!tH&&iR){e.preventDefault();let t=e.touches[0],i=e.touches[1],n=Math.sqrt(Math.pow(i.clientX-t.clientX,2)+Math.pow(i.clientY-t.clientY,2))/iR.distance;iA(Math.max(1,Math.min(3,iR.zoom*n)));return}if(1===e.touches.length&&iL&&!tH){e.preventDefault();let t=e.touches[0];iD({x:t.clientX-iX.x,y:t.clientY-iX.y});return}if(!tH)return;if(2===e.touches.length&&ih&&ix){let t=e.touches[0],i=e.touches[1],n=Math.atan2(i.clientY-t.clientY,i.clientX-t.clientX)*(180/Math.PI)-ih.angle,r=ih.rotation+n,a=Math.sqrt(Math.pow(i.clientX-t.clientX,2)+Math.pow(i.clientY-t.clientY,2))/ix.distance,l=Math.max(50,ix.width*a),s=Math.max(30,ix.height*a),o=tl.find(e=>e.id===tH);if(o&&("text"===o.type||"epitaph"===o.type||"fio"===o.type||"dates"===o.type)){let e=Math.max(8,Math.min(72,Math.round(ix.fontSize*a)));tk(t=>t.map(t=>t.id===tH?{...t,rotation:Math.round(r),width:l,height:s,fontSize:e}:t))}else tk(e=>e.map(e=>e.id===tH?{...e,rotation:Math.round(r),width:l,height:s}:e));return}let t=e.touches[0];if(tL){let e=u.current.getBoundingClientRect(),i=t.clientX-e.left,n=t.clientY-e.top,r=i-tG.centerX,a=180/Math.PI*Math.atan2(n-tG.centerY,r),l=tG.x-tG.centerX,s=180/Math.PI*Math.atan2(tG.y-tG.centerY,l),o=tG.rotation+(a-s)/3;tk(e=>e.map(e=>e.id===tH?{...e,rotation:Math.round(o)}:e))}else if(tT){let e=(t.clientX-tO.x)/iH,i=(t.clientY-tO.y)/iH,n=tl.find(e=>e.id===tH);if(n&&("text"===n.type||"epitaph"===n.type||"fio"===n.type||"dates"===n.type)){let t=Math.max(50,tO.width+e),n=Math.max(30,tO.height+i),r=Math.min(t/tO.width,n/tO.height),a=Math.max(8,Math.min(72,Math.round(tO.fontSize*r)));tk(e=>e.map(e=>e.id===tH?{...e,width:t,height:n,fontSize:a}:e))}else if(n&&tj(n.type)){let t=tS(n,tO,e,i);tk(e=>e.map(e=>e.id===tH?{...e,width:t.width,height:t.height,x:t.x,y:t.y}:e))}else{let t=Math.max(50,tO.width+e),n=Math.max(30,tO.height+i);tk(e=>e.map(e=>e.id===tH?{...e,width:t,height:n}:e))}}else if(tR){let e=u.current.getBoundingClientRect(),i=(t.clientX-e.left-e.width/2)/iH-iT.x/iH+e.width/2,n=(t.clientY-e.top-e.height/2)/iH-iT.y/iH+e.height/2,r=i-tY.x,a=n-tY.y,l=e.width/iH,s=e.height/iH;tk(e=>e.map(e=>e.id===tH?{...e,x:Math.max(-l,Math.min(r,2*l)),y:Math.max(-s,Math.min(a,2*s))}:e))}},handleTouchEnd:()=>{(tP.current||tE.current||tI.current)&&tz(),tP.current=!1,tE.current=!1,tI.current=!1,tW(!1),tD(!1),t_(!1),im(null),iu(null),iW(null),i_(!1)},handleResizeMouseDown:(e,t,i="se")=>{e.stopPropagation();let n=tl.find(e=>e.id===t);if(n&&u.current)if(tA(t),tX&&!tj(n.type)){let t=u.current.getBoundingClientRect();tI.current=!0,t_(!0),tV({x:e.clientX-t.left,y:e.clientY-t.top,rotation:n.rotation||0,centerX:n.x+n.width/2,centerY:n.y+n.height/2})}else tE.current=!0,tD(!0),tJ({x:e.clientX,y:e.clientY,width:n.width,height:n.height,fontSize:n.fontSize||24,elemX:n.x,elemY:n.y,handle:i})},handleResizeTouchStart:(e,t,i="se")=>{e.stopPropagation();let n=tl.find(e=>e.id===t);if(!n||!u.current)return;let r=e.touches[0];if(tA(t),tX&&!tj(n.type)){let e=u.current.getBoundingClientRect();tI.current=!0,t_(!0),tV({x:r.clientX-e.left,y:r.clientY-e.top,rotation:n.rotation||0,centerX:n.x+n.width/2,centerY:n.y+n.height/2})}else tE.current=!0,tD(!0),tJ({x:r.clientX,y:r.clientY,width:n.width,height:n.height,fontSize:n.fontSize||24,elemX:n.x,elemY:n.y,handle:i})},handleRotateMouseDown:(e,t)=>{e.stopPropagation();let i=tl.find(e=>e.id===t);if(!i||!u.current)return;let n=u.current.getBoundingClientRect();tA(t),tI.current=!0,t_(!0),tV({x:e.clientX-n.left,y:e.clientY-n.top,rotation:i.rotation||0,centerX:i.x+i.width/2,centerY:i.y+i.height/2})},handleRotateTouchStart:(e,t)=>{e.stopPropagation();let i=tl.find(e=>e.id===t);if(!i||!u.current)return;let n=e.touches[0],r=u.current.getBoundingClientRect();
23tA(t),tI.current=!0,t_(!0),tV({x:n.clientX-r.left,y:n.clientY-r.top,rotation:i.rotation||0,centerX:i.x+i.width/2,centerY:i.y+i.height/2})},toggleRotateMode:()=>{tB(!tX)},setElements:tk,saveDesign:()=>{if(0===tl.length)return void p({title:"Пустой дизайн",description:"Добавьте элементы на памятник",variant:"destructive"});try{let e={monumentImage:I,elements:tl,timestamp:Date.now()},t=JSON.parse(localStorage.getItem("monumentDesigns")||"[]");t.push(e);let i=JSON.stringify(t);localStorage.setItem("monumentDesigns",i),M(t),p({title:"Дизайн сохранен",description:"Проект сохранен в браузере"})}catch(e){console.error("❌ Ошибка сохранения:",e),p({title:"Ошибка сохранения",description:e instanceof Error?e.message:"Не удалось сохранить дизайн",variant:"destructive"})}},sendForCalculation:nF,exportDesign:nj,exportDesignAsPNG:nw,isSaving:i2,importDesign:nN,importInputRef:id,inlineEditingId:ia,handleInlineTextChange:(e,t,i)=>{tk(i=>i.map(i=>i.id===e?{...i,content:t}:i))},handleInlineEditBlur:e=>{if(!ia){i1.current=null,il(null);return}if(e){let t=tg.current.find(e=>e.id===ia);t?.autoSize&&tk(t=>t.map(t=>t.id===ia?{...t,width:Math.round(e.width),height:Math.round(e.height)}:t))}let t=i1.current;if(t){let e=t.find(e=>e.id===ia),i=tg.current.find(e=>e.id===ia),n=(e?.content??"")!==(i?.content??""),r=!!e?.autoSize&&(e?.width!==i?.width||e?.height!==i?.height);if(n||r){tp.current.past=[...tp.current.past,t].slice(-50),tp.current.future=[],td(!0),tx(!1);try{localStorage.setItem("constructor_design",JSON.stringify(tg.current))}catch(e){}}}i1.current=null,il(null)},canvasZoom:iH,onCanvasDoubleClick:()=>{iA(1===iH?2:1),iD({x:0,y:0})},onCanvasTouchStart:e=>{if(2!==e.touches.length||tH){if(1===e.touches.length&&iH>1&&!tH){let t=e.touches[0];i_(!0),iB({x:t.clientX-iT.x,y:t.clientY-iT.y})}}else{e.preventDefault();let t=e.touches[0],i=e.touches[1];iW({distance:Math.sqrt(Math.pow(i.clientX-t.clientX,2)+Math.pow(i.clientY-t.clientY,2)),zoom:iH})}},canvasPan:iT,onCanvasMouseDown:e=>{iH>1&&!tH&&(i_(!0),iB({x:e.clientX-iT.x,y:e.clientY-iT.y}))},updateElement:nm,onPrintOrder:n$,topOffset:48,inlineEraserElementId:iG,onStartInlineErase:e=>iV(e),onStopInlineErase:()=>iV(null),onSaveInlineErase:ng,inlineEraserBrushSize:iq,onChangeInlineEraserBrushSize:iK,inlineEraserHardness:iZ,onZoomChange:e=>{iA(e),1===e&&iD({x:0,y:0})},onCanvasDragOver:nr,onCanvasDrop:na,canvasAspectRatio:q,layoutOverlay:nU,monumentType:eG,monumentImage2:eq,monumentGapMm:eZ,monumentSlotHorizontal:e0,monumentSlotSizes:A,monumentWidthMm:X,monumentHeightMm:B,pedestalImage:eL,sceneBackgroundImage:eh,sceneMode:eR,showSceneDimensions:eT,pedestalWidthMm:eX,pedestalHeightMm:eY,pedestalAnchorPct:eO,monumentFlipHorizontal:e3,monumentFlipHorizontal2:e6,sceneVaseSides:nA,sceneVaseSrc:nR.src,sceneLampSides:nW,sceneLampSrc:el,sceneFlowerbed:eI,sceneFlowerbedSrc:es.src,mobileSceneCrop:nT,sceneCanvasWidth:nE.w,sceneCanvasHeight:nE.h,bottomChromePx:b?56:void 0,onFitImageContent:nO})}),(0,n.jsxs)("div",{className:"hidden lg:flex flex-shrink-0 justify-end items-center gap-2 bg-[#111] border-t border-white/5 px-2 py-1.5 z-30",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 bg-black/60 rounded px-2 py-1",children:[(0,n.jsx)("button",{onClick:()=>{iA(1),iD({x:0,y:0})},className:"text-white/60 hover:text-white transition-colors",title:"Сбросить масштаб",children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,n.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),(0,n.jsx)("input",{type:"range",min:1,max:4,step:.1,value:iH,onChange:e=>{let t=Number(e.target.value);iA(t),1===t&&iD({x:0,y:0})},className:"w-24",style:{accentColor:"hsl(var(--primary))"}}),(0,n.jsx)("button",{onClick:()=>iA(e=>Math.min(e+.5,4)),className:"text-white/60 hover:text-white transition-colors",title:"Увеличить",children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,n.jsx)("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),(0,n.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),(0,n.jsxs)("span",{className:"text-white/50 text-xs w-9 text-center",children:[Math.round(100*iH),"%"]})]}),(0,n.jsx)("button",{onClick:()=>tk([]),className:"h-7 w-7 rounded bg-black/60 hover:bg-red-900/80 text-white/70 hover:text-white flex items-center justify-center transition-colors",title:"Очистить холст",children:(0,n.jsx)(a.A,{name:"Trash2",size:14})})]})]}),(0,n.jsx)("div",{className:"hidden lg:flex flex-shrink-0 w-[280px] border-l border-white/10 bg-[#181818] flex-col overflow-hidden",children:(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsx)("div",{className:"flex-shrink-0 overflow-y-auto",style:{maxHeight:"60%"},children:(0,n.jsx)(tt,{selectedEl:nP,updateElement:nm,deleteElement:nx,fonts:ne,onEditImage:nu,eraserBrushSize:iq,onEraserBrushSizeChange:iK,eraserHardness:iZ,onEraserHardnessChange:iQ,layoutInfo:nX?{...nX,mmPerPx:nL}:null})}),(0,n.jsx)("div",{className:"flex-1 border-t border-white/10 overflow-hidden flex flex-col min-h-0",children:(0,n.jsx)(tf,{elements:tl,selectedElement:tH,setSelectedElement:tA,onMoveUp:e=>{tC(t=>{let i=t.findIndex(t=>t.id===e);if(i<0||i>=t.length-1)return t;let n=[...t];return[n[i],n[i+1]]=[n[i+1],n[i]],n})},onMoveDown:e=>{tC(t=>{let i=t.findIndex(t=>t.id===e);if(i<=0)return t;let n=[...t];return[n[i],n[i-1]]=[n[i-1],n[i]],n})},onMoveToFront:e=>{tC(t=>{let i=t.find(t=>
23t.id===e);return i?[...t.filter(t=>t.id!==e),i]:t})},onMoveToBack:e=>{tC(t=>{let i=t.find(t=>t.id===e);return i?[i,...t.filter(t=>t.id!==e)]:t})},onDelete:nx})})]})})]}),(0,n.jsx)(tn,{isOpen:t9,onClose:()=>{t7(!1),ir(null)},editingElement:ii,setEditingElement:ir,onApply:e=>{ii&&(nm(ii.id,e),t7(!1),ir(null),iA(1),iD({x:0,y:0}))},fonts:ne}),(0,n.jsx)(tu,{isOpen:iY,onClose:()=>{iU(!1),iJ(null)},imageUrl:nf,onSave:np}),(0,n.jsx)(to,{selectedEl:nP,updateElement:nm,deleteElement:nx,fonts:ne,uxMode:i,onClearSelection:()=>tA(null),onOpenEraser:()=>{tH&&nu(tH)},canErase:!!nP&&("image"===nP.type||"photo"===nP.type||"cross"===nP.type||"flower"===nP.type)}),(0,n.jsx)(tm,{uxMode:i,hasSelection:!!tH,onClearSelection:()=>tA(null),registerCloseHandler:e=>{y.current=e},addTextElement:ni,addEpitaphElement:nl,addFIOElement:ns,addDatesElement:no,applyInscriptionTemplate:nc,handlePhotoUpload:nh,photoInputRef:ic,surname:tq,setSurname:tK,name:tZ,setName:tQ,patronymic:t0,setPatronymic:t1,selectedFont:t2,setSelectedFont:t5,birthDate:t4,setBirthDate:t3,deathDate:t8,setDeathDate:t6,selectedDateFont:is,setSelectedDateFont:io,fonts:ne,crosses:iM,isLoadingCrosses:ik,flowers:iz,isLoadingFlowers:iF,addImageElement:nn,monumentImage:I,setMonumentImage:ta,catalogCategories:ip,catalogProducts:iw,selectedCategory:ib,setSelectedCategory:iv,isLoadingCatalog:ij,loadCatalog:i8,monumentWidthMm:e4.widthMm,monumentHeightMm:e4.heightMm,onMonumentSizeChange:nJ,scenePedestal:!!eL,onScenePedestalChange:e=>{e?(e_(eo.src),eB(eo.widthMm),eU(eo.heightMm)):(e_(null),eH(!1))},sceneFlowerbed:eI,onSceneFlowerbedChange:eH,canToggleFlowerbed:!!eL&&!eh,sceneVaseLeft:ep,sceneVaseRight:ef,onSceneVaseLeftChange:eg,onSceneVaseRightChange:ew,sceneVaseVariant:ey,onSceneVaseVariantChange:eM,sceneLampLeft:e$,sceneLampRight:eP,onSceneLampLeftChange:eF,onSceneLampRightChange:eE,canToggleSceneProps:!eh})]})}},54713:(e,t,i)=>{i.d(t,{Hh:()=>d,Jh:()=>x,UP:()=>c,dH:()=>m,ek:()=>o,hY:()=>h,k1:()=>s,me:()=>u,q4:()=>l,sZ:()=>r});var n=i(40980);let r="#F39200",a="shop-module-texture",l="overflow-hidden rounded-2xl border border-white/[0.08] shadow-[inset_0_1px_0_rgba(255,255,255,0.05),0_6px_20px_rgba(0,0,0,0.28)]",s="relative aspect-square overflow-hidden bg-[#2E2A29]",o="mx-auto h-full w-full max-h-full max-w-full object-contain p-4 md:p-5",c=(0,n.cn)("border-t border-white/[0.06]",a),d=(0,n.cn)(l,a),h=(0,n.cn)("rounded-xl border border-white/[0.08] shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] p-4 md:p-5",a),m=(0,n.cn)("rounded-xl border transition-all",a);function x(e,t=!0){let i="number"==typeof e?e:parseFloat(e),n=Number.isFinite(i)?i.toLocaleString("ru-RU"):String(e);return`${t?"от ":""}${n} ₽`}function u(e){let t=e.constructor_image_url?.trim();return t||e.image_url?.trim()||null}},81477:(e,t,i)=>{i.d(t,{BT:()=>c,Wu:()=>d,ZB:()=>o,Zp:()=>l,aR:()=>s});var n=i(95155),r=i(12115),a=i(40980);let l=r.forwardRef(({className:e,...t},i)=>(0,n.jsx)("div",{ref:i,className:(0,a.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));l.displayName="Card";let s=r.forwardRef(({className:e,...t},i)=>(0,n.jsx)("div",{ref:i,className:(0,a.cn)("flex flex-col space-y-1.5 p-6",e),...t}));s.displayName="CardHeader";let o=r.forwardRef(({className:e,...t},i)=>(0,n.jsx)("h3",{ref:i,className:(0,a.cn)("text-2xl font-semibold leading-none tracking-tight",e),...t}));o.displayName="CardTitle";let c=r.forwardRef(({className:e,...t},i)=>(0,n.jsx)("p",{ref:i,className:(0,a.cn)("text-sm text-muted-foreground",e),...t}));c.displayName="CardDescription";let d=r.forwardRef(({className:e,...t},i)=>(0,n.jsx)("div",{ref:i,className:(0,a.cn)("p-6 pt-0",e),...t}));d.displayName="CardContent",r.forwardRef(({className:e,...t},i)=>(0,n.jsx)("div",{ref:i,className:(0,a.cn)("flex items-center p-6 pt-0",e),...t})).displayName="CardFooter"},84675:(e,t,i)=>{i.d(t,{KY:()=>a,LB:()=>r});let n="constructor-print-order-preview";function r(e){sessionStorage.setItem(n,e)}function a(){let e=sessionStorage.getItem(n);return e&&sessionStorage.removeItem(n),e}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.