@thibezer/ui-components-kit 2.24.1 → 2.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/dist/botao.cjs +12 -1
  3. package/dist/botao.js +162 -3
  4. package/dist/camadas.cjs +311 -1
  5. package/dist/camadas.js +3244 -148
  6. package/dist/campo-texto.cjs +16 -1
  7. package/dist/campo-texto.js +308 -7
  8. package/dist/canvas.cjs +22 -22
  9. package/dist/canvas.js +230 -233
  10. package/dist/card.cjs +20 -1
  11. package/dist/card.js +145 -2
  12. package/dist/components/ui-canvas-prancha/index.d.ts +1 -1
  13. package/dist/components/ui-canvas-prancha/prancha-teclado.d.ts +18 -0
  14. package/dist/components/ui-canvas-prancha/ui-canvas-prancha-base.d.ts +4 -0
  15. package/dist/components/ui-editor-prancha/editor-modos.d.ts +10 -0
  16. package/dist/components/ui-editor-prancha/editor-tipos.d.ts +4 -0
  17. package/dist/components/ui-editor-prancha/index.d.ts +1 -0
  18. package/dist/components/ui-editor-prancha/ui-editor-prancha.d.ts +39 -6
  19. package/dist/core.cjs +1 -1
  20. package/dist/core.js +44 -55
  21. package/dist/{cores-utils-BrdynxRd.js → cores-utils-DMyqWvZh.js} +2 -2
  22. package/dist/cores.cjs +32 -1
  23. package/dist/cores.js +300 -13
  24. package/dist/custom-elements.json +1712 -1205
  25. package/dist/data.cjs +28 -1
  26. package/dist/data.js +286 -99
  27. package/dist/{feature_caixa-2Sxv3tGa.js → feature_caixa-BVc5LenS.js} +42 -42
  28. package/dist/{feature_desenho-BVHivWIB.js → feature_desenho-CC8Mp5Gp.js} +2 -2
  29. package/dist/feedback.cjs +52 -1
  30. package/dist/feedback.js +655 -25
  31. package/dist/forms.cjs +66 -1
  32. package/dist/forms.js +1216 -39
  33. package/dist/{geometria-px-DUs5FgLE.js → geometria-px-DHMPUsxC.js} +47 -47
  34. package/dist/index.cjs +67 -1
  35. package/dist/index.js +1476 -274
  36. package/dist/kit-base-CGqj9aiD.cjs +2 -0
  37. package/dist/kit-base-_THn4w3u.js +1079 -0
  38. package/dist/mapa.cjs +5 -5
  39. package/dist/mapa.js +16 -17
  40. package/dist/modal.cjs +18 -1
  41. package/dist/modal.js +235 -29
  42. package/dist/motor.js +49 -49
  43. package/dist/prancha-nucleo.cjs +3 -1
  44. package/dist/prancha-nucleo.js +3120 -277
  45. package/dist/prancha.cjs +38 -1
  46. package/dist/prancha.js +3233 -228
  47. package/dist/register.cjs +1 -1
  48. package/dist/register.js +3 -20
  49. package/dist/seletor-mapa-base.cjs +13 -13
  50. package/dist/seletor-mapa-base.js +3 -5
  51. package/dist/tabela.cjs +142 -1
  52. package/dist/tabela.js +3773 -92
  53. package/dist/tipos-elementos.d.ts +5 -1
  54. package/dist/tipos-vue.d.ts +4 -1
  55. package/dist/tools.cjs +16 -1
  56. package/dist/tools.js +1564 -26
  57. package/dist/ui-seletor-cor-BGw8SBPm.cjs +83 -0
  58. package/dist/{ui-seletor-cor-Cd8jkzXG.js → ui-seletor-cor-B_twSm-V.js} +8 -9
  59. package/dist/utils-ClVgqVyJ.cjs +1 -0
  60. package/dist/utils-DrHoxxmf.js +83 -0
  61. package/package.json +43 -2
  62. package/dist/acessibilidade-CSzX-DkG.cjs +0 -1
  63. package/dist/acessibilidade-CUlSXc2X.js +0 -38
  64. package/dist/altura-controle-ukMRPckR.cjs +0 -1
  65. package/dist/altura-controle-vxQiXG4q.js +0 -62
  66. package/dist/alvo-digitavel-CzCvNVQ3.js +0 -23
  67. package/dist/alvo-digitavel-DbH0hYFf.cjs +0 -1
  68. package/dist/degrade-CIxvOTUv.cjs +0 -1
  69. package/dist/degrade-gDa5sW__.js +0 -119
  70. package/dist/feature_caixa-CnYPKVFS.cjs +0 -1
  71. package/dist/feature_caixa-DCs9ZeSk.js +0 -1038
  72. package/dist/feature_historico-BAIYk1Me.cjs +0 -3
  73. package/dist/feature_historico-C4h9y5fu.js +0 -3039
  74. package/dist/form-atalhos-7JTYvumA.cjs +0 -1
  75. package/dist/form-atalhos-DDTlpgaB.js +0 -203
  76. package/dist/form-erros-CwPz7Jr4.cjs +0 -1
  77. package/dist/form-erros-DT5HklfD.js +0 -184
  78. package/dist/form-submissao-C-SPRKgT.js +0 -61
  79. package/dist/form-submissao-DxKO5MHI.cjs +0 -1
  80. package/dist/form-validacao-BlQFxUVj.js +0 -104
  81. package/dist/form-validacao-DIeyQVH5.cjs +0 -1
  82. package/dist/geometria-px-DKrWq_XY.js +0 -639
  83. package/dist/leaflet-CEPcxGWV.cjs +0 -1
  84. package/dist/leaflet-DOq10gfg.js +0 -84
  85. package/dist/leaflet-loader-94z5VsdY.cjs +0 -2
  86. package/dist/leaflet-loader-Cjcdgj5R.js +0 -21
  87. package/dist/listener-bag-D5omxZ9h.cjs +0 -1
  88. package/dist/listener-bag-DQgv7OON.js +0 -34
  89. package/dist/motor-By2te6PZ.js +0 -1400
  90. package/dist/motor-CkMxd378.cjs +0 -1
  91. package/dist/opcoes-CupvWVIm.js +0 -24
  92. package/dist/opcoes-vdAUY5OI.cjs +0 -1
  93. package/dist/parts-CaoQiCfI.js +0 -7
  94. package/dist/parts-vQa2873h.cjs +0 -1
  95. package/dist/prancha-paleta-BZ-9QDgh.js +0 -5276
  96. package/dist/prancha-paleta-Bb24vP71.cjs +0 -17
  97. package/dist/ssr-safe-5cWfJP-s.js +0 -10
  98. package/dist/ssr-safe-CiHD1adl.cjs +0 -1
  99. package/dist/svg-seguro-ChVJ2L2z.js +0 -74
  100. package/dist/svg-seguro-J2RM1Ssf.cjs +0 -1
  101. package/dist/ui-badge-DE58YSBY.cjs +0 -28
  102. package/dist/ui-badge-KgmI3jOD.js +0 -201
  103. package/dist/ui-botao-Dz8YvmiA.cjs +0 -12
  104. package/dist/ui-botao-zLkcMMyP.js +0 -168
  105. package/dist/ui-bus-CUd99VJi.js +0 -177
  106. package/dist/ui-bus-XqBLlTYQ.cjs +0 -1
  107. package/dist/ui-camadas-DoHPnbQm.js +0 -3133
  108. package/dist/ui-camadas-Vx7wYD4D.cjs +0 -311
  109. package/dist/ui-campo-texto-Dliyt9qr.cjs +0 -16
  110. package/dist/ui-campo-texto-btevggO3.js +0 -379
  111. package/dist/ui-card-7IEYbCN0.js +0 -150
  112. package/dist/ui-card-Bx8EyzYY.cjs +0 -20
  113. package/dist/ui-card-C-EJoKnm.js +0 -150
  114. package/dist/ui-card-DFnRp9bl.js +0 -146
  115. package/dist/ui-card-DrWVJQKw.cjs +0 -20
  116. package/dist/ui-card-DsIjHMmG.cjs +0 -20
  117. package/dist/ui-controle-cores-B1w_Yl69.cjs +0 -32
  118. package/dist/ui-controle-cores-BRjMvmMn.js +0 -291
  119. package/dist/ui-controle-cores-BcH9k2Fa.js +0 -292
  120. package/dist/ui-controle-cores-CvSTP6gJ.cjs +0 -32
  121. package/dist/ui-editor-prancha-CIngI6yI.js +0 -2886
  122. package/dist/ui-editor-prancha-DorSe6sC.cjs +0 -31
  123. package/dist/ui-linha-2kY7TNUJ.cjs +0 -38
  124. package/dist/ui-linha-B4mBRm1x.cjs +0 -61
  125. package/dist/ui-linha-DTEIIww4.js +0 -1167
  126. package/dist/ui-linha-KFF86FW5.js +0 -752
  127. package/dist/ui-modal-BrXzVZ65.js +0 -216
  128. package/dist/ui-modal-lARKzEVZ.cjs +0 -18
  129. package/dist/ui-paleta-ferramentas-Bu6JaT0s.js +0 -1245
  130. package/dist/ui-paleta-ferramentas-D3Jhwt26.cjs +0 -21
  131. package/dist/ui-paleta-ferramentas-DebHYiwd.js +0 -1615
  132. package/dist/ui-paleta-ferramentas-Dgejtluh.js +0 -1423
  133. package/dist/ui-paleta-ferramentas-hzyo8wBt.cjs +0 -22
  134. package/dist/ui-paleta-ferramentas-jWuICjW8.cjs +0 -22
  135. package/dist/ui-seletor-cor-0RLjcME6.cjs +0 -83
  136. package/dist/ui-seletor-cor-CMuuW-Ym.cjs +0 -83
  137. package/dist/ui-seletor-cor-DFIQ1sin.js +0 -405
  138. package/dist/ui-skeleton-BLEV6h3k.js +0 -653
  139. package/dist/ui-skeleton-B_XTaGrX.cjs +0 -52
  140. package/dist/ui-switch-BXIDwC-Y.cjs +0 -66
  141. package/dist/ui-switch-Ctxk-jKS.js +0 -1212
  142. package/dist/ui-tabela-CXxqbwXv.cjs +0 -7
  143. package/dist/ui-tabela-Cd0vOwnT.js +0 -1459
  144. package/dist/ui-tabela-propriedades-C5cIF5ES.js +0 -3779
  145. package/dist/ui-tabela-propriedades-CJyo568n.js +0 -3517
  146. package/dist/ui-tabela-propriedades-D96Djx-q.cjs +0 -136
  147. package/dist/ui-tabela-propriedades-Wa34hfIr.cjs +0 -142
  148. package/dist/ui-tabela-propriedades-ahQhQauu.js +0 -2329
  149. package/dist/ui-tabela-propriedades-w9JWhjHy.cjs +0 -142
  150. package/dist/zero-js-triggers-CJT988bR.js +0 -83
  151. package/dist/zero-js-triggers-CgM9IIQB.cjs +0 -1
package/dist/prancha.js CHANGED
@@ -1,231 +1,3236 @@
1
+ var Ge = Object.defineProperty;
2
+ var He = (t, a, e) => a in t ? Ge(t, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[a] = e;
3
+ var m = (t, a, e) => He(t, typeof a != "symbol" ? a + "" : a, e);
1
4
  /* empty css */
2
- import "./ui-paleta-ferramentas-DebHYiwd.js";
3
- import "./ui-camadas-DoHPnbQm.js";
4
- import "./ui-tabela-propriedades-ahQhQauu.js";
5
- import { A as i, C as c, a as t, b as m, F as A, c as l, P, U as E, d, e as b, f as D, g as p, h as C, i as O, j as S, k as _, l as h, m as R, n as N, o as M, p as I, r as T } from "./ui-editor-prancha-CIngI6yI.js";
6
- import { E as g } from "./feature_caixa-2Sxv3tGa.js";
7
- import { A as x, C as v, D as f, E as F, a as H, b as z, c as U, d as G, e as j, F as B, f as X, g as V, h as Q, H as k, I as K, i as q, j as w, k as y, K as J, L as W, M as Y, l as Z, m as $, n as aa, o as sa, O as oa, P as ra, p as ea, R as na, S as ia, T as ca, q as ta, r as ma, s as Aa, t as la, u as Pa, v as Ea, w as da, x as ba, y as Da, z as pa, B as Ca, G as Oa, J as Sa, N as _a, Q as ha, U as Ra, V as Na, W as Ma, X as Ia, Y as Ta, Z as ua, _ as ga, $ as La, a0 as xa, a1 as va, a2 as fa, a3 as Fa, a4 as Ha, a5 as za, a6 as Ua, a7 as Ga, a8 as ja, a9 as Ba, aa as Xa, ab as Va, ac as Qa, ad as ka, ae as Ka, af as qa, ag as wa, ah as ya, ai as Ja, aj as Wa, ak as Ya, al as Za, am as $a, an as as, ao as ss, ap as os, aq as rs, ar as es, as as ns, at as is, au as cs, av as ts, aw as ms, ax as As, ay as ls, az as Ps, aA as Es, aB as ds, aC as bs, aD as Ds, aE as ps, aF as Cs, aG as Os, aH as Ss, aI as _s, aJ as hs, aK as Rs, aL as Ns, aM as Ms, aN as Is, aO as Ts, aP as us, aQ as gs, aR as Ls, aS as xs, aT as vs, aU as fs, aV as Fs, aW as Hs, aX as zs, aY as Us, aZ as Gs, a_ as js, a$ as Bs, b0 as Xs, b1 as Vs, b2 as Qs, b3 as ks, b4 as Ks, b5 as qs, b6 as ws, b7 as ys, b8 as Js, b9 as Ws, ba as Ys, bb as Zs, bc as $s, bd as ao, be as so, bf as oo, bg as ro, bh as eo, bi as no, bj as io, bk as co, bl as to, bm as mo, bn as Ao, bo as lo, bp as Po, bq as Eo, br as bo, bs as Do, bt as po, bu as Co, bv as Oo, bw as So, bx as _o, by as ho, bz as Ro, bA as No, bB as Mo, bC as Io, bD as To, bE as uo, bF as go, bG as Lo, bH as xo, bI as vo, bJ as fo, bK as Fo, bL as Ho, bM as zo, bN as Uo, bO as Go, bP as jo, bQ as Bo, bR as Xo, bS as Vo, bT as Qo, bU as ko, bV as Ko, bW as qo, bX as wo, bY as yo, bZ as Jo, b_ as Wo, b$ as Yo, c0 as Zo, c1 as $o, c2 as ar, c3 as sr, c4 as or, c5 as rr, c6 as er, c7 as nr, c8 as ir, c9 as cr } from "./feature_historico-C4h9y5fu.js";
8
- import { ESTILO_DO_TIPO_LINHA as mr, ajustarAparenciaEmLote as Ar, ajustarElementosACaixa as lr, mapearPontoNaCaixa as Pr, normalizarParaOrigem as Er, resumirAparencia as dr } from "./prancha-nucleo.js";
5
+ import { IndicePrancha as $e, Historico as Be, normalizarElementos as Ke, analisarElemento as Ve, compor as wa, translacao as k, escala as q, mapaDeCamadas as Ue, normalizarCamadas as Xe, expandirGrupos as Ze, buscarSnapPrancha as te, ESPESSURA_TRACO_PADRAO_MM as We, COR_PADRAO_PRANCHA as Je, rotacao as Pa, espelharElementos as Qe, ehMatrizFinita as re, transformarElementos as T, definirRaiosDoRetangulo as Ye, normalizarElemento as at, moverAncoras as ie, excluirAncora as oe, centroDaSelecao as et, criarRetangulo as tt, criarElipse as rt, criarPoligonoRegular as it, criarEstrela as ot, transformarElemento as se, criarLinha as st, ESPACO_PLANO as nt, criarCaminho as Ia, paraMm as lt, criarTexto as ct, caixaDeCantos as ut, reordenar as dt, agrupar as ht, desagrupar as mt, alinhar as ft, distribuir as pt, ordenarPorEmpilhamento as $, aplicarAparencia as ne, criarMascara as gt, liberarMascara as vt, unirCaminhos as bt, dividirComLinha as yt, deslocarCaminho as At, duplicarElementos as le, simplificarCaminho as Pt, contornoDoTraco as St, converterEmCaminho as Mt, desenharElementos as N, caixaOrientada as zt, ancorasDoElemento as Sa, alcasDoElemento as ce, caixaDaSelecao as Ma, posicoesDasAlcas as ue, contornoNaFolha as za, aplicar as Et, posicaoLocalDaAlca as xt, ALCAS_ESCALA as Ct, raiosEfetivos as de, profundidadeNoCanto as he, limitesNaFolha as W, comRaioDeCanto as Tt, moverAlcaDaAncora as wt, moverAncora as It, rotacaoPorArrasto as Dt, matrizDeCisalhamentoPorAlca as _t, matrizDeEscalaPorAlca as Ft, guiasInteligentes as kt, marcasDosCantos as Lt, envelopeNaFolha as Rt, elementoNoTopo as oa, trechoMaisProximo as Ot, adicionarAncora as qt, ancoraMaisProxima as Nt, converterAncora as jt, elementosNaCaixa as Gt, deMm as Ht, caixaDoQuadro as me, OPERACOES_BOOLEANAS as $t, aplicarPathfinder as Bt, ehUnidadePrancha as Kt, temMedidorTexto as Vt, definirMedidorTexto as Ut, saneada as Xt, ehPredefinicao as Zt, gerarPredefinicao as Wt, envelopeVisual as Da, exportarSvg as Jt, ehPropriedadePrancha as Qt, ehPropriedadeDeGeometria as Yt, comPropriedade as ar, rotacaoEmGraus as er, MODOS_MESCLAGEM as tr, valorDaPropriedade as rr, resolverAparencia as ir, ITENS_PREDEFINICOES as _a } from "./prancha-nucleo.js";
6
+ import { DIMENSOES_FOLHA as ao, EPSILON_DETERMINANTE as eo, ESCALA_MINIMA as to, ESPESSURA_PADRAO_MM as ro, ESTILOS_TRACO as io, ESTILO_DO_TIPO_LINHA as oo, FAIXAS_MAXIMO as so, FAIXAS_PADRAO as no, FONTE_PADRAO as lo, FORMATOS_ABNT as co, IDENTIDADE as uo, IDS_PROPRIEDADES_PRANCHA as ho, KAPPA as mo, LIMITE_PONTA_PADRAO as fo, MAX_LINHAS_HACHURA as po, MESCLAGEM_CSS as go, MM_POR_PX as vo, MM_POR_UNIDADE as bo, PREDEFINICOES as yo, PRIORIDADE_SNAP_PRANCHA as Ao, ROTULOS_PREDEFINICOES as Po, SOMBRA_PADRAO as So, TIPO_LINHA_DO_ESTILO as Mo, adaptarContextoRelativo as zo, ajustarAparenciaEmLote as Eo, ajustarElementosACaixa as xo, aparenciaDe as Co, aplicarTodos as To, aplicarVetor as wo, areaComSinal as Io, areaDosPoligonos as Do, avisarUmaVez as _o, caixaDoQuadroAbnt as Fo, caixaDoTexto as ko, caixaNormalizada as Lo, caminhoDoContorno as Ro, caminhoFinito as Oo, caminhoParaSvg as qo, cisalhamento as No, comoCaminhoNaFolha as jo, comprimentoDaPonta as Go, contornoElipse as Ho, contornoEstrela as $o, contornoLocal as Bo, contornoLocalEmCache as Ko, contornoPoligonoRegular as Vo, contornoRetangulo as Uo, corComOpacidade as Xo, corNaPosicao as Zo, decompor as Wo, desenharPlano as Jo, determinante as Qo, diagnosticarContexto as Yo, direcaoNaPonta as as, ehFechado as es, ehIdentidade as ts, ehSingular as rs, elementosNoLaco as is, elementosNoPonto as os, emTornoDe as ss, espelhamento as ns, faixasDoGradienteLinear as ls, feicaoDoElemento as cs, fonteSegura as us, geometriaDaPonta as ds, girarElementos as hs, iguais as ms, inverter as fs, limitesLocais as ps, linhasDeHachura as gs, mapearPontoNaCaixa as vs, margensAbnt as bs, matriz as ys, matrizDoElemento as As, meiaEspessura as Ps, modoDeTransformacao as Ss, moverElemento as Ms, multiplicar as zs, normalizarAparencia as Es, normalizarGeometriaElemento as xs, normalizarGradiente as Cs, normalizarHachura as Ts, normalizarParaOrigem as ws, operacaoBooleana as Is, padraoTipoLinhaMm as Ds, pivoNaFolha as _s, planejar as Fs, planejarElemento as ks, planejarElementos as Ls, planoDe as Rs, pontoNoAnel as Os, raiosCabiveis as qs, recompor as Ns, redefinirAvisoContexto as js, regiaoDoElemento as Gs, resolverSombra as Hs, resumirAparencia as $s, temPreenchimento as Bs, testarElemento as Ks, transformarContorno as Vs, varreduraDoArco as Us } from "./prancha-nucleo.js";
7
+ import { n as or, T as sr } from "./geometria-px-DHMPUsxC.js";
8
+ import { K as nr, M as Fa, U as fe, S as pe, L as Ea, d as ge } from "./kit-base-_THn4w3u.js";
9
+ import { E as Zs } from "./feature_caixa-BVc5LenS.js";
10
+ import { S as lr } from "./feature_desenho-CC8Mp5Gp.js";
11
+ const cr = ":host{--ui-prancha-mesa: var(--ui-cor-fundo);--ui-prancha-papel: var(--ui-cor-papel);--ui-prancha-borda-papel: var(--ui-cor-borda);--ui-prancha-grade: var(--ui-cor-grade-papel);--ui-prancha-selecao: var(--ui-cor-primaria);--ui-prancha-alca: var(--ui-cor-superficie);--ui-prancha-guia: var(--ui-cor-guia);--ui-prancha-guia-inteligente: var(--ui-cor-guia-inteligente);--ui-prancha-snap: var(--ui-cor-destaque);--ui-prancha-regua: var(--ui-cor-fundo-elevado);--ui-prancha-texto-regua: var(--ui-cor-texto-secundario);--ui-prancha-tamanho-regua: 20px;display:block;position:relative;min-height:240px;min-width:240px;height:100%;background:var(--ui-cor-fundo);color:var(--ui-cor-texto);font-family:var(--ui-fonte-base);outline:none;contain:layout paint}:host([hidden]){display:none}.raiz{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;grid-template-columns:var(--ui-prancha-tamanho-regua) 1fr;grid-template-rows:var(--ui-prancha-tamanho-regua) 1fr}:host([sem-reguas]) .raiz{grid-template-columns:0 1fr;grid-template-rows:0 1fr}:host([sem-reguas]) .regua,:host([sem-reguas]) .canto{display:none}.canto{background:var(--ui-prancha-regua);border-right:1px solid var(--ui-cor-borda);border-bottom:1px solid var(--ui-cor-borda)}.regua{display:block;width:100%;height:100%;background:var(--ui-prancha-regua);cursor:default;touch-action:none}.regua-h{border-bottom:1px solid var(--ui-cor-borda);cursor:s-resize}.regua-v{border-right:1px solid var(--ui-cor-borda);cursor:e-resize}.viewport{position:relative;overflow:hidden;background:var(--ui-prancha-mesa);touch-action:none;cursor:default}.viewport:focus-visible{outline:2px solid var(--ui-cor-primaria);outline-offset:-2px}.viewport[data-cursor=mao]{cursor:grab}.viewport[data-cursor=arrastando]{cursor:grabbing}.viewport[data-cursor=mira]{cursor:crosshair}.viewport[data-cursor=mover]{cursor:move}.viewport[data-cursor=girar]{cursor:alias}.viewport[data-cursor=ancora]{cursor:pointer}.camada{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;display:block;pointer-events:none}.status{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}@media (pointer: coarse){:host{--ui-prancha-tamanho-regua: 24px}}";
12
+ function ur() {
13
+ return `
14
+ <style>${cr}</style>
15
+ <div class="raiz" part="base">
16
+ <div class="canto" part="canto-reguas" aria-hidden="true"></div>
17
+ <canvas class="regua regua-h" id="regua-h" part="regua regua-horizontal" aria-hidden="true"></canvas>
18
+ <canvas class="regua regua-v" id="regua-v" part="regua regua-vertical" aria-hidden="true"></canvas>
19
+ <div class="viewport" id="viewport" part="viewport" tabindex="0" role="application"
20
+ aria-roledescription="prancha de desenho" aria-label="Prancha" aria-describedby="ajuda">
21
+ <canvas class="camada" id="camada-base" part="canvas"></canvas>
22
+ <canvas class="camada" id="camada-sobreposicao" part="sobreposicao"></canvas>
23
+ </div>
24
+ <div class="status" id="ajuda">Atalhos: V seleção, A seleção direta, H mão, M retângulo, L elipse, P caneta, barra invertida linha, T texto. Setas movem, Shift multiplica por 10. Delete exclui. Ctrl+Z desfaz. Ctrl+0 ajusta a folha.</div>
25
+ <div class="status" id="status" part="status" role="status" aria-live="polite"></div>
26
+ </div>
27
+ `;
28
+ }
29
+ function ka(t, a) {
30
+ const e = new Map(t.map((o) => [o.id, o])), r = new Map(a.map((o) => [o.id, o])), i = { adicionados: [], atualizados: [], removidos: [] };
31
+ for (const [o, s] of r) {
32
+ const n = e.get(o);
33
+ n ? n !== s && i.atualizados.push(s) : i.adicionados.push(s);
34
+ }
35
+ for (const [o, s] of e) r.has(o) || i.removidos.push(s);
36
+ return i;
37
+ }
38
+ const ga = (t) => t.adicionados.length + t.atualizados.length + t.removidos.length === 0;
39
+ class dr {
40
+ constructor() {
41
+ m(this, "lista", []);
42
+ m(this, "porId", /* @__PURE__ */ new Map());
43
+ m(this, "posicoes", /* @__PURE__ */ new Map());
44
+ m(this, "_selecao", []);
45
+ m(this, "indice", new $e());
46
+ m(this, "historico", new Be({ limite: 100, janelaRajadaMs: 1e3 }));
47
+ /** Contador de mudanças do documento (carga, edição, desfazer/refazer, renomear): base do `modificado` do componente. */
48
+ m(this, "revisao", 0);
49
+ m(this, "ouvinteMudanca", null);
50
+ }
51
+ /** Registra quem é avisado depois de cada mudança do documento (o componente avalia o `modificado`). */
52
+ ouvirMudancas(a) {
53
+ this.ouvinteMudanca = a;
54
+ }
55
+ mudou() {
56
+ var a;
57
+ this.revisao++;
58
+ try {
59
+ (a = this.ouvinteMudanca) == null || a.call(this);
60
+ } catch {
61
+ }
62
+ }
63
+ get elementos() {
64
+ return this.lista;
65
+ }
66
+ obter(a) {
67
+ return this.porId.get(a);
68
+ }
69
+ get selecao() {
70
+ return this._selecao;
71
+ }
72
+ elementosSelecionados() {
73
+ return this._selecao.map((a) => this.porId.get(a)).filter((a) => !!a);
74
+ }
75
+ /** Troca tudo (carga de documento): normaliza, recomeça o histórico e limpa a seleção. */
76
+ definir(a) {
77
+ const e = Ke(a);
78
+ return this.aplicar(e.elementos), this.indice.definir(e.elementos), this.historico.limpar(), this._selecao = [], this.mudou(), e;
79
+ }
80
+ aplicar(a) {
81
+ this.lista = a, this.porId = new Map(a.map((e) => [e.id, e])), this.posicoes = new Map(a.map((e, r) => [e.id, r]));
82
+ }
83
+ /** Os elementos na ordem da lista do documento (o índice espacial devolve em outra ordem). */
84
+ naOrdemDoDocumento(a) {
85
+ return [...a].sort((e, r) => (this.posicoes.get(e.id) ?? 0) - (this.posicoes.get(r.id) ?? 0));
86
+ }
87
+ /** Mudança central: grava o passo no histórico, atualiza índice e seleção e devolve a diferença. */
88
+ substituir(a, e = {}) {
89
+ const r = this.lista, i = ka(r, a);
90
+ return ga(i) && r.length === a.length && r.every((o, s) => o === a[s]) || (e.registrar !== !1 && this.historico.registrar(r, { chave: e.chave, agora: e.agora }), this.aplicar(a), this.sincronizarIndice(i), this._selecao = this._selecao.filter((o) => this.porId.has(o)), this.mudou()), i;
91
+ }
92
+ sincronizarIndice(a) {
93
+ for (const r of a.removidos) this.indice.remover(r.id);
94
+ const e = [...a.adicionados, ...a.atualizados];
95
+ e.length > 0 && this.indice.atualizarVarios(e);
96
+ }
97
+ /** Aplica o lote do app (normalizado; ids repetidos e inválidos recusados). */
98
+ aplicarLote(a, e = !0) {
99
+ const r = { adicionados: [], atualizados: [], removidos: [], recusados: [] }, i = new Map(this.lista.map((d) => [d.id, d])), o = this.lista.map((d) => d.id), s = new Set((Array.isArray(a == null ? void 0 : a.remover) ? a.remover : []).filter((d) => typeof d == "string"));
100
+ for (const d of s)
101
+ i.delete(d) && r.removidos.push(d);
102
+ const n = (d, h) => {
103
+ Array.isArray(d) && d.forEach((u, f) => {
104
+ const p = Ve(u);
105
+ if (typeof p == "string") {
106
+ r.recusados.push({ indice: f, motivo: p });
107
+ return;
108
+ }
109
+ const v = i.has(p.id);
110
+ if (h === "adicionar" && v) {
111
+ r.recusados.push({ indice: f, id: p.id, motivo: "id-duplicado" });
112
+ return;
113
+ }
114
+ if (h === "atualizar" && !v) {
115
+ r.recusados.push({ indice: f, id: p.id, motivo: "id-invalido" });
116
+ return;
117
+ }
118
+ h === "adicionar" && o.push(p.id), i.set(p.id, p), (h === "adicionar" ? r.adicionados : r.atualizados).push(p.id);
119
+ });
120
+ };
121
+ n(a == null ? void 0 : a.adicionar, "adicionar"), n(a == null ? void 0 : a.atualizar, "atualizar");
122
+ const l = /* @__PURE__ */ new Set(), c = [];
123
+ for (const d of o) {
124
+ const h = i.get(d);
125
+ h && !l.has(d) && (l.add(d), c.push(h));
126
+ }
127
+ return { resultado: r, diferenca: this.substituir(c, { registrar: e }) };
128
+ }
129
+ desfazer() {
130
+ const a = this.historico.desfazer(this.lista);
131
+ return a ? this.restaurar(a) : null;
132
+ }
133
+ refazer() {
134
+ const a = this.historico.refazer(this.lista);
135
+ return a ? this.restaurar(a) : null;
136
+ }
137
+ restaurar(a) {
138
+ const e = ka(this.lista, a);
139
+ return this.aplicar(a), this.sincronizarIndice(e), this._selecao = this._selecao.filter((r) => this.porId.has(r)), this.mudou(), e;
140
+ }
141
+ /** Troca o id de um elemento em tudo (lista, índice, seleção e histórico). `false` se não existe ou o novo já existe. */
142
+ renomear(a, e) {
143
+ if (typeof e != "string" || !e.trim() || !this.porId.has(a) || this.porId.has(e)) return !1;
144
+ const r = (o) => o.map((s) => s.id === a ? { ...s, id: e } : s), i = r(this.lista);
145
+ return this.indice.remover(a), this.aplicar(i), this.indice.atualizar(this.porId.get(e)), this.historico.transformar(r), this._selecao = this._selecao.map((o) => o === a ? e : o), this.mudou(), !0;
146
+ }
147
+ /** Muda a seleção; devolve se mudou. Só ids existentes, não bloqueados nem ocultos, sem repetição, na ordem dada. */
148
+ selecionar(a, e = "substituir") {
149
+ const r = a.filter((n, l) => {
150
+ const c = this.porId.get(n);
151
+ return !!c && !c.bloqueado && !c.oculto && a.indexOf(n) === l;
152
+ }), i = this._selecao;
153
+ let o;
154
+ e === "substituir" ? o = r : e === "adicionar" ? o = [...i, ...r.filter((n) => !i.includes(n))] : e === "remover" ? o = i.filter((n) => !r.includes(n)) : o = [...i.filter((n) => !r.includes(n)), ...r.filter((n) => !i.includes(n))];
155
+ const s = o.length !== i.length || o.some((n, l) => n !== i[l]);
156
+ return s && (this._selecao = o), s;
157
+ }
158
+ }
159
+ const H = 96 / 25.4, ha = H * 0.02, ma = H * 64, z = (t) => typeof t == "number" && Number.isFinite(t);
160
+ class hr {
161
+ constructor() {
162
+ m(this, "zoom", H);
163
+ m(this, "pan", [0, 0]);
164
+ m(this, "largura", 0);
165
+ m(this, "altura", 0);
166
+ m(this, "dpr", 1);
167
+ }
168
+ get zoomPercentual() {
169
+ return this.zoom / H * 100;
170
+ }
171
+ /** Folha (mm) → px CSS da área de desenho. */
172
+ matrizTela() {
173
+ return wa(q(this.zoom), k(this.pan[0], this.pan[1]));
174
+ }
175
+ /** Folha (mm) → px do dispositivo (com o dpr): a matriz do pintor. */
176
+ matrizDispositivo() {
177
+ return wa(q(this.zoom), k(this.pan[0], this.pan[1]), q(this.dpr));
178
+ }
179
+ paraFolha(a, e) {
180
+ return [(a - this.pan[0]) / this.zoom, (e - this.pan[1]) / this.zoom];
181
+ }
182
+ paraTela(a) {
183
+ return [a[0] * this.zoom + this.pan[0], a[1] * this.zoom + this.pan[1]];
184
+ }
185
+ /** Muda o tamanho da área de desenho (px CSS) e o dpr; valores inválidos são ignorados. */
186
+ redimensionar(a, e, r = 1) {
187
+ z(a) && a >= 0 && (this.largura = a), z(e) && e >= 0 && (this.altura = e), z(r) && r > 0 && (this.dpr = Math.min(r, 4));
188
+ }
189
+ /** Zoom absoluto mantendo parado o ponto de tela `foco` (padrão: o centro). Devolve se mudou. */
190
+ definirZoom(a, e) {
191
+ if (!z(a) || a <= 0) return !1;
192
+ const r = Math.min(ma, Math.max(ha, a));
193
+ if (r === this.zoom) return !1;
194
+ const i = e && z(e[0]) && z(e[1]) ? e : [this.largura / 2, this.altura / 2], o = this.paraFolha(i[0], i[1]);
195
+ return this.zoom = r, this.pan = [i[0] - o[0] * r, i[1] - o[1] * r], !0;
196
+ }
197
+ zoomRelativo(a, e) {
198
+ return z(a) && a > 0 ? this.definirZoom(this.zoom * a, e) : !1;
199
+ }
200
+ deslocar(a, e) {
201
+ return !z(a) || !z(e) || a === 0 && e === 0 ? !1 : (this.pan = [this.pan[0] + a, this.pan[1] + e], !0);
202
+ }
203
+ /** Zoom absoluto mantendo o CENTRO da caixa (mm) no centro da área de desenho (usado no teto de zoom do enquadramento). */
204
+ definirZoomCentrado(a, e) {
205
+ return !z(a) || a <= 0 || !e || ![e.x, e.y, e.largura, e.altura].every(z) ? !1 : (this.zoom = Math.min(ma, Math.max(ha, a)), this.pan = [this.largura / 2 - (e.x + e.largura / 2) * this.zoom, this.altura / 2 - (e.y + e.altura / 2) * this.zoom], !0);
206
+ }
207
+ /** Enquadra a caixa (mm) com `margem` px em volta. Sem tamanho de área de desenho, não faz nada. */
208
+ enquadrar(a, e = 24) {
209
+ if (!a || ![a.x, a.y, a.largura, a.altura].every(z) || this.largura <= 0 || this.altura <= 0) return !1;
210
+ const r = Math.max(a.largura, 1e-6), i = Math.max(a.altura, 1e-6), o = Math.max(1, this.largura - 2 * e), s = Math.max(1, this.altura - 2 * e);
211
+ return this.zoom = Math.min(ma, Math.max(ha, Math.min(o / r, s / i))), this.pan = [this.largura / 2 - (a.x + r / 2) * this.zoom, this.altura / 2 - (a.y + i / 2) * this.zoom], !0;
212
+ }
213
+ }
214
+ function mr() {
215
+ return {
216
+ hoverId: null,
217
+ caixaSelecao: null,
218
+ substitutos: /* @__PURE__ */ new Map(),
219
+ previa: null,
220
+ pontosPrevia: [],
221
+ snap: null,
222
+ linhasInteligentes: [],
223
+ guiaArrastada: null,
224
+ pivo: null,
225
+ edicao: null,
226
+ rotulo: null,
227
+ ponteiro: null,
228
+ copiasEmGesto: []
229
+ };
230
+ }
231
+ function j(t) {
232
+ t.caixaSelecao = null, t.substitutos = /* @__PURE__ */ new Map(), t.previa = null, t.pontosPrevia = [], t.snap = null, t.linhasInteligentes = [], t.guiaArrastada = null, t.rotulo = null, t.copiasEmGesto = [];
233
+ }
234
+ const La = Object.freeze({
235
+ mesa: "--ui-prancha-mesa",
236
+ papel: "--ui-prancha-papel",
237
+ bordaPapel: "--ui-prancha-borda-papel",
238
+ grade: "--ui-prancha-grade",
239
+ selecao: "--ui-prancha-selecao",
240
+ alca: "--ui-prancha-alca",
241
+ guia: "--ui-prancha-guia",
242
+ guiaInteligente: "--ui-prancha-guia-inteligente",
243
+ snap: "--ui-prancha-snap",
244
+ regua: "--ui-prancha-regua",
245
+ textoRegua: "--ui-prancha-texto-regua"
246
+ }), va = Object.freeze({
247
+ mesa: "#0b0b0d",
248
+ papel: "#ffffff",
249
+ bordaPapel: "rgba(255, 255, 255, 0.08)",
250
+ grade: "rgba(59, 155, 255, 0.22)",
251
+ selecao: "#00E08A",
252
+ alca: "#141417",
253
+ guia: "#3b9bff",
254
+ guiaInteligente: "#ff4fd8",
255
+ snap: "#00E08A",
256
+ regua: "#1a1a1e",
257
+ textoRegua: "#9696a6"
258
+ });
259
+ function fr(t) {
260
+ var r;
261
+ const a = { ...va };
262
+ if (!t || typeof getComputedStyle != "function") return a;
263
+ let e = null;
264
+ try {
265
+ e = getComputedStyle(t);
266
+ } catch {
267
+ return a;
268
+ }
269
+ for (const i of Object.keys(La)) {
270
+ const o = (r = e.getPropertyValue(La[i])) == null ? void 0 : r.trim();
271
+ o && (a[i] = or(o, va[i]));
272
+ }
273
+ return a;
274
+ }
275
+ const pr = {
276
+ selecao: "Seleção",
277
+ "selecao-direta": "Seleção direta",
278
+ mao: "Mão",
279
+ retangulo: "Retângulo",
280
+ elipse: "Elipse",
281
+ "poligono-regular": "Polígono regular",
282
+ estrela: "Estrela",
283
+ linha: "Linha",
284
+ seta: "Seta",
285
+ polilinha: "Polilinha",
286
+ poligono: "Polígono",
287
+ caneta: "Caneta",
288
+ texto: "Texto"
289
+ };
290
+ function gr(t) {
291
+ return t <= 0 ? "Nenhum elemento selecionado" : t === 1 ? "1 elemento selecionado" : `${t} elementos selecionados`;
292
+ }
293
+ function vr(t) {
294
+ return `Ferramenta ${pr[t] ?? t}`;
295
+ }
296
+ function sa(t) {
297
+ return `Zoom ${Math.round(t)}%`;
298
+ }
299
+ function br(t, a) {
300
+ t && t.textContent !== a && (t.textContent = a);
301
+ }
302
+ class yr {
303
+ constructor(a) {
304
+ m(this, "doc", new dr());
305
+ m(this, "vista", new hr());
306
+ m(this, "ui", mr());
307
+ m(this, "cores", { ...va });
308
+ m(this, "guias", []);
309
+ m(this, "ferramenta", "selecao");
310
+ m(this, "opcoesFerramentas", {});
311
+ m(this, "folha", { largura: 210, altura: 297 });
312
+ m(this, "grade", 10);
313
+ m(this, "mostrarGrade", !1);
314
+ m(this, "snapLigado", !0);
315
+ m(this, "guiasInteligentes", !0);
316
+ m(this, "unidade", "mm");
317
+ m(this, "passoTeclado", 1);
318
+ m(this, "somenteLeitura", !1);
319
+ /** Margens da folha em mm (guias automáticas e quadro das pré-definições de moldura); `null` = sem margens. */
320
+ m(this, "margens", null);
321
+ /** Gera o id provisório de um elemento novo; o app pode trocar (`gerarId` do host) ou renomear depois. */
322
+ m(this, "gerarId");
323
+ m(this, "sequencia", 0);
324
+ /** Camadas da prancha (ordem = empilhamento), a camada dos elementos novos e o grupo isolado (duplo clique). */
325
+ m(this, "camadas", []);
326
+ m(this, "camadaAtiva", null);
327
+ m(this, "isolado", null);
328
+ /** Última transformação aplicada à seleção, para o Ctrl+D ("transformar de novo"). */
329
+ m(this, "ultimaTransformacao", null);
330
+ m(this, "cacheMapa", null);
331
+ /** Elementos para a base: os do documento com os substitutos do gesto em andamento no lugar. */
332
+ m(this, "cacheBase", null);
333
+ this.dep = a, this.gerarId = (e) => `${e}-${Date.now().toString(36)}-${(++this.sequencia).toString(36)}`;
334
+ }
335
+ emitir(a, e, r = !1) {
336
+ return this.dep.emitir(a, e, r);
337
+ }
338
+ agendar() {
339
+ this.dep.agendar();
340
+ }
341
+ anunciar(a) {
342
+ this.dep.anunciar(a);
343
+ }
344
+ recusar(a, e, r) {
345
+ this.emitir("prancha-recusa", r === void 0 ? { acao: a, motivo: e } : { acao: a, motivo: e, id: r });
346
+ }
347
+ /** Regras das camadas atuais (em cache pela lista). */
348
+ mapa() {
349
+ return (!this.cacheMapa || this.cacheMapa.camadas !== this.camadas) && (this.cacheMapa = { camadas: this.camadas, mapa: Ue(this.camadas) }), this.cacheMapa.mapa;
350
+ }
351
+ /** Pode ser selecionado agora: visível, destravado (ele e a camada), não é máscara e está no grupo isolado, se houver. */
352
+ podeSelecionar(a) {
353
+ const e = this.mapa();
354
+ return !!a && !a.mascara && e.visivel(a) && !e.travado(a) && (this.isolado === null || a.grupoId === this.isolado);
355
+ }
356
+ /** Elementos perto do ponto (pelo índice), visíveis, na ordem do documento (para o desempate do empilhamento). */
357
+ candidatosEm(a, e) {
358
+ const r = this.mapa();
359
+ return this.doc.naOrdemDoDocumento(this.doc.indice.consultarPonto(a, e).filter((i) => r.visivel(i)));
360
+ }
361
+ definirCamadas(a) {
362
+ this.camadas = Xe(a), this.camadaAtiva && !this.camadas.some((e) => e.id === this.camadaAtiva) && (this.camadaAtiva = null), this.emitir("prancha-camadas", { camadas: this.camadas.map((e) => ({ ...e })) }), this.podarSelecao(), this.agendar();
363
+ }
364
+ /** Isola um grupo (só os membros se selecionam; o resto fica esmaecido) ou sai do isolamento (`null`). */
365
+ isolar(a) {
366
+ const e = typeof a == "string" && this.doc.elementos.some((r) => r.grupoId === a) ? a : null;
367
+ e !== this.isolado && (this.isolado = e, this.emitir("prancha-isolamento", { grupoId: e }), this.anunciar(e ? "Grupo isolado" : "Saiu do grupo"), this.podarSelecao(), this.agendar());
368
+ }
369
+ /** Tira da seleção o que deixou de ser selecionável (camada oculta ou bloqueada, fora do grupo isolado). */
370
+ podarSelecao() {
371
+ const a = this.doc.selecao.filter((e) => this.podeSelecionar(this.doc.obter(e)));
372
+ a.length !== this.doc.selecao.length && this.selecionar(a, "substituir", !1);
373
+ }
374
+ /**
375
+ * Elementos da BASE: os do documento, sem os que estão num gesto (arrasto, alça, âncora). A lista fica a mesma durante o
376
+ * gesto inteiro, então a base não é repintada a cada quadro; os elementos em gesto vão na sobreposição
377
+ * (`elementosEmGesto`), por cima, como a prévia de arrasto dos editores vetoriais.
378
+ */
379
+ elementosVisiveis() {
380
+ const a = this.ui.substitutos;
381
+ if (a.size === 0) return this.doc.elementos;
382
+ const e = [...a.keys()].join("\0"), r = this.cacheBase;
383
+ if (r && r.elementos === this.doc.elementos && r.ids === e) return r.base;
384
+ const i = this.doc.elementos.filter((o) => !a.has(o.id));
385
+ return this.cacheBase = { elementos: this.doc.elementos, ids: e, base: i }, i;
386
+ }
387
+ /** Elementos transformados pelo gesto em andamento, na ordem de empilhamento. */
388
+ elementosEmGesto() {
389
+ const a = this.ui.substitutos, e = a.size === 0 ? [] : this.doc.elementos.filter((r) => a.has(r.id)).map((r) => a.get(r.id));
390
+ return this.ui.copiasEmGesto.length > 0 ? [...e, ...this.ui.copiasEmGesto] : e;
391
+ }
392
+ /** Emite os eventos da diferença (criados, atualizados, removidos) com o motivo. */
393
+ emitirDiferenca(a, e) {
394
+ a.adicionados.length > 0 && this.emitir("prancha-elemento-criado", { elementos: a.adicionados, motivo: e }), a.atualizados.length > 0 && this.emitir("prancha-elemento-atualizado", { elementos: a.atualizados, motivo: e }), a.removidos.length > 0 && this.emitir("prancha-elemento-removido", { ids: a.removidos.map((r) => r.id), elementos: a.removidos, motivo: e });
395
+ }
396
+ emitirHistorico() {
397
+ this.emitir("prancha-historico", { podeDesfazer: this.doc.historico.podeDesfazer, podeRefazer: this.doc.historico.podeRefazer });
398
+ }
399
+ /** Mudança do usuário: histórico + eventos + repintura. `chave` junta rajadas (setas, scrubber) num passo. */
400
+ aplicar(a, e, r) {
401
+ const i = this.doc.selecao.join("\0"), o = this.doc.elementos.map((l) => l.id).join("\0"), s = this.doc.substituir(a, { chave: r });
402
+ return this.doc.elementos.map((l) => l.id).join("\0") !== o && s.adicionados.length === 0 && s.removidos.length === 0 && (this.emitir("prancha-ordem", { ids: this.doc.elementos.map((l) => l.id), motivo: e }), ga(s) && this.emitirHistorico()), ga(s) || (this.emitirDiferenca(s, e), this.emitirHistorico(), this.ui.edicao && !this.doc.obter(this.ui.edicao.id) && (this.ui.edicao = null), this.doc.selecao.join("\0") !== i && this.emitirSelecao()), this.agendar(), s;
403
+ }
404
+ /** Substitui elementos pelo id (os demais ficam como estão). */
405
+ aplicarSubstituicoes(a, e, r) {
406
+ const i = new Map(a.map((o) => [o.id, o]));
407
+ return this.aplicar(this.doc.elementos.map((o) => i.get(o.id) ?? o), e, r);
408
+ }
409
+ emitirSelecao() {
410
+ const a = this.doc.elementosSelecionados();
411
+ this.emitir("prancha-selecao", { ids: a.map((e) => e.id), elementos: a }), this.anunciar(gr(a.length));
412
+ }
413
+ /**
414
+ * Muda a seleção. Fora do isolamento, um membro de grupo seleciona o grupo inteiro (`expandir`). Só entra o que pode ser
415
+ * selecionado (camadas, máscara, isolamento).
416
+ */
417
+ selecionar(a, e = "substituir", r = !0) {
418
+ const i = Array.isArray(a) ? a.filter((n) => typeof n == "string") : [], o = (r && this.isolado === null ? Ze(this.doc.elementos, i) : i).filter((n) => e === "remover" || this.podeSelecionar(this.doc.obter(n)));
419
+ return this.doc.selecionar(o, e) ? (this.ui.pivo = null, this.ui.edicao && !this.doc.selecao.includes(this.ui.edicao.id) && this.encerrarEdicao(), this.emitirSelecao(), this.agendar(), !0) : !1;
420
+ }
421
+ definirFerramenta(a) {
422
+ a !== this.ferramenta && (j(this.ui), a !== "selecao-direta" && this.ui.edicao && this.encerrarEdicao(), this.ferramenta = a, this.emitir("prancha-ferramenta", { ferramenta: a }), this.anunciar(vr(a)), this.agendar());
423
+ }
424
+ iniciarEdicao(a) {
425
+ var r;
426
+ const e = this.doc.obter(a);
427
+ return e ? e.bloqueado ? (this.recusar("editar-ancoras", "bloqueado", a), !1) : e.geometria.tipo === "texto" ? (this.recusar("editar-ancoras", "texto-sem-ancoras", a), !1) : (((r = this.ui.edicao) == null ? void 0 : r.id) === a || (this.ui.edicao && this.encerrarEdicao(), this.ui.edicao = { id: a, ancoras: [] }, this.doc.selecionar([a]), this.emitirSelecao(), this.emitir("prancha-edicao-iniciada", { elemento: e }), this.agendar()), !0) : !1;
428
+ }
429
+ encerrarEdicao() {
430
+ const a = this.ui.edicao;
431
+ if (!a) return;
432
+ this.ui.edicao = null;
433
+ const e = this.doc.obter(a.id);
434
+ e && this.emitir("prancha-edicao-concluida", { elemento: e }), this.agendar();
435
+ }
436
+ desfazer() {
437
+ const a = this.doc.desfazer();
438
+ return a ? (this.posHistorico(a, "desfazer"), !0) : (this.recusar("desfazer", "nada-a-desfazer"), !1);
439
+ }
440
+ refazer() {
441
+ const a = this.doc.refazer();
442
+ return a ? (this.posHistorico(a, "refazer"), !0) : (this.recusar("refazer", "nada-a-refazer"), !1);
443
+ }
444
+ posHistorico(a, e) {
445
+ j(this.ui), this.ui.edicao && !this.doc.obter(this.ui.edicao.id) && (this.ui.edicao = null), this.emitirDiferenca(a, e), this.emitirHistorico(), this.anunciar(e === "desfazer" ? "Desfeito" : "Refeito"), this.agendar();
446
+ }
447
+ /** Tolerância de snap em px (toque precisa de mais). */
448
+ toleranciaPx(a = !1) {
449
+ return a ? 16 : 8;
450
+ }
451
+ /**
452
+ * Snap do ponto (mm) aos elementos perto (pelo índice), às guias e (opcional) à grade. Grava o resultado no estado
453
+ * (para a sobreposição marcar). Snap desligado ou Alt: devolve o próprio ponto.
454
+ */
455
+ snapPonto(a, e = {}) {
456
+ if (!this.snapLigado || e.desligado)
457
+ return this.ui.snap = null, { ponto: a, resultado: null };
458
+ const r = this.toleranciaPx(e.toque), i = r / this.vista.zoom + 1, o = this.candidatosEm(a, i).filter((n) => !n.mascara), s = te(a, o, this.vista.zoom, {
459
+ toleranciaPx: r,
460
+ guias: this.guias,
461
+ grade: e.grade !== !1 && this.mostrarGrade ? { espacamento: this.grade } : null
462
+ }, e.excluir ?? []);
463
+ return this.ui.snap = s, { ponto: s ? s.coordenada : a, resultado: s };
464
+ }
465
+ /** Emite a vista (zoom/pan) e repinta. */
466
+ emitirVista() {
467
+ const a = this.vista;
468
+ this.emitir("prancha-vista", { zoom: a.zoom, zoomPercentual: a.zoomPercentual, pan: [a.pan[0], a.pan[1]] }), this.agendar();
469
+ }
470
+ emitirGuias() {
471
+ this.emitir("prancha-guias", { guias: this.guias.map((a) => ({ ...a })) }), this.agendar();
472
+ }
473
+ /** Aparência dos elementos novos (cópia; padrão traço preto 0,25 mm sem preenchimento). */
474
+ aparenciaNova() {
475
+ const a = this.opcoesFerramentas.aparencia;
476
+ return a ? JSON.parse(JSON.stringify(a)) : { traco: { cor: Je, espessura: We }, preenchimento: null };
477
+ }
478
+ }
479
+ const Z = (t) => typeof t == "number" && Number.isFinite(t);
480
+ function ua(t, a) {
481
+ if (t.somenteLeitura)
482
+ return t.recusar(a, "somente-leitura"), null;
483
+ const e = t.doc.elementosSelecionados().filter((r) => !r.bloqueado);
484
+ return e.length === 0 ? (t.recusar(a, "sem-selecao"), null) : e;
485
+ }
486
+ function J(t, a, e = "comando", r) {
487
+ if (!re(a)) return !1;
488
+ const i = ua(t, "transformar");
489
+ return i ? (t.aplicarSubstituicoes(T(i, a), e, r), !0) : !1;
490
+ }
491
+ const ve = (t, a, e, r = "comando", i) => Z(a) && Z(e) && J(t, k(a, e), r, i);
492
+ function da(t) {
493
+ return t.ui.pivo ?? et(t.doc.elementosSelecionados());
494
+ }
495
+ function be(t, a, e, r = "comando") {
496
+ const i = e ?? da(t);
497
+ return Z(a) && !!i && J(t, Pa(a * Math.PI / 180, i), r);
498
+ }
499
+ function ba(t, a, e = a, r, i = "comando") {
500
+ const o = r ?? da(t);
501
+ return !Z(a) || !Z(e) || a === 0 || e === 0 || !o ? !1 : J(t, q(a, e, o), i);
502
+ }
503
+ function Ar(t, a, e = "comando") {
504
+ if (a !== "horizontal" && a !== "vertical") return !1;
505
+ const r = ua(t, "espelhar");
506
+ return r ? (t.aplicarSubstituicoes(Qe(r, a, da(t) ?? void 0), e), !0) : !1;
507
+ }
508
+ function ye(t, a = "remover") {
509
+ const e = ua(t, "remover");
510
+ if (!e) return !1;
511
+ const r = new Set(e.map((i) => i.id));
512
+ return t.aplicar(t.doc.elementos.filter((i) => !r.has(i.id)), a), !0;
513
+ }
514
+ function Ae(t) {
515
+ return t.selecionar(t.doc.elementos.filter((a) => !a.bloqueado && !a.oculto).map((a) => a.id));
516
+ }
517
+ function Pr(t, a) {
518
+ const e = t.doc.elementos.filter((s) => !s.bloqueado && !s.oculto);
519
+ if (e.length === 0) return !1;
520
+ const r = t.doc.selecao[t.doc.selecao.length - 1], i = e.findIndex((s) => s.id === r), o = e[i < 0 ? a > 0 ? 0 : e.length - 1 : (i + a + e.length) % e.length];
521
+ return t.selecionar([o.id]);
522
+ }
523
+ function w(t, a, e) {
524
+ var i;
525
+ if (t.somenteLeitura)
526
+ return t.recusar("criar", "somente-leitura"), [];
527
+ const r = [];
528
+ for (const o of a) {
529
+ const s = ((i = o == null ? void 0 : o.geometria) == null ? void 0 : i.tipo) ?? "elemento", n = o != null && o.id && !t.doc.obter(o.id) && !r.some((d) => d.id === o.id) ? o.id : t.gerarId(s), l = !(o != null && o.camadaId) && t.camadaAtiva ? { camadaId: t.camadaAtiva } : {}, c = at({ ...o, id: n, ...l });
530
+ c ? r.push(c) : t.recusar("criar", "geometria-invalida");
531
+ }
532
+ return r.length === 0 ? [] : (t.aplicar([...t.doc.elementos, ...r], e), t.selecionar(r.map((o) => o.id)), t.anunciar(r.length === 1 ? "Elemento criado" : `${r.length} elementos criados`), r);
533
+ }
534
+ function Sr(t, a, e, r) {
535
+ const i = t.ui.edicao, o = i ? t.doc.obter(i.id) : void 0;
536
+ if (!i || !o || i.ancoras.length === 0) return !1;
537
+ const s = ie(o, i.ancoras, a, e);
538
+ return s ? (t.aplicarSubstituicoes([s], "editar-ancoras", r), !0) : (t.recusar("editar-ancoras", "matriz-singular", o.id), !1);
539
+ }
540
+ function Mr(t) {
541
+ const a = t.ui.edicao;
542
+ let e = a ? t.doc.obter(a.id) : void 0;
543
+ if (!a || !e || a.ancoras.length === 0) return !1;
544
+ let r = !1;
545
+ for (const i of [...a.ancoras].sort((o, s) => s - o)) {
546
+ const o = oe(e, i);
547
+ if (!o) {
548
+ t.recusar("excluir-ancora", "minimo-de-ancoras", e.id);
549
+ break;
550
+ }
551
+ e = o, r = !0;
552
+ }
553
+ return r ? (a.ancoras = [], t.aplicarSubstituicoes([e], "editar-ancoras"), !0) : !1;
554
+ }
555
+ function Pe(t, a) {
556
+ const e = ua(t, "definir-raios");
557
+ if (!e) return !1;
558
+ const r = e.map((i) => Ye(i, a)).filter((i) => !!i);
559
+ return r.length === 0 ? (t.recusar("definir-raios", "tipo-nao-suportado"), !1) : (t.aplicarSubstituicoes(r, "cantos"), !0);
560
+ }
561
+ const ra = ["retangulo", "elipse", "poligono-regular", "estrela", "linha", "seta"], Se = { polilinha: "linha", poligono: "poligono", caneta: "caneta" }, zr = "__previa__", Er = 3, xr = 8, Cr = 400, Tr = 4, na = (t) => ra.includes(t) || t in Se || t === "texto";
562
+ function Ra(t, a, e, r) {
563
+ let i = a[0] - t[0], o = a[1] - t[1];
564
+ if (e) {
565
+ const s = Math.max(Math.abs(i), Math.abs(o));
566
+ i = (i < 0 ? -1 : 1) * s, o = (o < 0 ? -1 : 1) * s;
567
+ }
568
+ return r ? { x: t[0] - Math.abs(i), y: t[1] - Math.abs(o), largura: 2 * Math.abs(i), altura: 2 * Math.abs(o) } : ut(t, [t[0] + i, t[1] + o]);
569
+ }
570
+ function wr(t, a) {
571
+ const e = a[0] - t[0], r = a[1] - t[1], i = Math.hypot(e, r), o = Math.round(Math.atan2(r, e) / (Math.PI / 4)) * (Math.PI / 4);
572
+ return [t[0] + i * Math.cos(o), t[1] + i * Math.sin(o)];
573
+ }
574
+ class Ir {
575
+ constructor(a) {
576
+ m(this, "arrasto", null);
577
+ m(this, "sessao", null);
578
+ m(this, "puxandoAlca", !1);
579
+ m(this, "ultimoClique", null);
580
+ this.c = a;
581
+ }
582
+ get emAndamento() {
583
+ return !!this.arrasto || !!this.sessao && this.sessao.nos > 0;
584
+ }
585
+ base(a = {}) {
586
+ return { id: zr, aparencia: this.c.aparenciaNova(), ...a };
587
+ }
588
+ /** Elemento da forma de arrasto entre `inicio` e `atual` (null se degenerado). */
589
+ construir(a, e, r, i) {
590
+ const o = this.c.opcoesFerramentas;
591
+ if (a === "retangulo" || a === "elipse") {
592
+ const s = Ra(e, r, i.shift, i.alt);
593
+ return a === "retangulo" ? tt(this.base(), s, o.raioCantos) : rt(this.base(), s);
594
+ }
595
+ if (a === "poligono-regular" || a === "estrela") {
596
+ const s = Math.hypot(r[0] - e[0], r[1] - e[1]), n = a === "poligono-regular" ? it(this.base(), e, s, o.lados ?? 6) : ot(this.base(), e, s, s * (o.proporcaoInterna ?? 0.45), o.pontas ?? 5);
597
+ if (!n || i.shift) return n;
598
+ const l = Math.atan2(r[1] - e[1], r[0] - e[0]) + Math.PI / 2;
599
+ return se(n, Pa(l, e));
600
+ }
601
+ if (a === "linha" || a === "seta") {
602
+ const s = i.shift ? wr(e, r) : r, n = this.c.aparenciaNova();
603
+ return a === "seta" && (n.traco = { ...n.traco ?? {}, pontaFim: o.ponta ?? { estilo: "triangulo" } }), st(this.base({ aparencia: n }), e, s);
604
+ }
605
+ return null;
606
+ }
607
+ pressionar(a, e, r) {
608
+ const i = this.c.ferramenta, { ponto: o } = this.c.snapPonto(a, { toque: r.toque, desligado: r.alt && !ra.includes(i) });
609
+ if (ra.includes(i)) {
610
+ this.arrasto = { inicio: o, atual: o, inicioPx: e };
611
+ return;
612
+ }
613
+ if (i === "texto") {
614
+ this.solicitarTexto(o);
615
+ return;
616
+ }
617
+ const s = Se[i];
618
+ if (!s) return;
619
+ this.sessao || (this.sessao = new lr(s, !1, { espaco: nt }));
620
+ const n = this.sessao, l = Date.now(), c = !!this.ultimoClique && l - this.ultimoClique.t <= Cr && Math.hypot(e[0] - this.ultimoClique.x, e[1] - this.ultimoClique.y) <= Tr;
621
+ this.ultimoClique = { t: l, x: e[0], y: e[1] };
622
+ const d = n.primeiro;
623
+ if (d && n.fechaNoPrimeiro) {
624
+ const h = this.c.vista.paraTela(d);
625
+ if (Math.hypot(h[0] - e[0], h[1] - e[1]) <= xr) {
626
+ this.finalizar(n.concluirFechando());
627
+ return;
628
+ }
629
+ }
630
+ if (c && s !== "caneta") {
631
+ this.concluir();
632
+ return;
633
+ }
634
+ n.clicar(o), s === "caneta" && (this.puxandoAlca = !0), this.atualizarPrevia();
635
+ }
636
+ mover(a, e, r) {
637
+ const i = this.c.ferramenta;
638
+ if (this.arrasto) {
639
+ const { ponto: o } = this.c.snapPonto(a, { toque: r.toque });
640
+ this.arrasto.atual = o, this.c.ui.previa = this.construir(i, this.arrasto.inicio, o, r);
641
+ const s = Ra(this.arrasto.inicio, o, r.shift, r.alt), n = (l) => Math.round(l * 10) / 10;
642
+ this.c.ui.rotulo = { texto: `${n(s.largura)} × ${n(s.altura)} mm`, em: o }, this.c.agendar();
643
+ return;
644
+ }
645
+ if (this.sessao) {
646
+ const { ponto: o } = this.c.snapPonto(a, { toque: r.toque, desligado: r.alt });
647
+ this.puxandoAlca ? this.sessao.definirAlca(o) : this.sessao.mover(o), this.atualizarPrevia();
648
+ } else na(i) && (this.c.snapPonto(a, { toque: r.toque, desligado: r.alt }), this.c.agendar());
649
+ }
650
+ soltar(a, e, r) {
651
+ this.puxandoAlca = !1;
652
+ const i = this.arrasto;
653
+ if (!i) return;
654
+ this.arrasto = null;
655
+ const o = this.c.ui.previa;
656
+ if (j(this.c.ui), !o || Math.hypot(e[0] - i.inicioPx[0], e[1] - i.inicioPx[1]) < Er) {
657
+ this.c.recusar("desenhar", "forma-pequena"), this.c.agendar();
658
+ return;
659
+ }
660
+ w(this.c, [{ ...o, id: "" }], "ferramenta");
661
+ }
662
+ atualizarPrevia() {
663
+ const a = this.sessao;
664
+ if (!a) return;
665
+ const e = a.previa();
666
+ this.c.ui.previa = e && (e.tipo === "LineString" || e.tipo === "Polygon") ? Ia(this.base(), e) : null, this.c.ui.pontosPrevia = a.ferramenta === "caneta" ? a.ancoras.map((r) => r.ponto) : [...a.pontos], this.c.agendar();
667
+ }
668
+ finalizar(a) {
669
+ if (this.sessao = null, this.ultimoClique = null, j(this.c.ui), a && (a.tipo === "LineString" || a.tipo === "Polygon")) {
670
+ const e = Ia({ id: "", aparencia: this.c.aparenciaNova() }, a);
671
+ e && w(this.c, [e], "ferramenta");
672
+ } else
673
+ this.c.recusar("desenhar", "geometria-invalida");
674
+ this.c.agendar();
675
+ }
676
+ concluir() {
677
+ const a = this.sessao;
678
+ return !a || !a.podeConcluir ? !1 : (this.finalizar(a.concluir()), !0);
679
+ }
680
+ cancelar() {
681
+ this.arrasto = null, this.sessao = null, this.puxandoAlca = !1, this.ultimoClique = null, j(this.c.ui), this.c.agendar();
682
+ }
683
+ /** Enter, Esc e Backspace durante o desenho; devolve se tratou. */
684
+ tecla(a) {
685
+ return a === "Enter" && this.sessao ? this.concluir() || !0 : a === "Escape" && this.emAndamento ? (this.cancelar(), !0) : a === "Backspace" && this.sessao && this.sessao.nos > 0 ? (this.sessao.desfazer(), this.sessao.nos === 0 ? this.cancelar() : this.atualizarPrevia(), !0) : !1;
686
+ }
687
+ /** Teclado: Enter com a ferramenta ativa e nada em andamento cria a forma padrão (40 × 30 mm) no centro da vista. */
688
+ criarNoCentro() {
689
+ const a = this.c.ferramenta, e = this.c.vista, r = e.largura > 0 ? e.paraFolha(e.largura / 2, e.altura / 2) : [this.c.folha.largura / 2, this.c.folha.altura / 2];
690
+ if (a === "texto")
691
+ return this.solicitarTexto(r), !0;
692
+ if (!ra.includes(a)) return !1;
693
+ const i = this.construir(a, [r[0] - 20, r[1] - 15], [r[0] + 20, r[1] + 15], { shift: !1, alt: !1 });
694
+ return !!i && w(this.c, [{ ...i, id: "" }], "ferramenta").length > 0;
695
+ }
696
+ solicitarTexto(a) {
697
+ const e = this.c.opcoesFerramentas, r = e.tamanhoTexto && e.tamanhoTexto > 0 ? e.tamanhoTexto : lt(12, "pt"), i = (n) => {
698
+ var c;
699
+ const l = ct({ id: "", aparencia: { preenchimento: { cor: ((c = this.c.aparenciaNova().traco) == null ? void 0 : c.cor) ?? void 0 } } }, a, n, r);
700
+ return l ? w(this.c, [l], "texto")[0] ?? null : null;
701
+ }, o = { posicao: a, concluir: (n) => i(typeof n == "string" ? n : String(n ?? "")) };
702
+ this.c.emitir("prancha-texto-solicitado", o, !0) || i(e.textoPadrao ?? "Texto");
703
+ }
704
+ }
705
+ const U = 5, _ = { elementos: [], colagens: 0 }, ya = (t) => typeof t == "number" && Number.isFinite(t);
706
+ function y(t, a, e = 1) {
707
+ if (t.somenteLeitura)
708
+ return t.recusar(a, "somente-leitura"), null;
709
+ const r = t.doc.elementosSelecionados().filter((i) => !t.mapa().travado(i));
710
+ return r.length < e ? (t.recusar(a, "sem-selecao"), null) : r;
711
+ }
712
+ function Q(t, a, e) {
713
+ return "ok" in e ? e.ok : (t.recusar(a, e.motivo === "texto" ? "texto-sem-ancoras" : e.motivo === "tipos-incompativeis" || e.motivo === "sem-forma-fechada" ? "tipo-nao-suportado" : "geometria-invalida"), null);
714
+ }
715
+ function D(t, a) {
716
+ const e = y(t, "ordem");
717
+ return !e || !["frente", "tras", "avancar", "recuar"].includes(a) ? !1 : (t.aplicar(dt(t.doc.elementos, e.map((r) => r.id), a, t.camadas), "ordem"), !0);
718
+ }
719
+ function Me(t) {
720
+ const a = y(t, "agrupar", 2);
721
+ return a ? (t.aplicar(ht(t.doc.elementos, a.map((e) => e.id), t.gerarId("grupo"), t.camadas), "agrupar"), !0) : !1;
722
+ }
723
+ function ze(t) {
724
+ const a = y(t, "desagrupar");
725
+ if (!a) return !1;
726
+ const e = a.map((r) => r.id);
727
+ return t.isolado && a.some((r) => r.grupoId === t.isolado) && t.isolar(null), t.aplicar(mt(t.doc.elementos, e), "desagrupar"), !0;
728
+ }
729
+ function la(t, a) {
730
+ const e = y(t, a === "bloqueado" ? "bloquear" : "ocultar");
731
+ if (!e) return !1;
732
+ const r = new Set(e.map((i) => i.id));
733
+ return t.selecionar([]), t.aplicar(t.doc.elementos.map((i) => r.has(i.id) ? { ...i, [a]: !0 } : i), a === "bloqueado" ? "bloquear" : "ocultar"), !0;
734
+ }
735
+ function ca(t, a) {
736
+ if (t.somenteLeitura)
737
+ return t.recusar("liberar", "somente-leitura"), !1;
738
+ const e = [], r = t.doc.elementos.map((i) => {
739
+ if (!i[a]) return i;
740
+ e.push(i.id);
741
+ const o = { ...i };
742
+ return delete o[a], o;
743
+ });
744
+ return e.length === 0 ? !1 : (t.aplicar(r, a === "bloqueado" ? "bloquear" : "ocultar"), t.selecionar(e), !0);
745
+ }
746
+ function Dr(t, a, e = "selecao") {
747
+ const r = y(t, "alinhar");
748
+ if (!r) return !1;
749
+ let i = { tipo: "selecao" };
750
+ e === "folha" ? i = { tipo: "caixa", caixa: { x: 0, y: 0, largura: t.folha.largura, altura: t.folha.altura } } : e === "chave" ? i = { tipo: "chave", id: t.doc.selecao[0] } : e && typeof e == "object" && (i = { tipo: "caixa", caixa: e });
751
+ const o = ft(r, a, i);
752
+ return o.length === 0 ? !1 : (t.aplicarSubstituicoes(o, "alinhar"), !0);
753
+ }
754
+ function _r(t, a, e = "espacos", r) {
755
+ const i = y(t, "distribuir", 2);
756
+ if (!i) return !1;
757
+ const o = pt(i, a === "vertical" ? "vertical" : "horizontal", e === "centros" ? "centros" : "espacos", ya(r) ? r : void 0);
758
+ return o.length === 0 ? !1 : (t.aplicarSubstituicoes(o, "distribuir"), !0);
759
+ }
760
+ function xa(t, a, e, r) {
761
+ const i = le($(a, t.camadas), t.gerarId, e);
762
+ return w(t, i, r);
763
+ }
764
+ function Fr(t, a = [U, U]) {
765
+ const e = y(t, "duplicar");
766
+ if (!e) return !1;
767
+ const r = ya(a == null ? void 0 : a[0]) && ya(a == null ? void 0 : a[1]) ? a : [U, U], i = xa(t, e, r, "duplicar");
768
+ return t.ultimaTransformacao = { matriz: k(r[0], r[1]), duplicar: !0 }, i.length > 0;
769
+ }
770
+ function Oa(t, a, e = !1) {
771
+ re(a) && (t.ultimaTransformacao = { matriz: a, duplicar: e });
772
+ }
773
+ function Ee(t) {
774
+ const a = t.ultimaTransformacao;
775
+ if (!a)
776
+ return t.recusar("transformar-de-novo", "nada-a-refazer"), !1;
777
+ const e = y(t, "transformar-de-novo");
778
+ if (!e) return !1;
779
+ if (a.duplicar) {
780
+ const i = xa(t, e, [0, 0], "duplicar");
781
+ return i.length === 0 ? !1 : (t.aplicarSubstituicoes(T(i, a.matriz), "transformar"), t.ultimaTransformacao = a, !0);
782
+ }
783
+ const r = J(t, a.matriz, "transformar");
784
+ return t.ultimaTransformacao = a, r;
785
+ }
786
+ function Ca(t) {
787
+ var e, r, i, o;
788
+ const a = t.doc.elementosSelecionados();
789
+ if (a.length === 0)
790
+ return t.recusar("copiar", "sem-selecao"), !1;
791
+ _.elementos = JSON.parse(JSON.stringify($(a, t.camadas))), _.colagens = 0;
792
+ try {
793
+ const s = typeof navigator < "u" ? navigator : void 0;
794
+ (o = (i = (r = (e = s == null ? void 0 : s.clipboard) == null ? void 0 : e.writeText) == null ? void 0 : r.call(e, JSON.stringify({ tipo: "ui-canvas-prancha", elementos: _.elementos }))) == null ? void 0 : i.catch) == null || o.call(i, () => {
795
+ });
796
+ } catch {
797
+ }
798
+ return t.anunciar(a.length === 1 ? "Elemento copiado" : `${a.length} elementos copiados`), !0;
799
+ }
800
+ function xe(t) {
801
+ const a = y(t, "recortar");
802
+ if (!a || !Ca(t)) return !1;
803
+ const e = new Set(a.map((r) => r.id));
804
+ return t.aplicar(t.doc.elementos.filter((r) => !e.has(r.id)), "recortar"), !0;
805
+ }
806
+ function Ce(t, a = !1) {
807
+ if (_.elementos.length === 0)
808
+ return t.recusar("colar", "sem-selecao"), !1;
809
+ if (t.somenteLeitura)
810
+ return t.recusar("colar", "somente-leitura"), !1;
811
+ _.colagens++;
812
+ const e = a ? 0 : U * _.colagens;
813
+ return xa(t, _.elementos, [e, e], "colar").length > 0;
814
+ }
815
+ function kr(t, a) {
816
+ const e = a.aparencia ? JSON.parse(JSON.stringify(a.aparencia)) : void 0;
817
+ t.emitir("prancha-conta-gotas", { elemento: a, aparencia: e });
818
+ const r = t.doc.elementosSelecionados().filter((i) => i.id !== a.id && !t.mapa().travado(i));
819
+ return r.length === 0 ? (t.opcoesFerramentas = { ...t.opcoesFerramentas, aparencia: e }, t.anunciar("Aparência guardada para as formas novas"), !0) : t.somenteLeitura ? (t.recusar("conta-gotas", "somente-leitura"), !1) : (t.aplicarSubstituicoes(ne(r, e), "conta-gotas"), !0);
820
+ }
821
+ function Lr(t, a) {
822
+ const e = y(t, "aparencia");
823
+ return e ? (t.aplicarSubstituicoes(ne(e, a ?? void 0), "aparencia"), !0) : !1;
824
+ }
825
+ function Rr(t, a) {
826
+ const e = y(t, "mover-camada");
827
+ return !e || typeof a != "string" || !t.camadas.some((r) => r.id === a) ? (e && t.recusar("mover-camada", "id-invalido", typeof a == "string" ? a : void 0), !1) : (t.aplicarSubstituicoes(e.map((r) => ({ ...r, camadaId: a })), "camada"), !0);
828
+ }
829
+ function Te(t) {
830
+ const a = y(t, "mascara", 2);
831
+ if (!a) return !1;
832
+ const e = Q(t, "mascara", gt(t.doc.elementos, a.map((r) => r.id), t.gerarId("grupo"), t.camadas));
833
+ return e ? (t.aplicar(e, "mascara"), !0) : !1;
834
+ }
835
+ function we(t) {
836
+ const a = y(t, "liberar-mascara");
837
+ if (!a) return !1;
838
+ const e = vt(t.doc.elementos, a.map((r) => r.id));
839
+ return e.every((r, i) => r === t.doc.elementos[i]) ? (t.recusar("liberar-mascara", "tipo-nao-suportado"), !1) : (t.aplicar(e, "mascara"), !0);
840
+ }
841
+ function Ie(t, a = 0.01) {
842
+ const e = y(t, "unir", 2);
843
+ if (!e) return !1;
844
+ const r = $(e, t.camadas), i = Q(t, "unir", bt(r, a));
845
+ if (!i) return !1;
846
+ const o = new Set(r.slice(1).map((s) => s.id));
847
+ return t.aplicar(t.doc.elementos.filter((s) => !o.has(s.id)).map((s) => s.id === i.id ? i : s), "unir"), !0;
848
+ }
849
+ function Or(t) {
850
+ const a = y(t, "dividir", 2);
851
+ if (!a) return !1;
852
+ const e = $(a, t.camadas), r = [...e].reverse().find((n) => n.geometria.tipo === "linha" || n.geometria.tipo === "caminho" && n.geometria.geometria.tipo === "LineString"), i = e.find((n) => n !== r);
853
+ if (!r || !i)
854
+ return t.recusar("dividir", "tipo-nao-suportado"), !1;
855
+ const o = Q(t, "dividir", yt(i, r, t.gerarId));
856
+ if (!o) return !1;
857
+ const s = [];
858
+ for (const n of t.doc.elementos)
859
+ n.id !== r.id && (n.id === i.id ? s.push(...o) : s.push(n));
860
+ return t.aplicar(s, "dividir"), t.selecionar(o.map((n) => n.id)), !0;
861
+ }
862
+ function qr(t, a) {
863
+ const e = y(t, "deslocar-caminho");
864
+ if (!e) return !1;
865
+ const r = e.map((i) => Q(t, "deslocar-caminho", At(i, a, t.gerarId("caminho")))).filter((i) => !!i);
866
+ return r.length > 0 && w(t, r, "deslocar-caminho").length > 0;
867
+ }
868
+ function Ta(t, a, e, r) {
869
+ const i = y(t, a);
870
+ if (!i) return !1;
871
+ const o = [];
872
+ for (const s of i) {
873
+ const n = r(s), l = n && typeof n == "object" && ("ok" in n || "motivo" in n) ? Q(t, a, n) : n;
874
+ l && o.push(l);
875
+ }
876
+ return o.length === 0 ? !1 : (t.aplicarSubstituicoes(o, e), !0);
877
+ }
878
+ const Nr = (t, a = 0.2) => Ta(t, "simplificar", "simplificar", (e) => Pt(e, a)), jr = (t) => Ta(t, "contorno-traco", "contorno-traco", (a) => St(a)), Gr = (t) => Ta(t, "converter-caminho", "converter-caminho", (a) => a.geometria.tipo === "caminho" ? null : Mt(a)), Hr = 7, De = 22, qa = 6, G = (t, a) => t.setTransform(a, 0, 0, a, 0, 0);
879
+ function S(t, a, e = !0) {
880
+ if (a.length !== 0) {
881
+ t.moveTo(a[0][0], a[0][1]);
882
+ for (let r = 1; r < a.length; r++) t.lineTo(a[r][0], a[r][1]);
883
+ e && t.closePath();
884
+ }
885
+ }
886
+ function fa(t, a, e, r, i) {
887
+ const o = e / 2;
888
+ t.beginPath(), S(t, [[a[0] - o, a[1] - o], [a[0] + o, a[1] - o], [a[0] + o, a[1] + o], [a[0] - o, a[1] + o]]), t.fillStyle = r, t.fill(), t.strokeStyle = i, t.stroke();
889
+ }
890
+ function Y(t, a, e) {
891
+ const r = [];
892
+ for (let i = 0; i < 16; i++) r.push([a[0] + e * Math.cos(i * Math.PI / 8), a[1] + e * Math.sin(i * Math.PI / 8)]);
893
+ S(t, r);
894
+ }
895
+ function $r(t, a) {
896
+ const e = a.grade;
897
+ if (!e || !(e > 0)) return;
898
+ const { vista: r, folha: i } = a;
899
+ let o = e;
900
+ for (; o * r.zoom < 8; ) o *= 2;
901
+ const [s, n] = r.paraTela([0, 0]), [l, c] = r.paraTela([i.largura, i.altura]);
902
+ t.beginPath();
903
+ for (let d = 0; d <= i.largura + 1e-9; d += o) {
904
+ const h = Math.round(r.paraTela([d, 0])[0]) + 0.5;
905
+ t.moveTo(h, n), t.lineTo(h, c);
906
+ }
907
+ for (let d = 0; d <= i.altura + 1e-9; d += o) {
908
+ const h = Math.round(r.paraTela([0, d])[1]) + 0.5;
909
+ t.moveTo(s, h), t.lineTo(l, h);
910
+ }
911
+ t.strokeStyle = a.cores.grade, t.lineWidth = 1, t.setLineDash([]), t.globalAlpha = 1, t.stroke();
912
+ }
913
+ function Br(t, a, e, r) {
914
+ const i = a.matrizDispositivo();
915
+ t.setTransform(i.a, i.b, i.c, i.d, i.e, i.f), t.globalAlpha = 0.6, t.fillStyle = r, t.fillRect(0, 0, e.largura, e.altura);
916
+ }
917
+ function Kr(t, a) {
918
+ const { vista: e, folha: r, cores: i } = a;
919
+ t.save(), G(t, e.dpr), t.globalAlpha = 1, t.fillStyle = i.mesa, t.fillRect(0, 0, e.largura, e.altura), t.restore();
920
+ const o = e.matrizDispositivo();
921
+ N(t, [], { matriz: o, fundo: { cor: i.papel, largura: r.largura, altura: r.altura } }), t.save(), G(t, e.dpr), $r(t, a), t.restore(), N(t, a.elementos, { matriz: o, camadas: a.camadas }), a.isolados && a.isolados.length > 0 && (t.save(), Br(t, e, r, i.papel), t.restore(), N(t, a.isolados, { matriz: o, camadas: a.camadas })), t.save(), G(t, e.dpr);
922
+ const [s, n] = e.paraTela([0, 0]), [l, c] = e.paraTela([r.largura, r.altura]);
923
+ t.beginPath(), S(t, [[s, n], [l, n], [l, c], [s, c]]), t.strokeStyle = i.bordaPapel, t.lineWidth = 1, t.stroke();
924
+ const d = a.margens;
925
+ if (d && d.largura > 0 && d.altura > 0) {
926
+ const [h, u] = e.paraTela([d.x, d.y]), [f, p] = e.paraTela([d.x + d.largura, d.y + d.altura]);
927
+ t.beginPath(), S(t, [[h, u], [f, u], [f, p], [h, p]]), t.strokeStyle = i.guiaInteligente, t.globalAlpha = 0.6, t.setLineDash([6, 4]), t.stroke(), t.setLineDash([]), t.globalAlpha = 1;
928
+ }
929
+ t.restore();
930
+ }
931
+ function Na(t, a, e) {
932
+ const r = za(a);
933
+ if (!r) return;
934
+ const i = r.tipo === "Polygon" ? r.aneis : r.partes && r.partes.length > 1 ? r.partes : [r.coordenadas];
935
+ for (const o of i) S(t, o.map((s) => e.paraTela(s)), r.tipo === "Polygon");
936
+ }
937
+ function ja(t, a) {
938
+ return ["no", "ne", "se", "so"].map((e) => a.paraTela(Et(t.quadro, xt(t, e))));
939
+ }
940
+ function Ga(t, a, e) {
941
+ if (a.orientacao === "horizontal") {
942
+ const r = Math.round(e.paraTela([0, a.posicao])[1]) + 0.5;
943
+ t.moveTo(0, r), t.lineTo(e.largura, r);
944
+ } else {
945
+ const r = Math.round(e.paraTela([a.posicao, 0])[0]) + 0.5;
946
+ t.moveTo(r, 0), t.lineTo(r, e.altura);
947
+ }
948
+ }
949
+ function pa(t, a, e, r) {
950
+ typeof t.fillText == "function" && (t.font = "11px sans-serif", t.fillStyle = r, t.fillText(a, e[0], e[1]));
951
+ }
952
+ function Vr(t, a) {
953
+ const { vista: e, cores: r, ui: i } = a;
954
+ t.save(), G(t, e.dpr), typeof t.clearRect == "function" && t.clearRect(0, 0, e.largura, e.altura), t.globalAlpha = 1, t.lineWidth = 1, t.setLineDash([]), t.beginPath();
955
+ for (const s of a.guias) Ga(t, s, e);
956
+ t.strokeStyle = r.guia, t.stroke(), i.guiaArrastada && (t.beginPath(), Ga(t, i.guiaArrastada.guia, e), t.setLineDash([4, 3]), t.stroke(), t.setLineDash([])), a.hover && !a.selecionados.includes(a.hover) && (t.beginPath(), Na(t, a.hover, e), t.strokeStyle = r.selecao, t.stroke()), a.emGesto.length > 0 && (N(t, a.emGesto, { matriz: e.matrizDispositivo() }), G(t, e.dpr), t.globalAlpha = 1, t.lineWidth = 1, t.setLineDash([])), i.previa && (N(t, [i.previa], { matriz: e.matrizDispositivo() }), G(t, e.dpr), t.globalAlpha = 1, t.lineWidth = 1, t.setLineDash([]));
957
+ for (const s of i.pontosPrevia) fa(t, e.paraTela(s), qa, r.alca, r.selecao);
958
+ const o = i.edicao ? a.selecionados.find((s) => s.id === i.edicao.id) ?? null : null;
959
+ for (const s of a.selecionados) {
960
+ const n = zt(s);
961
+ !n || s === o || (t.beginPath(), S(t, ja(n, e)), t.strokeStyle = r.selecao, t.stroke());
962
+ }
963
+ if (o && i.edicao) {
964
+ t.beginPath(), Na(t, o, e), t.strokeStyle = r.selecao, t.stroke();
965
+ const s = Sa(o), n = ce(o);
966
+ t.beginPath(), i.edicao.ancoras.forEach((l) => {
967
+ const c = s[l], d = n[l];
968
+ if (!(!c || !d))
969
+ for (const h of [d.entrada, d.saida]) h && S(t, [e.paraTela(c), e.paraTela(h)], !1);
970
+ }), t.stroke(), i.edicao.ancoras.forEach((l) => {
971
+ const c = n[l];
972
+ if (c)
973
+ for (const d of [c.entrada, c.saida])
974
+ d && (t.beginPath(), Y(t, e.paraTela(d), 3), t.fillStyle = r.selecao, t.fill());
975
+ }), s.forEach((l, c) => fa(t, e.paraTela(l), qa, i.edicao.ancoras.includes(c) ? r.selecao : r.alca, r.selecao));
976
+ } else if (a.caixaTransformacao && a.selecionados.length > 0) {
977
+ const s = Ma(a.selecionados);
978
+ if (s) {
979
+ const n = ue(s, De / e.zoom);
980
+ t.beginPath(), S(t, ja(s, e)), S(t, [e.paraTela(n.alcas.n), e.paraTela(n.rotacao)], !1), t.strokeStyle = r.selecao, t.stroke();
981
+ for (const c of Object.values(n.alcas)) fa(t, e.paraTela(c), Hr, r.alca, r.selecao);
982
+ t.beginPath(), Y(t, e.paraTela(n.rotacao), 4), t.fillStyle = r.alca, t.fill(), t.stroke();
983
+ for (const c of a.marcasCantos ?? [])
984
+ t.beginPath(), Y(t, e.paraTela(c), 3.5), t.fillStyle = r.alca, t.fill(), t.strokeStyle = r.selecao, t.stroke();
985
+ const l = e.paraTela(i.pivo ?? n.centro);
986
+ t.beginPath(), Y(t, l, 4), S(t, [[l[0] - 7, l[1]], [l[0] + 7, l[1]]], !1), S(t, [[l[0], l[1] - 7], [l[0], l[1] + 7]], !1), t.stroke();
987
+ }
988
+ }
989
+ if (i.linhasInteligentes.length > 0) {
990
+ t.beginPath();
991
+ for (const s of i.linhasInteligentes) {
992
+ const n = e.paraTela(s.orientacao === "vertical" ? [s.posicao, s.de] : [s.de, s.posicao]), l = e.paraTela(s.orientacao === "vertical" ? [s.posicao, s.ate] : [s.ate, s.posicao]);
993
+ S(t, [n, l], !1);
994
+ }
995
+ t.strokeStyle = r.guiaInteligente, t.stroke();
996
+ for (const s of i.linhasInteligentes) {
997
+ if (s.distancia === void 0) continue;
998
+ const n = e.paraTela(s.orientacao === "vertical" ? [s.posicao, (s.de + s.ate) / 2] : [(s.de + s.ate) / 2, s.posicao]);
999
+ pa(t, `${Math.round(s.distancia * 100) / 100} mm`, [n[0] + 4, n[1] - 4], r.guiaInteligente);
1000
+ }
1001
+ }
1002
+ if (i.caixaSelecao) {
1003
+ const s = e.paraTela(i.caixaSelecao.de), n = e.paraTela(i.caixaSelecao.ate);
1004
+ t.beginPath(), S(t, [s, [n[0], s[1]], n, [s[0], n[1]]]), t.setLineDash(i.caixaSelecao.crossing ? [5, 3] : []), t.strokeStyle = r.selecao, t.stroke(), t.setLineDash([]);
1005
+ }
1006
+ if (i.snap) {
1007
+ const s = e.paraTela(i.snap.coordenada);
1008
+ t.beginPath(), S(t, [[s[0] - 5, s[1] - 5], [s[0] + 5, s[1] - 5], [s[0] + 5, s[1] + 5], [s[0] - 5, s[1] + 5]]), t.strokeStyle = r.snap, t.stroke(), pa(t, i.snap.tipo, [s[0] + 8, s[1] - 8], r.snap);
1009
+ }
1010
+ if (i.rotulo) {
1011
+ const s = e.paraTela(i.rotulo.em);
1012
+ pa(t, i.rotulo.texto, [s[0] + 12, s[1] + 18], r.selecao);
1013
+ }
1014
+ t.restore();
1015
+ }
1016
+ const Ur = 14;
1017
+ function _e(t) {
1018
+ const a = t.doc.elementosSelecionados();
1019
+ return a.length !== 1 || t.ferramenta !== "selecao" || t.somenteLeitura ? null : Lt(t.ui.substitutos.get(a[0].id) ?? a[0], Ur / t.vista.zoom);
1020
+ }
1021
+ const F = (t, a) => Math.hypot(t[0] - a[0], t[1] - a[1]);
1022
+ function Ha(t, a, e) {
1023
+ const r = t.doc.elementosSelecionados(), i = r.length > 0 ? Ma(r) : null;
1024
+ if (!i) return null;
1025
+ const o = e ? 19 : 6, s = t.vista, n = ue(i, De / s.zoom), l = _e(t);
1026
+ if (l) {
1027
+ const c = l.findIndex((d) => F(s.paraTela(d), a) <= o);
1028
+ if (c >= 0) return { tipo: "canto", canto: c };
1029
+ }
1030
+ if (F(s.paraTela(t.ui.pivo ?? n.centro), a) <= o) return { tipo: "pivo" };
1031
+ if (F(s.paraTela(n.rotacao), a) <= o) return { tipo: "rotacao" };
1032
+ for (const c of Ct) if (F(s.paraTela(n.alcas[c]), a) <= o) return { tipo: "escala", alca: c };
1033
+ return null;
1034
+ }
1035
+ function Xr(t, a, e, r) {
1036
+ const i = t.doc.elementosSelecionados().filter((n) => !n.bloqueado), o = Ma(i);
1037
+ if (!o || i.length === 0) return null;
1038
+ if (a.tipo === "pivo") return { tipo: "pivo" };
1039
+ if (a.tipo === "canto") {
1040
+ const n = i[0], l = de(n), c = he(n, a.canto ?? 0, e);
1041
+ return i.length !== 1 || !l || c === null ? null : { tipo: "canto", original: n, indice: a.canto ?? 0, raio0: l[a.canto ?? 0], profundidade0: c };
1042
+ }
1043
+ if (a.tipo === "rotacao") return { tipo: "rotacao", pivo: da(t) ?? e, inicio: e, originais: i };
1044
+ const s = a.alca;
1045
+ return r.ctrl && (s === "n" || s === "s" || s === "e" || s === "o") ? { tipo: "cisalhamento", caixa: o, alca: s, originais: i } : { tipo: "escala", caixa: o, alca: s, originais: i };
1046
+ }
1047
+ function Zr(t, a, e) {
1048
+ const r = 50 / t.vista.zoom, i = t.doc.indice.consultarCaixa(a, r).filter((s) => !e.has(s.id) && !s.oculto), o = [{ x: 0, y: 0, largura: t.folha.largura, altura: t.folha.altura }];
1049
+ for (const s of i.slice(0, 200)) {
1050
+ const n = W(s);
1051
+ n && o.push(n);
1052
+ }
1053
+ return o;
1054
+ }
1055
+ function Wr(t) {
1056
+ let a = 1 / 0, e = 1 / 0, r = -1 / 0, i = -1 / 0;
1057
+ for (const o of t) {
1058
+ const s = Rt(o);
1059
+ s && (a = Math.min(a, s.x), e = Math.min(e, s.y), r = Math.max(r, s.x + s.largura), i = Math.max(i, s.y + s.altura));
1060
+ }
1061
+ return a <= r ? { x: a, y: e, largura: r - a, altura: i - e } : null;
1062
+ }
1063
+ function Jr(t, a, e = !1, r = !1) {
1064
+ const i = t.doc.elementosSelecionados().filter((n) => !n.bloqueado);
1065
+ if (i.length === 0) return null;
1066
+ const o = i.length <= 200 ? i.length === 1 ? W(i[0]) : Wr(i) : null, s = t.snapLigado && i.length <= 200 ? te(a, i, t.vista.zoom, { toleranciaPx: t.toleranciaPx(e), meio: !1, aresta: !1 }) : null;
1067
+ return { tipo: "mover", inicio: s ? s.coordenada : a, originais: i, caixa: o, duplicar: r };
1068
+ }
1069
+ function Qr(t, a, e, r) {
1070
+ var s, n, l;
1071
+ const i = t.ui;
1072
+ i.linhasInteligentes = [], i.snap = null;
1073
+ let o = [];
1074
+ switch (a.tipo) {
1075
+ case "pivo":
1076
+ i.pivo = t.snapPonto(e, { toque: r.toque, desligado: r.alt }).ponto;
1077
+ break;
1078
+ case "mover": {
1079
+ let c = e[0] - a.inicio[0], d = e[1] - a.inicio[1];
1080
+ r.shift && (Math.abs(c) >= Math.abs(d) ? d = 0 : c = 0);
1081
+ const h = new Set(a.originais.map((f) => f.id));
1082
+ if ((!r.alt || a.duplicar) && t.snapLigado) {
1083
+ const f = t.snapPonto([a.inicio[0] + c, a.inicio[1] + d], { excluir: h, grade: !1, toque: r.toque });
1084
+ if (f.resultado)
1085
+ c = f.ponto[0] - a.inicio[0], d = f.ponto[1] - a.inicio[1];
1086
+ else if (a.caixa && t.guiasInteligentes) {
1087
+ const p = { ...a.caixa, x: a.caixa.x + c, y: a.caixa.y + d }, v = kt(p, Zr(t, p, h), 6 / t.vista.zoom);
1088
+ if (c += v.correcao[0], d += v.correcao[1], i.linhasInteligentes = v.linhas, v.linhas.length === 0) {
1089
+ const b = t.snapPonto([a.inicio[0] + c, a.inicio[1] + d], { excluir: h, toque: r.toque });
1090
+ ((s = b.resultado) == null ? void 0 : s.tipo) === "grade" && (c = b.ponto[0] - a.inicio[0], d = b.ponto[1] - a.inicio[1]);
1091
+ }
1092
+ }
1093
+ }
1094
+ a.matriz = k(c, d), o = T(a.originais, a.matriz), a.duplicar && (i.copiasEmGesto = o, o = []);
1095
+ const u = (f) => Math.round(f * 100) / 100;
1096
+ i.rotulo = { texto: `Δ ${u(c)}, ${u(d)} mm`, em: e };
1097
+ break;
1098
+ }
1099
+ case "escala": {
1100
+ const c = t.snapPonto(e, { excluir: a.originais.map((h) => h.id), toque: r.toque }).ponto, d = Ft(a.caixa, a.alca, c, { proporcional: r.shift, doCentro: r.alt });
1101
+ d && (a.matriz = d, o = T(a.originais, d));
1102
+ break;
1103
+ }
1104
+ case "cisalhamento": {
1105
+ const c = _t(a.caixa, a.alca, e);
1106
+ c && (a.matriz = c, o = T(a.originais, c));
1107
+ break;
1108
+ }
1109
+ case "rotacao": {
1110
+ const c = Dt(a.pivo, a.inicio, e, r.shift ? Math.PI / 4 : void 0);
1111
+ a.matriz = c.matriz, o = T(a.originais, c.matriz), i.rotulo = { texto: `${Math.round(c.angulo * 180 / Math.PI * 10) / 10}°`, em: e };
1112
+ break;
1113
+ }
1114
+ case "ancora": {
1115
+ const c = ((n = i.edicao) == null ? void 0 : n.ancoras) ?? [];
1116
+ if (c.length > 1 && c.includes(a.indice)) {
1117
+ const d = ie(a.original, c, e[0] - a.inicio[0], e[1] - a.inicio[1]);
1118
+ d && (o = [d]);
1119
+ } else {
1120
+ const d = t.snapPonto(e, { excluir: [a.original.id], toque: r.toque, desligado: r.alt }).ponto, h = It(a.original, a.indice, d);
1121
+ h && (o = [h]);
1122
+ }
1123
+ break;
1124
+ }
1125
+ case "alca-bezier": {
1126
+ const c = wt(a.original, a.indice, a.qual, e, !r.alt);
1127
+ c && (o = [c]);
1128
+ break;
1129
+ }
1130
+ case "canto": {
1131
+ const c = he(a.original, a.indice, e);
1132
+ if (c === null) break;
1133
+ const d = Tt(a.original, r.alt ? a.indice : null, a.raio0 + c - a.profundidade0);
1134
+ if (d) {
1135
+ o = [d];
1136
+ const h = ((l = de(d)) == null ? void 0 : l[a.indice]) ?? 0;
1137
+ i.rotulo = { texto: `R ${Math.round(h * 100) / 100} mm`, em: e };
1138
+ }
1139
+ break;
1140
+ }
1141
+ }
1142
+ i.substitutos = new Map(o.map((c) => [c.id, c])), t.agendar();
1143
+ }
1144
+ function Yr(t, a) {
1145
+ const e = [...t.ui.substitutos.values()];
1146
+ if (t.ui.substitutos = /* @__PURE__ */ new Map(), t.ui.copiasEmGesto = [], t.ui.linhasInteligentes = [], t.ui.snap = null, t.ui.rotulo = null, a.tipo === "mover" && a.duplicar) {
1147
+ if (a.matriz) {
1148
+ const i = T(le(a.originais, t.gerarId), a.matriz);
1149
+ w(t, i, "duplicar"), Oa(t, a.matriz, !0);
1150
+ }
1151
+ t.agendar();
1152
+ return;
1153
+ }
1154
+ if ((a.tipo === "mover" || a.tipo === "escala" || a.tipo === "rotacao" || a.tipo === "cisalhamento") && a.matriz && e.length > 0 && Oa(t, a.matriz, !1), a.tipo === "pivo" || e.length === 0) {
1155
+ t.agendar();
1156
+ return;
1157
+ }
1158
+ const r = a.tipo === "mover" ? "mover" : a.tipo === "ancora" || a.tipo === "alca-bezier" ? "editar-ancoras" : a.tipo === "canto" ? "cantos" : "transformar";
1159
+ (a.tipo === "rotacao" || a.tipo === "escala" || a.tipo === "cisalhamento") && t.ui.pivo && a.tipo !== "rotacao" && (t.ui.pivo = null), t.aplicarSubstituicoes(e, r);
1160
+ }
1161
+ function $a(t, a, e) {
1162
+ const r = t.ui.edicao, i = r ? t.doc.obter(r.id) : void 0;
1163
+ if (!r || !i) return null;
1164
+ const o = e ? 19 : 6, s = t.vista, n = ce(i);
1165
+ for (const d of r.ancoras) {
1166
+ const h = n[d];
1167
+ if (h != null && h.saida && F(s.paraTela(h.saida), a) <= o) return { tipo: "alca", indice: d, qual: "saida" };
1168
+ if (h != null && h.entrada && F(s.paraTela(h.entrada), a) <= o) return { tipo: "alca", indice: d, qual: "entrada" };
1169
+ }
1170
+ const l = Sa(i);
1171
+ let c = null;
1172
+ return l.forEach((d, h) => {
1173
+ const u = F(s.paraTela(d), a);
1174
+ u <= o && (!c || u < c.d) && (c = { indice: h, d: u });
1175
+ }), c ? { tipo: "ancora", indice: c.indice } : null;
1176
+ }
1177
+ function ai(t, a, e) {
1178
+ const r = t.ui.edicao, i = r ? t.doc.obter(r.id) : void 0;
1179
+ if (!i) return [];
1180
+ const o = Math.min(a[0], e[0]), s = Math.max(a[0], e[0]), n = Math.min(a[1], e[1]), l = Math.max(a[1], e[1]);
1181
+ return Sa(i).map((c, d) => c[0] >= o && c[0] <= s && c[1] >= n && c[1] <= l ? d : -1).filter((c) => c >= 0);
1182
+ }
1183
+ const ei = ["conta-gotas", "adicionar-ancora", "excluir-ancora", "converter-ancora"], ti = (t) => ei.includes(t), Fe = (t, a) => (a ? 19 : 8) / t.vista.zoom;
1184
+ function ri(t, a, e) {
1185
+ const r = Fe(t, e), i = t.doc.elementosSelecionados(), o = oa(a, t.candidatosEm(a, r + 2), { tolerancia: r, camadas: t.camadas });
1186
+ return o && !i.includes(o) ? [...i, o] : i;
1187
+ }
1188
+ function ii(t, a, e) {
1189
+ const r = t.ferramenta, i = Fe(t, e);
1190
+ if (r === "conta-gotas") {
1191
+ const o = oa(a, t.candidatosEm(a, i + 2), { tolerancia: i, camadas: t.camadas, incluirBloqueados: !0 });
1192
+ return o ? kr(t, o) : !1;
1193
+ }
1194
+ if (t.somenteLeitura)
1195
+ return t.recusar("editar-ancoras", "somente-leitura"), !1;
1196
+ for (const o of ri(t, a, e)) {
1197
+ if (!t.podeSelecionar(o)) continue;
1198
+ let s = null;
1199
+ if (r === "adicionar-ancora") {
1200
+ const n = Ot(o, a, i);
1201
+ if (n === null) continue;
1202
+ s = qt(o, n, a);
1203
+ } else {
1204
+ const n = Nt(o, a, i);
1205
+ if (n === null) continue;
1206
+ if (s = r === "excluir-ancora" ? oe(o, n) : jt(o, n), !s)
1207
+ return t.recusar(r, r === "excluir-ancora" ? "minimo-de-ancoras" : "tipo-nao-suportado", o.id), !1;
1208
+ }
1209
+ return s ? (t.aplicarSubstituicoes([s], "editar-ancoras"), t.doc.selecao.includes(s.id) || t.selecionar([s.id], "substituir", !1), !0) : (t.recusar(r, o.geometria.tipo === "texto" ? "texto-sem-ancoras" : "tipo-nao-suportado", o.id), !1);
1210
+ }
1211
+ return !1;
1212
+ }
1213
+ const oi = 4, Ba = 3;
1214
+ class si {
1215
+ constructor(a, e, r) {
1216
+ m(this, "gesto", { tipo: "nenhum" });
1217
+ /** Espaço segurado (pan temporário). */
1218
+ m(this, "espaco", !1);
1219
+ m(this, "ultimoClique", null);
1220
+ this.c = a, this.viewport = e, this.ferramentas = r;
1221
+ }
1222
+ conectar(a, e, r) {
1223
+ a.add(this.viewport, "pointerdown", (i) => this.pressionar(i)), a.add(this.viewport, "pointermove", (i) => this.mover(i)), a.add(this.viewport, "pointerup", (i) => this.soltar(i)), a.add(this.viewport, "pointercancel", () => this.cancelar()), a.add(this.viewport, "pointerleave", () => this.sair()), a.add(this.viewport, "wheel", (i) => this.roda(i), { passive: !1 }), a.add(this.viewport, "contextmenu", (i) => {
1224
+ this.ferramentas.emAndamento && i.preventDefault();
1225
+ }), a.add(e, "pointerdown", (i) => this.puxarGuia(i, "horizontal")), a.add(r, "pointerdown", (i) => this.puxarGuia(i, "vertical"));
1226
+ }
1227
+ get ocupado() {
1228
+ return this.gesto.tipo !== "nenhum" || this.ferramentas.emAndamento;
1229
+ }
1230
+ local(a) {
1231
+ var r, i;
1232
+ const e = (i = (r = this.viewport).getBoundingClientRect) == null ? void 0 : i.call(r);
1233
+ return [a.clientX - ((e == null ? void 0 : e.left) ?? 0), a.clientY - ((e == null ? void 0 : e.top) ?? 0)];
1234
+ }
1235
+ mod(a) {
1236
+ return { shift: a.shiftKey, alt: a.altKey, ctrl: a.ctrlKey || a.metaKey, toque: a.pointerType === "touch" };
1237
+ }
1238
+ capturar(a) {
1239
+ var e, r;
1240
+ try {
1241
+ (r = (e = this.viewport).setPointerCapture) == null || r.call(e, a.pointerId);
1242
+ } catch {
1243
+ }
1244
+ }
1245
+ cursor(a) {
1246
+ this.viewport.dataset.cursor !== a && (this.viewport.dataset.cursor = a);
1247
+ }
1248
+ guiaSob(a) {
1249
+ const e = this.c.vista;
1250
+ for (let r = this.c.guias.length - 1; r >= 0; r--) {
1251
+ const i = this.c.guias[r];
1252
+ if ((i.orientacao === "horizontal" ? Math.abs(e.paraTela([0, i.posicao])[1] - a[1]) : Math.abs(e.paraTela([i.posicao, 0])[0] - a[0])) <= oi) return r;
1253
+ }
1254
+ return null;
1255
+ }
1256
+ pressionar(a) {
1257
+ if (a.button === 2) return;
1258
+ try {
1259
+ this.viewport.focus({ preventScroll: !0 });
1260
+ } catch {
1261
+ }
1262
+ const e = this.local(a), r = this.c.vista.paraFolha(e[0], e[1]), i = this.mod(a), o = this.c.ferramenta;
1263
+ if (this.capturar(a), a.button === 1 || this.espaco || o === "mao") {
1264
+ this.gesto = { tipo: "pan", inicioPx: e, panInicial: [...this.c.vista.pan] }, this.cursor("arrastando");
1265
+ return;
1266
+ }
1267
+ if (ti(o)) {
1268
+ ii(this.c, r, i.toque);
1269
+ return;
1270
+ }
1271
+ if (na(o)) {
1272
+ if (this.c.somenteLeitura) {
1273
+ this.c.recusar("desenhar", "somente-leitura");
1274
+ return;
1275
+ }
1276
+ this.gesto = { tipo: "desenho" }, this.ferramentas.pressionar(r, e, i);
1277
+ return;
1278
+ }
1279
+ const s = Date.now(), n = !i.shift && !!this.ultimoClique && s - this.ultimoClique.t <= 400 && Math.hypot(e[0] - this.ultimoClique.x, e[1] - this.ultimoClique.y) <= 4;
1280
+ if (this.ultimoClique = n ? null : { t: s, x: e[0], y: e[1] }, o === "selecao-direta" && this.c.ui.edicao) {
1281
+ const u = $a(this.c, e, i.toque), f = this.c.doc.obter(this.c.ui.edicao.id);
1282
+ if (u && f && !this.c.somenteLeitura) {
1283
+ const p = this.c.ui.edicao;
1284
+ u.tipo === "alca" ? this.gesto = { tipo: "selecao", gesto: { tipo: "alca-bezier", original: f, indice: u.indice, qual: u.qual }, inicioPx: e, moveu: !1 } : (i.shift ? p.ancoras = p.ancoras.includes(u.indice) ? p.ancoras.filter((v) => v !== u.indice) : [...p.ancoras, u.indice] : p.ancoras.includes(u.indice) || (p.ancoras = [u.indice]), this.gesto = { tipo: "selecao", gesto: { tipo: "ancora", original: f, indice: u.indice, inicio: r }, inicioPx: e, moveu: !1 }), this.c.agendar();
1285
+ return;
1286
+ }
1287
+ }
1288
+ if (o === "selecao" && !this.c.somenteLeitura) {
1289
+ const u = Ha(this.c, e, i.toque);
1290
+ if (u) {
1291
+ const f = Xr(this.c, u, r, i);
1292
+ if (f) {
1293
+ this.gesto = { tipo: "selecao", gesto: f, inicioPx: e, moveu: !1 };
1294
+ return;
1295
+ }
1296
+ }
1297
+ }
1298
+ const l = (i.toque ? 12 : 4) / this.c.vista.zoom, c = this.c.candidatosEm(r, l + 2).filter((u) => this.c.podeSelecionar(u)), d = oa(r, c, { tolerancia: l, camadas: this.c.camadas });
1299
+ if (d) {
1300
+ if (n && o === "selecao") {
1301
+ if (d.grupoId && this.c.isolado !== d.grupoId) {
1302
+ this.c.isolar(d.grupoId), this.c.selecionar([d.id], "substituir", !1);
1303
+ return;
1304
+ }
1305
+ this.c.definirFerramenta("selecao-direta"), this.c.iniciarEdicao(d.id);
1306
+ return;
1307
+ }
1308
+ if (o === "selecao-direta" ? this.c.iniciarEdicao(d.id) : i.shift ? this.c.selecionar([d.id], "alternar") : this.c.doc.selecao.includes(d.id) || this.c.selecionar([d.id]), this.c.somenteLeitura || !this.c.doc.selecao.includes(d.id)) return;
1309
+ const u = Jr(this.c, r, i.toque, i.alt && o === "selecao");
1310
+ u && (this.gesto = { tipo: "selecao", gesto: u, inicioPx: e, moveu: !1 });
1311
+ return;
1312
+ }
1313
+ if (n && this.c.isolado) {
1314
+ this.c.isolar(null);
1315
+ return;
1316
+ }
1317
+ const h = o === "selecao" && !this.c.somenteLeitura ? this.guiaSob(e) : null;
1318
+ if (h !== null) {
1319
+ this.gesto = { tipo: "guia", indice: h }, this.c.ui.guiaArrastada = { guia: { ...this.c.guias[h] }, indice: h };
1320
+ return;
1321
+ }
1322
+ this.gesto = { tipo: "caixa", de: r, dePx: e, aditivo: i.shift, moveu: !1 };
1323
+ }
1324
+ mover(a) {
1325
+ const e = this.local(a), r = this.c.vista.paraFolha(e[0], e[1]), i = this.mod(a);
1326
+ this.c.ui.ponteiro = r, this.c.emitir("prancha-ponteiro", { coordenada: r });
1327
+ const o = this.gesto;
1328
+ switch (o.tipo) {
1329
+ case "pan":
1330
+ this.c.vista.pan = [o.panInicial[0] + e[0] - o.inicioPx[0], o.panInicial[1] + e[1] - o.inicioPx[1]], this.c.emitirVista();
1331
+ return;
1332
+ case "desenho":
1333
+ this.ferramentas.mover(r, e, i);
1334
+ return;
1335
+ case "selecao":
1336
+ if (!o.moveu && Math.hypot(e[0] - o.inicioPx[0], e[1] - o.inicioPx[1]) < Ba) return;
1337
+ o.moveu = !0, Qr(this.c, o.gesto, r, i);
1338
+ return;
1339
+ case "guia": {
1340
+ const s = this.c.ui.guiaArrastada;
1341
+ s && (s.guia = { ...s.guia, posicao: s.guia.orientacao === "horizontal" ? r[1] : r[0] }), this.c.agendar();
1342
+ return;
1343
+ }
1344
+ case "caixa":
1345
+ if (!o.moveu && Math.hypot(e[0] - o.dePx[0], e[1] - o.dePx[1]) < Ba) return;
1346
+ o.moveu = !0, this.c.ui.caixaSelecao = { de: o.de, ate: r, crossing: r[0] < o.de[0] }, this.c.agendar();
1347
+ return;
1348
+ }
1349
+ if (na(this.c.ferramenta)) {
1350
+ this.ferramentas.mover(r, e, i), this.cursor("mira");
1351
+ return;
1352
+ }
1353
+ this.atualizarHover(r, e, i.toque);
1354
+ }
1355
+ atualizarHover(a, e, r) {
1356
+ const i = this.c.ferramenta;
1357
+ if (i === "mao" || this.espaco) {
1358
+ this.cursor("mao");
1359
+ return;
1360
+ }
1361
+ const o = i === "selecao" ? Ha(this.c, e, r) : null, s = 4 / this.c.vista.zoom, n = oa(a, this.c.candidatosEm(a, s + 2).filter((c) => this.c.podeSelecionar(c)), { tolerancia: s, camadas: this.c.camadas }), l = (n == null ? void 0 : n.id) ?? null;
1362
+ this.cursor(o ? o.tipo === "rotacao" ? "girar" : "mover" : i === "selecao-direta" && $a(this.c, e, r) ? "ancora" : n ? "mover" : "padrao"), l !== this.c.ui.hoverId ? (this.c.ui.hoverId = l, this.c.agendar()) : this.c.ui.ponteiro && this.c.agendar();
1363
+ }
1364
+ soltar(a) {
1365
+ var o, s;
1366
+ const e = this.local(a), r = this.c.vista.paraFolha(e[0], e[1]), i = this.gesto;
1367
+ this.gesto = { tipo: "nenhum" };
1368
+ try {
1369
+ (s = (o = this.viewport).releasePointerCapture) == null || s.call(o, a.pointerId);
1370
+ } catch {
1371
+ }
1372
+ switch (i.tipo) {
1373
+ case "pan":
1374
+ this.cursor(this.espaco || this.c.ferramenta === "mao" ? "mao" : "padrao");
1375
+ return;
1376
+ case "desenho":
1377
+ this.ferramentas.soltar(r, e, this.mod(a));
1378
+ return;
1379
+ case "selecao":
1380
+ i.moveu ? Yr(this.c, i.gesto) : this.c.agendar();
1381
+ return;
1382
+ case "guia":
1383
+ this.soltarGuia(i.indice, e);
1384
+ return;
1385
+ case "caixa":
1386
+ this.soltarCaixa(i, r);
1387
+ return;
1388
+ default:
1389
+ return;
1390
+ }
1391
+ }
1392
+ soltarCaixa(a, e) {
1393
+ if (this.c.ui.caixaSelecao = null, !a.moveu) {
1394
+ this.c.ui.edicao && this.c.ferramenta === "selecao-direta" && this.c.encerrarEdicao(), a.aditivo || this.c.selecionar([]), this.c.agendar();
1395
+ return;
1396
+ }
1397
+ if (this.c.ferramenta === "selecao-direta" && this.c.ui.edicao) {
1398
+ this.c.ui.edicao.ancoras = ai(this.c, a.de, e), this.c.agendar();
1399
+ return;
1400
+ }
1401
+ const r = { x: Math.min(a.de[0], e[0]), y: Math.min(a.de[1], e[1]), largura: Math.abs(e[0] - a.de[0]), altura: Math.abs(e[1] - a.de[1]) }, i = e[0] < a.de[0] ? "crossing" : "window", o = this.c.doc.indice.consultarCaixa(r).filter((n) => this.c.podeSelecionar(n)), s = Gt(r, o, i, { camadas: this.c.camadas }).map((n) => n.id);
1402
+ this.c.selecionar(s, a.aditivo ? "adicionar" : "substituir") || this.c.agendar();
1403
+ }
1404
+ puxarGuia(a, e) {
1405
+ if (a.button !== 0 || this.c.somenteLeitura) return;
1406
+ const r = this.local(a), i = this.c.vista.paraFolha(r[0], r[1]);
1407
+ this.capturar(a), this.gesto = { tipo: "guia", indice: null }, this.c.ui.guiaArrastada = { guia: { orientacao: e, posicao: e === "horizontal" ? i[1] : i[0] }, indice: null }, this.c.agendar();
1408
+ }
1409
+ soltarGuia(a, e) {
1410
+ const r = this.c.ui.guiaArrastada;
1411
+ if (this.c.ui.guiaArrastada = null, !r) return;
1412
+ const i = r.guia.orientacao === "horizontal" ? e[1] < 0 : e[0] < 0;
1413
+ a === null ? i || (this.c.guias = [...this.c.guias, r.guia]) : i ? this.c.guias = this.c.guias.filter((o, s) => s !== a) : this.c.guias = this.c.guias.map((o, s) => s === a ? r.guia : o), this.c.emitirGuias();
1414
+ }
1415
+ roda(a) {
1416
+ a.preventDefault();
1417
+ const e = this.local(a), r = a.deltaMode === 1 ? a.deltaY * 16 : a.deltaY;
1418
+ if (a.shiftKey && !a.ctrlKey) {
1419
+ this.c.vista.deslocar(-r, 0), this.c.emitirVista();
1420
+ return;
1421
+ }
1422
+ this.c.vista.zoomRelativo(Math.exp(-r * 15e-4), e) && (this.c.emitirVista(), this.c.anunciar(sa(this.c.vista.zoomPercentual)));
1423
+ }
1424
+ sair() {
1425
+ this.gesto.tipo === "nenhum" && (this.c.ui.ponteiro = null, this.c.ui.hoverId = null, this.c.ui.snap = null, this.c.emitir("prancha-ponteiro", { coordenada: null }), this.c.agendar());
1426
+ }
1427
+ /** Cancela qualquer gesto (Esc, perda de ponteiro): nada muda no documento. */
1428
+ cancelar() {
1429
+ this.gesto = { tipo: "nenhum" }, this.ferramentas.cancelar(), j(this.c.ui), this.c.agendar();
1430
+ }
1431
+ }
1432
+ function ni(t, a = 50) {
1433
+ if (!(t > 0) || !Number.isFinite(t)) return 1;
1434
+ const e = a / t, r = 10 ** Math.floor(Math.log10(e));
1435
+ for (const i of [1, 2, 5, 10]) if (i * r >= e) return i * r;
1436
+ return 10 * r;
1437
+ }
1438
+ function li(t, a) {
1439
+ const { vista: e, cores: r, comprimento: i, espessura: o } = a, s = a.orientacao === "horizontal";
1440
+ t.save(), t.setTransform(e.dpr, 0, 0, e.dpr, 0, 0), t.globalAlpha = 1, t.fillStyle = r.regua, t.fillRect(0, 0, s ? i : o, s ? o : i);
1441
+ const n = 1 / Ht(1, a.unidade), l = e.zoom * n, c = ni(l), d = c / (c * l >= 100 ? 10 : 5), h = (s ? e.pan[0] : e.pan[1]) + a.deslocamento, u = Math.floor(-h / l / d) * d, f = (i - h) / l;
1442
+ t.beginPath();
1443
+ const p = [];
1444
+ for (let v = u, b = 0; v <= f && b < 5e3; v += d, b++) {
1445
+ const M = Math.round(h + v * l) + 0.5, x = Math.abs(v / c - Math.round(v / c)) < 1e-6, C = x ? o : o * 0.3;
1446
+ s ? (t.moveTo(M, o), t.lineTo(M, o - C)) : (t.moveTo(o, M), t.lineTo(o - C, M)), x && p.push([String(Math.round(v * 1e3) / 1e3), M]);
1447
+ }
1448
+ if (t.strokeStyle = r.textoRegua, t.lineWidth = 1, t.setLineDash([]), t.stroke(), typeof t.fillText == "function") {
1449
+ t.font = "9px sans-serif", t.fillStyle = r.textoRegua;
1450
+ for (const [v, b] of p)
1451
+ s ? t.fillText(v, b + 2, 9) : t.fillText(v, 1, b + 10);
1452
+ }
1453
+ if (a.ponteiro) {
1454
+ const v = e.paraTela(a.ponteiro), b = Math.round((s ? v[0] : v[1]) + a.deslocamento) + 0.5;
1455
+ t.beginPath(), s ? (t.moveTo(b, 0), t.lineTo(b, o)) : (t.moveTo(0, b), t.lineTo(o, b)), t.strokeStyle = r.selecao, t.stroke();
1456
+ }
1457
+ t.restore();
1458
+ }
1459
+ const Ka = (t) => {
1460
+ var a;
1461
+ try {
1462
+ return ((a = t.getContext) == null ? void 0 : a.call(t, "2d")) ?? null;
1463
+ } catch {
1464
+ return null;
1465
+ }
1466
+ };
1467
+ class ci {
1468
+ constructor(a, e, r) {
1469
+ m(this, "pedido", null);
1470
+ m(this, "contextos", /* @__PURE__ */ new Map());
1471
+ m(this, "ultimaBase", { elementos: null, texto: "" });
1472
+ m(this, "quadros", 0);
1473
+ m(this, "pinturasBase", 0);
1474
+ this.c = a, this.cv = e, this.fabrica = r;
1475
+ }
1476
+ /** Esquece os contextos (a fábrica mudou) e força a próxima pintura da base. */
1477
+ reiniciar() {
1478
+ this.contextos.clear(), this.ultimaBase = { elementos: null, texto: "" };
1479
+ }
1480
+ ctx(a, e) {
1481
+ return this.contextos.has(a) || this.contextos.set(a, this.fabrica()(e, a)), this.contextos.get(a) ?? null;
1482
+ }
1483
+ agendar() {
1484
+ this.pedido || (typeof requestAnimationFrame == "function" ? this.pedido = { tipo: "raf", id: requestAnimationFrame(() => {
1485
+ this.pedido = null, this.pintar();
1486
+ }) } : typeof setTimeout == "function" && (this.pedido = { tipo: "timeout", id: setTimeout(() => {
1487
+ this.pedido = null, this.pintar();
1488
+ }, 16) }));
1489
+ }
1490
+ cancelar() {
1491
+ this.pedido && (this.pedido.tipo === "raf" && typeof cancelAnimationFrame == "function" ? cancelAnimationFrame(this.pedido.id) : clearTimeout(this.pedido.id), this.pedido = null);
1492
+ }
1493
+ ajustar(a, e, r, i) {
1494
+ const o = Math.max(0, Math.round(e * i)), s = Math.max(0, Math.round(r * i));
1495
+ return a.width === o && a.height === s ? !1 : (a.width = o, a.height = s, !0);
1496
+ }
1497
+ /** Mede a área de desenho; devolve se o tamanho mudou. */
1498
+ medir() {
1499
+ const a = this.c.vista, e = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, r = `${a.largura}x${a.altura}@${a.dpr}`;
1500
+ a.redimensionar(this.cv.viewport.clientWidth || 0, this.cv.viewport.clientHeight || 0, e);
1501
+ const i = r !== `${a.largura}x${a.altura}@${a.dpr}`;
1502
+ return i && (this.ultimaBase = { elementos: null, texto: "" }), i;
1503
+ }
1504
+ /** Pinta agora (o que estiver agendado é descartado). */
1505
+ pintar() {
1506
+ this.cancelar(), this.quadros++;
1507
+ const a = this.c, e = a.vista;
1508
+ if (e.largura <= 0 || e.altura <= 0) return;
1509
+ const r = this.ajustar(this.cv.base, e.largura, e.altura, e.dpr);
1510
+ this.ajustar(this.cv.sobreposicao, e.largura, e.altura, e.dpr);
1511
+ const i = a.elementosVisiveis(), o = [
1512
+ e.zoom,
1513
+ e.pan[0],
1514
+ e.pan[1],
1515
+ e.largura,
1516
+ e.altura,
1517
+ e.dpr,
1518
+ a.folha.largura,
1519
+ a.folha.altura,
1520
+ a.mostrarGrade ? a.grade : 0,
1521
+ Object.values(a.cores).join(),
1522
+ JSON.stringify(a.camadas),
1523
+ a.isolado ?? "",
1524
+ JSON.stringify(a.margens)
1525
+ ].join("|"), s = this.ctx("base", this.cv.base);
1526
+ if (s && (r || i !== this.ultimaBase.elementos || o !== this.ultimaBase.texto)) {
1527
+ try {
1528
+ const l = a.isolado ? i.filter((c) => c.grupoId === a.isolado) : null;
1529
+ Kr(s, { vista: e, folha: a.folha, cores: a.cores, elementos: i, grade: a.mostrarGrade ? a.grade : null, camadas: a.camadas, isolados: l, margens: a.margens ? me(a.folha.largura, a.folha.altura, a.margens) : null }), this.pinturasBase++;
1530
+ } catch {
1531
+ }
1532
+ this.ultimaBase = { elementos: i, texto: o };
1533
+ }
1534
+ const n = this.ctx("sobreposicao", this.cv.sobreposicao);
1535
+ if (n)
1536
+ try {
1537
+ const l = a.ui.hoverId ? a.doc.obter(a.ui.hoverId) ?? null : null, c = a.doc.elementosSelecionados().map((d) => a.ui.substitutos.get(d.id) ?? d);
1538
+ Vr(n, { vista: e, cores: a.cores, ui: a.ui, selecionados: c, emGesto: a.elementosEmGesto(), hover: l, guias: a.guias, caixaTransformacao: a.ferramenta === "selecao", marcasCantos: _e(a) });
1539
+ } catch {
1540
+ }
1541
+ this.pintarReguas();
1542
+ }
1543
+ pintarReguas() {
1544
+ const a = this.c;
1545
+ for (const [e, r, i] of [["regua-horizontal", this.cv.reguaH, "horizontal"], ["regua-vertical", this.cv.reguaV, "vertical"]]) {
1546
+ const o = i === "horizontal" ? r.clientWidth : r.clientHeight, s = i === "horizontal" ? r.clientHeight : r.clientWidth;
1547
+ if (!(o > 0 && s > 0)) continue;
1548
+ this.ajustar(r, i === "horizontal" ? o : s, i === "horizontal" ? s : o, a.vista.dpr);
1549
+ const n = this.ctx(e, r);
1550
+ if (n)
1551
+ try {
1552
+ li(n, { orientacao: i, vista: a.vista, unidade: a.unidade, comprimento: o, espessura: s, cores: a.cores, ponteiro: a.ui.ponteiro, deslocamento: 0 });
1553
+ } catch {
1554
+ }
1555
+ }
1556
+ }
1557
+ }
1558
+ function L(t, a) {
1559
+ if (!$t.includes(a))
1560
+ return t.recusar("pathfinder", "comando-desconhecido"), !1;
1561
+ const e = y(t, "pathfinder", 2);
1562
+ if (!e) return !1;
1563
+ const r = Bt($(e, t.camadas), a);
1564
+ if (!("ok" in r)) {
1565
+ const n = r.motivo === "sem-intersecao" || r.motivo === "resultado-vazio";
1566
+ return t.recusar("pathfinder", n ? "resultado-vazio" : "tipo-nao-suportado"), !1;
1567
+ }
1568
+ const { resultado: i, usados: o } = r.ok, s = new Set(o.filter((n) => n !== i.id));
1569
+ return t.aplicar(t.doc.elementos.filter((n) => !s.has(n.id)).map((n) => n.id === i.id ? i : n), "pathfinder"), t.selecionar([i.id]), !0;
1570
+ }
1571
+ const ke = /* @__PURE__ */ new WeakSet(), Va = /* @__PURE__ */ new WeakSet(), Ji = (t) => !!t && ke.has(t);
1572
+ function ui(t) {
1573
+ ke.add(t);
1574
+ }
1575
+ const Aa = (t) => t === "exclusivo" || t === "isolado" ? t : "local";
1576
+ function di(t) {
1577
+ if (!t || typeof t != "object") return !1;
1578
+ const a = typeof t.key == "string" ? t.key : "";
1579
+ if (a === "F5" || a === "F11" || a === "F12" || a === "Tab") return !0;
1580
+ if (!(t.ctrlKey || t.metaKey) || t.altKey) return !1;
1581
+ const r = a.length === 1 ? a.toLowerCase() : a;
1582
+ return !!(t.shiftKey && (r === "i" || r === "j") || r === "r" || r === "l" || r === "w" || r === "t" || (r === "+" || r === "=" || r === "-" || r === "0") && !t.defaultPrevented);
1583
+ }
1584
+ function Le(t, a, e) {
1585
+ for (const r of ["keydown", "keyup", "keypress"])
1586
+ t.add(a, r, (i) => {
1587
+ e() && !di(i) && i.stopPropagation();
1588
+ });
1589
+ }
1590
+ const Ua = { Digit1: "uniao", Digit2: "subtracao", Digit3: "intersecao", Digit4: "exclusao" }, Xa = {
1591
+ v: "selecao",
1592
+ a: "selecao-direta",
1593
+ h: "mao",
1594
+ m: "retangulo",
1595
+ l: "elipse",
1596
+ p: "caneta",
1597
+ "\\": "linha",
1598
+ t: "texto"
1599
+ };
1600
+ function hi(t, a, e, r) {
1601
+ if (r.defaultPrevented || nr(r)) return !1;
1602
+ const i = r.key, o = r.ctrlKey || r.metaKey, s = i.length === 1 ? i.toLowerCase() : i;
1603
+ if (i === " " && !o)
1604
+ return Fa(r) ? !1 : (a.espaco || (a.espaco = !0, t.agendar()), !0);
1605
+ if (a.ferramentas.tecla(i)) return !0;
1606
+ if (o) {
1607
+ if (r.shiftKey && !r.altKey && (s === "i" || s === "j")) return !1;
1608
+ const l = r.code ?? "";
1609
+ return r.altKey && r.shiftKey && l in Ua ? L(t, Ua[l]) || !0 : l === "BracketRight" || i === "]" || i === "}" ? D(t, r.shiftKey ? "frente" : "avancar") || !0 : l === "BracketLeft" || i === "[" || i === "{" ? D(t, r.shiftKey ? "tras" : "recuar") || !0 : s === "g" ? (r.shiftKey ? ze(t) : Me(t)) || !0 : l === "Digit2" || i === "2" ? (r.altKey ? ca(t, "bloqueado") : la(t, "bloqueado")) || !0 : l === "Digit3" || i === "3" ? (r.altKey ? ca(t, "oculto") : la(t, "oculto")) || !0 : l === "Digit7" || i === "7" ? (r.altKey ? we(t) : Te(t)) || !0 : s === "c" && !r.shiftKey ? Ca(t) || !0 : s === "x" ? xe(t) || !0 : s === "v" ? Ce(t, r.shiftKey) || !0 : s === "d" ? Ee(t) || !0 : s === "j" ? Ie(t) || !0 : s === "z" && !r.shiftKey ? (t.desfazer(), !0) : s === "z" && r.shiftKey || s === "y" ? (t.refazer(), !0) : s === "a" ? (Ae(t), !0) : i === "0" ? (e.ajustarFolha(), !0) : i === "1" ? (e.definirZoomPercentual(100), !0) : i === "=" || i === "+" ? (t.vista.zoomRelativo(1.25), t.emitirVista(), t.anunciar(sa(t.vista.zoomPercentual)), !0) : i === "-" ? (t.vista.zoomRelativo(0.8), t.emitirVista(), t.anunciar(sa(t.vista.zoomPercentual)), !0) : !1;
1610
+ }
1611
+ if (r.altKey && (i === "=" || i === "+")) return ba(t, 1.1, 1.1, void 0, "teclado") || !0;
1612
+ if (r.altKey && i === "-") return ba(t, 0.9, 0.9, void 0, "teclado") || !0;
1613
+ if (i.startsWith("Arrow")) {
1614
+ if (a.ocupado) return !0;
1615
+ const l = t.passoTeclado * (r.shiftKey ? 10 : 1), c = i === "ArrowLeft" ? -l : i === "ArrowRight" ? l : 0, d = i === "ArrowUp" ? -l : i === "ArrowDown" ? l : 0;
1616
+ if (t.ui.edicao && t.ui.edicao.ancoras.length > 0) Sr(t, c, d, "teclado-ancoras");
1617
+ else if (t.doc.selecao.length > 0) ve(t, c, d, "teclado", "teclado-mover");
1618
+ else return !1;
1619
+ return !0;
1620
+ }
1621
+ if (i === "Delete" || i === "Backspace") {
1622
+ if (t.ui.edicao && t.ui.edicao.ancoras.length > 0) Mr(t);
1623
+ else if (t.doc.selecao.length > 0) ye(t);
1624
+ else return !1;
1625
+ return !0;
1626
+ }
1627
+ if (i === "Escape")
1628
+ return a.ocupado ? (a.cancelar(), !0) : t.ui.edicao ? (t.encerrarEdicao(), !0) : t.isolado ? (t.isolar(null), !0) : t.doc.selecao.length > 0 ? (t.selecionar([]), !0) : (Va.has(r) || (Va.add(r), t.emitir("prancha-esc-sem-efeito", {})), !1);
1629
+ if (i === "Enter")
1630
+ return Fa(r) ? !1 : na(t.ferramenta) ? a.ferramentas.criarNoCentro() || !0 : t.doc.selecao.length === 1 && !t.ui.edicao ? (t.definirFerramenta("selecao-direta"), t.iniciarEdicao(t.doc.selecao[0]) || !0) : !1;
1631
+ if (i === "PageDown" || i === "PageUp") return Pr(t, i === "PageDown" ? 1 : -1) || !0;
1632
+ if (s === "r" && !r.altKey) return be(t, r.shiftKey ? -15 : 15, void 0, "teclado") || !0;
1633
+ const n = r.altKey ? null : s === "i" && !r.shiftKey ? "conta-gotas" : i === "+" || i === "=" ? "adicionar-ancora" : i === "-" ? "excluir-ancora" : s === "c" && r.shiftKey ? "converter-ancora" : null;
1634
+ return n ? (a.ocupado && a.cancelar(), t.definirFerramenta(n), !0) : !r.altKey && !r.shiftKey && Xa[s] ? (a.ocupado && a.cancelar(), t.definirFerramenta(Xa[s]), !0) : !1;
1635
+ }
1636
+ function mi(t, a, e) {
1637
+ e.key === " " && a.espaco && (a.espaco = !1, t.agendar());
1638
+ }
1639
+ const Re = [
1640
+ "selecao",
1641
+ "selecao-direta",
1642
+ "mao",
1643
+ "retangulo",
1644
+ "elipse",
1645
+ "poligono-regular",
1646
+ "estrela",
1647
+ "linha",
1648
+ "seta",
1649
+ "polilinha",
1650
+ "poligono",
1651
+ "caneta",
1652
+ "texto",
1653
+ // Fase 4
1654
+ "conta-gotas",
1655
+ "adicionar-ancora",
1656
+ "excluir-ancora",
1657
+ "converter-ancora"
1658
+ ];
1659
+ function Oe(t) {
1660
+ return typeof t == "string" && Re.includes(t);
1661
+ }
1662
+ const fi = "prancha:comando", pi = [
1663
+ "definirFerramenta",
1664
+ "selecionarElementos",
1665
+ "alternarSelecaoElemento",
1666
+ "limparSelecao",
1667
+ "selecionarTudo",
1668
+ "desfazer",
1669
+ "refazer",
1670
+ "moverSelecao",
1671
+ "girarSelecao",
1672
+ "escalarSelecao",
1673
+ "espelharSelecao",
1674
+ "transformarSelecao",
1675
+ "removerSelecao",
1676
+ "definirRaiosCantos",
1677
+ "inserirPredefinicao",
1678
+ "ajustarFolha",
1679
+ "ajustarSelecao",
1680
+ "definirZoom",
1681
+ "aproximar",
1682
+ "afastar",
1683
+ "deslocarVista",
1684
+ "definirGuias",
1685
+ "adicionarGuia",
1686
+ "removerGuia",
1687
+ "definirSnap",
1688
+ "editarAncoras",
1689
+ "concluirEdicao",
1690
+ "definirOpcoesFerramentas",
1691
+ // Fase 4
1692
+ "definirCamadas",
1693
+ "definirCamadaAtiva",
1694
+ "moverSelecaoParaCamada",
1695
+ "isolarGrupo",
1696
+ "ordenarSelecao",
1697
+ "trazerParaFrente",
1698
+ "enviarParaTras",
1699
+ "avancar",
1700
+ "recuar",
1701
+ "agruparSelecao",
1702
+ "desagruparSelecao",
1703
+ "bloquearSelecao",
1704
+ "ocultarSelecao",
1705
+ "desbloquearTudo",
1706
+ "mostrarTudo",
1707
+ "alinharSelecao",
1708
+ "distribuirSelecao",
1709
+ "duplicarSelecao",
1710
+ "transformarDeNovo",
1711
+ "copiar",
1712
+ "recortar",
1713
+ "colar",
1714
+ "aplicarAparencia",
1715
+ "criarMascara",
1716
+ "liberarMascara",
1717
+ "unirSelecao",
1718
+ "dividirSelecao",
1719
+ "deslocarCaminho",
1720
+ "simplificarSelecao",
1721
+ "contornarTraco",
1722
+ "converterEmCaminho",
1723
+ // Fase 5
1724
+ "pathfinder",
1725
+ "unirFormas",
1726
+ "subtrairFrente",
1727
+ "intersectarFormas",
1728
+ "excluirSobreposicao",
1729
+ // Fase 6
1730
+ "aplicarPropriedade",
1731
+ "alterarElementos"
1732
+ ];
1733
+ function gi(t) {
1734
+ return typeof t == "string" && pi.includes(t);
1735
+ }
1736
+ function vi(t, a) {
1737
+ return fe.on(fi, (e) => {
1738
+ !e || typeof e != "object" || e.alvo !== void 0 && e.alvo !== t.id || a(e.comando, Array.isArray(e.args) ? e.args : []);
1739
+ });
1740
+ }
1741
+ const qe = [
1742
+ "largura",
1743
+ "altura",
1744
+ "unidade",
1745
+ "grade",
1746
+ "mostrar-grade",
1747
+ "sem-reguas",
1748
+ "sem-snap",
1749
+ "sem-guias-inteligentes",
1750
+ "ferramenta",
1751
+ "rotulo",
1752
+ "somente-leitura",
1753
+ "passo-teclado",
1754
+ "margens",
1755
+ "teclado",
1756
+ "ajustar-ao-abrir"
1757
+ ];
1758
+ function Ne(t) {
1759
+ if (!t) return null;
1760
+ const a = t.trim().split(/[\s,;]+/).map((e) => parseFloat(e.replace(",", ".")));
1761
+ return a.length !== 1 && a.length !== 4 || !a.every((e) => Number.isFinite(e) && e >= 0 && e <= 1e5) ? null : a.length === 1 ? { esquerda: a[0], direita: a[0], superior: a[0], inferior: a[0] } : { esquerda: a[0], direita: a[1], superior: a[2], inferior: a[3] };
1762
+ }
1763
+ const Za = (t) => t === "conteudo" || t === "nenhum" ? t : "folha", aa = (t, a, e, r) => {
1764
+ const i = t === null ? NaN : parseFloat(t.replace(",", "."));
1765
+ return Number.isFinite(i) && i >= e && i <= r ? i : a;
1766
+ };
1767
+ function bi(t, a, e) {
1768
+ switch (a) {
1769
+ case "largura": {
1770
+ const r = aa(e, 210, 1, 1e5), i = r !== t.folha.largura;
1771
+ return t.folha = { ...t.folha, largura: r }, i;
1772
+ }
1773
+ case "altura": {
1774
+ const r = aa(e, 297, 1, 1e5), i = r !== t.folha.altura;
1775
+ return t.folha = { ...t.folha, altura: r }, i;
1776
+ }
1777
+ case "unidade":
1778
+ t.unidade = e && Kt(e) ? e : "mm";
1779
+ break;
1780
+ case "grade":
1781
+ t.grade = aa(e, 10, 0.1, 1e4);
1782
+ break;
1783
+ case "mostrar-grade":
1784
+ t.mostrarGrade = e !== null && e !== "false";
1785
+ break;
1786
+ case "sem-snap":
1787
+ t.snapLigado = e === null || e === "false";
1788
+ break;
1789
+ case "sem-guias-inteligentes":
1790
+ t.guiasInteligentes = e === null || e === "false";
1791
+ break;
1792
+ case "ferramenta":
1793
+ t.definirFerramenta(e && Oe(e) ? e : "selecao");
1794
+ break;
1795
+ case "somente-leitura":
1796
+ t.somenteLeitura = e !== null && e !== "false";
1797
+ break;
1798
+ case "passo-teclado":
1799
+ t.passoTeclado = aa(e, 1, 1e-3, 1e3);
1800
+ break;
1801
+ case "margens":
1802
+ t.margens = Ne(e);
1803
+ break;
1804
+ }
1805
+ return t.agendar(), !1;
1806
+ }
1807
+ const Wa = 100, yi = 4e3;
1808
+ function Ai(t) {
1809
+ let a;
1810
+ const e = /* @__PURE__ */ new Map();
1811
+ return (r, i, o) => {
1812
+ var l;
1813
+ if (a === void 0)
1814
+ try {
1815
+ const c = (l = t()) == null ? void 0 : l.getContext("2d");
1816
+ a = c && typeof c.measureText == "function" ? c : null;
1817
+ } catch {
1818
+ a = null;
1819
+ }
1820
+ if (!a) return null;
1821
+ const s = `${i}\0${r}`;
1822
+ let n = e.get(s);
1823
+ if (n === void 0) {
1824
+ try {
1825
+ a.font = `${Wa}px ${i}`;
1826
+ const c = a.measureText(r).width;
1827
+ n = Number.isFinite(c) && c >= 0 ? c / Wa : null;
1828
+ } catch {
1829
+ n = null;
1830
+ }
1831
+ e.size >= yi && e.clear(), e.set(s, n);
1832
+ }
1833
+ return n === null ? null : n * o;
1834
+ };
1835
+ }
1836
+ function Pi() {
1837
+ if (Vt() || typeof document > "u") return !1;
1838
+ const t = Ai(() => document.createElement("canvas"));
1839
+ return t("M", "sans-serif", 1) === null ? !1 : (Ut(t), !0);
1840
+ }
1841
+ class Si extends pe {
1842
+ constructor() {
1843
+ super();
1844
+ m(this, "shadow");
1845
+ m(this, "bag", new Ea());
1846
+ m(this, "c");
1847
+ m(this, "interacao");
1848
+ m(this, "render");
1849
+ m(this, "viewport");
1850
+ m(this, "status");
1851
+ m(this, "observador", null);
1852
+ m(this, "desligarBus", []);
1853
+ m(this, "ponteiroSobre", !1);
1854
+ m(this, "focoDentro", !1);
1855
+ m(this, "enquadrou", !1);
1856
+ m(this, "_fabrica", Ka);
1857
+ m(this, "revisaoSalva", 0);
1858
+ m(this, "_modificado", !1);
1859
+ m(this, "conteudoEnquadrado", !1);
1860
+ m(this, "_pronto");
1861
+ m(this, "resolverPronto", null);
1862
+ m(this, "fimPronto", 0);
1863
+ m(this, "carregando", !1);
1864
+ this.shadow = this.attachShadow({ mode: "open" }), this.shadow.innerHTML = ur();
1865
+ const e = (r) => this.shadow.getElementById(r);
1866
+ this.viewport = e("viewport"), this.status = e("status"), this.c = new yr({
1867
+ emitir: (r, i, o) => {
1868
+ const s = new CustomEvent(r, { detail: i, bubbles: !0, composed: !0, cancelable: !!o });
1869
+ return this.dispatchEvent(s), s.defaultPrevented;
1870
+ },
1871
+ agendar: () => {
1872
+ var r;
1873
+ return (r = this.render) == null ? void 0 : r.agendar();
1874
+ },
1875
+ anunciar: (r) => br(this.status, r)
1876
+ }), this._pronto = new Promise((r) => {
1877
+ this.resolverPronto = r;
1878
+ }), this.c.doc.ouvirMudancas(() => this.avaliarModificado()), this.interacao = new si(this.c, this.viewport, new Ir(this.c)), this.render = new ci(this.c, {
1879
+ viewport: this.viewport,
1880
+ base: e("camada-base"),
1881
+ sobreposicao: e("camada-sobreposicao"),
1882
+ reguaH: e("regua-h"),
1883
+ reguaV: e("regua-v")
1884
+ }, () => this._fabrica);
1885
+ }
1886
+ static get observedAttributes() {
1887
+ return qe;
1888
+ }
1889
+ connectedCallback() {
1890
+ var e;
1891
+ this.bag.cleanup(), this.interacao.conectar(this.bag, this.shadow.getElementById("regua-h"), this.shadow.getElementById("regua-v")), Le(this.bag, this, () => this.modoTeclado() === "isolado"), this.bag.add(this, "pointerenter", () => {
1892
+ this.ponteiroSobre = !0;
1893
+ }), this.bag.add(this, "pointerleave", () => {
1894
+ this.ponteiroSobre = !1;
1895
+ }), this.bag.add(this, "focusin", () => {
1896
+ this.focoDentro = !0;
1897
+ }), this.bag.add(this, "focusout", () => {
1898
+ this.focoDentro = !1;
1899
+ }), this.bag.add(this.viewport, "keydown", (r) => this.tecla(r, !0)), typeof window < "u" && (this.bag.add(window, "keydown", (r) => {
1900
+ const i = this.modoTeclado();
1901
+ i === "exclusivo" ? this.tecla(r, !0, !0) : i === "isolado" && this.noEscopoDoTeclado(r) && this.tecla(r, !1, !0);
1902
+ }, { capture: !0 }), this.bag.add(window, "keydown", (r) => this.tecla(r)), this.bag.add(window, "keyup", (r) => mi(this.c, this.interacao, r), { capture: !0 }), this.bag.add(window, "blur", () => {
1903
+ this.interacao.espaco = !1;
1904
+ })), typeof ResizeObserver == "function" && ((e = this.observador) == null || e.disconnect(), this.observador = new ResizeObserver(() => this.redimensionar()), this.observador.observe(this.viewport)), this.desligarBus.forEach((r) => r()), this.desligarBus = [
1905
+ vi(this, (r, i) => this.executarComando(r, i)),
1906
+ fe.on("tema:alterado", () => this.atualizarCores())
1907
+ ], Pi() && this.c.doc.indice.definir(this.c.doc.elementos), this.atualizarCores(), this.atualizarRotulo(), this.c.margens = Ne(this.getAttribute("margens")), this.redimensionar(), this.prepararPronto();
1908
+ }
1909
+ disconnectedCallback() {
1910
+ var e;
1911
+ this.fimPronto && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(this.fimPronto), this.fimPronto = 0, this.bag.cleanup(), (e = this.observador) == null || e.disconnect(), this.observador = null, this.desligarBus.forEach((r) => r()), this.desligarBus = [], this.render.cancelar(), this.interacao.cancelar();
1912
+ }
1913
+ attributeChangedCallback(e, r, i) {
1914
+ if (e === "rotulo") {
1915
+ this.atualizarRotulo();
1916
+ return;
1917
+ }
1918
+ if (e === "teclado") return;
1919
+ bi(this.c, e, i) && !this.enquadrou && this.ajustarFolha();
1920
+ }
1921
+ /** Resolve `pronto` quando a área de desenho foi medida; sem layout (teste, aba oculta), dois quadros depois. */
1922
+ prepararPronto() {
1923
+ if (this.resolverPronto) {
1924
+ if (this.c.vista.largura > 0) {
1925
+ this.concluirPronto();
1926
+ return;
1927
+ }
1928
+ typeof requestAnimationFrame == "function" && !this.fimPronto ? this.fimPronto = requestAnimationFrame(() => {
1929
+ this.fimPronto = requestAnimationFrame(() => {
1930
+ this.fimPronto = 0, this.concluirPronto();
1931
+ });
1932
+ }) : typeof requestAnimationFrame != "function" && this.concluirPronto();
1933
+ }
1934
+ }
1935
+ concluirPronto() {
1936
+ const e = this.resolverPronto;
1937
+ e && (this.resolverPronto = null, e(), this.dispatchEvent(new CustomEvent("prancha-pronta", { bubbles: !0, composed: !0, detail: {} })));
1938
+ }
1939
+ atualizarRotulo() {
1940
+ this.viewport.setAttribute("aria-label", this.getAttribute("rotulo") || "Prancha");
1941
+ }
1942
+ atualizarCores() {
1943
+ this.c.cores = fr(this), this.render.reiniciar(), this.c.agendar();
1944
+ }
1945
+ redimensionar() {
1946
+ if (this.render.medir(), !this.enquadrou && this.c.vista.largura > 0) {
1947
+ const e = Za(this.getAttribute("ajustar-ao-abrir"));
1948
+ e === "conteudo" && this.c.doc.elementos.length > 0 ? (this.ajustarElementos(), this.conteudoEnquadrado = !0) : e !== "nenhum" && this.c.vista.enquadrar({ x: 0, y: 0, largura: this.c.folha.largura, altura: this.c.folha.altura }), this.enquadrou = !0;
1949
+ }
1950
+ this.render.pintar(), this.prepararPronto();
1951
+ }
1952
+ /** Modo do atributo `teclado`: `local` (padrão), `exclusivo` ou `isolado`. */
1953
+ modoTeclado() {
1954
+ return Aa(this.getAttribute("teclado"));
1955
+ }
1956
+ tecladoExclusivo() {
1957
+ return this.modoTeclado() === "exclusivo";
1958
+ }
1959
+ /** O evento veio de dentro desta prancha ou do editor (outro componente) que a contém? */
1960
+ noEscopoDoTeclado(e) {
1961
+ const r = this.getRootNode().host, i = typeof e.composedPath == "function" ? e.composedPath() : [];
1962
+ return i.includes(this) || !!r && i.includes(r);
1963
+ }
1964
+ tecla(e, r = !1, i = !1) {
1965
+ !r && !this.focoDentro && !this.ponteiroSobre || !i && e.defaultPrevented && this.tecladoExclusivo() || hi(this.c, this.interacao, { ajustarFolha: () => this.ajustarFolha(), definirZoomPercentual: (o) => this.definirZoom(o) }, e) && (e.preventDefault(), e.stopPropagation(), i && e.stopImmediatePropagation(), ui(e));
1966
+ }
1967
+ // ---------- modificado, revisão e ciclo de vida ----------
1968
+ /** O documento mudou desde a carga (`definirElementos`) ou desde `marcarComoSalvo()`. */
1969
+ get modificado() {
1970
+ return this._modificado;
1971
+ }
1972
+ /** Contador de mudanças do documento (carga, edição, desfazer/refazer, renomear). */
1973
+ get revisao() {
1974
+ return this.c.doc.revisao;
1975
+ }
1976
+ /** Registra o estado atual como o salvo: `modificado` volta a `false` (e `prancha-modificado` só emite na transição). */
1977
+ marcarComoSalvo() {
1978
+ this.revisaoSalva = this.c.doc.revisao, this.avaliarModificado();
1979
+ }
1980
+ avaliarModificado() {
1981
+ if (this.carregando) return;
1982
+ const e = this.c.doc.revisao !== this.revisaoSalva;
1983
+ e !== this._modificado && (this._modificado = e, this.c.emitir("prancha-modificado", { modificado: e, revisao: this.c.doc.revisao }));
1984
+ }
1985
+ /**
1986
+ * Resolve quando a área de desenho foi medida e a prancha consegue enquadrar (ou, sem layout, dois quadros depois da
1987
+ * conexão). Também emite `prancha-pronta` uma vez.
1988
+ */
1989
+ get pronto() {
1990
+ return this._pronto;
1991
+ }
1992
+ /** Dá o foco à área de desenho (o `focus()` do host entrega o foco ao viewport, onde o teclado da prancha escuta). */
1993
+ focus(e) {
1994
+ this.viewport.focus(e);
1995
+ }
1996
+ // ---------- propriedades ----------
1997
+ /** Ferramenta ativa. */
1998
+ get ferramenta() {
1999
+ return this.c.ferramenta;
2000
+ }
2001
+ set ferramenta(e) {
2002
+ this.definirFerramenta(e);
2003
+ }
2004
+ /** Elementos do documento (na ordem de empilhamento). */
2005
+ get elementos() {
2006
+ return [...this.c.doc.elementos];
2007
+ }
2008
+ /** Ids selecionados. */
2009
+ get selecao() {
2010
+ return [...this.c.doc.selecao];
2011
+ }
2012
+ get podeDesfazer() {
2013
+ return this.c.doc.historico.podeDesfazer;
2014
+ }
2015
+ get podeRefazer() {
2016
+ return this.c.doc.historico.podeRefazer;
2017
+ }
2018
+ /** Id provisório dos elementos criados pelo usuário (o app pode trocar por um gerador próprio). */
2019
+ get gerarId() {
2020
+ return this.c.gerarId;
2021
+ }
2022
+ set gerarId(e) {
2023
+ typeof e == "function" && (this.c.gerarId = e);
2024
+ }
2025
+ /** Fábrica do contexto 2D de cada canvas (padrão `getContext('2d')`); serve para pintar com um contexto próprio ou de teste. */
2026
+ get fabricaContexto() {
2027
+ return this._fabrica;
2028
+ }
2029
+ set fabricaContexto(e) {
2030
+ this._fabrica = typeof e == "function" ? e : Ka, this.render.reiniciar(), this.c.agendar();
2031
+ }
2032
+ // ---------- dados (sincronização do app: não emite prancha-elemento-*) ----------
2033
+ /** Carrega o documento (normaliza; recomeça o histórico e a seleção). Devolve os recusados. */
2034
+ definirElementos(e) {
2035
+ this.carregando = !0;
2036
+ const r = (() => {
2037
+ try {
2038
+ return this.c.doc.definir(e);
2039
+ } finally {
2040
+ this.carregando = !1;
2041
+ }
2042
+ })();
2043
+ return this.c.ui.edicao = null, this.c.emitirHistorico(), this.marcarComoSalvo(), !this.conteudoEnquadrado && this.enquadrou && Za(this.getAttribute("ajustar-ao-abrir")) === "conteudo" && r.elementos.length > 0 && (this.conteudoEnquadrado = !0, this.ajustarElementos()), this.c.agendar(), { aceitos: r.elementos.length, recusados: r.recusados };
2044
+ }
2045
+ /** Lote de mudanças do app (adicionar, atualizar, remover) de uma vez. */
2046
+ aplicarLote(e, r = {}) {
2047
+ const { resultado: i } = this.c.doc.aplicarLote(e, r.historico !== !1);
2048
+ return this.c.emitirHistorico(), this.c.agendar(), i;
2049
+ }
2050
+ adicionarElemento(e, r) {
2051
+ return this.aplicarLote({ adicionar: [e] }, r).adicionados.length === 1;
2052
+ }
2053
+ atualizarElemento(e, r) {
2054
+ return this.aplicarLote({ atualizar: [e] }, r).atualizados.length === 1;
2055
+ }
2056
+ removerElemento(e, r) {
2057
+ return this.aplicarLote({ remover: [e] }, r).removidos.length === 1;
2058
+ }
2059
+ obterElementos() {
2060
+ return this.elementos;
2061
+ }
2062
+ obterElemento(e) {
2063
+ return this.c.doc.obter(e) ?? null;
2064
+ }
2065
+ /** Troca o id provisório pelo definitivo em tudo (documento, seleção e histórico). */
2066
+ renomearElemento(e, r) {
2067
+ var o;
2068
+ const i = this.c.doc.renomear(e, r);
2069
+ return i && ((o = this.c.ui.edicao) == null ? void 0 : o.id) === e && (this.c.ui.edicao.id = r), i;
2070
+ }
2071
+ // ---------- seleção e ferramentas ----------
2072
+ selecionarElementos(e) {
2073
+ return this.c.selecionar(Array.isArray(e) ? e : []);
2074
+ }
2075
+ alternarSelecaoElemento(e) {
2076
+ return this.c.selecionar([e], "alternar");
2077
+ }
2078
+ limparSelecao() {
2079
+ return this.c.selecionar([]);
2080
+ }
2081
+ selecionarTudo() {
2082
+ return Ae(this.c);
2083
+ }
2084
+ obterSelecao() {
2085
+ return this.c.doc.elementosSelecionados();
2086
+ }
2087
+ definirFerramenta(e) {
2088
+ this.interacao.cancelar(), this.c.definirFerramenta(Oe(e) ? e : "selecao");
2089
+ }
2090
+ definirOpcoesFerramentas(e) {
2091
+ this.c.opcoesFerramentas = e && typeof e == "object" ? { ...e } : {};
2092
+ }
2093
+ obterOpcoesFerramentas() {
2094
+ return { ...this.c.opcoesFerramentas };
2095
+ }
2096
+ /** Entra na seleção direta (âncoras) do elemento. */
2097
+ editarAncoras(e) {
2098
+ const r = typeof e == "string" ? this.c.doc.obter(e) : void 0;
2099
+ return r ? r.bloqueado || r.geometria.tipo === "texto" ? this.c.iniciarEdicao(e) : (this.c.definirFerramenta("selecao-direta"), this.c.iniciarEdicao(e)) : (this.c.recusar("editar-ancoras", "id-invalido", typeof e == "string" ? e : void 0), !1);
2100
+ }
2101
+ concluirEdicao() {
2102
+ this.c.encerrarEdicao();
2103
+ }
2104
+ // ---------- histórico e comandos sobre a seleção (emitem prancha-elemento-*) ----------
2105
+ desfazer() {
2106
+ return this.c.desfazer();
2107
+ }
2108
+ refazer() {
2109
+ return this.c.refazer();
2110
+ }
2111
+ moverSelecao(e, r) {
2112
+ return ve(this.c, e, r);
2113
+ }
2114
+ girarSelecao(e, r) {
2115
+ return be(this.c, e, r);
2116
+ }
2117
+ escalarSelecao(e, r, i) {
2118
+ return ba(this.c, e, r ?? e, i);
2119
+ }
2120
+ espelharSelecao(e) {
2121
+ return Ar(this.c, e);
2122
+ }
2123
+ transformarSelecao(e) {
2124
+ return J(this.c, Xt(e));
2125
+ }
2126
+ removerSelecao() {
2127
+ return ye(this.c);
2128
+ }
2129
+ /** Raios dos cantos dos retângulos selecionados, em mm (número = os quatro; ou [sup. esq., sup. dir., inf. dir., inf. esq.]). */
2130
+ definirRaiosCantos(e) {
2131
+ return Pe(this.c, e);
2132
+ }
2133
+ /**
2134
+ * Insere uma pré-definição (moldura, seta...) e a deixa selecionada. Sem `caixa`: com `opcoes.quadro: 'margens'` (e o
2135
+ * atributo `margens`), o quadro das margens; senão, uma caixa no CENTRO DA ÁREA VISÍVEL, de tamanho proporcional ao zoom
2136
+ * (cerca de 35% da largura e 25% da altura visíveis, limitada à folha), para a forma nascer à vista.
2137
+ */
2138
+ inserirPredefinicao(e, r, i = {}) {
2139
+ if (!Zt(e))
2140
+ return this.c.recusar("inserir-predefinicao", "geometria-invalida"), [];
2141
+ const { quadro: o, ...s } = i ?? {}, n = r ?? (o === "margens" && this.c.margens ? me(this.c.folha.largura, this.c.folha.altura, this.c.margens) : null) ?? this.caixaNaVista(), l = Wt(e, n, { ...s, id: s.id ?? this.c.gerarId(e) });
2142
+ return w(this.c, l, "predefinicao");
2143
+ }
2144
+ /** Caixa (mm) no centro da área visível, proporcional ao zoom e dentro da folha; sem vista medida, 60 × 40 mm no centro da folha. */
2145
+ caixaNaVista() {
2146
+ const e = this.c.folha, r = this.c.vista;
2147
+ let i = 0, o = 0, s = e.largura, n = e.altura;
2148
+ if (r.largura > 0 && r.altura > 0) {
2149
+ const v = r.paraFolha(0, 0), b = r.paraFolha(r.largura, r.altura), M = Math.max(0, v[0]), x = Math.max(0, v[1]), C = Math.min(e.largura, b[0]), B = Math.min(e.altura, b[1]);
2150
+ C > M && B > x && (i = M, o = x, s = C, n = B);
2151
+ }
2152
+ const l = (s - i) * (r.largura > 0 ? 0.35 : 0.3), c = (n - o) * (r.largura > 0 ? 0.25 : 0.15), d = Math.max(1, Math.min(l, e.largura)), h = Math.max(1, Math.min(c, e.altura)), u = r.largura > 0 && r.altura > 0 ? r.paraFolha(r.largura / 2, r.altura / 2) : [(i + s) / 2, (o + n) / 2], f = Math.min(e.largura, Math.max(0, u[0])), p = Math.min(e.altura, Math.max(0, u[1]));
2153
+ return { x: f - d / 2, y: p - h / 2, largura: d, altura: h };
2154
+ }
2155
+ // ---------- vista ----------
2156
+ ajustarFolha() {
2157
+ this.render.medir(), this.c.vista.enquadrar({ x: 0, y: 0, largura: this.c.folha.largura, altura: this.c.folha.altura }) && (this.enquadrou = !0), this.c.emitirVista();
2158
+ }
2159
+ ajustarSelecao() {
2160
+ const e = this.c.doc.elementosSelecionados();
2161
+ if (e.length === 0) {
2162
+ this.c.recusar("ajustar-selecao", "sem-selecao");
2163
+ return;
2164
+ }
2165
+ const r = Da(e);
2166
+ r && this.c.vista.enquadrar(r, 48) && this.c.emitirVista();
2167
+ }
2168
+ /**
2169
+ * Enquadra os elementos (os `ids`, ou todos) SEM mexer na seleção, com teto de zoom (`zoomMaximo`, em %: um elemento
2170
+ * pequeno não é ampliado absurdamente). Devolve se enquadrou.
2171
+ */
2172
+ ajustarElementos(e, r = {}) {
2173
+ const i = Array.isArray(e) ? e.map((c) => this.c.doc.obter(c)).filter((c) => !!c) : [...this.c.doc.elementos], o = Da(i);
2174
+ if (!o) return !1;
2175
+ const s = Number.isFinite(r == null ? void 0 : r.margem) && r.margem >= 0 ? r.margem : 48, n = Number.isFinite(r == null ? void 0 : r.zoomMaximo) && r.zoomMaximo > 0 ? r.zoomMaximo : 800;
2176
+ if (!this.c.vista.enquadrar(o, s)) return !1;
2177
+ const l = n / 100 * H;
2178
+ return this.c.vista.zoom > l && this.c.vista.definirZoomCentrado(l, o), this.c.emitirVista(), !0;
2179
+ }
2180
+ /** Zoom em % (100% = tamanho real a 96 dpi), no centro da vista. */
2181
+ definirZoom(e) {
2182
+ this.c.vista.definirZoom(e / 100 * H) && (this.c.emitirVista(), this.c.anunciar(sa(this.c.vista.zoomPercentual)));
2183
+ }
2184
+ aproximar() {
2185
+ this.definirZoom(this.c.vista.zoomPercentual * 1.25);
2186
+ }
2187
+ afastar() {
2188
+ this.definirZoom(this.c.vista.zoomPercentual * 0.8);
2189
+ }
2190
+ deslocarVista(e, r) {
2191
+ this.c.vista.deslocar(e, r) && this.c.emitirVista();
2192
+ }
2193
+ obterVista() {
2194
+ const e = this.c.vista;
2195
+ return { zoom: e.zoom, zoomPercentual: e.zoomPercentual, pan: [e.pan[0], e.pan[1]] };
2196
+ }
2197
+ /** Ponto da área de desenho (px CSS) → folha (mm), e o inverso. */
2198
+ paraFolha(e, r) {
2199
+ return this.c.vista.paraFolha(e, r);
2200
+ }
2201
+ paraTela(e) {
2202
+ return this.c.vista.paraTela(e);
2203
+ }
2204
+ // ---------- guias e snap ----------
2205
+ definirGuias(e) {
2206
+ this.c.guias = (Array.isArray(e) ? e : []).filter((r) => r && (r.orientacao === "horizontal" || r.orientacao === "vertical") && Number.isFinite(r.posicao)).map((r) => ({ ...r })), this.c.emitirGuias();
2207
+ }
2208
+ adicionarGuia(e) {
2209
+ this.definirGuias([...this.c.guias, e]);
2210
+ }
2211
+ removerGuia(e) {
2212
+ this.definirGuias(this.c.guias.filter((r, i) => i !== e));
2213
+ }
2214
+ obterGuias() {
2215
+ return this.c.guias.map((e) => ({ ...e }));
2216
+ }
2217
+ definirSnap(e) {
2218
+ this.toggleAttribute("sem-snap", !e);
2219
+ }
2220
+ // ---------- exportação ----------
2221
+ /** SVG da folha com os elementos (o mesmo plano de pintura da tela). */
2222
+ exportarSvg(e = {}) {
2223
+ return Jt(this.c.doc.elementos, { largura: this.c.folha.largura, altura: this.c.folha.altura, fundo: "#ffffff", ...e });
2224
+ }
2225
+ /** Pinta os elementos num contexto próprio (ex.: o PDF vetorial do app) com o mesmo código da tela. */
2226
+ desenharEm(e, r = {}) {
2227
+ return N(e, this.c.doc.elementos, r);
2228
+ }
2229
+ /** Mede e pinta agora (sem esperar o próximo quadro). */
2230
+ renderizarAgora() {
2231
+ this.render.medir(), this.render.pintar();
2232
+ }
2233
+ /** Executa um comando público pelo nome (o mesmo que o `ui-bus` usa). Comando desconhecido emite `prancha-recusa`. */
2234
+ executarComando(e, r = []) {
2235
+ if (!gi(e)) {
2236
+ this.c.recusar("executar-comando", "comando-desconhecido");
2237
+ return;
2238
+ }
2239
+ const i = this[e];
2240
+ try {
2241
+ return i.apply(this, Array.isArray(r) ? r : []);
2242
+ } catch {
2243
+ this.c.recusar(e, "geometria-invalida");
2244
+ return;
2245
+ }
2246
+ }
2247
+ }
2248
+ const Ja = (t) => {
2249
+ const a = typeof t == "string" && t.trim() !== "" ? Number(t.replace(",", ".")) : t;
2250
+ return typeof a == "number" && Number.isFinite(a) ? a : null;
2251
+ };
2252
+ function Mi(t) {
2253
+ let a = 1 / 0, e = 1 / 0, r = -1 / 0, i = -1 / 0;
2254
+ for (const o of t) {
2255
+ const s = W(o);
2256
+ s && (a = Math.min(a, s.x), e = Math.min(e, s.y), r = Math.max(r, s.x + s.largura), i = Math.max(i, s.y + s.altura));
2257
+ }
2258
+ return Number.isFinite(a) ? { x: a, y: e, largura: r - a, altura: i - e } : null;
2259
+ }
2260
+ function zi(t, a, e) {
2261
+ const r = Mi(t);
2262
+ if (!r) return null;
2263
+ let i = null;
2264
+ if (a === "geometria.x") i = k(e - r.x, 0);
2265
+ else if (a === "geometria.y") i = k(0, e - r.y);
2266
+ else if (a === "geometria.largura" && e > 0 && r.largura > 0) i = q(e / r.largura, 1, [r.x, r.y]);
2267
+ else if (a === "geometria.altura" && e > 0 && r.altura > 0) i = q(1, e / r.altura, [r.x, r.y]);
2268
+ else if (a === "geometria.rotacao")
2269
+ return t.map((o) => {
2270
+ const s = W(o);
2271
+ if (!s) return o;
2272
+ const n = (e - er(o)) * Math.PI / 180;
2273
+ return se(o, Pa(n, [s.x + s.largura / 2, s.y + s.altura / 2]));
2274
+ });
2275
+ return i ? T(t, i) : null;
2276
+ }
2277
+ function Ei(t, a, e) {
2278
+ if (t.somenteLeitura)
2279
+ return t.recusar("propriedade", "somente-leitura"), !1;
2280
+ if (!Qt(a))
2281
+ return t.recusar("propriedade", "comando-desconhecido"), !1;
2282
+ const r = t.doc.elementosSelecionados();
2283
+ if (r.length === 0)
2284
+ return t.recusar("propriedade", "sem-selecao"), !1;
2285
+ const i = a === "elemento.bloqueado" || a === "elemento.oculto" ? r : r.filter((s) => !t.mapa().travado(s));
2286
+ if (i.length === 0)
2287
+ return t.recusar("propriedade", "bloqueado"), !1;
2288
+ if (a === "geometria.raio") {
2289
+ const s = Ja(e);
2290
+ return s === null || s < 0 ? (t.recusar("propriedade", "geometria-invalida"), !1) : Pe(t, s);
2291
+ }
2292
+ let o;
2293
+ if (Yt(a)) {
2294
+ const s = Ja(e);
2295
+ o = s === null ? null : zi(i, a, s);
2296
+ } else {
2297
+ const s = i.map((n) => ar(n, a, e));
2298
+ o = s.every((n) => n !== null) ? s : null;
2299
+ }
2300
+ return o ? (t.aplicarSubstituicoes(o, "propriedades", `propriedade:${a}`), !0) : (t.recusar("propriedade", "geometria-invalida"), !1);
2301
+ }
2302
+ function xi(t, a, e) {
2303
+ if (t.somenteLeitura)
2304
+ return t.recusar("alterar", "somente-leitura"), !1;
2305
+ if (!e || typeof e != "object" || !Array.isArray(a))
2306
+ return t.recusar("alterar", "geometria-invalida"), !1;
2307
+ const r = a.map((o) => typeof o == "string" ? t.doc.obter(o) : void 0).filter((o) => !!o);
2308
+ if (r.length === 0 || e.camadaId !== void 0 && e.camadaId !== null && !t.camadas.some((o) => o.id === e.camadaId))
2309
+ return t.recusar("alterar", "id-invalido"), !1;
2310
+ const i = r.map((o) => {
2311
+ const s = { ...o };
2312
+ e.nome !== void 0 && (typeof e.nome == "string" && e.nome.trim() !== "" ? s.nome = e.nome : delete s.nome);
2313
+ for (const n of ["oculto", "bloqueado"])
2314
+ typeof e[n] == "boolean" && (e[n] ? s[n] = !0 : delete s[n]);
2315
+ return e.camadaId !== void 0 && (e.camadaId ? s.camadaId = e.camadaId : delete s.camadaId), s;
2316
+ });
2317
+ return t.aplicarSubstituicoes(i, "propriedades"), !0;
2318
+ }
2319
+ const Ci = {
2320
+ retangulo: "Retângulo",
2321
+ elipse: "Elipse",
2322
+ "poligono-regular": "Polígono",
2323
+ estrela: "Estrela",
2324
+ linha: "Linha",
2325
+ caminho: "Caminho",
2326
+ texto: "Texto"
2327
+ }, je = (t) => {
2328
+ var a;
2329
+ return Ci[(a = t == null ? void 0 : t.geometria) == null ? void 0 : a.tipo] ?? "Elemento";
2330
+ }, Ti = {
2331
+ normal: "Normal",
2332
+ multiplicar: "Multiplicar",
2333
+ tela: "Tela",
2334
+ sobrepor: "Sobrepor",
2335
+ escurecer: "Escurecer",
2336
+ clarear: "Clarear",
2337
+ "subexposicao-cor": "Subexposição de cores",
2338
+ "superexposicao-cor": "Superexposição de cores",
2339
+ "luz-dura": "Luz direta",
2340
+ "luz-suave": "Luz indireta",
2341
+ diferenca: "Diferença",
2342
+ exclusao: "Exclusão",
2343
+ matiz: "Matiz",
2344
+ saturacao: "Saturação",
2345
+ cor: "Cor",
2346
+ luminosidade: "Luminosidade"
2347
+ }, wi = {
2348
+ continua: "Contínua",
2349
+ tracejada: "Tracejada",
2350
+ "tracejada-curta": "Tracejada curta",
2351
+ "tracejada-longa": "Tracejada longa",
2352
+ pontilhada: "Pontilhada",
2353
+ "traco-ponto": "Traço-ponto"
2354
+ }, X = (t) => t.map(([a, e]) => ({ id: a, rotulo: e })), Qa = X([["nenhuma", "Nenhuma"], ["triangulo", "Triângulo"], ["triangulo-aberto", "Triângulo vazado"], ["aberta", "Aberta"], ["circulo", "Círculo"], ["quadrado", "Quadrado"], ["losango", "Losango"], ["barra", "Barra"]]);
2355
+ function g(t, a, e, r, i = {}) {
2356
+ const o = t.map((l) => rr(l, a)).filter((l) => l !== void 0);
2357
+ if (o.length === 0) return null;
2358
+ const s = (l) => JSON.stringify(l);
2359
+ return o.every((l) => s(l) === s(o[0])) && o[0] !== null ? { id: a, rotulo: e, tipo: r, valor: o[0], ...i } : { id: a, rotulo: e, tipo: r, valor: null, misto: !0, ...i };
2360
+ }
2361
+ const E = { unidade: "mm", casasDecimais: 2, passo: 0.5 }, ea = { unidade: "%", casasDecimais: 0, passo: 5, min: 0, max: 100 }, R = (t) => t.filter((a) => a !== null);
2362
+ function Ii(t) {
2363
+ let a = 1 / 0, e = 1 / 0, r = -1 / 0, i = -1 / 0;
2364
+ for (const n of t) {
2365
+ const l = W(n);
2366
+ l && (a = Math.min(a, l.x), e = Math.min(e, l.y), r = Math.max(r, l.x + l.largura), i = Math.max(i, l.y + l.altura));
2367
+ }
2368
+ const o = (n) => Math.round(n * 1e6) / 1e6, s = Number.isFinite(a) ? [
2369
+ { id: "geometria.x", rotulo: "X", tipo: "numero", valor: o(a), ...E },
2370
+ { id: "geometria.y", rotulo: "Y", tipo: "numero", valor: o(e), ...E },
2371
+ { id: "geometria.largura", rotulo: "Largura", tipo: "numero", valor: o(r - a), ...E, min: 0 },
2372
+ { id: "geometria.altura", rotulo: "Altura", tipo: "numero", valor: o(i - e), ...E, min: 0 }
2373
+ ] : [];
2374
+ return s.push(g(t, "geometria.rotacao", "Rotação", "numero", { unidade: "°", casasDecimais: 2, passo: 15 })), t.every((n) => n.geometria.tipo === "retangulo") && s.push(g(t, "geometria.raio", "Raio dos cantos", "numero", { ...E, min: 0 })), R(s);
2375
+ }
2376
+ const I = (t) => String(Math.round(t * 100) / 100).replace(".", ",");
2377
+ function Di(t) {
2378
+ const a = t && Number.isFinite(t.largura) && Number.isFinite(t.altura) ? t : null, e = [{ id: "dica", rotulo: "Seleção", tipo: "readonly", valor: "Nada selecionado", dica: "Selecione um elemento para editar: clique nele ou arraste um retângulo de seleção." }];
2379
+ if (a) {
2380
+ e.push({ id: "folha.tamanho", rotulo: "Folha", tipo: "readonly", valor: `${I(a.largura)} × ${I(a.altura)} mm` }), a.unidade && e.push({ id: "folha.unidade", rotulo: "Unidade", tipo: "readonly", valor: a.unidade }), Number.isFinite(a.grade) && e.push({ id: "folha.grade", rotulo: "Grade", tipo: "readonly", valor: `${I(a.grade)} mm` });
2381
+ const r = a.margens;
2382
+ r && e.push({ id: "folha.margens", rotulo: "Margens", tipo: "readonly", valor: `${I(r.esquerda)} / ${I(r.direita)} / ${I(r.superior)} / ${I(r.inferior)} mm`, dica: "esquerda / direita / superior / inferior" });
2383
+ }
2384
+ return [{ id: "folha", titulo: "Folha", aberto: !0, propriedades: e }];
2385
+ }
2386
+ function _i(t) {
2387
+ const a = Array.isArray(t) ? t.filter((l) => l && typeof l == "object" && l.geometria) : [];
2388
+ if (a.length === 0) return [];
2389
+ const e = a.filter((l) => l.geometria.tipo === "texto"), r = a.filter((l) => {
2390
+ var c;
2391
+ return l.geometria.tipo !== "texto" && ((c = za(l)) == null ? void 0 : c.tipo) === "Polygon";
2392
+ }), i = a.length > e.length, o = a.length === 1 ? je(a[0]) : `${a.length} elementos`, s = [
2393
+ {
2394
+ id: "elemento",
2395
+ titulo: "Elemento",
2396
+ aberto: !0,
2397
+ propriedades: R([
2398
+ { id: "elemento.tipo", rotulo: "Tipo", tipo: "readonly", valor: o },
2399
+ g(a, "elemento.nome", "Nome", "texto"),
2400
+ g(a, "elemento.bloqueado", "Bloqueado", "booleano"),
2401
+ g(a, "elemento.oculto", "Oculto", "booleano")
2402
+ ])
2403
+ },
2404
+ { id: "geometria", titulo: "Posição e tamanho", aberto: !0, propriedades: Ii(a) }
2405
+ ];
2406
+ if (i) {
2407
+ const l = a.filter((c) => c.geometria.tipo !== "texto");
2408
+ s.push({
2409
+ id: "traco",
2410
+ titulo: "Traço",
2411
+ aberto: !0,
2412
+ propriedades: R([
2413
+ g(l, "traco.ativo", "Com traço", "booleano"),
2414
+ g(l, "traco.cor", "Cor", "cor"),
2415
+ g(l, "traco.espessura", "Espessura", "numero", { ...E, passo: 0.05, min: 0 }),
2416
+ g(l, "traco.opacidade", "Opacidade", "numero", ea),
2417
+ g(l, "traco.tipoLinha", "Tipo de linha", "linha", { opcoes: sr.map((c) => ({ id: c, rotulo: wi[c] ?? c })) }),
2418
+ g(l, "traco.escalaTipoLinha", "Escala da linha", "numero", { casasDecimais: 2, passo: 0.1, min: 0 }),
2419
+ g(l, "traco.terminacao", "Terminação", "selecao", { opcoes: X([["reta", "Reta"], ["arredondada", "Arredondada"], ["quadrada", "Quadrada"]]) }),
2420
+ g(l, "traco.juncao", "Junção", "selecao", { opcoes: X([["angular", "Angular"], ["arredondada", "Arredondada"], ["chanfrada", "Chanfrada"]]) }),
2421
+ r.length === l.length ? g(l, "traco.alinhamento", "Alinhamento", "selecao", { opcoes: X([["centro", "Centro"], ["dentro", "Dentro"], ["fora", "Fora"]]) }) : null,
2422
+ r.length === 0 ? g(l, "traco.pontaInicio", "Ponta inicial", "selecao", { opcoes: Qa }) : null,
2423
+ r.length === 0 ? g(l, "traco.pontaFim", "Ponta final", "selecao", { opcoes: Qa }) : null
2424
+ ])
2425
+ });
2426
+ }
2427
+ return [...r, ...e].length === a.length && s.push({
2428
+ id: "preenchimento",
2429
+ titulo: "Preenchimento",
2430
+ aberto: !0,
2431
+ propriedades: R([
2432
+ g(a, "preenchimento.ativo", "Com preenchimento", "booleano"),
2433
+ g(a, "preenchimento.cor", "Cor", "cor"),
2434
+ g(a, "preenchimento.opacidade", "Opacidade", "numero", ea),
2435
+ e.length === 0 ? g(a, "preenchimento.regra", "Regra", "selecao", { opcoes: X([["nonzero", "Diferente de zero"], ["evenodd", "Par-ímpar"]]) }) : null
2436
+ ])
2437
+ }), r.length === a.length && s.push({
2438
+ id: "hachura",
2439
+ titulo: "Hachura",
2440
+ aberto: !1,
2441
+ propriedades: R([
2442
+ g(a, "hachura.ativa", "Com hachura", "booleano"),
2443
+ g(a, "hachura.angulo", "Ângulo", "numero", { unidade: "°", casasDecimais: 1, passo: 15 }),
2444
+ g(a, "hachura.espacamento", "Espaçamento", "numero", { ...E, min: 0.1 }),
2445
+ g(a, "hachura.cor", "Cor", "cor"),
2446
+ g(a, "hachura.cruzada", "Cruzada", "booleano")
2447
+ ])
2448
+ }), s.push({
2449
+ id: "efeitos",
2450
+ titulo: "Efeitos",
2451
+ aberto: !1,
2452
+ propriedades: R([
2453
+ g(a, "efeitos.opacidade", "Opacidade", "numero", ea),
2454
+ g(a, "efeitos.mesclagem", "Mesclagem", "selecao", { opcoes: tr.map((l) => ({ id: l, rotulo: Ti[l] })) }),
2455
+ g(a, "sombra.ativa", "Sombra", "booleano"),
2456
+ g(a, "sombra.dx", "Sombra X", "numero", E),
2457
+ g(a, "sombra.dy", "Sombra Y", "numero", E),
2458
+ g(a, "sombra.desfoque", "Desfoque", "numero", { ...E, min: 0 }),
2459
+ g(a, "sombra.cor", "Cor da sombra", "cor"),
2460
+ g(a, "sombra.opacidade", "Opacidade da sombra", "numero", ea)
2461
+ ])
2462
+ }), s.filter((l) => l.propriedades.length > 0);
2463
+ }
2464
+ const O = "prancha:sem-camada", Ya = (t) => typeof t == "string" && t !== O ? t : null;
2465
+ function Fi(t, a = [], e = {}) {
2466
+ const r = Array.isArray(t) ? t.filter((u) => u && typeof u == "object" && u.geometria) : [], i = Array.isArray(a) ? a.filter((u) => u && typeof u.id == "string") : [], o = new Set(i.map((u) => u.id)), s = i.length === 0 && ((e == null ? void 0 : e.ocultarSemCamada) === !0 || (e == null ? void 0 : e.modo) === "simples"), n = (u) => u.camadaId && o.has(u.camadaId) ? u.camadaId : s ? "" : O, l = /* @__PURE__ */ new Map();
2467
+ for (const u of r) l.set(n(u), (l.get(n(u)) ?? 0) + 1);
2468
+ const c = [];
2469
+ !s && (l.has(O) || i.length === 0) && c.push({ id: O, name: "Sem camada", visible: !0, locked: !1, opacity: 1, order: 0, count: l.get(O) ?? 0 });
2470
+ for (const u of [...i].reverse())
2471
+ c.push({
2472
+ id: u.id,
2473
+ name: u.nome ?? u.id,
2474
+ visible: u.visivel !== !1,
2475
+ locked: u.bloqueada === !0,
2476
+ opacity: typeof u.opacidade == "number" && Number.isFinite(u.opacidade) ? Math.min(1, Math.max(0, u.opacidade)) : 1,
2477
+ order: c.length,
2478
+ count: l.get(u.id) ?? 0
2479
+ });
2480
+ const d = /* @__PURE__ */ new Map(), h = [...$(r, i)].reverse().map((u) => {
2481
+ var x, C, B;
2482
+ const f = je(u);
2483
+ let p = u.nome;
2484
+ if (!p) {
2485
+ const K = (d.get(f) ?? 0) + 1;
2486
+ d.set(f, K), p = `${f} ${K}`;
2487
+ }
2488
+ const b = u.geometria.tipo === "texto" ? "Text" : ((x = za(u)) == null ? void 0 : x.tipo) === "Polygon" ? "Polygon" : "LineString";
2489
+ let M;
2490
+ try {
2491
+ const K = ir(u);
2492
+ M = ((C = K.preenchimento) == null ? void 0 : C.cor) ?? ((B = K.traco) == null ? void 0 : B.cor);
2493
+ } catch {
2494
+ M = void 0;
2495
+ }
2496
+ return { id: u.id, name: p, layerId: n(u), type: b, geometryType: b, visible: u.oculto !== !0, locked: u.bloqueado === !0, color: M };
2497
+ });
2498
+ return { camadas: c, feicoes: h };
2499
+ }
2500
+ function ki(t, a, e) {
2501
+ const r = Array.isArray(t) ? t : [];
2502
+ return !e || typeof e != "object" ? [...r] : r.map((i) => {
2503
+ if (i.id !== a) return i;
2504
+ const o = { ...i };
2505
+ return typeof e.visivel == "boolean" && (o.visivel = e.visivel), typeof e.bloqueada == "boolean" && (o.bloqueada = e.bloqueada), typeof e.opacidade == "number" && Number.isFinite(e.opacidade) && (o.opacidade = Math.min(1, Math.max(0, e.opacidade))), typeof e.nome == "string" && e.nome.trim() !== "" && (o.nome = e.nome), o;
2506
+ });
2507
+ }
2508
+ function Li(t, a) {
2509
+ const e = Array.isArray(t) ? t : [], r = new Map(e.map((n) => [n.id, n])), i = /* @__PURE__ */ new Set(), o = [];
2510
+ for (const n of Array.isArray(a) ? a : []) {
2511
+ const l = typeof n == "string" ? r.get(n) : void 0;
2512
+ l && !i.has(l.id) && (i.add(l.id), o.push(l));
2513
+ }
2514
+ return [...e.filter((n) => !i.has(n.id)), ...o.reverse()];
2515
+ }
2516
+ class Ri extends Si {
2517
+ static get observedAttributes() {
2518
+ return qe;
2519
+ }
2520
+ // ---------- camadas e isolamento ----------
2521
+ /** Camadas da prancha (a primeira fica atrás). Elementos sem camada ficam por cima. */
2522
+ definirCamadas(a) {
2523
+ this.c.definirCamadas(a);
2524
+ }
2525
+ obterCamadas() {
2526
+ return this.c.camadas.map((a) => ({ ...a }));
2527
+ }
2528
+ /** Camada que recebe os elementos novos (desenhados, colados, pré-definições); `null` = sem camada. */
2529
+ definirCamadaAtiva(a) {
2530
+ this.c.camadaAtiva = typeof a == "string" && this.c.camadas.some((e) => e.id === a) ? a : null;
2531
+ }
2532
+ moverSelecaoParaCamada(a) {
2533
+ return Rr(this.c, a);
2534
+ }
2535
+ /** Isola um grupo (só os membros se selecionam) ou sai do isolamento com `null`. */
2536
+ isolarGrupo(a) {
2537
+ this.c.isolar(a);
2538
+ }
2539
+ // ---------- ordem, grupos, bloquear e ocultar ----------
2540
+ ordenarSelecao(a) {
2541
+ return D(this.c, a);
2542
+ }
2543
+ trazerParaFrente() {
2544
+ return D(this.c, "frente");
2545
+ }
2546
+ enviarParaTras() {
2547
+ return D(this.c, "tras");
2548
+ }
2549
+ avancar() {
2550
+ return D(this.c, "avancar");
2551
+ }
2552
+ recuar() {
2553
+ return D(this.c, "recuar");
2554
+ }
2555
+ agruparSelecao() {
2556
+ return Me(this.c);
2557
+ }
2558
+ desagruparSelecao() {
2559
+ return ze(this.c);
2560
+ }
2561
+ bloquearSelecao() {
2562
+ return la(this.c, "bloqueado");
2563
+ }
2564
+ ocultarSelecao() {
2565
+ return la(this.c, "oculto");
2566
+ }
2567
+ desbloquearTudo() {
2568
+ return ca(this.c, "bloqueado");
2569
+ }
2570
+ mostrarTudo() {
2571
+ return ca(this.c, "oculto");
2572
+ }
2573
+ // ---------- alinhar, distribuir, duplicar ----------
2574
+ /** Alinha à seleção, à folha, ao primeiro selecionado (`'chave'`) ou a uma caixa em mm (as margens, o quadro). */
2575
+ alinharSelecao(a, e = "selecao") {
2576
+ return Dr(this.c, a, e);
2577
+ }
2578
+ /** Distribui centros ou espaços (iguais, ou `espacamento` fixo em mm). */
2579
+ distribuirSelecao(a, e = "espacos", r) {
2580
+ return _r(this.c, a, e, r);
2581
+ }
2582
+ duplicarSelecao(a) {
2583
+ return Fr(this.c, a);
2584
+ }
2585
+ /** Ctrl+D: repete a última transformação (duplicando, se ela foi uma cópia). */
2586
+ transformarDeNovo() {
2587
+ return Ee(this.c);
2588
+ }
2589
+ // ---------- área de transferência e aparência ----------
2590
+ copiar() {
2591
+ return Ca(this.c);
2592
+ }
2593
+ recortar() {
2594
+ return xe(this.c);
2595
+ }
2596
+ /** Cola deslocado a cada colagem, ou no mesmo lugar (`noLugar`). */
2597
+ colar(a = !1) {
2598
+ return Ce(this.c, a);
2599
+ }
2600
+ aplicarAparencia(a) {
2601
+ return Lr(this.c, a);
2602
+ }
2603
+ // ---------- máscara e operações de caminho ----------
2604
+ criarMascara() {
2605
+ return Te(this.c);
2606
+ }
2607
+ liberarMascara() {
2608
+ return we(this.c);
2609
+ }
2610
+ unirSelecao(a) {
2611
+ return Ie(this.c, a);
2612
+ }
2613
+ dividirSelecao() {
2614
+ return Or(this.c);
2615
+ }
2616
+ /** Deslocar caminho (offset): cria um contorno novo a `distancia` mm (negativo = para dentro). */
2617
+ deslocarCaminho(a) {
2618
+ return qr(this.c, a);
2619
+ }
2620
+ simplificarSelecao(a) {
2621
+ return Nr(this.c, a);
2622
+ }
2623
+ contornarTraco() {
2624
+ return jr(this.c);
2625
+ }
2626
+ converterEmCaminho() {
2627
+ return Gr(this.c);
2628
+ }
2629
+ // ---------- Pathfinder (Fase 5) ----------
2630
+ /**
2631
+ * Operação booleana sobre a seleção: `'uniao'`, `'subtracao'` (o mais atrás menos os outros), `'intersecao'` ou
2632
+ * `'exclusao'`. O resultado é um caminho composto com o id e a aparência do mais à frente (na subtração, do mais atrás).
2633
+ */
2634
+ pathfinder(a) {
2635
+ return L(this.c, a);
2636
+ }
2637
+ /** Ctrl+Alt+Shift+1. */
2638
+ unirFormas() {
2639
+ return L(this.c, "uniao");
2640
+ }
2641
+ /** Ctrl+Alt+Shift+2 ("menos frente"). */
2642
+ subtrairFrente() {
2643
+ return L(this.c, "subtracao");
2644
+ }
2645
+ /** Ctrl+Alt+Shift+3. */
2646
+ intersectarFormas() {
2647
+ return L(this.c, "intersecao");
2648
+ }
2649
+ /** Ctrl+Alt+Shift+4. */
2650
+ excluirSobreposicao() {
2651
+ return L(this.c, "exclusao");
2652
+ }
2653
+ // ---------- painéis (Fase 6) ----------
2654
+ /**
2655
+ * Categorias para o `<ui-tabela-propriedades>` com a seleção atual. Sem seleção: a categoria "Folha" (tamanho, unidade,
2656
+ * grade, margens, somente leitura) com a dica "Selecione um elemento para editar", em vez de um painel vazio.
2657
+ */
2658
+ categoriasDePropriedades() {
2659
+ const a = this.c.doc.elementosSelecionados();
2660
+ return a.length > 0 ? _i(a) : Di({ largura: this.c.folha.largura, altura: this.c.folha.altura, unidade: this.c.unidade, grade: this.c.grade, margens: this.c.margens });
2661
+ }
2662
+ /**
2663
+ * Aplica um campo do painel de propriedades à seleção (o `id` e o `valor` do `ui-propriedade-alterada`). Ação do usuário:
2664
+ * histórico (rajada no mesmo campo = um passo) e `prancha-elemento-atualizado` com motivo `propriedades`.
2665
+ */
2666
+ aplicarPropriedade(a, e) {
2667
+ return Ei(this.c, a, e);
2668
+ }
2669
+ /** Dados para o `<ui-camadas>` (`painel.definirCamadas(d.camadas, d.feicoes)`), da frente para trás. */
2670
+ dadosParaPainelDeCamadas(a) {
2671
+ return Fi(this.c.doc.elementos, this.c.camadas, a);
2672
+ }
2673
+ /** Oculta, trava, renomeia ou muda de camada elementos pelo id (o painel de camadas), inclusive travados. */
2674
+ alterarElementos(a, e) {
2675
+ return xi(this.c, a, e);
2676
+ }
2677
+ }
2678
+ ge("ui-canvas-prancha", Ri);
2679
+ const A = (t) => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`, ia = {
2680
+ selecao: A('<path d="M5 3l14 8-6 2-3 6z" fill="currentColor"/>'),
2681
+ "selecao-direta": A('<path d="M5 3l14 8-6 2-3 6z"/>'),
2682
+ mao: A('<path d="M18 11V6a2 2 0 0 0-4 0M14 10V4a2 2 0 0 0-4 0v2M10 10.5V6a2 2 0 0 0-4 0v8M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.9-5.9-2.4L3.4 16a2 2 0 0 1 3.2-2.4L8 15"/>'),
2683
+ retangulo: A('<rect x="3" y="5" width="18" height="14" rx="1"/>'),
2684
+ elipse: A('<ellipse cx="12" cy="12" rx="9" ry="7"/>'),
2685
+ "poligono-regular": A('<path d="M12 3l8 5v8l-8 5-8-5V8z"/>'),
2686
+ estrela: A('<path d="M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6L12 16.6 6.6 19.5l1.2-6L3.3 9.3l6.1-.7z"/>'),
2687
+ linha: A('<line x1="5" y1="19" x2="19" y2="5"/>'),
2688
+ seta: A('<line x1="5" y1="19" x2="19" y2="5"/><path d="M11 5h8v8"/>'),
2689
+ polilinha: A('<polyline points="3 17 9 11 13 15 21 7"/>'),
2690
+ poligono: A('<path d="M4 18l3-12 10 2 3 9z"/>'),
2691
+ caneta: A('<path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="M2 2l7.6 7.6"/>'),
2692
+ texto: A('<path d="M4 7V4h16v3M9 20h6M12 4v16"/>'),
2693
+ "conta-gotas": A('<path d="M14 4l6 6M17 7l-9 9-4 1 1-4 9-9"/>'),
2694
+ "adicionar-ancora": A('<path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5"/><path d="M4 20h6M7 17v6"/>'),
2695
+ "excluir-ancora": A('<path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5"/><path d="M4 20h6"/>'),
2696
+ "converter-ancora": A('<path d="M4 20L12 4l8 16"/><path d="M8 12h8"/>')
2697
+ }, P = (t, a, e) => ({ id: t, rotulo: a, icone: ia[t], tipo: "ferramenta", ...e ? { atalho: e } : {} }), Oi = Object.freeze([
2698
+ P("selecao", "Seleção", "V"),
2699
+ P("selecao-direta", "Seleção direta", "A"),
2700
+ { id: "grupo-caneta", rotulo: "Caneta", icone: ia.caneta, tipo: "ferramenta", filhos: [
2701
+ P("caneta", "Caneta", "P"),
2702
+ P("adicionar-ancora", "Adicionar âncora", "+"),
2703
+ P("excluir-ancora", "Excluir âncora", "-"),
2704
+ P("converter-ancora", "Converter âncora", "Shift+C")
2705
+ ] },
2706
+ P("texto", "Texto", "T"),
2707
+ { id: "grupo-linhas", rotulo: "Linhas", icone: ia.linha, tipo: "ferramenta", filhos: [
2708
+ P("linha", "Linha", "\\"),
2709
+ P("seta", "Seta"),
2710
+ P("polilinha", "Polilinha"),
2711
+ P("poligono", "Polígono")
2712
+ ] },
2713
+ { id: "grupo-formas", rotulo: "Formas", icone: ia.retangulo, tipo: "ferramenta", filhos: [
2714
+ P("retangulo", "Retângulo", "M"),
2715
+ P("elipse", "Elipse", "L"),
2716
+ P("poligono-regular", "Polígono regular"),
2717
+ P("estrela", "Estrela")
2718
+ ] },
2719
+ P("conta-gotas", "Conta-gotas", "I"),
2720
+ P("mao", "Mão", "H")
2721
+ ]);
2722
+ function qi(t) {
2723
+ return typeof t == "string" && Re.includes(t) ? t : null;
2724
+ }
2725
+ const Ni = ["prancha-elemento-criado", "prancha-elemento-atualizado", "prancha-elemento-removido", "prancha-ordem", "prancha-camadas"], ji = (t) => t.detail ?? {};
2726
+ function Gi(t) {
2727
+ const { prancha: a, paleta: e, camadas: r, propriedades: i } = t ?? {};
2728
+ if (!a) return () => {
2729
+ };
2730
+ const o = new Ea(), s = (h, u, f) => o.add(h, u, (p) => {
2731
+ try {
2732
+ f(ji(p));
2733
+ } catch {
2734
+ }
2735
+ });
2736
+ e && (e.ferramentas = Oi, e.valor = a.ferramenta, s(e, "ui-change", (h) => {
2737
+ const u = qi(h.valor);
2738
+ u && a.definirFerramenta(u);
2739
+ }), s(a, "prancha-ferramenta", (h) => {
2740
+ e.valor = h.ferramenta;
2741
+ }));
2742
+ const n = () => {
2743
+ i && (i.categorias = a.categoriasDePropriedades());
2744
+ };
2745
+ i && s(i, "ui-propriedade-alterada", (h) => {
2746
+ a.aplicarPropriedade(h.id, h.valor);
2747
+ });
2748
+ const l = () => {
2749
+ var u;
2750
+ if (!r) return;
2751
+ const h = a.dadosParaPainelDeCamadas({ ocultarSemCamada: t.listaPlana !== !1 });
2752
+ r.definirCamadas(h.camadas, h.feicoes), (u = r.selecionarFeicoes) == null || u.call(r, a.selecao);
2753
+ }, c = (h, u) => {
2754
+ h !== O && a.definirCamadas(ki(a.obterCamadas(), h, u));
2755
+ };
2756
+ if (r) {
2757
+ const h = r;
2758
+ s(h, "ui-camada-visibilidade", (u) => c(u.camadaId, { visivel: u.visivel })), s(h, "ui-camada-bloqueio", (u) => c(u.camadaId, { bloqueada: u.bloqueado })), s(h, "ui-camada-opacidade", (u) => c(u.camadaId, { opacidade: u.opacidade })), s(h, "ui-camada-renomeada", (u) => c(u.camadaId, { nome: u.novoNome })), s(h, "ui-camada-selecionada", (u) => a.definirCamadaAtiva(Ya(u.camadaId))), s(h, "ui-camadas-reordenadas", (u) => {
2759
+ a.definirCamadas(Li(a.obterCamadas(), (u.camadas ?? []).map((f) => f.id)));
2760
+ }), s(h, "ui-camada-adicionar", () => {
2761
+ const u = a.obterCamadas();
2762
+ let f = u.length + 1;
2763
+ for (; u.some((p) => p.id === `camada-${f}`); ) f++;
2764
+ a.definirCamadas([...u, { id: `camada-${f}`, nome: `Camada ${f}` }]);
2765
+ }), s(h, "ui-feicao-selecionada", (u) => a.selecionarElementos([u.feicaoId])), s(h, "ui-feicoes-selecionadas", (u) => a.selecionarElementos(u.feicoesIds ?? [])), s(h, "ui-feicao-visibilidade", (u) => a.alterarElementos([u.feicaoId], { oculto: !u.visivel })), s(h, "ui-feicao-bloqueio", (u) => a.alterarElementos([u.feicaoId], { bloqueado: u.bloqueado })), s(h, "ui-feicao-renomeada", (u) => a.alterarElementos([u.feicaoId], { nome: u.novoNome })), s(h, "ui-feicao-movida", (u) => a.alterarElementos([u.feicaoId], { camadaId: Ya(u.camadaDestinoId) }));
2766
+ }
2767
+ for (const h of Ni) o.add(a, h, () => {
2768
+ l(), n();
2769
+ });
2770
+ o.add(a, "prancha-selecao", () => {
2771
+ var h;
2772
+ (h = r == null ? void 0 : r.selecionarFeicoes) == null || h.call(r, a.selecao), n();
2773
+ }), l(), n();
2774
+ let d = !0;
2775
+ return () => {
2776
+ d && (d = !1, o.cleanup());
2777
+ };
2778
+ }
2779
+ const Hi = 720, ta = (t) => t === "botoes" || t === "menu" ? t : "auto", V = (t) => t === "fixa" || t === "gaveta" ? t : "auto", $i = ":host{--ui-editor-prancha-lateral: 300px;display:block;min-height:360px;min-width:240px;height:100%;color:var(--ui-cor-texto);font-family:var(--ui-fonte-base);box-sizing:border-box}:host([hidden]){display:none}.raiz{container-type:inline-size;container-name:editor;position:relative;display:grid;grid-template-rows:auto minmax(0,1fr) auto;height:100%;min-height:inherit;gap:var(--ui-espaco-sm);box-sizing:border-box}.barra{display:flex;flex-wrap:nowrap;gap:var(--ui-espaco-xs);align-items:center;min-width:0}.botoes-formas{display:flex;flex-wrap:wrap;gap:var(--ui-espaco-xs);min-width:0;flex:1 1 auto}.formas-menu{position:relative;display:none;flex:0 0 auto}.btn-lateral{display:none;margin-inline-start:auto;flex:0 0 auto}.acoes{display:flex;flex-wrap:nowrap;gap:var(--ui-espaco-xs);align-items:center;justify-content:flex-end;flex:0 0 auto}.area{position:relative;display:flex;gap:var(--ui-espaco-sm);align-items:stretch;min-height:0;min-width:0}.area>ui-paleta-ferramentas{flex:0 0 auto}.area>ui-canvas-prancha{flex:1 1 auto;min-width:0;height:auto}.lateral{flex:0 0 var(--ui-editor-prancha-lateral);display:flex;flex-direction:column;gap:var(--ui-espaco-sm);min-width:0}.lateral>ui-tabela-propriedades{flex:1 1 auto;min-height:200px}button{font:inherit;font-size:var(--ui-tamanho-corpo-sm);color:var(--ui-cor-texto);background:var(--ui-cor-superficie);border:1px solid var(--ui-cor-borda);border-radius:var(--ui-raio-sm);padding:var(--ui-espaco-xs) var(--ui-espaco-md);min-height:var(--ui-touch-target-min);cursor:pointer;white-space:nowrap}button:hover{border-color:var(--ui-cor-primaria)}button:focus-visible{outline:2px solid var(--ui-cor-primaria);outline-offset:2px}button.primario{background:var(--ui-cor-primaria);color:var(--ui-cor-texto-sobre-primaria, #000);border-color:var(--ui-cor-primaria)}.menu-formas{position:absolute;inset-block-start:100%;inset-inline-start:0;z-index:20;min-width:200px;max-height:70vh;overflow:auto;margin-block-start:var(--ui-espaco-xs);padding:var(--ui-espaco-xs);background:var(--ui-cor-superficie);border:1px solid var(--ui-cor-borda);border-radius:var(--ui-raio-sm);box-shadow:var(--ui-sombra-md, 0 8px 24px rgba(0, 0, 0, .35))}.menu-formas[hidden]{display:none}.menu-formas button{display:block;width:100%;text-align:start;border-color:transparent;background:transparent}.menu-formas button:hover,.menu-formas button:focus-visible{background:var(--ui-cor-fundo-elevado)}.menu-grupo{padding:var(--ui-espaco-xs) var(--ui-espaco-sm);font-size:var(--ui-tamanho-caption);color:var(--ui-cor-texto-secundario);text-transform:uppercase}.raiz[data-barra=menu] .botoes-formas{display:none}.raiz[data-barra=menu] .formas-menu{display:block}.raiz[data-lateral=gaveta] .btn-lateral{display:inline-block}.raiz[data-lateral=gaveta] .lateral{position:absolute;inset-block:0;inset-inline-end:0;z-index:10;width:min(var(--ui-editor-prancha-lateral),92%);padding:var(--ui-espaco-sm);box-sizing:border-box;background:var(--ui-cor-fundo);border:1px solid var(--ui-cor-borda);box-shadow:var(--ui-sombra-md, 0 8px 24px rgba(0, 0, 0, .35))}.raiz[data-lateral=gaveta][data-lateral-aberta=false] .lateral{display:none}@container editor (max-width: 719.98px){.raiz[data-barra=auto] .botoes-formas{display:none}.raiz[data-barra=auto] .formas-menu{display:block}.raiz[data-lateral=auto] .btn-lateral{display:inline-block}.raiz[data-lateral=auto] .lateral{position:absolute;inset-block:0;inset-inline-end:0;z-index:10;width:min(var(--ui-editor-prancha-lateral),92%);padding:var(--ui-espaco-sm);box-sizing:border-box;background:var(--ui-cor-fundo);border:1px solid var(--ui-cor-borda);box-shadow:var(--ui-sombra-md, 0 8px 24px rgba(0, 0, 0, .35))}.raiz[data-lateral=auto][data-lateral-aberta=false] .lateral{display:none}}@container editor (max-width: 420px){.area{flex-direction:column}.area>ui-paleta-ferramentas{align-self:flex-start}}", ae = ["largura", "altura", "unidade", "grade", "mostrar-grade", "margens", "ajustar-ao-abrir", "somente-leitura", "sem-snap", "sem-reguas", "rotulo"], ee = { molduras: "Molduras", formas: "Formas", linhas: "Linhas", setas: "Setas" };
2780
+ class Bi extends pe {
2781
+ constructor() {
2782
+ super();
2783
+ m(this, "shadow");
2784
+ m(this, "bag", new Ea());
2785
+ m(this, "desligarPaineis", null);
2786
+ m(this, "observador", null);
2787
+ m(this, "_prancha");
2788
+ m(this, "paleta");
2789
+ m(this, "painelCamadas");
2790
+ m(this, "painelPropriedades");
2791
+ m(this, "raiz");
2792
+ m(this, "botaoLateral");
2793
+ m(this, "botaoFormas");
2794
+ m(this, "menuFormas");
2795
+ m(this, "_lateralAberta", !1);
2796
+ m(this, "estreito", !1);
2797
+ this.shadow = this.attachShadow({ mode: "open" }), this.shadow.innerHTML = `
2798
+ <style>${$i}</style>
2799
+ <div class="raiz" id="raiz" part="base" data-barra="auto" data-lateral="auto" data-lateral-aberta="false">
2800
+ <div class="barra" part="barra" id="barra" role="toolbar" aria-label="Formas e painéis">
2801
+ <div class="botoes-formas" id="botoes-formas" role="group" aria-label="Pré-definições"></div>
2802
+ <div class="formas-menu">
2803
+ <button type="button" id="btn-formas" class="btn-formas" aria-haspopup="menu" aria-expanded="false" aria-controls="menu-formas">Formas ▾</button>
2804
+ <div id="menu-formas" class="menu-formas" part="menu-formas" role="menu" aria-label="Formas" hidden></div>
2805
+ </div>
2806
+ <button type="button" id="btn-lateral" class="btn-lateral" aria-expanded="false" aria-controls="lateral" aria-keyshortcuts="Alt+P" title="Propriedades e camadas (Alt+P)">Propriedades</button>
2807
+ </div>
2808
+ <div class="area">
2809
+ <ui-paleta-ferramentas id="paleta" orientacao="vertical" atalhos></ui-paleta-ferramentas>
2810
+ <ui-canvas-prancha id="prancha" part="prancha" teclado="isolado" ajustar-ao-abrir="folha"></ui-canvas-prancha>
2811
+ <div class="lateral" id="lateral" part="lateral" role="region" aria-label="Camadas e propriedades">
2812
+ <ui-camadas id="camadas" densidade="compacto" mostrar-mapas-base="false" mostrar-rodape="false" persistir="false" altura="260"></ui-camadas>
2813
+ <ui-tabela-propriedades id="propriedades" titulo="Aparência" modo-aplicar="imediato"></ui-tabela-propriedades>
2814
+ </div>
2815
+ </div>
2816
+ <div class="acoes" part="acoes">
2817
+ <button type="button" id="cancelar">Cancelar</button>
2818
+ <button type="button" id="concluir" class="primario">Concluir</button>
2819
+ </div>
2820
+ </div>`;
2821
+ const e = (s) => this.shadow.getElementById(s);
2822
+ this._prancha = e("prancha"), this.paleta = e("paleta"), this.painelCamadas = e("camadas"), this.painelPropriedades = e("propriedades"), this.raiz = e("raiz"), this.botaoLateral = e("btn-lateral"), this.botaoFormas = e("btn-formas"), this.menuFormas = e("menu-formas");
2823
+ const r = e("botoes-formas");
2824
+ let i = null, o = null;
2825
+ for (const s of _a) {
2826
+ const n = document.createElement("button");
2827
+ if (n.type = "button", n.dataset.predefinicao = s.valor, n.textContent = s.rotulo, r.appendChild(n), s.grupo !== i) {
2828
+ i = s.grupo, o = document.createElement("div"), o.setAttribute("role", "group"), o.setAttribute("aria-label", ee[s.grupo]);
2829
+ const c = document.createElement("div");
2830
+ c.className = "menu-grupo", c.setAttribute("aria-hidden", "true"), c.textContent = ee[s.grupo], o.appendChild(c), this.menuFormas.appendChild(o);
2831
+ }
2832
+ const l = document.createElement("button");
2833
+ l.type = "button", l.setAttribute("role", "menuitem"), l.tabIndex = -1, l.dataset.predefinicao = s.valor, l.textContent = s.rotulo, o == null || o.appendChild(l);
2834
+ }
2835
+ }
2836
+ static get observedAttributes() {
2837
+ return [...ae, "teclado", "barra-formas", "lateral"];
2838
+ }
2839
+ connectedCallback() {
2840
+ var e, r;
2841
+ this.bag.cleanup(), (e = this.observador) == null || e.disconnect(), this.observador = null, (r = this.desligarPaineis) == null || r.call(this), this.sincronizarAtributos(), this.desligarPaineis = Gi({
2842
+ prancha: this._prancha,
2843
+ paleta: this.paleta,
2844
+ camadas: this.painelCamadas,
2845
+ propriedades: this.painelPropriedades
2846
+ }), Le(this.bag, this, () => Aa(this.getAttribute("teclado") ?? "isolado") === "isolado"), this.bag.add(this.shadow.getElementById("concluir"), "click", () => this.concluir()), this.bag.add(this.shadow.getElementById("cancelar"), "click", () => this.cancelar()), this.bag.add(this.shadow.getElementById("botoes-formas"), "click", (i) => {
2847
+ var s, n;
2848
+ const o = (n = (s = i.target) == null ? void 0 : s.closest) == null ? void 0 : n.call(s, "button[data-predefinicao]");
2849
+ o && this.inserir(o.dataset.predefinicao);
2850
+ }), this.bag.add(this.botaoFormas, "click", () => this.alternarMenuFormas()), this.bag.add(this.botaoFormas, "keydown", (i) => {
2851
+ i.key === "ArrowDown" && (i.preventDefault(), this.abrirMenuFormas());
2852
+ }), this.bag.add(this.menuFormas, "click", (i) => {
2853
+ var s, n;
2854
+ const o = (n = (s = i.target) == null ? void 0 : s.closest) == null ? void 0 : n.call(s, "button[data-predefinicao]");
2855
+ o && (this.fecharMenuFormas(!1), this.inserir(o.dataset.predefinicao));
2856
+ }), this.bag.add(this.menuFormas, "keydown", (i) => this.tecladoDoMenu(i)), typeof document < "u" && this.bag.add(document, "pointerdown", (i) => {
2857
+ if (this.menuFormas.hidden) return;
2858
+ const o = typeof i.composedPath == "function" ? i.composedPath() : [];
2859
+ !o.includes(this.menuFormas) && !o.includes(this.botaoFormas) && this.fecharMenuFormas(!1);
2860
+ }), this.bag.add(this.botaoLateral, "click", () => {
2861
+ this.lateralAberta = !this.lateralAberta;
2862
+ }), this.bag.add(this.shadow.getElementById("lateral"), "keydown", (i) => {
2863
+ i.key === "Escape" && this.emGaveta() && this._lateralAberta && (i.preventDefault(), i.stopPropagation(), this.lateralAberta = !1, this.botaoLateral.focus());
2864
+ }), this.bag.add(this, "keydown", (i) => {
2865
+ i.altKey && !i.ctrlKey && !i.metaKey && typeof i.key == "string" && i.key.toLowerCase() === "p" && (i.preventDefault(), this.lateralAberta = !this.lateralAberta, this._lateralAberta && this.emGaveta() && this.painelPropriedades.focus());
2866
+ }, { capture: !0 }), this.bag.add(this._prancha, "prancha-esc-sem-efeito", () => this.cancelar()), typeof ResizeObserver == "function" && (this.observador = new ResizeObserver((i) => {
2867
+ var s, n;
2868
+ const o = ((n = (s = i[i.length - 1]) == null ? void 0 : s.contentRect) == null ? void 0 : n.width) ?? 0;
2869
+ o > 0 && this.definirLargura(o);
2870
+ }), this.observador.observe(this.raiz)), this.atualizarLateral();
2871
+ }
2872
+ disconnectedCallback() {
2873
+ var e, r;
2874
+ this.bag.cleanup(), (e = this.observador) == null || e.disconnect(), this.observador = null, (r = this.desligarPaineis) == null || r.call(this), this.desligarPaineis = null, this.fecharMenuFormas(!1);
2875
+ }
2876
+ attributeChangedCallback(e, r, i) {
2877
+ if (e === "barra-formas") {
2878
+ this.raiz.dataset.barra = ta(i);
2879
+ return;
2880
+ }
2881
+ if (e === "lateral") {
2882
+ this.raiz.dataset.lateral = V(i), this.atualizarLateral();
2883
+ return;
2884
+ }
2885
+ this.repassar(e, i);
2886
+ }
2887
+ repassar(e, r) {
2888
+ if (e === "teclado") {
2889
+ const i = Aa(r ?? "isolado");
2890
+ i === "local" ? this._prancha.removeAttribute("teclado") : this._prancha.setAttribute("teclado", i);
2891
+ return;
2892
+ }
2893
+ r === null ? this._prancha.removeAttribute(e) : this._prancha.setAttribute(e, r);
2894
+ }
2895
+ sincronizarAtributos() {
2896
+ for (const e of ae) this.repassar(e, this.getAttribute(e));
2897
+ this.repassar("teclado", this.getAttribute("teclado")), this.raiz.dataset.barra = ta(this.getAttribute("barra-formas")), this.raiz.dataset.lateral = V(this.getAttribute("lateral"));
2898
+ }
2899
+ inserir(e) {
2900
+ const r = _a.find((i) => i.valor === e);
2901
+ r && this._prancha.inserirPredefinicao(r.valor, void 0, r.usaQuadro ? { quadro: "margens" } : {});
2902
+ }
2903
+ // ---------- menu "Formas" ----------
2904
+ itensDoMenu() {
2905
+ return Array.from(this.menuFormas.querySelectorAll('button[role="menuitem"]'));
2906
+ }
2907
+ abrirMenuFormas() {
2908
+ var e;
2909
+ this.menuFormas.hidden = !1, this.botaoFormas.setAttribute("aria-expanded", "true"), (e = this.itensDoMenu()[0]) == null || e.focus();
2910
+ }
2911
+ fecharMenuFormas(e) {
2912
+ this.menuFormas.hidden || (this.menuFormas.hidden = !0, this.botaoFormas.setAttribute("aria-expanded", "false"), e && this.botaoFormas.focus());
2913
+ }
2914
+ alternarMenuFormas() {
2915
+ this.menuFormas.hidden ? this.abrirMenuFormas() : this.fecharMenuFormas(!0);
2916
+ }
2917
+ tecladoDoMenu(e) {
2918
+ const r = this.itensDoMenu(), i = r.indexOf(this.shadow.activeElement);
2919
+ if (e.key === "Escape") {
2920
+ e.preventDefault(), e.stopPropagation(), this.fecharMenuFormas(!0);
2921
+ return;
2922
+ }
2923
+ if (e.key === "Tab") {
2924
+ this.fecharMenuFormas(!1);
2925
+ return;
2926
+ }
2927
+ const o = (s) => {
2928
+ var n;
2929
+ e.preventDefault(), (n = r[(s + r.length) % r.length]) == null || n.focus();
2930
+ };
2931
+ e.key === "ArrowDown" ? o(i + 1) : e.key === "ArrowUp" ? o(i - 1) : e.key === "Home" ? o(0) : e.key === "End" && o(r.length - 1);
2932
+ }
2933
+ // ---------- lateral ----------
2934
+ emGaveta() {
2935
+ const e = V(this.getAttribute("lateral"));
2936
+ return e === "gaveta" || e === "auto" && this.estreito;
2937
+ }
2938
+ definirLargura(e) {
2939
+ const r = e < Hi;
2940
+ r !== this.estreito && (this.estreito = r, this.atualizarLateral());
2941
+ }
2942
+ atualizarLateral() {
2943
+ const e = this.emGaveta();
2944
+ e || (this._lateralAberta = !1), this.raiz.dataset.lateralAberta = String(this._lateralAberta), this.botaoLateral.setAttribute("aria-expanded", String(!e || this._lateralAberta)), this.botaoLateral.toggleAttribute("data-gaveta", e);
2945
+ }
2946
+ /** A lateral (camadas e propriedades) está visível? Em modo fixo é sempre `true`; em gaveta, é o estado aberto/fechado. */
2947
+ get lateralAberta() {
2948
+ return !this.emGaveta() || this._lateralAberta;
2949
+ }
2950
+ set lateralAberta(e) {
2951
+ this.emGaveta() && (this._lateralAberta = !!e, this.atualizarLateral(), this._lateralAberta && this.painelPropriedades.focus());
2952
+ }
2953
+ /** `auto`, `fixa` ou `gaveta`. */
2954
+ get lateral() {
2955
+ return V(this.getAttribute("lateral"));
2956
+ }
2957
+ set lateral(e) {
2958
+ this.setAttribute("lateral", V(e));
2959
+ }
2960
+ /** `auto`, `botoes` ou `menu`. */
2961
+ get barraFormas() {
2962
+ return ta(this.getAttribute("barra-formas"));
2963
+ }
2964
+ set barraFormas(e) {
2965
+ this.setAttribute("barra-formas", ta(e));
2966
+ }
2967
+ // ---------- API ----------
2968
+ /** A prancha interna (para usar a API completa: ferramentas, vista, exportação). */
2969
+ get prancha() {
2970
+ return this._prancha;
2971
+ }
2972
+ /** Elementos do desenho. Ao atribuir, carrega (normaliza) e marca como salvo. */
2973
+ get elementos() {
2974
+ return this._prancha.obterElementos();
2975
+ }
2976
+ set elementos(e) {
2977
+ this._prancha.definirElementos(Array.isArray(e) ? e : []);
2978
+ }
2979
+ get camadas() {
2980
+ return this._prancha.obterCamadas();
2981
+ }
2982
+ set camadas(e) {
2983
+ this._prancha.definirCamadas(Array.isArray(e) ? e : []);
2984
+ }
2985
+ get modificado() {
2986
+ return this._prancha.modificado;
2987
+ }
2988
+ marcarComoSalvo() {
2989
+ this._prancha.marcarComoSalvo();
2990
+ }
2991
+ /** Resolve quando a prancha mediu o layout e consegue enquadrar. */
2992
+ get pronto() {
2993
+ return this._prancha.pronto;
2994
+ }
2995
+ /** Confirma: emite `editor-concluir` com os dados atuais. */
2996
+ concluir() {
2997
+ const e = { elementos: this._prancha.obterElementos(), camadas: this._prancha.obterCamadas(), modificado: this._prancha.modificado };
2998
+ this.dispatchEvent(new CustomEvent("editor-concluir", { detail: e, bubbles: !0, composed: !0 }));
2999
+ }
3000
+ /** Cancela: emite `editor-cancelar`. */
3001
+ cancelar() {
3002
+ const e = { modificado: this._prancha.modificado };
3003
+ this.dispatchEvent(new CustomEvent("editor-cancelar", { detail: e, bubbles: !0, composed: !0 }));
3004
+ }
3005
+ focus(e) {
3006
+ this._prancha.focus(e);
3007
+ }
3008
+ }
3009
+ ge("ui-editor-prancha", Bi);
9
3010
  export {
10
- x as ALCAS_ESCALA,
11
- i as ATRIBUTOS_PRANCHA,
12
- c as CAMADA_SEM_CAMADA,
13
- t as CANAL_COMANDOS_PRANCHA,
14
- m as COMANDOS_PRANCHA,
15
- v as COR_PADRAO_PRANCHA,
16
- f as DIMENSOES_FOLHA,
17
- F as EPSILON_DETERMINANTE,
18
- H as ESCALA_MINIMA,
19
- g as ESPACO_GEOGRAFICO,
20
- z as ESPACO_PLANO,
21
- U as ESPESSURA_PADRAO_MM,
22
- G as ESPESSURA_TRACO_PADRAO_MM,
23
- j as ESTILOS_TRACO,
24
- mr as ESTILO_DO_TIPO_LINHA,
25
- B as FAIXAS_MAXIMO,
26
- X as FAIXAS_PADRAO,
27
- A as FERRAMENTAS_PALETA_PRANCHA,
28
- l as FERRAMENTAS_PRANCHA,
29
- V as FONTE_PADRAO,
30
- Q as FORMATOS_ABNT,
31
- k as Historico,
32
- K as IDENTIDADE,
33
- q as IDS_PROPRIEDADES_PRANCHA,
34
- w as ITENS_PREDEFINICOES,
35
- y as IndicePrancha,
36
- J as KAPPA,
37
- W as LIMITE_PONTA_PADRAO,
38
- Y as MAX_LINHAS_HACHURA,
39
- Z as MESCLAGEM_CSS,
40
- $ as MM_POR_PX,
41
- aa as MM_POR_UNIDADE,
42
- sa as MODOS_MESCLAGEM,
43
- oa as OPERACOES_BOOLEANAS,
44
- ra as PREDEFINICOES,
45
- ea as PRIORIDADE_SNAP_PRANCHA,
46
- P as PX_POR_MM_100,
47
- na as ROTULOS_PREDEFINICOES,
48
- ia as SOMBRA_PADRAO,
49
- ca as TIPO_LINHA_DO_ESTILO,
50
- E as UICanvasPrancha,
51
- d as UICanvasPranchaBase,
52
- b as UIEditorPrancha,
53
- ta as adaptarContextoRelativo,
54
- ma as adicionarAncora,
55
- Aa as agrupar,
56
- Ar as ajustarAparenciaEmLote,
57
- lr as ajustarElementosACaixa,
58
- la as alcasDoElemento,
59
- Pa as alinhar,
60
- Ea as analisarElemento,
61
- da as ancoraMaisProxima,
62
- ba as ancorasDoElemento,
63
- Da as aparenciaDe,
64
- pa as aplicar,
65
- Ca as aplicarAparencia,
66
- Oa as aplicarPathfinder,
67
- Sa as aplicarTodos,
68
- _a as aplicarVetor,
69
- ha as areaComSinal,
70
- Ra as areaDosPoligonos,
71
- Na as avisarUmaVez,
72
- Ma as buscarSnapPrancha,
73
- Ia as caixaDaSelecao,
74
- Ta as caixaDeCantos,
75
- ua as caixaDoQuadro,
76
- ga as caixaDoQuadroAbnt,
77
- La as caixaDoTexto,
78
- xa as caixaNormalizada,
79
- va as caixaOrientada,
80
- D as camadaDoPainel,
81
- p as camadasComMudanca,
82
- C as camadasNaOrdemDoPainel,
83
- fa as caminhoDoContorno,
84
- Fa as caminhoFinito,
85
- Ha as caminhoParaSvg,
86
- O as categoriasDePropriedades,
87
- S as categoriasSemSelecao,
88
- za as centroDaSelecao,
89
- Ua as cisalhamento,
90
- Ga as comPropriedade,
91
- ja as comRaioDeCanto,
92
- Ba as comoCaminhoNaFolha,
93
- Xa as compor,
94
- Va as comprimentoDaPonta,
95
- Qa as contornoDoTraco,
96
- ka as contornoElipse,
97
- Ka as contornoEstrela,
98
- qa as contornoLocal,
99
- wa as contornoLocalEmCache,
100
- ya as contornoNaFolha,
101
- Ja as contornoPoligonoRegular,
102
- Wa as contornoRetangulo,
103
- Ya as converterAncora,
104
- Za as converterEmCaminho,
105
- $a as corComOpacidade,
106
- as as corNaPosicao,
107
- ss as criarCaminho,
108
- os as criarElipse,
109
- rs as criarEstrela,
110
- es as criarLinha,
111
- ns as criarMascara,
112
- is as criarPoligonoRegular,
113
- cs as criarRetangulo,
114
- ts as criarTexto,
115
- _ as dadosParaPainelDeCamadas,
116
- ms as deMm,
117
- As as decompor,
118
- ls as definirMedidorTexto,
119
- Ps as definirRaiosDoRetangulo,
120
- Es as desagrupar,
121
- ds as desenharElementos,
122
- bs as desenharPlano,
123
- Ds as deslocarCaminho,
124
- ps as determinante,
125
- Cs as diagnosticarContexto,
126
- Os as direcaoNaPonta,
127
- Ss as distribuir,
128
- _s as dividirComLinha,
129
- hs as duplicarElementos,
130
- Rs as ehFechado,
131
- h as ehFerramentaPrancha,
132
- Ns as ehIdentidade,
133
- Ms as ehMatrizFinita,
134
- Is as ehPredefinicao,
135
- Ts as ehPropriedadeDeGeometria,
136
- us as ehPropriedadePrancha,
137
- gs as ehSingular,
138
- Ls as ehUnidadePrancha,
139
- xs as elementoNoTopo,
140
- vs as elementosNaCaixa,
141
- fs as elementosNoLaco,
142
- Fs as elementosNoPonto,
143
- Hs as emTornoDe,
144
- zs as envelopeNaFolha,
145
- Us as envelopeVisual,
146
- Gs as escala,
147
- js as espelhamento,
148
- Bs as espelharElementos,
149
- R as eventoTratadoPelaPrancha,
150
- Xs as excluirAncora,
151
- Vs as expandirGrupos,
152
- Qs as exportarSvg,
153
- ks as faixasDoGradienteLinear,
154
- Ks as feicaoDoElemento,
155
- N as ferramentaDaPaleta,
156
- qs as fonteSegura,
157
- ws as geometriaDaPonta,
158
- ys as gerarPredefinicao,
159
- Js as girarElementos,
160
- Ws as guiasInteligentes,
161
- Ys as iguais,
162
- Zs as inverter,
163
- M as lerMargens,
164
- $s as liberarMascara,
165
- I as ligarPaineisPrancha,
166
- ao as limitesLocais,
167
- so as limitesNaFolha,
168
- oo as linhasDeHachura,
169
- ro as mapaDeCamadas,
170
- Pr as mapearPontoNaCaixa,
171
- eo as marcasDosCantos,
172
- no as margensAbnt,
173
- io as matriz,
174
- co as matrizDeCisalhamentoPorAlca,
175
- to as matrizDeEscalaPorAlca,
176
- mo as matrizDoElemento,
177
- Ao as meiaEspessura,
178
- lo as modoDeTransformacao,
179
- Po as moverAlcaDaAncora,
180
- Eo as moverAncora,
181
- bo as moverAncoras,
182
- Do as moverElemento,
183
- po as multiplicar,
184
- Co as normalizarAparencia,
185
- Oo as normalizarCamadas,
186
- So as normalizarElemento,
187
- _o as normalizarElementos,
188
- ho as normalizarGeometriaElemento,
189
- Ro as normalizarGradiente,
190
- No as normalizarHachura,
191
- Er as normalizarParaOrigem,
192
- Mo as operacaoBooleana,
193
- Io as ordenarPorEmpilhamento,
194
- To as padraoTipoLinhaMm,
195
- uo as paraMm,
196
- go as pivoNaFolha,
197
- Lo as planejar,
198
- xo as planejarElemento,
199
- vo as planejarElementos,
200
- fo as planoDe,
201
- Fo as pontoNoAnel,
202
- Ho as posicaoLocalDaAlca,
203
- zo as posicoesDasAlcas,
204
- Uo as profundidadeNoCanto,
205
- Go as raiosCabiveis,
206
- jo as raiosEfetivos,
207
- Bo as recompor,
208
- Xo as redefinirAvisoContexto,
209
- Vo as regiaoDoElemento,
210
- Qo as reordenar,
211
- ko as resolverAparencia,
212
- Ko as resolverSombra,
213
- dr as resumirAparencia,
214
- qo as rotacao,
215
- wo as rotacaoEmGraus,
216
- yo as rotacaoPorArrasto,
217
- T as rotuloDoTipo,
218
- Jo as saneada,
219
- Wo as simplificarCaminho,
220
- Yo as temMedidorTexto,
221
- Zo as temPreenchimento,
222
- $o as testarElemento,
223
- ar as transformarContorno,
224
- sr as transformarElemento,
225
- or as transformarElementos,
226
- rr as translacao,
227
- er as trechoMaisProximo,
228
- nr as unirCaminhos,
229
- ir as valorDaPropriedade,
230
- cr as varreduraDoArco
3011
+ Ct as ALCAS_ESCALA,
3012
+ qe as ATRIBUTOS_PRANCHA,
3013
+ O as CAMADA_SEM_CAMADA,
3014
+ fi as CANAL_COMANDOS_PRANCHA,
3015
+ pi as COMANDOS_PRANCHA,
3016
+ Je as COR_PADRAO_PRANCHA,
3017
+ ao as DIMENSOES_FOLHA,
3018
+ eo as EPSILON_DETERMINANTE,
3019
+ to as ESCALA_MINIMA,
3020
+ Zs as ESPACO_GEOGRAFICO,
3021
+ nt as ESPACO_PLANO,
3022
+ ro as ESPESSURA_PADRAO_MM,
3023
+ We as ESPESSURA_TRACO_PADRAO_MM,
3024
+ io as ESTILOS_TRACO,
3025
+ oo as ESTILO_DO_TIPO_LINHA,
3026
+ so as FAIXAS_MAXIMO,
3027
+ no as FAIXAS_PADRAO,
3028
+ Oi as FERRAMENTAS_PALETA_PRANCHA,
3029
+ Re as FERRAMENTAS_PRANCHA,
3030
+ lo as FONTE_PADRAO,
3031
+ co as FORMATOS_ABNT,
3032
+ Be as Historico,
3033
+ uo as IDENTIDADE,
3034
+ ho as IDS_PROPRIEDADES_PRANCHA,
3035
+ _a as ITENS_PREDEFINICOES,
3036
+ $e as IndicePrancha,
3037
+ mo as KAPPA,
3038
+ Hi as LARGURA_ESTREITA_PX,
3039
+ fo as LIMITE_PONTA_PADRAO,
3040
+ po as MAX_LINHAS_HACHURA,
3041
+ go as MESCLAGEM_CSS,
3042
+ vo as MM_POR_PX,
3043
+ bo as MM_POR_UNIDADE,
3044
+ tr as MODOS_MESCLAGEM,
3045
+ $t as OPERACOES_BOOLEANAS,
3046
+ yo as PREDEFINICOES,
3047
+ Ao as PRIORIDADE_SNAP_PRANCHA,
3048
+ H as PX_POR_MM_100,
3049
+ Po as ROTULOS_PREDEFINICOES,
3050
+ So as SOMBRA_PADRAO,
3051
+ Mo as TIPO_LINHA_DO_ESTILO,
3052
+ Ri as UICanvasPrancha,
3053
+ Si as UICanvasPranchaBase,
3054
+ Bi as UIEditorPrancha,
3055
+ zo as adaptarContextoRelativo,
3056
+ qt as adicionarAncora,
3057
+ ht as agrupar,
3058
+ Eo as ajustarAparenciaEmLote,
3059
+ xo as ajustarElementosACaixa,
3060
+ ce as alcasDoElemento,
3061
+ ft as alinhar,
3062
+ Ve as analisarElemento,
3063
+ Nt as ancoraMaisProxima,
3064
+ Sa as ancorasDoElemento,
3065
+ Co as aparenciaDe,
3066
+ Et as aplicar,
3067
+ ne as aplicarAparencia,
3068
+ Bt as aplicarPathfinder,
3069
+ To as aplicarTodos,
3070
+ wo as aplicarVetor,
3071
+ Io as areaComSinal,
3072
+ Do as areaDosPoligonos,
3073
+ _o as avisarUmaVez,
3074
+ te as buscarSnapPrancha,
3075
+ Ma as caixaDaSelecao,
3076
+ ut as caixaDeCantos,
3077
+ me as caixaDoQuadro,
3078
+ Fo as caixaDoQuadroAbnt,
3079
+ ko as caixaDoTexto,
3080
+ Lo as caixaNormalizada,
3081
+ zt as caixaOrientada,
3082
+ Ya as camadaDoPainel,
3083
+ ki as camadasComMudanca,
3084
+ Li as camadasNaOrdemDoPainel,
3085
+ Ro as caminhoDoContorno,
3086
+ Oo as caminhoFinito,
3087
+ qo as caminhoParaSvg,
3088
+ _i as categoriasDePropriedades,
3089
+ Di as categoriasSemSelecao,
3090
+ et as centroDaSelecao,
3091
+ No as cisalhamento,
3092
+ ar as comPropriedade,
3093
+ Tt as comRaioDeCanto,
3094
+ jo as comoCaminhoNaFolha,
3095
+ wa as compor,
3096
+ Go as comprimentoDaPonta,
3097
+ St as contornoDoTraco,
3098
+ Ho as contornoElipse,
3099
+ $o as contornoEstrela,
3100
+ Bo as contornoLocal,
3101
+ Ko as contornoLocalEmCache,
3102
+ za as contornoNaFolha,
3103
+ Vo as contornoPoligonoRegular,
3104
+ Uo as contornoRetangulo,
3105
+ jt as converterAncora,
3106
+ Mt as converterEmCaminho,
3107
+ Xo as corComOpacidade,
3108
+ Zo as corNaPosicao,
3109
+ Ia as criarCaminho,
3110
+ rt as criarElipse,
3111
+ ot as criarEstrela,
3112
+ st as criarLinha,
3113
+ gt as criarMascara,
3114
+ it as criarPoligonoRegular,
3115
+ tt as criarRetangulo,
3116
+ ct as criarTexto,
3117
+ Fi as dadosParaPainelDeCamadas,
3118
+ Ht as deMm,
3119
+ Wo as decompor,
3120
+ Ut as definirMedidorTexto,
3121
+ Ye as definirRaiosDoRetangulo,
3122
+ mt as desagrupar,
3123
+ N as desenharElementos,
3124
+ Jo as desenharPlano,
3125
+ At as deslocarCaminho,
3126
+ Qo as determinante,
3127
+ Yo as diagnosticarContexto,
3128
+ as as direcaoNaPonta,
3129
+ pt as distribuir,
3130
+ yt as dividirComLinha,
3131
+ le as duplicarElementos,
3132
+ es as ehFechado,
3133
+ Oe as ehFerramentaPrancha,
3134
+ ts as ehIdentidade,
3135
+ re as ehMatrizFinita,
3136
+ Zt as ehPredefinicao,
3137
+ Yt as ehPropriedadeDeGeometria,
3138
+ Qt as ehPropriedadePrancha,
3139
+ rs as ehSingular,
3140
+ Kt as ehUnidadePrancha,
3141
+ oa as elementoNoTopo,
3142
+ Gt as elementosNaCaixa,
3143
+ is as elementosNoLaco,
3144
+ os as elementosNoPonto,
3145
+ ss as emTornoDe,
3146
+ Rt as envelopeNaFolha,
3147
+ Da as envelopeVisual,
3148
+ q as escala,
3149
+ ns as espelhamento,
3150
+ Qe as espelharElementos,
3151
+ Ji as eventoTratadoPelaPrancha,
3152
+ oe as excluirAncora,
3153
+ Ze as expandirGrupos,
3154
+ Jt as exportarSvg,
3155
+ ls as faixasDoGradienteLinear,
3156
+ cs as feicaoDoElemento,
3157
+ qi as ferramentaDaPaleta,
3158
+ us as fonteSegura,
3159
+ ds as geometriaDaPonta,
3160
+ Wt as gerarPredefinicao,
3161
+ hs as girarElementos,
3162
+ kt as guiasInteligentes,
3163
+ ms as iguais,
3164
+ Le as instalarIsolamentoDeTeclas,
3165
+ fs as inverter,
3166
+ Ne as lerMargens,
3167
+ Aa as lerModoTeclado,
3168
+ vt as liberarMascara,
3169
+ Gi as ligarPaineisPrancha,
3170
+ ps as limitesLocais,
3171
+ W as limitesNaFolha,
3172
+ gs as linhasDeHachura,
3173
+ Ue as mapaDeCamadas,
3174
+ vs as mapearPontoNaCaixa,
3175
+ Lt as marcasDosCantos,
3176
+ bs as margensAbnt,
3177
+ ys as matriz,
3178
+ _t as matrizDeCisalhamentoPorAlca,
3179
+ Ft as matrizDeEscalaPorAlca,
3180
+ As as matrizDoElemento,
3181
+ Ps as meiaEspessura,
3182
+ Ss as modoDeTransformacao,
3183
+ wt as moverAlcaDaAncora,
3184
+ It as moverAncora,
3185
+ ie as moverAncoras,
3186
+ Ms as moverElemento,
3187
+ zs as multiplicar,
3188
+ Es as normalizarAparencia,
3189
+ Xe as normalizarCamadas,
3190
+ at as normalizarElemento,
3191
+ Ke as normalizarElementos,
3192
+ xs as normalizarGeometriaElemento,
3193
+ Cs as normalizarGradiente,
3194
+ Ts as normalizarHachura,
3195
+ ws as normalizarParaOrigem,
3196
+ Is as operacaoBooleana,
3197
+ $ as ordenarPorEmpilhamento,
3198
+ Ds as padraoTipoLinhaMm,
3199
+ lt as paraMm,
3200
+ _s as pivoNaFolha,
3201
+ Fs as planejar,
3202
+ ks as planejarElemento,
3203
+ Ls as planejarElementos,
3204
+ Rs as planoDe,
3205
+ Os as pontoNoAnel,
3206
+ xt as posicaoLocalDaAlca,
3207
+ ue as posicoesDasAlcas,
3208
+ he as profundidadeNoCanto,
3209
+ qs as raiosCabiveis,
3210
+ de as raiosEfetivos,
3211
+ Ns as recompor,
3212
+ js as redefinirAvisoContexto,
3213
+ Gs as regiaoDoElemento,
3214
+ dt as reordenar,
3215
+ ir as resolverAparencia,
3216
+ Hs as resolverSombra,
3217
+ $s as resumirAparencia,
3218
+ Pa as rotacao,
3219
+ er as rotacaoEmGraus,
3220
+ Dt as rotacaoPorArrasto,
3221
+ je as rotuloDoTipo,
3222
+ Xt as saneada,
3223
+ Pt as simplificarCaminho,
3224
+ di as teclaReservadaDoNavegador,
3225
+ Vt as temMedidorTexto,
3226
+ Bs as temPreenchimento,
3227
+ Ks as testarElemento,
3228
+ Vs as transformarContorno,
3229
+ se as transformarElemento,
3230
+ T as transformarElementos,
3231
+ k as translacao,
3232
+ Ot as trechoMaisProximo,
3233
+ bt as unirCaminhos,
3234
+ rr as valorDaPropriedade,
3235
+ Us as varreduraDoArco
231
3236
  };