Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat(erp): seasonal Halloween decorations
naveenkashf51efc02cf76
diff --git a/apps/erp/app/components/Halloween/BarSpider.tsx b/apps/erp/app/components/Halloween/BarSpider.tsxnew file mode 100644index 0000000000..cdf1a6f444--- /dev/null+++ b/apps/erp/app/components/Halloween/BarSpider.tsx@@ -0,0 +1,338 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { cn } from "@carbon/react";+import { useLingui } from "@lingui/react/macro";+import { useReducedMotion } from "motion/react";+import { useEffect, useRef, useState } from "react";+import type { Obstacle } from "./bar-spider";+import { createBarSpider, HIT_SIZE } from "./bar-spider";+import { BAR_HEIGHT } from "./corner-web";+import { LEG_BAND, LEG_COLOUR, RealSpiderBody } from "./RealSpider";++// The top bar's corner webs and the spider that crawls along the bar between+// them. The layer covers the bar but is drawing only: every click passes+// through it. The spider's own button is the one thing that takes a click,+// and only while it is clear of everything on the bar. The behaviour lives+// in bar-spider.ts.++const SNAP_MS = 460;++type Phase = "shown" | "snapping" | "away";++type WebRefs = {+ spokes: SVGPathElement | null;+ rings: SVGPathElement | null;+ torn: SVGPathElement | null;+};++const emptyWeb = (): WebRefs => ({ spokes: null, rings: null, torn: null });++/**+ * The top bar is the layer's sibling that starts where it does and is as+ * tall. Everything on it you can see or press, as boxes in the layer's+ * coordinates.+ */+function measureBar(layer: HTMLElement) {+ const card = layer.parentElement;+ if (!card) return null;+ const origin = layer.getBoundingClientRect();+ const bar = Array.from(card.children).find((child) => {+ if (child === layer) return false;+ const box = child.getBoundingClientRect();+ return (+ Math.abs(box.top - origin.top) < 2 &&+ Math.abs(box.height - origin.height) < 3+ );+ });+ if (!(bar instanceof HTMLElement)) return null;+ const obstacles: Obstacle[] = [];+ for (const node of Array.from(bar.querySelectorAll("*"))) {+ // Links and buttons whole, and every other element that holds no+ // further elements (text, icons).+ const leaf =+ node.childElementCount === 0 ||+ node.matches("a, button, input, select, textarea, [role]");+ if (!leaf) continue;+ const box = node.getBoundingClientRect();+ if (box.width < 1 || box.height < 1) continue;+ obstacles.push({+ left: box.left - origin.left,+ top: box.top - origin.top,+ right: box.right - origin.left,+ bottom: box.bottom - origin.top+ });+ }+ return { bar, obstacles };+}++export function BarSpider({+ revealOpen,+ onOpen,+ onPreload+}: {+ revealOpen: boolean;+ onOpen: () => void;+ onPreload: () => void;+}) {+ const { t } = useLingui();+ const reducedMotion = useReducedMotion() ?? false;+ const [phase, setPhase] = useState<Phase>("shown");+ const [grabbing, setGrabbing] = useState(false);++ const layerRef = useRef<HTMLDivElement>(null);+ const svgRef = useRef<SVGSVGElement>(null);+ const websRef = useRef<WebRefs[]>([emptyWeb(), emptyWeb()]);+ const draglineRef = useRef<SVGLineElement>(null);+ const bodyRef = useRef<SVGGElement>(null);+ const femursRef = useRef<SVGPathElement>(null);+ const tibiaeRef = useRef<SVGPathElement>(null);+ const tarsiRef = useRef<SVGPathElement>(null);+ const jointsRef = useRef<SVGPathElement>(null);+ const bristlesRef = useRef<SVGPathElement>(null);+ const buttonRef = useRef<HTMLButtonElement>(null);++ const sim = useRef<ReturnType<typeof createBarSpider> | null>(null);+ if (sim.current === null) sim.current = createBarSpider();++ const onOpenRef = useRef(onOpen);+ onOpenRef.current = onOpen;++ // Wire the simulation to the drawing, size it to the bar, and keep both the+ // size and the bar's contents current: the bar lays out after the first+ // paint, each page has its own breadcrumbs, windows get resized.+ useEffect(() => {+ const s = sim.current;+ const layer = layerRef.current;+ const card = layer?.parentElement;+ if (!s || !layer || !card) return;+ s.attach(+ {+ svg: svgRef.current,+ webs: websRef.current,+ dragline: draglineRef.current,+ body: bodyRef.current,+ femurs: femursRef.current,+ tibiae: tibiaeRef.current,+ tarsi: tarsiRef.current,+ joints: jointsRef.current,+ bristles: bristlesRef.current,+ button: buttonRef.current+ },+ { reducedMotion }+ );++ let frame = 0;+ let watched: Element | null = null;+ const barResized = new ResizeObserver(() => schedule());+ const barChanged = new MutationObserver(() => schedule());+ function measure() {+ if (!layer) return;+ s?.layout(layer.getBoundingClientRect().width);+ const found = measureBar(layer);+ s?.setObstacles(found?.obstacles ?? []);+ if (!found || found.bar === watched) return;+ barResized.disconnect();+ barChanged.disconnect();+ watched = found.bar;+ barResized.observe(found.bar);+ barChanged.observe(found.bar, {+ childList: true,+ subtree: true,+ characterData: true+ });+ }+ function schedule() {+ cancelAnimationFrame(frame);+ frame = requestAnimationFrame(measure);+ }+ const layerResized = new ResizeObserver(schedule);+ layerResized.observe(layer);+ const cardChanged = new MutationObserver(schedule);+ cardChanged.observe(card, { childList: true });++ measure();+ s.appear();+ return () => {+ cancelAnimationFrame(frame);+ barResized.disconnect();+ barChanged.disconnect();+ layerResized.disconnect();+ cardChanged.disconnect();+ s.detach();+ };+ }, [reducedMotion]);++ // The spider comes back once the surprise is closed.+ useEffect(() => {+ if (revealOpen || phase !== "away") return;+ setPhase("shown");+ sim.current?.appear();+ }, [revealOpen, phase]);++ useEffect(() => {+ if (phase !== "snapping") return;+ const timer = window.setTimeout(() => {+ setPhase("away");+ sim.current?.sleep();+ onOpenRef.current();+ }, SNAP_MS);+ return () => window.clearTimeout(timer);+ }, [phase]);++ const letGo = () => {+ sim.current?.release();+ setGrabbing(false);+ };++ const open = () => {+ if (phase !== "shown") return;+ onPreload();+ sim.current?.snap();+ setPhase("snapping");+ };++ const silk = {+ fill: "none",+ stroke: "currentColor",+ strokeLinecap: "round" as const,+ strokeLinejoin: "round" as const+ };++ return (+ <div+ ref={layerRef}+ className="pointer-events-none absolute inset-x-0 top-0 z-20 hidden text-foreground md:block"+ style={{ height: "var(--topbar-height)" }}+ >+ <svg+ ref={svgRef}+ width="100%"+ height={BAR_HEIGHT}+ className={cn(+ "absolute inset-0 overflow-visible transition-opacity ease-out",+ phase === "shown"+ ? "opacity-100 duration-300"+ : "opacity-0 duration-500"+ )}+ aria-hidden+ >+ <defs>+ <filter+ id="halloween-spider-shadow"+ x="-50%"+ y="-50%"+ width="200%"+ height="200%"+ >+ <feDropShadow+ dx="1"+ dy="2"+ stdDeviation="0.9"+ floodColor="#000000"+ floodOpacity="0.28"+ />+ </filter>+ </defs>++ {websRef.current.map((_, k) => {+ const id = `halloween-corner-web-${k}`;+ const at = (name: keyof WebRefs) => (node: SVGPathElement | null) => {+ websRef.current[k][name] = node;+ };+ return (+ <g key={id}>+ <path+ ref={at("spokes")}+ {...silk}+ strokeOpacity={0.22}+ strokeWidth={0.7}+ />+ <path+ ref={at("rings")}+ {...silk}+ strokeOpacity={0.18}+ strokeWidth={0.6}+ />+ <path+ ref={at("torn")}+ {...silk}+ strokeOpacity={0.16}+ strokeWidth={0.5}+ />+ </g>+ );+ })}+ <line+ ref={draglineRef}+ stroke="currentColor"+ strokeOpacity={0.5}+ strokeWidth={0.45}+ visibility="hidden"+ />++ <g filter="url(#halloween-spider-shadow)">+ <g fill="none" stroke={LEG_COLOUR} strokeLinecap="round">+ <path+ ref={bristlesRef}+ stroke="#1c130c"+ strokeOpacity={0.75}+ strokeWidth={0.26}+ />+ <path ref={femursRef} strokeWidth={1.3} />+ <path ref={tibiaeRef} strokeWidth={1} />+ <path ref={tarsiRef} strokeWidth={0.68} />+ <path+ ref={jointsRef}+ stroke={LEG_BAND}+ strokeWidth={0.94}+ strokeLinecap="butt"+ />+ </g>+ <g ref={bodyRef}>+ <RealSpiderBody idPrefix="halloween-bar-spider" />+ </g>+ </g>+ </svg>+ <button+ ref={buttonRef}+ type="button"+ aria-label={t`Halloween surprise`}+ title={t`Poke the spider… if you dare`}+ disabled={phase !== "shown"}+ className={cn(+ "absolute left-0 top-0 rounded-full outline-none touch-none",+ "focus-visible:ring-2 focus-visible:ring-ring",+ grabbing ? "cursor-grabbing" : "cursor-grab"+ )}+ // The simulation switches pointer events on and off as the spider+ // moves, so it never covers anything on the bar.+ style={{ width: HIT_SIZE, height: HIT_SIZE, pointerEvents: "none" }}+ onPointerEnter={onPreload}+ onFocus={onPreload}+ onPointerDown={(event) => {+ // Only the main button grabs: a right-click opens a context menu+ // that swallows the release.+ if (event.button !== 0) return;+ event.currentTarget.setPointerCapture(event.pointerId);+ sim.current?.grab(event.clientX, event.clientY);+ setGrabbing(true);+ }}+ onPointerMove={(event) => {+ const held = (event.buttons & 1) === 1;+ sim.current?.drag(event.clientX, event.clientY, held);+ if (!held) setGrabbing(false);+ }}+ onPointerUp={letGo}+ onPointerCancel={letGo}+ onLostPointerCapture={letGo}+ onClick={() => {+ // A drag ends in a click too; only a press that stayed put opens.+ if (sim.current?.consumeDrag()) return;+ open();+ }}+ />+ </div>+ );+}diff --git a/apps/erp/app/components/Halloween/HalloweenLayer.tsx b/apps/erp/app/components/Halloween/HalloweenLayer.tsxnew file mode 100644index 0000000000..6b5567c086--- /dev/null+++ b/apps/erp/app/components/Halloween/HalloweenLayer.tsx@@ -0,0 +1,51 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { AnimatePresence } from "motion/react";+import { lazy, Suspense, useCallback, useState } from "react";+import { BarSpider } from "./BarSpider";+import { hideDecorations, useHalloweenDecorations } from "./season";++// Seasonal decoration. To remove it, delete this folder, its mount in+// routes/x+/_layout.tsx and the pumpkin home icon in+// components/Layout/Topbar/Breadcrumbs.tsx. Until then it switches itself on+// and off with the season (season.ts).++const loadReveal = () => import("./HalloweenReveal");+const HalloweenReveal = lazy(loadReveal);++function preloadReveal() {+ void loadReveal();+}++export function HalloweenLayer({ userId }: { userId: string }) {+ const shown = useHalloweenDecorations(userId);+ const [revealOpen, setRevealOpen] = useState(false);++ const open = useCallback(() => setRevealOpen(true), []);+ const close = useCallback(() => setRevealOpen(false), []);+ const hide = useCallback(() => {+ setRevealOpen(false);+ hideDecorations(userId);+ }, [userId]);++ return (+ <>+ {shown && (+ <BarSpider+ revealOpen={revealOpen}+ onOpen={open}+ onPreload={preloadReveal}+ />+ )}+ <AnimatePresence>+ {revealOpen && (+ <Suspense key="halloween-reveal" fallback={null}>+ <HalloweenReveal onClose={close} onHide={hide} />+ </Suspense>+ )}+ </AnimatePresence>+ </>+ );+}diff --git a/apps/erp/app/components/Halloween/HalloweenReveal.tsx b/apps/erp/app/components/Halloween/HalloweenReveal.tsxnew file mode 100644index 0000000000..ebd72f6861--- /dev/null+++ b/apps/erp/app/components/Halloween/HalloweenReveal.tsx@@ -0,0 +1,76 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { Button, useEscape } from "@carbon/react";+import { Trans, useLingui } from "@lingui/react/macro";+import { motion, useReducedMotion } from "motion/react";+import { useEffect, useRef } from "react";+import { createPortal } from "react-dom";+import { HalloweenScene, NIGHT } from "./HalloweenScene";++// The surprise behind the spider web, over the whole screen. It closes on its+// own, on Escape, or on a click anywhere.++const AUTO_CLOSE_MS = 10_000;++export default function HalloweenReveal({+ onClose,+ onHide+}: {+ onClose: () => void;+ onHide: () => void;+}) {+ const { t } = useLingui();+ const still = useReducedMotion() ?? false;+ const closeRef = useRef<HTMLButtonElement>(null);++ useEscape(onClose);++ useEffect(() => {+ closeRef.current?.focus();+ const timer = window.setTimeout(onClose, AUTO_CLOSE_MS);+ return () => window.clearTimeout(timer);+ }, [onClose]);++ return createPortal(+ <motion.div+ role="dialog"+ aria-modal+ aria-label={t`Happy Halloween`}+ className="fixed inset-0 z-[100] cursor-pointer select-none overflow-hidden"+ style={{ backgroundColor: NIGHT }}+ initial={{ opacity: 0 }}+ animate={{ opacity: 1 }}+ exit={{ opacity: 0 }}+ transition={{ duration: still ? 0.2 : 0.6, ease: "easeOut" }}+ onClick={onClose}+ >+ <HalloweenScene+ title={t`Happy Halloween`}+ subtitle={t`Something wicked this way ships.`}+ still={still}+ />++ <motion.div+ className="absolute inset-x-0 bottom-10 flex justify-center gap-2"+ initial={still ? false : { opacity: 0, y: 12 }}+ animate={{ opacity: 1, y: 0 }}+ transition={{ duration: 0.5, delay: 2.4 }}+ onClick={(event) => event.stopPropagation()}+ >+ <Button ref={closeRef} variant="secondary" onClick={onClose}>+ <Trans>Close</Trans>+ </Button>+ <Button+ variant="ghost"+ className="text-white/80 hover:bg-white/10 hover:text-white"+ onClick={onHide}+ >+ <Trans>Hide decorations</Trans>+ </Button>+ </motion.div>+ </motion.div>,+ document.body+ );+}diff --git a/apps/erp/app/components/Halloween/HalloweenScene.tsx b/apps/erp/app/components/Halloween/HalloweenScene.tsxnew file mode 100644index 0000000000..dbedf187ef--- /dev/null+++ b/apps/erp/app/components/Halloween/HalloweenScene.tsx@@ -0,0 +1,888 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { motion } from "motion/react";+import type { ReactNode } from "react";+import { JackOLanterns, LANTERN_THUD_AT } from "./Pumpkins";+import { SpiderBody } from "./Spider";+import type { BatFlight, GravestoneShape } from "./scene";+import { BATS, CLOUDS, FENCE, GRASS, GRAVESTONES, STARS, TREE } from "./scene";+import {+ Loop,+ LoopTransform,+ SCENE_ORIGIN,+ StillContext,+ useStill+} from "./scene-loops";++// The surprise behind the spider web: a moonlit graveyard. A haunted house+// lets out a colony of bats, a ghost rises from a grave, jack-o'-lanterns+// arrive and are lit one by one, a spider drops in on its thread.++export const NIGHT = "#06030a";+const SILHOUETTE = "#0a0613";+const GROUND = "#110920";++/** The night scene on its own: the reveal puts it on screen. */+export function HalloweenScene({+ title,+ subtitle,+ still+}: {+ title: string;+ subtitle: string;+ /** Reduced motion: every element at rest, no loops. */+ still: boolean;+}) {+ return (+ <StillContext.Provider value={still}>+ <svg+ viewBox="0 0 1600 900"+ preserveAspectRatio="xMidYMid slice"+ className="absolute inset-0 h-full w-full"+ aria-hidden+ >+ <SceneDefs />++ <Thud>+ <rect width={1600} height={900} fill="url(#hw-sky)" />+ <Stars />+ <ellipse+ cx={800}+ cy={690}+ rx={980}+ ry={190}+ fill="url(#hw-horizon)"+ />+ <Moon />+ <Clouds />+ {BATS.slice(0, 2).map((bat) => (+ <FlyingBat key={bat.id} flight={bat} silhouette />+ ))}++ {/* Far hills, then the house on its rise */}+ <path+ d="M 0 640 C 200 590, 380 612, 560 632 S 900 598, 1100 624 S 1400 588, 1600 614 L 1600 900 L 0 900 Z"+ fill="#1b0f2a"+ />+ <HauntedHouse />+ <path+ d="M 0 702 C 300 672, 600 690, 900 700 S 1350 680, 1600 690 L 1600 900 L 0 900 Z"+ fill={GROUND}+ />+ <Fence />+ <Fog y={716} opacity={0.15} drift={18} />+ <Tree />+ <Ghost />++ {/* Foreground graveyard */}+ <path+ d="M 0 768 C 260 728, 520 752, 760 760 S 1200 736, 1600 752 L 1600 900 L 0 900 Z"+ fill={NIGHT}+ />+ {GRAVESTONES.map((stone) => (+ <Gravestone key={stone.id} {...stone} />+ ))}+ <path d={GRASS} fill={NIGHT} />+ <JackOLanterns />+ <Fog y={858} opacity={0.1} drift={24} />++ <Title title={title} subtitle={subtitle} />+ {BATS.slice(2).map((bat) => (+ <FlyingBat key={bat.id} flight={bat} />+ ))}+ <DroppingSpider />+ </Thud>++ <rect width={1600} height={900} fill="url(#hw-vignette)" />+ {!still && (+ <motion.rect+ width={1600}+ height={900}+ fill="#e9e3ff"+ initial={{ opacity: 0 }}+ animate={{ opacity: [0, 0.3, 0, 0.12, 0] }}+ transition={{+ duration: 1.1,+ delay: 0.35,+ times: [0, 0.12, 0.4, 0.5, 1]+ }}+ />+ )}+ </svg>+ </StillContext.Provider>+ );+}++/** The scene jolts when the big lantern lands. */+function Thud({ children }: { children: ReactNode }) {+ const still = useStill();+ return (+ <motion.g+ initial={{ y: 0 }}+ animate={still ? { y: 0 } : { y: [0, 0, 6, -3, 1.5, 0] }}+ transition={{+ delay: LANTERN_THUD_AT - 0.02,+ duration: 0.42,+ times: [0, 0.05, 0.22, 0.5, 0.75, 1]+ }}+ >+ {children}+ </motion.g>+ );+}++function SceneDefs() {+ return (+ <defs>+ <linearGradient id="hw-sky" x1="0" y1="0" x2="0" y2="1">+ <stop offset="0" stopColor="#05030c" />+ <stop offset="0.42" stopColor="#140a28" />+ <stop offset="0.72" stopColor="#2a1240" />+ <stop offset="1" stopColor="#47193a" />+ </linearGradient>+ <radialGradient id="hw-horizon" cx="0.5" cy="0.5" r="0.5">+ <stop offset="0" stopColor="#ff7a1a" stopOpacity={0.22} />+ <stop offset="0.6" stopColor="#a8325e" stopOpacity={0.08} />+ <stop offset="1" stopColor="#a8325e" stopOpacity={0} />+ </radialGradient>+ <radialGradient id="hw-moon" cx="0.4" cy="0.36" r="0.68">+ <stop offset="0" stopColor="#fffbea" />+ <stop offset="0.55" stopColor="#f6e3a8" />+ <stop offset="1" stopColor="#d6b062" />+ </radialGradient>+ <radialGradient id="hw-moon-glow" cx="0.5" cy="0.5" r="0.5">+ <stop offset="0" stopColor="#ffe8a8" stopOpacity={0.5} />+ <stop offset="0.3" stopColor="#ffd78a" stopOpacity={0.16} />+ <stop offset="1" stopColor="#ffd78a" stopOpacity={0} />+ </radialGradient>+ <linearGradient id="hw-cloud" x1="0" y1="0" x2="0" y2="1">+ <stop offset="0" stopColor="#4d3670" />+ <stop offset="0.5" stopColor="#2a1a42" />+ <stop offset="1" stopColor="#170e26" />+ </linearGradient>+ <radialGradient id="hw-window-glow" cx="0.5" cy="0.5" r="0.5">+ <stop offset="0" stopColor="#ffb547" stopOpacity={0.55} />+ <stop offset="1" stopColor="#ff8a1f" stopOpacity={0} />+ </radialGradient>+ <radialGradient id="hw-pumpkin" cx="0.38" cy="0.32" r="0.78">+ <stop offset="0" stopColor="#ffb25a" />+ <stop offset="0.5" stopColor="#f47b16" />+ <stop offset="1" stopColor="#a33a06" />+ </radialGradient>+ <radialGradient id="hw-carve" cx="0.5" cy="0.5" r="0.62">+ <stop offset="0" stopColor="#fffde3" />+ <stop offset="0.35" stopColor="#ffe066" />+ <stop offset="0.8" stopColor="#ff9a1a" />+ <stop offset="1" stopColor="#e05a00" />+ </radialGradient>+ <radialGradient id="hw-bloom" cx="0.5" cy="0.5" r="0.5">+ <stop offset="0" stopColor="#ffcf4a" stopOpacity={0.55} />+ <stop offset="1" stopColor="#ff8a1f" stopOpacity={0} />+ </radialGradient>+ <radialGradient id="hw-floor-glow" cx="0.5" cy="0.5" r="0.5">+ <stop offset="0" stopColor="#ff8a1f" stopOpacity={0.5} />+ <stop offset="1" stopColor="#ff8a1f" stopOpacity={0} />+ </radialGradient>+ <radialGradient id="hw-ghost" cx="0.45" cy="0.3" r="0.8">+ <stop offset="0" stopColor="#ffffff" />+ <stop offset="0.7" stopColor="#ece7ff" />+ <stop offset="1" stopColor="#c9bff0" />+ </radialGradient>+ <radialGradient id="hw-ghost-aura" cx="0.5" cy="0.5" r="0.5">+ <stop offset="0" stopColor="#e9e3ff" stopOpacity={0.4} />+ <stop offset="1" stopColor="#e9e3ff" stopOpacity={0} />+ </radialGradient>+ <radialGradient id="hw-fog" cx="0.5" cy="0.5" r="0.5">+ <stop offset="0" stopColor="#d9ceff" stopOpacity={1} />+ <stop offset="1" stopColor="#d9ceff" stopOpacity={0} />+ </radialGradient>+ <linearGradient id="hw-title" x1="0" y1="0" x2="0" y2="1">+ <stop offset="0" stopColor="#ffe39a" />+ <stop offset="0.45" stopColor="#ff9a2e" />+ <stop offset="1" stopColor="#c43c0c" />+ </linearGradient>+ <radialGradient id="hw-vignette" cx="0.5" cy="0.45" r="0.75">+ <stop offset="0.55" stopColor="#000000" stopOpacity={0} />+ <stop offset="1" stopColor="#000000" stopOpacity={0.7} />+ </radialGradient>+ <filter id="hw-title-glow" x="-20%" y="-60%" width="140%" height="220%">+ <feGaussianBlur stdDeviation="14" />+ </filter>+ {/* A slow ripple through the lettering, like heat over a candle */}+ <filter id="hw-title-wobble" x="-5%" y="-20%" width="110%" height="140%">+ <feTurbulence+ type="fractalNoise"+ baseFrequency="0.011 0.03"+ numOctaves={2}+ seed={3}+ >+ <Loop+ attributeName="baseFrequency"+ values="0.011 0.03;0.016 0.04;0.011 0.03"+ dur="7s"+ />+ </feTurbulence>+ <feDisplacementMap in="SourceGraphic" scale="5" />+ </filter>+ </defs>+ );+}++function Stars() {+ return (+ <g fill="#fff8e7">+ {STARS.map((star) => (+ <circle+ key={star.id}+ cx={star.x}+ cy={star.y}+ r={star.r}+ opacity={star.opacity}+ >+ <Loop+ attributeName="opacity"+ values={`${star.opacity};${star.opacity * 0.2};${star.opacity}`}+ dur={`${star.twinkle}s`}+ begin={`${star.delay}s`}+ />+ </circle>+ ))}+ </g>+ );+}++const CRATERS = [+ { id: "c1", x: -32, y: -18, r: 17 },+ { id: "c2", x: 24, y: 20, r: 12 },+ { id: "c3", x: -8, y: 40, r: 9 },+ { id: "c4", x: 42, y: -30, r: 7.5 },+ { id: "c5", x: -50, y: 24, r: 6 },+ { id: "c6", x: 12, y: -52, r: 5.5 },+ { id: "c7", x: 56, y: 12, r: 4.5 }+];++function Moon() {+ const still = useStill();+ return (+ <motion.g+ style={SCENE_ORIGIN}+ initial={still ? false : { x: 1335, y: 470, opacity: 0 }}+ animate={{ x: 1335, y: 215, opacity: 1 }}+ transition={{ duration: 2.4, ease: [0.16, 1, 0.3, 1] }}+ >+ <circle r={320} fill="url(#hw-moon-glow)" />+ <circle r={98} fill="url(#hw-moon)" />+ {/* Maria: the darker plains */}+ <path+ d="M -60 -40 C -40 -62, -6 -58, 4 -36 C 12 -18, -14 -4, -34 -10 C -52 -16, -70 -24, -60 -40 Z"+ fill="#d9bd78"+ opacity={0.35}+ />+ <path+ d="M 10 10 C 30 -6, 66 4, 62 30 C 58 54, 26 62, 10 46 C 0 36, -4 22, 10 10 Z"+ fill="#d9bd78"+ opacity={0.3}+ />+ {CRATERS.map((crater) => (+ <g key={crater.id}>+ <circle+ cx={crater.x}+ cy={crater.y}+ r={crater.r}+ fill="#cdae66"+ opacity={0.5}+ />+ <circle+ cx={crater.x + crater.r * 0.18}+ cy={crater.y + crater.r * 0.18}+ r={crater.r * 0.78}+ fill="#f3dfa4"+ opacity={0.55}+ />+ </g>+ ))}+ {/* Shade the limb away from the light */}+ <circle+ r={98}+ fill="none"+ stroke="#b08a3e"+ strokeOpacity={0.25}+ strokeWidth={6}+ />+ </motion.g>+ );+}++function Clouds() {+ return (+ <g>+ {CLOUDS.map((cloud) => (+ <g key={cloud.id} transform={`translate(${cloud.x} ${cloud.y})`}>+ <g opacity={cloud.opacity}>+ <path d={cloud.d} fill="url(#hw-cloud)" />+ <LoopTransform+ type="translate"+ values="0 0; 70 0; 0 0"+ dur={`${cloud.drift}s`}+ />+ </g>+ </g>+ ))}+ </g>+ );+}++const WINDOWS = [+ { id: "w-main-1", x: 270, y: 500, w: 24, h: 32, dur: 2.3, out: false },+ { id: "w-main-2", x: 374, y: 500, w: 24, h: 32, dur: 3.1, out: true },+ { id: "w-main-3", x: 266, y: 560, w: 24, h: 30, dur: 2.7, out: false },+ { id: "w-main-4", x: 384, y: 560, w: 20, h: 30, dur: 1.9, out: false },+ { id: "w-wing", x: 214, y: 552, w: 24, h: 28, dur: 3.6, out: false },+ { id: "w-tower-2", x: 424, y: 490, w: 26, h: 32, dur: 2.9, out: false },+ { id: "w-tower-slit", x: 431, y: 550, w: 12, h: 26, dur: 2.2, out: false }+];++function HauntedHouse() {+ return (+ <g>+ <path+ d="M 30 704 C 110 612, 300 588, 470 610 C 570 624, 640 664, 700 704 Z"+ fill="#140b23"+ />+ {/* Window light spills out first, so the walls cut it off */}+ {WINDOWS.map((w) => (+ <ellipse+ key={`${w.id}-glow`}+ cx={w.x + w.w / 2}+ cy={w.y + w.h / 2}+ rx={w.w * 1.9}+ ry={w.h * 1.4}+ fill="url(#hw-window-glow)"+ >+ <Loop+ attributeName="opacity"+ values={w.out ? "1;1;0.1;0.1;1" : "1;0.75;1;0.85;1"}+ dur={`${w.out ? 7 : w.dur}s`}+ />+ </ellipse>+ ))}+ <g fill={SILHOUETTE}>+ {/* Left wing */}+ <rect x={196} y={532} width={62} height={82} />+ <path d="M 186 535 L 227 496 L 268 535 Z" />+ {/* Main house, its crooked chimney and its porch */}+ <path d="M 282 448 L 298 443 L 305 474 L 288 478 Z" />+ <rect x={252} y={478} width={168} height={136} />+ <path d="M 238 483 L 336 402 L 434 483 Z" />+ <path d="M 294 566 L 382 566 L 372 554 L 304 554 Z" />+ <rect x={302} y={566} width={4} height={48} />+ <rect x={370} y={566} width={4} height={48} />+ {/* The tower */}+ <rect x={408} y={392} width={58} height={222} />+ <path d="M 398 397 L 437 292 L 476 397 Z" />+ <rect x={435.5} y={262} width={3} height={32} />+ <circle cx={437} cy={262} r={3.5} />+ </g>+ {/* Weathervane */}+ <path+ d="M 424 272 L 450 272 M 445 267 L 450 272 L 445 277 M 424 268 L 428 272 L 424 276"+ stroke={SILHOUETTE}+ strokeWidth={2.2}+ fill="none"+ strokeLinecap="round"+ />+ {/* A shutter hanging off one hinge */}+ <rect+ x={399}+ y={499}+ width={8}+ height={34}+ fill={SILHOUETTE}+ transform="rotate(14 399 499)"+ />++ {WINDOWS.map((w) => (+ <g key={w.id}>+ <rect x={w.x} y={w.y} width={w.w} height={w.h} fill="#ffb84a">+ <Loop+ attributeName="opacity"+ values={w.out ? "1;1;0.12;0.12;1" : "1;0.82;1;0.9;1"}+ dur={`${w.out ? 7 : w.dur}s`}+ />+ </rect>+ <path+ d={`M ${w.x + w.w / 2} ${w.y} V ${w.y + w.h} M ${w.x} ${w.y + w.h * 0.45} H ${w.x + w.w}`}+ stroke={SILHOUETTE}+ strokeWidth={2}+ />+ </g>+ ))}++ {/* The arched tower window, and someone standing in it */}+ <path+ d="M 424 458 L 424 432 Q 437 414 450 432 L 450 458 Z"+ fill="#ffb84a"+ >+ <Loop attributeName="opacity" values="1;0.8;1;0.7;1" dur="2.6s" />+ </path>+ <circle cx={437} cy={441} r={5} fill="#1a0b10" />+ <path+ d="M 427 458 Q 428 446 437 446 Q 446 446 447 458 Z"+ fill="#1a0b10"+ />++ {/* Attic window and the front door */}+ <circle cx={336} cy={452} r={11} fill="#ffb84a">+ <Loop+ attributeName="opacity"+ values="0.9;0.6;0.95;0.7;0.9"+ dur="3.3s"+ />+ </circle>+ <path+ d="M 336 441 V 463 M 325 452 H 347"+ stroke={SILHOUETTE}+ strokeWidth={2}+ />+ <path+ d="M 326 614 L 326 586 Q 338 572 350 586 L 350 614 Z"+ fill="#ff9a2e"+ opacity={0.55}+ />+ </g>+ );+}++function Fence() {+ return (+ <g fill="#0d0818">+ {FENCE.posts.map((post) => (+ <g+ key={post.id}+ transform={`rotate(${post.tilt} ${post.x} ${FENCE.baseY})`}+ >+ <rect x={post.x - 1.6} y={FENCE.baseY - 52} width={3.2} height={52} />+ <path+ d={`M ${post.x - 4} ${FENCE.baseY - 51} L ${post.x} ${FENCE.baseY - 63} L ${post.x + 4} ${FENCE.baseY - 51} Z`}+ />+ </g>+ ))}+ <path d={FENCE.rails} stroke="#0d0818" strokeWidth={2.4} fill="none" />+ </g>+ );+}++function Tree() {+ const { fork } = TREE;+ return (+ <g>+ <g fill="none" stroke={NIGHT} strokeLinecap="round">+ {TREE.branches.map((branch) => (+ <path key={branch.id} d={branch.d} strokeWidth={branch.width} />+ ))}+ </g>+ <path d={TREE.roots} fill={NIGHT} />+ {/* An owl in the fork, blinking */}+ {[-6, 6].map((dx) => (+ <ellipse+ key={`owl-${dx}`}+ cx={fork.x + dx - 4}+ cy={fork.y + 26}+ rx={3.2}+ ry={3.2}+ fill="#ffd34a"+ >+ <Loop+ attributeName="ry"+ values="3.2;3.2;0.3;3.2;3.2"+ keyTimes="0;0.9;0.94;0.98;1"+ dur="4.5s"+ />+ </ellipse>+ ))}+ </g>+ );+}++function Fog({+ y,+ opacity,+ drift+}: {+ y: number;+ opacity: number;+ drift: number;+}) {+ return (+ <g opacity={opacity}>+ <g>+ {[-120, 330, 780, 1230, 1680].map((x, i) => (+ <ellipse+ key={`fog-${x}`}+ cx={x}+ cy={y + (i % 2) * 16}+ rx={330}+ ry={54}+ fill="url(#hw-fog)"+ />+ ))}+ <LoopTransform+ type="translate"+ values="-60 0; 60 0; -60 0"+ dur={`${drift}s`}+ />+ </g>+ </g>+ );+}++const GHOST_BODY = {+ a: "M -50 12 C -50 -52, 50 -52, 50 12 L 50 64 Q 40 80 30 66 Q 20 52 10 68 Q 0 84 -10 68 Q -20 52 -30 66 Q -40 80 -50 64 Z",+ b: "M -50 12 C -50 -52, 50 -52, 50 12 L 50 66 Q 40 52 30 68 Q 20 84 10 66 Q 0 52 -10 66 Q -20 82 -30 68 Q -40 54 -50 66 Z"+};++function Ghost() {+ const still = useStill();+ return (+ <motion.g+ style={SCENE_ORIGIN}+ initial={+ still+ ? { x: 1150, y: 620, opacity: 0.9, scale: 0.75 }+ : { x: 1052, y: 812, opacity: 0, scale: 0.4 }+ }+ animate={+ still+ ? undefined+ : {+ x: [1052, 1080, 1140, 1210],+ y: [812, 700, 630, 560],+ opacity: [0, 0.95, 0.95, 0],+ scale: [0.4, 0.7, 0.78, 0.82]+ }+ }+ transition={{+ duration: 6.5,+ delay: 2.2,+ ease: "easeInOut",+ times: [0, 0.3, 0.7, 1]+ }}+ >+ <g>+ <LoopTransform+ type="translate"+ values="0 0; 0 -10; 0 0"+ dur="2.4s"+ calcMode="spline"+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"+ />+ <ellipse cx={0} cy={10} rx={110} ry={110} fill="url(#hw-ghost-aura)" />+ <path d={GHOST_BODY.a} fill="url(#hw-ghost)" opacity={0.94}>+ <Loop+ attributeName="d"+ values={`${GHOST_BODY.a};${GHOST_BODY.b};${GHOST_BODY.a}`}+ dur="1.4s"+ />+ </path>+ {/* Arms */}+ <path+ d="M -46 14 Q -66 8 -72 -10"+ stroke="#efeaff"+ strokeWidth={13}+ strokeLinecap="round"+ fill="none"+ >+ <LoopTransform+ type="rotate"+ values="0 -46 14; -14 -46 14; 0 -46 14"+ dur="1.6s"+ />+ </path>+ <path+ d="M 46 14 Q 66 8 72 -10"+ stroke="#efeaff"+ strokeWidth={13}+ strokeLinecap="round"+ fill="none"+ >+ <LoopTransform+ type="rotate"+ values="0 46 14; 14 46 14; 0 46 14"+ dur="1.6s"+ />+ </path>+ {/* Face */}+ <ellipse cx={-16} cy={-6} rx={6.5} ry={10} fill="#1b1027" />+ <ellipse cx={16} cy={-6} rx={6.5} ry={10} fill="#1b1027" />+ <circle cx={-18} cy={-10} r={2} fill="#ffffff" opacity={0.7} />+ <circle cx={14} cy={-10} r={2} fill="#ffffff" opacity={0.7} />+ <ellipse cx={0} cy={20} rx={8} ry={11} fill="#1b1027">+ <Loop attributeName="ry" values="11;14;11" dur="1.8s" />+ </ellipse>+ </g>+ </motion.g>+ );+}++function Gravestone({+ x,+ y,+ scale,+ tilt,+ shape+}: {+ x: number;+ y: number;+ scale: number;+ tilt: number;+ shape: GravestoneShape;+}) {+ const outline =+ shape === "round"+ ? "M -26 0 L -26 -58 A 26 26 0 0 1 26 -58 L 26 0 Z"+ : shape === "cross"+ ? "M -6 0 L -6 -60 L -22 -60 L -22 -72 L -6 -72 L -6 -92 L 6 -92 L 6 -72 L 22 -72 L 22 -60 L 6 -60 L 6 0 Z"+ : "M -22 0 L -22 -50 Q -22 -78 0 -94 Q 22 -78 22 -50 L 22 0 Z";++ return (+ <g transform={`translate(${x} ${y}) rotate(${tilt}) scale(${scale})`}>+ <path d={outline} fill="#140e1f" stroke="#2c2142" strokeWidth={1.4} />+ {/* Moonlight catches the right-hand edge */}+ <path+ d={outline}+ fill="none"+ stroke="#4a3b66"+ strokeWidth={1.2}+ strokeDasharray="0 9 60 400"+ opacity={0.7}+ />+ {shape !== "cross" && (+ <g fill="#07040c">+ <rect x={-3} y={-74} width={6} height={18} rx={1} />+ <rect x={-9} y={-69} width={18} height={5} rx={1} />+ <rect x={-14} y={-46} width={28} height={2.4} rx={1} />+ <rect x={-10} y={-39} width={20} height={2} rx={1} />+ <rect x={-12} y={-32} width={24} height={2} rx={1} />+ </g>+ )}+ <path+ d="M 10 -34 l -5 8 l 4 6 l -4 9"+ stroke="#07040c"+ strokeWidth={1}+ fill="none"+ />+ </g>+ );+}++function Title({ title, subtitle }: { title: string; subtitle: string }) {+ const still = useStill();+ return (+ <g>+ <motion.g+ initial={still ? false : { opacity: 0 }}+ animate={{ opacity: [0, 1, 0.25, 1, 0.55, 1] }}+ transition={{+ duration: 1.5,+ delay: 1.3,+ times: [0, 0.18, 0.3, 0.48, 0.62, 1]+ }}+ >+ <text+ x={740}+ y={212}+ textAnchor="middle"+ fontFamily="Georgia, 'Times New Roman', serif"+ fontWeight={700}+ fontSize={98}+ letterSpacing={3}+ fill="#ff7a1a"+ filter="url(#hw-title-glow)"+ opacity={0.6}+ >+ {title}+ <Loop+ attributeName="opacity"+ values="0.6;0.4;0.65;0.5;0.6"+ dur="2.2s"+ />+ </text>+ <text+ x={740}+ y={212}+ textAnchor="middle"+ fontFamily="Georgia, 'Times New Roman', serif"+ fontWeight={700}+ fontSize={98}+ letterSpacing={3}+ fill="url(#hw-title)"+ stroke="#3a0d00"+ strokeWidth={3}+ paintOrder="stroke"+ filter={still ? undefined : "url(#hw-title-wobble)"}+ >+ {title}+ </text>+ </motion.g>+ <motion.text+ x={740}+ y={266}+ textAnchor="middle"+ fontFamily="Georgia, 'Times New Roman', serif"+ fontStyle="italic"+ fontSize={30}+ letterSpacing={2}+ fill="#e6dcff"+ initial={still ? false : { opacity: 0 }}+ animate={{ opacity: 0.85 }}+ transition={{ duration: 1, delay: 2.4 }}+ >+ {subtitle}+ </motion.text>+ </g>+ );+}++function Wing({ silhouette, flap }: { silhouette: boolean; flap: number }) {+ return (+ <g>+ <path d="M -3 -4 C -14 -17, -36 -23, -60 -12 C -55 -6, -53 -1, -51 6 C -45 0, -39 0, -34 6 C -29 0, -22 0, -17 7 C -12 2, -7 1, -3 5 Z" />+ {!silhouette && (+ <path+ d="M -3 -3 L -51 5 M -3 -3 L -34 5 M -3 -3 L -17 6 M -3 -4 L -60 -12"+ fill="none"+ stroke="#1f1630"+ strokeWidth={1.1}+ />+ )}+ <LoopTransform+ type="scale"+ values="1 1; 1 -0.45; 1 1"+ dur={`${flap}s`}+ calcMode="spline"+ keySplines="0.4 0 0.6 1; 0.4 0 0.6 1"+ />+ </g>+ );+}++function FlyingBat({+ flight,+ silhouette = false+}: {+ flight: BatFlight;+ silhouette?: boolean;+}) {+ const still = useStill();+ if (still) {+ // Parked mid-flight.+ return (+ <g+ transform={`translate(${flight.x[2]} ${flight.y[2]}) scale(${flight.scale[2]})`}+ >+ <Bat silhouette={silhouette} flap={flight.flap} />+ </g>+ );+ }+ return (+ <motion.g+ style={SCENE_ORIGIN}+ initial={{+ x: flight.x[0],+ y: flight.y[0],+ scale: flight.scale[0],+ opacity: 0+ }}+ animate={{+ x: flight.x,+ y: flight.y,+ scale: flight.scale,+ rotate: flight.rotate,+ opacity: [0, 1, 1, 1]+ }}+ transition={{+ duration: flight.duration,+ delay: flight.delay,+ ease: "easeIn"+ }}+ >+ <Bat silhouette={silhouette} flap={flight.flap} />+ </motion.g>+ );+}++function Bat({ silhouette, flap }: { silhouette: boolean; flap: number }) {+ // Blacker than the darkest sky, with a moonlit rim so it reads up there too.+ return (+ <g+ fill="#020104"+ stroke="#4a3768"+ strokeWidth={silhouette ? 4 : 1.6}+ strokeLinejoin="round"+ >+ <Wing silhouette={silhouette} flap={flap} />+ <g transform="scale(-1 1)">+ <Wing silhouette={silhouette} flap={flap} />+ </g>+ <ellipse cx={0} cy={3} rx={6.5} ry={10} />+ <circle cx={0} cy={-8} r={6} />+ <path d="M -5 -11 L -6.5 -21 L -1.5 -13 Z M 5 -11 L 6.5 -21 L 1.5 -13 Z" />+ {!silhouette && (+ <g stroke="none">+ <circle cx={-2.3} cy={-8.6} r={1.2} fill="#ff5a1f" />+ <circle cx={2.3} cy={-8.6} r={1.2} fill="#ff5a1f" />+ <path+ d="M -2 -4 l 0.6 1.8 l 0.6 -1.8 Z M 0.8 -4 l 0.6 1.8 l 0.6 -1.8 Z"+ fill="#ffffff"+ />+ </g>+ )}+ </g>+ );+}++function DroppingSpider() {+ const still = useStill();+ return (+ <motion.g+ style={SCENE_ORIGIN}+ initial={still ? { x: 196, y: 300 } : { x: 196, y: -180 }}+ animate={{ x: 196, y: 300 }}+ transition={{+ type: "spring",+ stiffness: 70,+ damping: 6,+ mass: 1.2,+ delay: 0.9+ }}+ >+ <g>+ <LoopTransform+ type="translate"+ values="0 0; 0 -8; 0 0"+ dur="2.8s"+ calcMode="spline"+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"+ />+ <line+ x1={0}+ y1={-1400}+ x2={0}+ y2={0}+ stroke="#d8d2ea"+ strokeOpacity={0.55}+ strokeWidth={1.2}+ />+ <g transform="scale(2.6)">+ <SpiderBody+ idPrefix="halloween-reveal-spider"+ animateLegs+ rimOpacity={0.3}+ />+ </g>+ </g>+ </motion.g>+ );+}diff --git a/apps/erp/app/components/Halloween/PumpkinHomeIcon.tsx b/apps/erp/app/components/Halloween/PumpkinHomeIcon.tsxnew file mode 100644index 0000000000..12345cab61--- /dev/null+++ b/apps/erp/app/components/Halloween/PumpkinHomeIcon.tsx@@ -0,0 +1,52 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { cn } from "@carbon/react";+import type { ReactNode } from "react";+import { useHalloweenDecorations } from "./season";++// The breadcrumbs' home icon, carved into a jack-o'-lantern for the season.+// Outside it, or once the user hides the decorations, the usual icon.++export function PumpkinHomeIcon({+ userId,+ fallback,+ className+}: {+ userId: string;+ fallback: ReactNode;+ className?: string;+}) {+ const shown = useHalloweenDecorations(userId);+ if (!shown) return fallback;+ return (+ <svg+ viewBox="0 0 16 16"+ className={cn(+ "origin-bottom transition-transform duration-300 ease-out hover:-rotate-12",+ className+ )}+ aria-hidden+ >+ {/* Stem, curling off to one side */}+ <path+ d="M7.6 4.2 C7.5 3 7.9 2 9.1 1.4"+ fill="none"+ stroke="#5b7a2b"+ strokeWidth={1.4}+ strokeLinecap="round"+ />+ {/* The pumpkin: three lobes, the middle one in front */}+ <ellipse cx={4.9} cy={9.3} rx={3.9} ry={5} fill="#d9620f" />+ <ellipse cx={11.1} cy={9.3} rx={3.9} ry={5} fill="#d9620f" />+ <ellipse cx={8} cy={9.3} rx={4.1} ry={5.3} fill="#f47c1c" />+ {/* Carved face */}+ <g fill="#3a1a05">+ <path d="M4.9 8.6 L6.6 6.9 L7.1 9.1 Z" />+ <path d="M11.1 8.6 L9.4 6.9 L8.9 9.1 Z" />+ <path d="M4.5 10.4 Q8 13.8 11.5 10.4 L10.4 11.1 L9.8 10.5 L9 11.4 L8 10.7 L7 11.4 L6.2 10.5 L5.6 11.1 Z" />+ </g>+ </svg>+ );+}diff --git a/apps/erp/app/components/Halloween/Pumpkins.test.ts b/apps/erp/app/components/Halloween/Pumpkins.test.tsnew file mode 100644index 0000000000..ea45da3461--- /dev/null+++ b/apps/erp/app/components/Halloween/Pumpkins.test.ts@@ -0,0 +1,19 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { describe, expect, it } from "vitest";+import { MOUTH } from "./Pumpkins";++const commands = (d: string) => d.replace(/[^A-Za-z]/g, "");+const numbers = (d: string) => d.match(/-?\d+(\.\d+)?/g)?.map(Number) ?? [];++describe("the cackling mouth", () => {+ // SMIL only morphs a path between shapes with the same commands; any+ // difference and the mouth snaps instead of opening.+ it("opens and shuts through shapes SMIL can morph between", () => {+ expect(commands(MOUTH.half)).toBe(commands(MOUTH.shut));+ expect(commands(MOUTH.wide)).toBe(commands(MOUTH.shut));+ expect(numbers(MOUTH.wide)).toHaveLength(numbers(MOUTH.shut).length);+ });+});diff --git a/apps/erp/app/components/Halloween/Pumpkins.tsx b/apps/erp/app/components/Halloween/Pumpkins.tsxnew file mode 100644index 0000000000..132191022a--- /dev/null+++ b/apps/erp/app/components/Halloween/Pumpkins.tsx@@ -0,0 +1,722 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import type { Transition } from "motion/react";+import { motion } from "motion/react";+import type { ReactNode } from "react";+import { seededRandom } from "./scene";+import { Loop, LoopTransform, SCENE_ORIGIN, useStill } from "./scene-loops";++// Three jack-o'-lanterns, each with its own entrance and its own temper.+//+// The big one falls out of the sky, squashes on landing and kicks up dust;+// once lit it rocks back and cackles. The middle one bursts up out of the+// ground, throwing dirt, and sways. The small one rolls in from the right,+// rocks to a stop, and hops now and then.+//+// They all arrive dark and are lit one by one: a spark, a sputter, then a+// steady flame whose hot spot drifts about inside the carving. Smoke curls+// from the lid and embers float up.+//+// Each lantern is drawn in its own space: the base sits on y 0, the body is a+// little over 110 tall, centred around y -45.++type Entrance = "drop" | "rise" | "roll";+type Temper = "cackle" | "sway" | "hop";++type Lantern = {+ id: string;+ x: number;+ y: number;+ size: number;+ entrance: Entrance;+ enterAt: number;+ lightAt: number;+ temper: Temper;+ /** Seconds per flicker cycle. */+ flicker: number;+};++const DROP_DURATION = 1.05;+// Far enough that the lantern starts above the top of the screen.+const DROP_HEIGHT = 1000;+// Where in the drop the lantern hits the ground.+const DROP_IMPACT = 0.42;+const RISE_DURATION = 0.95;+const ROLL_DURATION = 1.45;+const ROLL_FROM_X = 1720;+const CENTRE_Y = -45;+const RADIUS = 45;++// Drawn back to front: the small one rolls to a stop in front of the middle one.+const LANTERNS: Lantern[] = [+ {+ id: "middle",+ x: 1128,+ y: 850,+ size: 0.95,+ entrance: "rise",+ enterAt: 1.8,+ lightAt: 2.75,+ temper: "sway",+ flicker: 1.3+ },+ {+ id: "small",+ x: 1222,+ y: 862,+ size: 0.66,+ entrance: "roll",+ enterAt: 2.3,+ lightAt: 3.95,+ temper: "hop",+ flicker: 2.1+ },+ {+ id: "big",+ x: 560,+ y: 846,+ size: 1.3,+ entrance: "drop",+ enterAt: 0.95,+ lightAt: 2.1,+ temper: "cackle",+ flicker: 1.7+ }+];++/** When the falling lantern hits the ground: the whole scene thuds. */+export const LANTERN_THUD_AT =+ (LANTERNS.find((lantern) => lantern.entrance === "drop")?.enterAt ?? 0) ++ DROP_DURATION * DROP_IMPACT;++const RIBS = [+ { id: "outer-left", cx: -40, cy: -44, rx: 30, ry: 41 },+ { id: "outer-right", cx: 40, cy: -44, rx: 30, ry: 41 },+ { id: "inner-left", cx: -19, cy: -45, rx: 32, ry: 44 },+ { id: "inner-right", cx: 19, cy: -45, rx: 32, ry: 44 },+ { id: "centre", cx: 0, cy: -46, rx: 26, ry: 45 }+];++const EYES_AND_NOSE = [+ "M -34 -58 L -12 -56 L -24 -76 Z",+ "M 34 -58 L 12 -56 L 24 -76 Z",+ "M -6 -43 L 6 -43 L 0 -53 Z"+];++// The carved mouth, teeth included: a jack-o'-lantern's teeth are uncut+// pumpkin, so the hole's outline goes round them and they move with the lips.+// Each lip is one quadratic from corner to corner; the teeth are cut into it+// by splitting that curve exactly, so every mouth has the same commands and+// SMIL can morph shut → half → wide.+const MOUTH_HALF_WIDTH = 42;+// [from x, tip x, to x, tip length]: hanging from the upper lip…+const UPPER_TEETH = [+ [-12, -8, -4, 8.5],+ [14, 18, 22, 7.5]+] as const;+// …and standing on the lower lip, listed right to left as it is drawn.+const LOWER_TEETH = [+ [10, 6, 2, 7.5],+ [-19, -22.5, -26, 6.5]+] as const;++function mouthPath(corner: number, upper: number, lower: number) {+ const w = MOUTH_HALF_WIDTH;+ // A lip through (-w, corner), (0, middle), (w, corner).+ const lip = (middle: number) => {+ const control = 2 * middle - corner;+ const tAt = (x: number) => (x / w + 1) / 2;+ const at = (t: number) =>+ (1 - t) * (1 - t) * corner + 2 * (1 - t) * t * control + t * t * corner;+ // The quadratic from x0 to x1, as its own control point.+ const span = (x0: number, x1: number) => {+ const t0 = tAt(x0);+ const t1 = tAt(x1);+ const slope =+ 2 * (1 - t0) * (control - corner) + 2 * t0 * (corner - control);+ const cx = x0 + (x1 - x0) / 2;+ const cy = at(t0) + ((t1 - t0) * slope) / 2;+ return `Q ${cx} ${cy} ${x1} ${at(t1)}`;+ };+ return { y: (x: number) => at(tAt(x)), span };+ };+ const top = lip(upper);+ const bottom = lip(lower);++ let d = `M ${-w} ${corner}`;+ let x = -w;+ for (const [from, tip, to, length] of UPPER_TEETH) {+ d += ` ${top.span(x, from)} L ${tip} ${top.y(tip) + length} L ${to} ${top.y(to)}`;+ x = to;+ }+ d += ` ${top.span(x, w)}`;+ x = w;+ for (const [from, tip, to, length] of LOWER_TEETH) {+ d += ` ${bottom.span(x, from)} L ${tip} ${bottom.y(tip) - length} L ${to} ${bottom.y(to)}`;+ x = to;+ }+ return `${d} ${bottom.span(x, -w)} Z`;+}++export const MOUTH = {+ shut: mouthPath(-33, -26, -9),+ half: mouthPath(-34, -28, -2),+ wide: mouthPath(-35, -31, 6)+};++// A cackle: three quick "ha"s every few seconds, the body rocking with them.+const CACKLE = {+ dur: "3.8s",+ keyTimes: "0;0.6;0.65;0.7;0.75;0.8;0.85;0.92;1",+ mouth: [+ MOUTH.shut,+ MOUTH.shut,+ MOUTH.wide,+ MOUTH.half,+ MOUTH.wide,+ MOUTH.half,+ MOUTH.wide,+ MOUTH.shut,+ MOUTH.shut+ ].join(";"),+ rock: "0;0;-4;3;-4;3;-3;0;0"+};++const SMOKE = {+ a: "M 6 -112 C -6 -132, 16 -150, 2 -172 S -12 -206, 8 -236",+ b: "M 6 -112 C 18 -132, -6 -152, 8 -174 S 16 -206, -4 -236"+};++type Particle = { id: string; dx: number; dy: number; r: number };++function particles(seed: number, count: number, spread: number): Particle[] {+ const rand = seededRandom(seed);+ return Array.from({ length: count }, (_, i) => {+ const side = i % 2 === 0 ? -1 : 1;+ return {+ id: `p-${seed}-${i}`,+ dx: side * (spread * 0.35 + rand() * spread),+ dy: 18 + rand() * 46,+ r: 2.4 + rand() * 3.2+ };+ });+}++const DUST = particles(7, 9, 90);+const DIRT = particles(11, 10, 70);++export function JackOLanterns() {+ return (+ <g>+ <defs>+ <linearGradient+ id="hw-smoke"+ gradientUnits="userSpaceOnUse"+ x1="0"+ y1="-112"+ x2="0"+ y2="-236"+ >+ <stop offset="0" stopColor="#ddd4f2" stopOpacity={0.45} />+ <stop offset="1" stopColor="#ddd4f2" stopOpacity={0} />+ </linearGradient>+ <filter+ id="hw-smoke-soft"+ x="-100%"+ y="-10%"+ width="300%"+ height="120%"+ >+ <feGaussianBlur stdDeviation="1.8" />+ </filter>+ </defs>+ {LANTERNS.map((lantern) => (+ <JackOLantern key={lantern.id} lantern={lantern} />+ ))}+ </g>+ );+}++function JackOLantern({ lantern }: { lantern: Lantern }) {+ const { id, x, y, size, entrance, lightAt, flicker } = lantern;+ const candle = `hw-candle-${id}`;+ const ground = `hw-ground-${id}`;+ const place = `translate(${x} ${y}) scale(${size})`;++ return (+ <g>+ <defs>+ {/* The candle's hot spot wanders as the flame moves. */}+ <radialGradient id={candle} cx="0.5" cy="0.55" r="0.66">+ <Loop+ attributeName="cx"+ values="0.44;0.58;0.47;0.55;0.44"+ dur={`${flicker * 1.9}s`}+ />+ <Loop+ attributeName="cy"+ values="0.58;0.5;0.56;0.48;0.58"+ dur={`${flicker * 2.3}s`}+ />+ <stop offset="0" stopColor="#fffde6" />+ <stop offset="0.3" stopColor="#ffe680" />+ <stop offset="0.75" stopColor="#ff9d1c" />+ <stop offset="1" stopColor="#d9530a" />+ </radialGradient>+ <clipPath id={ground}>+ <rect x={x - 220} y={y - 420} width={440} height={426} />+ </clipPath>+ </defs>++ {/* Candlelight pooled on the ground */}+ <g transform={place}>+ <Lit at={lightAt}>+ <ellipse cx={0} cy={-2} rx={140} ry={32} fill="url(#hw-floor-glow)">+ <Loop+ attributeName="opacity"+ values="1;0.75;0.95;0.62;1;0.85;1"+ dur={`${flicker}s`}+ />+ </ellipse>+ </Lit>+ </g>++ {entrance === "rise" ? (+ <g clipPath={`url(#${ground})`}>+ <Entrance lantern={lantern} />+ </g>+ ) : (+ <Entrance lantern={lantern} />+ )}++ {entrance === "drop" && (+ <Burst+ place={place}+ at={lantern.enterAt + DROP_DURATION * DROP_IMPACT}+ bits={DUST}+ fill="#4a3a63"+ height={0.5}+ />+ )}+ {entrance === "rise" && (+ <Burst+ place={place}+ at={lantern.enterAt + 0.05}+ bits={DIRT}+ fill="#1c1128"+ height={1.4}+ />+ )}+ </g>+ );+}++/** Fades in with a candle's sputter: catches, gutters, catches again. */+function Lit({ at, children }: { at: number; children: ReactNode }) {+ const still = useStill();+ return (+ <motion.g+ initial={still ? false : { opacity: 0 }}+ animate={{ opacity: [0, 0.9, 0.12, 1, 0.5, 1] }}+ transition={{+ delay: at,+ duration: 0.95,+ times: [0, 0.08, 0.22, 0.42, 0.66, 1]+ }}+ >+ {children}+ </motion.g>+ );+}++function Entrance({ lantern }: { lantern: Lantern }) {+ const still = useStill();+ const { x, y, size, entrance, enterAt } = lantern;+ const body = <Temperament lantern={lantern} />;++ if (still) {+ return <g transform={`translate(${x} ${y}) scale(${size})`}>{body}</g>;+ }++ if (entrance === "drop") {+ // Falls, squashes flat on impact, springs up tall, settles.+ return (+ <motion.g+ style={SCENE_ORIGIN}+ initial={{+ x,+ y: y - DROP_HEIGHT,+ scale: size,+ scaleX: 0.9,+ scaleY: 1.14+ }}+ animate={{+ y: [y - DROP_HEIGHT, y, y, y, y],+ scaleX: [0.9, 1.3, 0.9, 1.05, 1],+ scaleY: [1.14, 0.68, 1.12, 0.97, 1]+ }}+ transition={{+ duration: DROP_DURATION,+ delay: enterAt,+ times: [0, DROP_IMPACT, 0.6, 0.8, 1],+ ease: ["easeIn", "easeOut", "easeInOut", "easeOut"]+ }}+ >+ {body}+ </motion.g>+ );+ }++ if (entrance === "rise") {+ // Bursts up out of the ground, overshoots, wobbles back down.+ return (+ <motion.g+ style={SCENE_ORIGIN}+ initial={{ x, y: y + 130 * size, scale: size, rotate: -10 }}+ animate={{+ y: [y + 130 * size, y - 16 * size, y + 3 * size, y],+ rotate: [-10, 7, -3, 0]+ }}+ transition={{+ duration: RISE_DURATION,+ delay: enterAt,+ times: [0, 0.5, 0.78, 1],+ ease: ["easeOut", "easeInOut", "easeOut"]+ }}+ >+ {body}+ </motion.g>+ );+ }++ // Rolls in from the right. The turn matches the distance covered, so it+ // never skids, and lands upright after a little overshoot.+ const degreesPer = 180 / Math.PI / (RADIUS * size);+ const overshoot = 12;+ const timing = {+ duration: ROLL_DURATION,+ delay: enterAt,+ times: [0, 0.82, 1],+ ease: ["easeOut", "easeInOut"]+ } satisfies Transition;+ return (+ <motion.g+ style={SCENE_ORIGIN}+ initial={{ x: ROLL_FROM_X, y, scale: size }}+ animate={{ x: [ROLL_FROM_X, x - overshoot, x] }}+ transition={timing}+ >+ <motion.g+ style={{ ...SCENE_ORIGIN, originY: `${CENTRE_Y}px` }}+ initial={{ rotate: (ROLL_FROM_X - x) * degreesPer }}+ animate={{+ rotate: [(ROLL_FROM_X - x) * degreesPer, -overshoot * degreesPer, 0]+ }}+ transition={timing}+ >+ {body}+ </motion.g>+ </motion.g>+ );+}++/** What each lantern does once it is lit. */+function Temperament({ lantern }: { lantern: Lantern }) {+ const { temper, lightAt } = lantern;+ const begin = `${lightAt + 1.2}s`;+ const face = <Face lantern={lantern} />;++ if (temper === "cackle") {+ return (+ <g>+ <LoopTransform+ type="rotate"+ values={CACKLE.rock}+ keyTimes={CACKLE.keyTimes}+ dur={CACKLE.dur}+ begin={begin}+ />+ {face}+ </g>+ );+ }++ if (temper === "sway") {+ return (+ <g>+ <LoopTransform+ type="rotate"+ values="0;2.6;0;-2.6;0"+ dur="3.4s"+ calcMode="spline"+ keySplines="0.45 0 0.55 1;0.45 0 0.55 1;0.45 0 0.55 1;0.45 0 0.55 1"+ begin={begin}+ />+ {face}+ </g>+ );+ }++ // A hop: crouch, spring up, land with a squash.+ return (+ <g>+ <LoopTransform+ type="translate"+ values="0 0;0 0;0 -30;0 0;0 0"+ keyTimes="0;0.72;0.84;0.95;1"+ calcMode="spline"+ keySplines="0 0 1 1;0.2 0.7 0.4 1;0.6 0 0.8 0.3;0 0 1 1"+ dur="2.8s"+ begin={begin}+ />+ <g>+ <LoopTransform+ type="scale"+ values="1 1;1 1;1.12 0.86;0.92 1.1;1 1;1.16 0.84;1 1"+ keyTimes="0;0.66;0.72;0.78;0.9;0.96;1"+ dur="2.8s"+ begin={begin}+ />+ {face}+ </g>+ </g>+ );+}++function Face({ lantern }: { lantern: Lantern }) {+ const { id, temper, lightAt } = lantern;+ const cackles = temper === "cackle";+ const begin = `${lightAt + 1.2}s`;+ const candle = `url(#hw-candle-${id})`;++ const mouth = (fill: string) => (+ <path d={MOUTH.shut} fill={fill}>+ {cackles && (+ <Loop+ attributeName="d"+ values={CACKLE.mouth}+ keyTimes={CACKLE.keyTimes}+ dur={CACKLE.dur}+ begin={begin}+ />+ )}+ </path>+ );++ return (+ <g>+ <Lit at={lightAt}>+ <ellipse cx={0} cy={-46} rx={100} ry={74} fill="url(#hw-bloom)">+ <Loop+ attributeName="opacity"+ values="1;0.72;0.95;0.6;1;0.86;1"+ dur={`${lantern.flicker}s`}+ />+ </ellipse>+ </Lit>++ <ellipse cx={0} cy={-3} rx={58} ry={6} fill="#000000" opacity={0.4} />+ {RIBS.map((rib) => (+ <ellipse+ key={rib.id}+ cx={rib.cx}+ cy={rib.cy}+ rx={rib.rx}+ ry={rib.ry}+ fill="url(#hw-pumpkin)"+ stroke="#8f3307"+ strokeOpacity={0.75}+ strokeWidth={1.6}+ />+ ))}+ <ellipse+ cx={-8}+ cy={-66}+ rx={6}+ ry={15}+ fill="#ffffff"+ opacity={0.13}+ transform="rotate(-8 -8 -66)"+ />+ {/* Moonlight on the right-hand rib */}+ <path+ d="M 55 -79.5 A 30 41 0 0 1 55 -8.5"+ fill="none"+ stroke="#ffe2b8"+ strokeOpacity={0.18}+ strokeWidth={3}+ strokeLinecap="round"+ />+ <path+ d="M -5 -86 C -7 -98, -3 -108, 5 -113 L 10 -109 C 3 -104, 3 -96, 6 -86 Z"+ fill="#5d6b2c"+ stroke="#2f3a15"+ strokeWidth={1.2}+ />+ <path+ d="M 5 -92 c 12 -6 20 2 15 10 c -3 5 -11 3 -9 -3"+ stroke="#4b5a22"+ strokeWidth={2}+ fill="none"+ strokeLinecap="round"+ />++ {/* The carving: cut walls, then dark holes, then the candlelight */}+ <g fill="#6e2804" transform="translate(1.8 2.2)">+ {EYES_AND_NOSE.map((d) => (+ <path key={`wall-${d}`} d={d} />+ ))}+ {mouth("#6e2804")}+ </g>+ <g fill="#1d0a03">+ {EYES_AND_NOSE.map((d) => (+ <path key={`hole-${d}`} d={d} />+ ))}+ {mouth("#1d0a03")}+ </g>+ <Lit at={lightAt}>+ {/* Light spilling onto the skin around the face */}+ <ellipse+ cx={0}+ cy={-40}+ rx={52}+ ry={40}+ fill="url(#hw-bloom)"+ opacity={0.55}+ />+ <g fill={candle}>+ {EYES_AND_NOSE.map((d) => (+ <path key={`light-${d}`} d={d} />+ ))}+ {mouth(candle)}+ <Loop+ attributeName="opacity"+ values="1;0.84;1;0.76;1;0.92;1"+ dur={`${lantern.flicker}s`}+ />+ </g>+ </Lit>+ <Lit at={lightAt + 0.6}>+ <Smoke />+ <Embers offset={lantern.flicker * 0.5} />+ </Lit>+ <Spark at={lightAt} />+ </g>+ );+}++/** The match: a bright flash in the mouth just as the candle catches. */+function Spark({ at }: { at: number }) {+ const still = useStill();+ if (still) return null;+ return (+ <motion.circle+ cx={0}+ cy={-30}+ fill="#fff7cf"+ initial={{ r: 0, opacity: 0 }}+ animate={{ r: [0, 18, 4, 0], opacity: [0, 1, 0.8, 0] }}+ transition={{ delay: at - 0.08, duration: 0.42, times: [0, 0.3, 0.6, 1] }}+ />+ );+}++function Smoke() {+ return (+ <path+ d={SMOKE.a}+ fill="none"+ stroke="url(#hw-smoke)"+ strokeWidth={5}+ strokeLinecap="round"+ strokeDasharray="34 30"+ filter="url(#hw-smoke-soft)"+ >+ <Loop attributeName="stroke-dashoffset" values="0;-128" dur="3s" />+ <Loop+ attributeName="d"+ values={`${SMOKE.a};${SMOKE.b};${SMOKE.a}`}+ dur="4.6s"+ />+ </path>+ );+}++const EMBERS = [+ { id: "e1", x: -10, drift: 14, dur: 2.6, begin: 0 },+ { id: "e2", x: 8, drift: -12, dur: 3.1, begin: 0.9 },+ { id: "e3", x: -2, drift: 10, dur: 2.2, begin: 1.7 }+];++/** A few sparks lifting off the flame through the lid. */+function Embers({ offset }: { offset: number }) {+ return (+ <g fill="#ffb347">+ {EMBERS.map((ember) => (+ <circle key={ember.id} cx={ember.x} cy={-100} r={1.6} opacity={0}>+ <Loop+ attributeName="cy"+ values="-100;-210"+ dur={`${ember.dur}s`}+ begin={`${ember.begin + offset}s`}+ />+ <Loop+ attributeName="cx"+ values={`${ember.x};${ember.x + ember.drift / 2};${ember.x + ember.drift}`}+ dur={`${ember.dur}s`}+ begin={`${ember.begin + offset}s`}+ />+ <Loop+ attributeName="opacity"+ values="0;1;0.8;0"+ keyTimes="0;0.15;0.6;1"+ dur={`${ember.dur}s`}+ begin={`${ember.begin + offset}s`}+ />+ </circle>+ ))}+ </g>+ );+}++/** Dust or dirt thrown out from the base, falling back as it fades. */+function Burst({+ place,+ at,+ bits,+ fill,+ height+}: {+ place: string;+ at: number;+ bits: Particle[];+ fill: string;+ height: number;+}) {+ const still = useStill();+ if (still) return null;+ return (+ <g transform={place} fill={fill}>+ {bits.map((bit) => (+ <motion.circle+ key={bit.id}+ r={bit.r}+ initial={{ cx: 0, cy: -4, opacity: 0 }}+ animate={{+ cx: [0, bit.dx * 0.6, bit.dx],+ cy: [-4, -4 - bit.dy * height, 6],+ opacity: [0, 0.85, 0]+ }}+ transition={{+ delay: at,+ duration: 0.75,+ times: [0, 0.4, 1],+ ease: ["easeOut", "easeIn"]+ }}+ />+ ))}+ </g>+ );+}diff --git a/apps/erp/app/components/Halloween/RealSpider.tsx b/apps/erp/app/components/Halloween/RealSpider.tsxnew file mode 100644index 0000000000..283b6cda4c--- /dev/null+++ b/apps/erp/app/components/Halloween/RealSpider.tsx@@ -0,0 +1,217 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++// A European garden spider (Araneus diadematus) seen from above: the bulbous+// abdomen with its dark leaf-shaped folium and the white cross it is named+// for, the cephalothorax with its radiating grooves and eight small eyes, the+// chelicerae and the palps. The legs are drawn separately, by the rig, so they+// can move.+//+// In the spider's own frame the head is along +y; units are pre-scale.++const ABDOMEN_HAIRS = Array.from({ length: 26 }, (_, i) => {+ const angle = (i / 26) * Math.PI * 2;+ const x = Math.cos(angle) * 7.7;+ const y = -12.6 + Math.sin(angle) * 9.5;+ const lean = 0.25;+ return {+ id: `hair-${i}`,+ d: `M ${x} ${y} l ${Math.cos(angle + lean) * 1.3} ${Math.sin(angle + lean) * 1.3}`+ };+});++// The white cross: a line of spots down the middle, and one either side.+const CROSS = [+ { id: "c1", x: 0, y: -7.4, r: 0.85 },+ { id: "c2", x: 0, y: -9.9, r: 0.8 },+ { id: "c3", x: 0, y: -12.4, r: 0.72 },+ { id: "c4", x: 0, y: -14.7, r: 0.58 },+ { id: "c5", x: -2.4, y: -10.2, r: 0.68 },+ { id: "c6", x: 2.4, y: -10.2, r: 0.68 }+];++const SIDE_SPOTS = [+ { id: "s1", x: -5.7, y: -9.4 },+ { id: "s2", x: 5.7, y: -9.4 },+ { id: "s3", x: -6.3, y: -13.2 },+ { id: "s4", x: 6.3, y: -13.2 },+ { id: "s5", x: -5, y: -16.8 },+ { id: "s6", x: 5, y: -16.8 }+];++// Eight eyes in two rows at the front of the head.+const EYES = [+ { id: "ame-l", x: -0.65, y: 4.95, r: 0.52 },+ { id: "ame-r", x: 0.65, y: 4.95, r: 0.52 },+ { id: "ale-l", x: -2.05, y: 4.5, r: 0.4 },+ { id: "ale-r", x: 2.05, y: 4.5, r: 0.4 },+ { id: "pme-l", x: -0.8, y: 3.85, r: 0.44 },+ { id: "pme-r", x: 0.8, y: 3.85, r: 0.44 },+ { id: "ple-l", x: -2.4, y: 3.55, r: 0.36 },+ { id: "ple-r", x: 2.4, y: 3.55, r: 0.36 }+];++const GROOVES = [-150, -110, -70, -30, 30, 70, 110, 150].map((deg) => {+ const a = ((deg - 90) * Math.PI) / 180;+ return {+ id: `groove-${deg}`,+ d: `M ${Math.cos(a) * 1.2} ${-0.6 + Math.sin(a) * 1.2} L ${Math.cos(a) * 3.9} ${0.4 + Math.sin(a) * 4.4}`+ };+});++export function RealSpiderBody({ idPrefix }: { idPrefix: string }) {+ const abdomen = `${idPrefix}-abdomen`;+ const thorax = `${idPrefix}-thorax`;++ return (+ <g>+ <defs>+ <radialGradient id={abdomen} cx="0.42" cy="0.36" r="0.75">+ <stop offset="0" stopColor="#b07a45" />+ <stop offset="0.45" stopColor="#6e4826" />+ <stop offset="1" stopColor="#2e1b0d" />+ </radialGradient>+ <radialGradient id={thorax} cx="0.45" cy="0.4" r="0.75">+ <stop offset="0" stopColor="#a47650" />+ <stop offset="1" stopColor="#3e2817" />+ </radialGradient>+ </defs>++ {/* Palps, the short feelers either side of the fangs */}+ <g fill="none" strokeLinecap="round">+ <path+ d="M -2.2 5 L -3.5 7.4 L -3 9.7 M 2.2 5 L 3.5 7.4 L 3 9.7"+ stroke="#33241a"+ strokeWidth={1.05}+ strokeLinejoin="round"+ />+ <path+ d="M -3.5 7.4 l 0.01 0 M 3.5 7.4 l 0.01 0"+ stroke="#b08a62"+ strokeWidth={0.9}+ />+ </g>++ {/* Abdomen */}+ <g+ stroke="#8a6a4c"+ strokeOpacity={0.6}+ strokeWidth={0.32}+ strokeLinecap="round"+ >+ {ABDOMEN_HAIRS.map((hair) => (+ <path key={hair.id} d={hair.d} />+ ))}+ </g>+ {/* A faint rim in the theme's text colour, so the spider reads against a+ dark bar as well as a light one */}+ <ellipse+ cx={0}+ cy={-12.6}+ rx={7.8}+ ry={9.6}+ fill={`url(#${abdomen})`}+ stroke="currentColor"+ strokeOpacity={0.22}+ strokeWidth={0.55}+ />+ <path+ d="M 0 -4.2 C 3.2 -5.2, 4.6 -7.6, 4.1 -9.8 C 5.2 -11.6, 5.3 -13.9, 4.2 -15.3 C 4.6 -17.4, 3.4 -19.8, 1.6 -21 C 1 -21.6, -1 -21.6, -1.6 -21 C -3.4 -19.8, -4.6 -17.4, -4.2 -15.3 C -5.3 -13.9, -5.2 -11.6, -4.1 -9.8 C -4.6 -7.6, -3.2 -5.2, 0 -4.2 Z"+ fill="#120b06"+ fillOpacity={0.5}+ stroke="#9a7452"+ strokeOpacity={0.55}+ strokeWidth={0.45}+ />+ <g fill="#ecdcbc" fillOpacity={0.88}>+ {CROSS.map((spot) => (+ <circle key={spot.id} cx={spot.x} cy={spot.y} r={spot.r} />+ ))}+ </g>+ <g fill="#d9c29b" fillOpacity={0.45}>+ {SIDE_SPOTS.map((spot) => (+ <ellipse key={spot.id} cx={spot.x} cy={spot.y} rx={0.55} ry={0.85} />+ ))}+ </g>+ <ellipse+ cx={-2.9}+ cy={-16}+ rx={2.4}+ ry={1.25}+ fill="#ffffff"+ fillOpacity={0.15}+ transform="rotate(-30 -2.9 -16)"+ />+ <circle cx={-3.4} cy={-16.7} r={0.42} fill="#ffffff" fillOpacity={0.5} />+ <circle cx={0} cy={-21.9} r={0.9} fill="#1a110a" />++ {/* Waist */}+ <ellipse cx={0} cy={-4.3} rx={1.4} ry={1.1} fill="#241710" />++ {/* Cephalothorax, its grooves, and the eyes and fangs at the front */}+ <ellipse+ cx={0}+ cy={0.6}+ rx={4.7}+ ry={5.3}+ fill={`url(#${thorax})`}+ stroke="currentColor"+ strokeOpacity={0.22}+ strokeWidth={0.5}+ />+ <g+ stroke="#1a110a"+ strokeOpacity={0.5}+ strokeWidth={0.3}+ strokeLinecap="round"+ >+ {GROOVES.map((groove) => (+ <path key={groove.id} d={groove.d} />+ ))}+ </g>+ <ellipse cx={0} cy={-0.7} rx={0.35} ry={0.85} fill="#140d08" />+ <path+ d="M -2.7 2.3 Q 0 3.5 2.7 2.3"+ fill="none"+ stroke="#a3815e"+ strokeOpacity={0.4}+ strokeWidth={0.35}+ />+ {EYES.map((eye) => (+ <g key={eye.id}>+ <circle cx={eye.x} cy={eye.y} r={eye.r} fill="#050302" />+ <circle+ cx={eye.x - eye.r * 0.3}+ cy={eye.y - eye.r * 0.3}+ r={eye.r * 0.32}+ fill="#ffffff"+ fillOpacity={0.6}+ />+ </g>+ ))}+ <ellipse+ cx={-1.15}+ cy={6.25}+ rx={1.05}+ ry={1.4}+ fill="#2a1b11"+ stroke="#4a3423"+ strokeWidth={0.3}+ />+ <ellipse+ cx={1.15}+ cy={6.25}+ rx={1.05}+ ry={1.4}+ fill="#2a1b11"+ stroke="#4a3423"+ strokeWidth={0.3}+ />+ </g>+ );+}++/** Leg colours, shared with the leg paths the rig draws. */+export const LEG_COLOUR = "#5a3c24";+export const LEG_BAND = "#d8b27e";diff --git a/apps/erp/app/components/Halloween/Spider.tsx b/apps/erp/app/components/Halloween/Spider.tsxnew file mode 100644index 0000000000..bd43b36fb9--- /dev/null+++ b/apps/erp/app/components/Halloween/Spider.tsx@@ -0,0 +1,256 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import type { MutableRefObject } from "react";++// The spider hangs head-down from its thread. Its local origin is the+// spinneret, where the thread attaches; the body extends down the +y axis.++type Point = readonly [number, number];+type Leg = { hip: Point; knee: Point; foot: Point };++const LEFT_LEGS: Leg[] = [+ { hip: [-5.2, 24.8], knee: [-14.5, 17.2], foot: [-17.5, 6] },+ { hip: [-6.4, 26.9], knee: [-18.2, 22.8], foot: [-25.5, 15] },+ { hip: [-6.4, 29.1], knee: [-18.2, 32.4], foot: [-25, 41] },+ { hip: [-5.2, 31.2], knee: [-13.6, 38.8], foot: [-15.6, 50] }+];++const mirror = ([x, y]: Point): Point => [-x, y];++export const SPIDER_LEGS: Leg[] = [+ ...LEFT_LEGS,+ ...LEFT_LEGS.map((leg) => ({+ hip: mirror(leg.hip),+ knee: mirror(leg.knee),+ foot: mirror(leg.foot)+ }))+];++/** The middle of the body: where a grab or a click lands. */+export const SPIDER_BODY_CENTER_Y = 22;++/** The two large front eyes; their pupils follow the pointer. */+export const SPIDER_EYES: Point[] = [+ [-2.8, 30.4],+ [2.8, 30.4]+];++// Short bristles around the abdomen's outline.+const BRISTLES = Array.from({ length: 16 }, (_, i) => {+ const angle = (i / 16) * Math.PI * 2;+ const x = Math.cos(angle) * 9.6;+ const y = 11 + Math.sin(angle) * 11.6;+ return {+ id: `bristle-${i}`,+ d: `M ${x} ${y} l ${Math.cos(angle) * 1.8} ${Math.sin(angle) * 1.8}`+ };+});++export function SpiderBody({+ idPrefix,+ legRefs,+ pupilRefs,+ animateLegs = false,+ rimOpacity = 0.16+}: {+ idPrefix: string;+ /** Hands each leg's group to a caller that poses it frame by frame. */+ legRefs?: MutableRefObject<(SVGGElement | null)[]>;+ pupilRefs?: MutableRefObject<(SVGCircleElement | null)[]>;+ /** Let the legs twitch on their own, for a spider nobody is driving. */+ animateLegs?: boolean;+ rimOpacity?: number;+}) {+ const abdomen = `${idPrefix}-abdomen`;+ const thorax = `${idPrefix}-thorax`;+ const eye = `${idPrefix}-eye`;++ return (+ <g>+ <defs>+ <radialGradient id={abdomen} cx="0.36" cy="0.3" r="0.8">+ <stop offset="0" stopColor="#57456a" />+ <stop offset="0.42" stopColor="#261d31" />+ <stop offset="1" stopColor="#0b080f" />+ </radialGradient>+ <radialGradient id={thorax} cx="0.4" cy="0.3" r="0.8">+ <stop offset="0" stopColor="#4a3b5a" />+ <stop offset="0.5" stopColor="#1e1727" />+ <stop offset="1" stopColor="#0b080f" />+ </radialGradient>+ <radialGradient id={eye} cx="0.4" cy="0.35" r="0.7">+ <stop offset="0" stopColor="#fffdf4" />+ <stop offset="1" stopColor="#e9dcc4" />+ </radialGradient>+ </defs>++ {SPIDER_LEGS.map((leg, i) => (+ <g+ key={`leg-${leg.hip[0]}-${leg.hip[1]}`}+ ref={(el) => {+ if (legRefs) legRefs.current[i] = el;+ }}+ >+ {/* A faint light halo, so the legs read on a dark page */}+ <path+ d={`M ${leg.hip[0]} ${leg.hip[1]} L ${leg.knee[0]} ${leg.knee[1]} L ${leg.foot[0]} ${leg.foot[1]}`}+ fill="none"+ stroke="#ffffff"+ strokeOpacity={0.2}+ strokeWidth={3.8}+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ <path+ d={`M ${leg.hip[0]} ${leg.hip[1]} L ${leg.knee[0]} ${leg.knee[1]}`}+ stroke="#16111b"+ strokeWidth={2.5}+ strokeLinecap="round"+ />+ <path+ d={`M ${leg.knee[0]} ${leg.knee[1]} L ${leg.foot[0]} ${leg.foot[1]}`}+ stroke="#16111b"+ strokeWidth={1.7}+ strokeLinecap="round"+ />+ <path+ d={`M ${leg.hip[0]} ${leg.hip[1] - 0.5} L ${leg.knee[0]} ${leg.knee[1] - 0.5}`}+ stroke="#ffffff"+ strokeOpacity={0.14}+ strokeWidth={0.6}+ strokeLinecap="round"+ />+ <circle cx={leg.knee[0]} cy={leg.knee[1]} r={1.3} fill="#2d2335" />+ {animateLegs && (+ <animateTransform+ attributeName="transform"+ type="rotate"+ values={`0 ${leg.hip[0]} ${leg.hip[1]}; ${i % 2 === 0 ? 7 : -7} ${leg.hip[0]} ${leg.hip[1]}; 0 ${leg.hip[0]} ${leg.hip[1]}`}+ dur={`${0.9 + (i % 4) * 0.23}s`}+ begin={`${(i % 3) * 0.17}s`}+ repeatCount="indefinite"+ />+ )}+ </g>+ ))}++ {/* Abdomen, hung from the thread */}+ <g stroke="#2a2134" strokeWidth={0.6} strokeLinecap="round">+ {BRISTLES.map((bristle) => (+ <path key={bristle.id} d={bristle.d} />+ ))}+ </g>+ <ellipse+ cx={0}+ cy={11}+ rx={9.6}+ ry={11.6}+ fill={`url(#${abdomen})`}+ stroke="#ffffff"+ strokeOpacity={rimOpacity}+ strokeWidth={0.6}+ />+ <path+ d="M -5.5 5.5 Q 0 8.5 5.5 5.5 M -6.6 9.5 Q 0 12.8 6.6 9.5 M -6.2 13.8 Q 0 17 6.2 13.8"+ fill="none"+ stroke="#3c2f4a"+ strokeWidth={0.7}+ strokeLinecap="round"+ />+ {/* The marking: a pumpkin-orange hourglass */}+ <path+ d="M -2.7 8.2 L 2.7 8.2 L 0.75 12 L 2.7 15.8 L -2.7 15.8 L -0.75 12 Z"+ fill="#ff7518"+ stroke="#ffb066"+ strokeOpacity={0.6}+ strokeWidth={0.35}+ strokeLinejoin="round"+ />+ <ellipse+ cx={-3.6}+ cy={5.4}+ rx={3.1}+ ry={1.9}+ fill="#ffffff"+ fillOpacity={0.3}+ transform="rotate(-32 -3.6 5.4)"+ />+ <circle cx={0} cy={0.6} r={1} fill="#1a141f" />++ {/* Waist, then the head */}+ <ellipse cx={0} cy={22.8} rx={2.4} ry={1.7} fill="#120e16" />+ <ellipse+ cx={0}+ cy={28.2}+ rx={7.3}+ ry={6.7}+ fill={`url(#${thorax})`}+ stroke="#ffffff"+ strokeOpacity={rimOpacity}+ strokeWidth={0.55}+ />+ <ellipse+ cx={-2.6}+ cy={25.2}+ rx={2}+ ry={1.1}+ fill="#ffffff"+ fillOpacity={0.2}+ transform="rotate(-24 -2.6 25.2)"+ />++ {/* Eyes: two big ones that watch you, six small ones that don't */}+ {[-5.3, 5.3].map((x) => (+ <g key={`small-eye-${x}`}>+ <circle cx={x} cy={27.1} r={1.05} fill="#271f2e" />+ <circle cx={x - 0.3} cy={26.8} r={0.36} fill="#ffffff" />+ </g>+ ))}+ {[-1.5, 1.5].map((x) => (+ <g key={`top-eye-${x}`}>+ <circle cx={x} cy={25.9} r={0.8} fill="#271f2e" />+ <circle cx={x - 0.2} cy={25.7} r={0.26} fill="#ffffff" />+ </g>+ ))}+ {SPIDER_EYES.map(([x, y], i) => (+ <g key={`eye-${x}`}>+ <circle+ cx={x}+ cy={y}+ r={2.6}+ fill={`url(#${eye})`}+ stroke="#0b080f"+ strokeWidth={0.4}+ />+ <circle+ ref={(el) => {+ if (pupilRefs) pupilRefs.current[i] = el;+ }}+ cx={x}+ cy={y + 0.3}+ r={1.45}+ fill="#130e18"+ />+ <circle cx={x - 0.75} cy={y - 0.85} r={0.62} fill="#ffffff" />+ </g>+ ))}++ {/* Fangs */}+ <path+ d="M -2.1 33.9 Q -2.9 36.4 -1.1 37.6 M 2.1 33.9 Q 2.9 36.4 1.1 37.6"+ fill="none"+ stroke="#1a141f"+ strokeWidth={1.3}+ strokeLinecap="round"+ />+ <path+ d="M -1.5 37 L -1.1 37.6 M 1.5 37 L 1.1 37.6"+ stroke="#ff9a3c"+ strokeWidth={0.7}+ strokeLinecap="round"+ />+ </g>+ );+}diff --git a/apps/erp/app/components/Halloween/bar-spider.test.ts b/apps/erp/app/components/Halloween/bar-spider.test.tsnew file mode 100644index 0000000000..ec97e5e764--- /dev/null+++ b/apps/erp/app/components/Halloween/bar-spider.test.ts@@ -0,0 +1,319 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import type { BarSpiderElements, Obstacle } from "./bar-spider";+import { createBarSpider, HIT_SIZE } from "./bar-spider";+import { BAR_HEIGHT } from "./corner-web";++// The spider lives on the top bar all day: it has to keep to the bar, never+// take a click meant for something on it, never stick to the pointer, and let+// the page sleep when it rests. The browser's frame and timer clocks, and its+// pointer events, are the boundary.++const WIDTH = 1200;+// A bar like the real one: breadcrumbs on the left, buttons on the right.+const BAR: Obstacle[] = [+ { left: 16, top: 15, right: 40, bottom: 34 },+ { left: 48, top: 16, right: 220, bottom: 33 },+ ...[0, 1, 2, 3, 4].map((i) => ({+ left: WIDTH - 210 + i * 40,+ top: 8.5,+ right: WIDTH - 178 + i * 40,+ bottom: 40.5+ }))+];++type FakeElement = {+ attrs: Map<string, string>;+ style: Record<string, string>;+ setAttribute: (name: string, value: string) => void;+ getBoundingClientRect: () => { left: number; top: number };+};++function fakeElement(): FakeElement {+ const attrs = new Map<string, string>();+ return {+ attrs,+ style: {},+ setAttribute: (name, value) => attrs.set(name, String(value)),+ getBoundingClientRect: () => ({ left: 0, top: 0 })+ };+}++const frames = new Map<number, FrameRequestCallback>();+// Timers fire when they fall due, as in a browser.+const timers = new Map<number, { due: number; fire: () => void }>();+let pointerMove: ((event: Partial<PointerEvent>) => void) | null = null;+let nextId = 1;+let now = 0;++function fireDue() {+ for (const [id, timer] of [...timers.entries()].sort(+ (a, b) => a[1].due - b[1].due+ )) {+ if (timer.due > now) break;+ timers.delete(id);+ timer.fire();+ }+}++function step() {+ now += 1000 / 60;+ fireDue();+ const pending = [...frames.values()];+ frames.clear();+ for (const callback of pending) callback(now);+}++/** Run for a while; whenever the loop sleeps, skip ahead to the next timer. */+function live(seconds: number, each?: () => void) {+ const end = now + seconds * 1000;+ while (now < end) {+ if (frames.size === 0) {+ const next = Math.min(...[...timers.values()].map((t) => t.due));+ if (!Number.isFinite(next) || next > end) {+ now = end;+ return;+ }+ now = Math.max(now, next);+ fireDue();+ continue;+ }+ step();+ each?.();+ }+}++function moveTo(x: number, y: number) {+ now += 16;+ pointerMove?.({ clientX: x, clientY: y, timeStamp: now });+}++function setup(options = {}) {+ const sim = createBarSpider();+ const web = () => ({+ spokes: fakeElement(),+ rings: fakeElement(),+ torn: fakeElement()+ });+ const el = {+ svg: fakeElement(),+ webs: [web(), web()],+ dragline: fakeElement(),+ body: fakeElement(),+ femurs: fakeElement(),+ tibiae: fakeElement(),+ tarsi: fakeElement(),+ joints: fakeElement(),+ bristles: fakeElement(),+ button: fakeElement()+ };+ sim.attach(el as unknown as BarSpiderElements, options);+ sim.layout(WIDTH);+ sim.setObstacles(BAR);+ return { sim, el };+}++beforeEach(() => {+ frames.clear();+ timers.clear();+ pointerMove = null;+ now = 0;+ vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => {+ const id = nextId++;+ frames.set(id, callback);+ return id;+ });+ vi.stubGlobal("cancelAnimationFrame", (id: number) => frames.delete(id));+ vi.stubGlobal("performance", { now: () => now });+ vi.stubGlobal("document", { visibilityState: "visible" });+ vi.stubGlobal("window", {+ setTimeout: (callback: () => void, ms = 0) => {+ const id = nextId++;+ timers.set(id, { due: now + ms, fire: callback });+ return id;+ },+ clearTimeout: (id: number) => timers.delete(id),+ addEventListener: (_: string, listener: typeof pointerMove) => {+ pointerMove = listener;+ },+ removeEventListener: vi.fn()+ });+});++afterEach(() => {+ vi.unstubAllGlobals();+});++const overlaps = (a: Obstacle, b: Obstacle) =>+ a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;++describe("createBarSpider", () => {+ it("crawls out of its web and along the bar, and never takes a click meant for the bar", () => {+ const { sim, el } = setup();+ sim.appear();+ expect(sim.state().mode).toBe("rest");++ let lowest = 0;+ let travelled = 0;+ let clickableSomewhere = false;+ let previous = sim.state().body.x;+ live(180, () => {+ const state = sim.state();+ travelled += Math.abs(state.body.x - previous);+ previous = state.body.x;+ lowest = Math.max(lowest, state.body.y);+ const takesClicks = el.button.style.pointerEvents === "auto";+ if (takesClicks) {+ clickableSomewhere = true;+ // Whenever it takes clicks, nothing on the bar is under it...+ for (const thing of BAR) expect(overlaps(state.hit, thing)).toBe(false);+ }+ // ...and its target never leaves the bar.+ expect(state.hit.top).toBeGreaterThanOrEqual(0);+ expect(state.hit.top + HIT_SIZE).toBeLessThanOrEqual(BAR_HEIGHT);+ });+ // It wandered well along the bar, keeping to it, and could be clicked+ // out in the open.+ expect(travelled).toBeGreaterThan(300);+ expect(lowest).toBeLessThan(BAR_HEIGHT);+ expect(clickableSomewhere).toBe(true);+ });++ it("runs for a web when the pointer comes close, then comes back out once it is quiet", () => {+ const { sim } = setup();+ sim.appear();+ // Out on the bar, somewhere in the open.+ live(30, () => undefined);+ for (let tries = 0; tries < 20 && sim.state().mode === "rest"; tries++)+ live(5);+ const { body } = sim.state();++ moveTo(body.x + 20, body.y);+ live(12, () => {+ if (sim.state().mode !== "hide") moveTo(sim.state().body.x + 20, body.y);+ });+ const hiding = sim.state();+ expect(hiding.mode).toBe("hide");+ // Ran away from the pointer, into the left-hand web.+ expect(+ Math.hypot(+ hiding.body.x - hiding.hubs[0].x,+ hiding.body.y - hiding.hubs[0].y+ )+ ).toBeLessThan(1);++ moveTo(WIDTH / 2, 400);+ let outAgain = false;+ live(20, () => {+ if (sim.state().mode === "walk") outAgain = true;+ });+ expect(outAgain).toBe(true);+ });++ it("stops and turns to face a pointer drawing near, follows it, then moves on once it has gone", () => {+ const { sim } = setup();+ sim.appear();+ // Out on the bar, walking.+ live(30);+ for (let tries = 0; tries < 40 && sim.state().mode !== "walk"; tries++)+ live(1);+ expect(sim.state().mode).toBe("walk");++ // Closer than it would watch from, not so close it runs.+ const facing = (dx: number, dy: number) => Math.atan2(-dx, dy);+ const angleTo = (x: number, y: number) => {+ const { body } = sim.state();+ return facing(x - body.x, y - body.y);+ };+ const off = (a: number, b: number) =>+ Math.abs(Math.atan2(Math.sin(a - b), Math.cos(a - b)));+ let { body } = sim.state();+ moveTo(body.x + 70, body.y - 60);+ expect(sim.state().mode).toBe("watch");+ live(2);+ expect(+ off(sim.state().body.angle, angleTo(body.x + 70, body.y - 60))+ ).toBeLessThan(0.02);+ // Facing a still pointer, it lets the page sleep.+ expect(frames.size).toBe(0);++ // It follows the pointer round to its other side.+ ({ body } = sim.state());+ moveTo(body.x - 80, body.y - 40);+ live(2);+ expect(sim.state().mode).toBe("watch");+ expect(+ off(sim.state().body.angle, angleTo(body.x - 80, body.y - 40))+ ).toBeLessThan(0.02);++ // The pointer goes; after a moment it walks on.+ moveTo(body.x, 900);+ let walkedOn = false;+ live(4, () => {+ if (sim.state().mode === "walk") walkedOn = true;+ });+ expect(walkedOn).toBe(true);+ });++ it("lets go when the release never arrives, instead of sticking to the pointer", () => {+ const { sim } = setup();+ sim.appear();+ live(10);+ const { body } = sim.state();++ sim.grab(body.x, body.y);+ sim.drag(body.x - 10, body.y + 60);+ expect(sim.state().mode).toBe("drag");+ sim.drag(body.x - 12, body.y + 70, false);+ // Hovering about afterwards must not pick the spider up again.+ sim.drag(body.x + 120, body.y + 90);+ expect(sim.state().mode).not.toBe("drag");++ let backOnTheBar = false;+ live(12, () => {+ if (sim.state().body.y < BAR_HEIGHT && sim.state().mode !== "dangle") {+ backOnTheBar = true;+ }+ });+ expect(backOnTheBar).toBe(true);+ });++ it("lets the page sleep while it rests", () => {+ const { sim } = setup();+ sim.appear();+ let slept = false;+ live(120, () => {+ if (frames.size === 0) slept = true;+ });+ expect(slept).toBe(true);+ });++ it("with reduced motion it simply stays in its web", () => {+ const { sim } = setup({ reducedMotion: true });+ sim.appear();+ expect(frames.size).toBe(0);+ expect(timers.size).toBe(0);+ expect(sim.state().mode).toBe("rest");+ });++ it("a press that stays put is a click, not a drag", () => {+ const { sim } = setup();+ sim.appear();+ sim.grab(100, 100);+ sim.drag(102, 101);+ sim.release();+ expect(sim.consumeDrag()).toBe(false);+ });++ it("stops every frame and timer on detach", () => {+ const { sim } = setup();+ sim.appear();+ live(5);+ sim.detach();+ expect(frames.size).toBe(0);+ expect(timers.size).toBe(0);+ });+});diff --git a/apps/erp/app/components/Halloween/bar-spider.ts b/apps/erp/app/components/Halloween/bar-spider.tsnew file mode 100644index 0000000000..5881fc888b--- /dev/null+++ b/apps/erp/app/components/Halloween/bar-spider.ts@@ -0,0 +1,914 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import type { CornerWeb } from "./corner-web";+import { BAR_HEIGHT, createCornerWeb } from "./corner-web";+import { seededRandom } from "./scene";+import type { Body, LegPose, Surface } from "./spider-rig";+import { createRig, SPIDER_SCALE, toWorld } from "./spider-rig";++// A garden spider living on the top bar, with a web in each of its top+// corners.+//+// It rests in one web, head down, and now and then climbs out and crawls+// along the bar's lower edge: a few steps, a stop to feel about, a few more,+// sometimes all the way across to the other web. A pointer drawing near makes+// it stop and turn to face it, following it as it moves; one coming close+// sends it running for the nearest web, where it hides until things are quiet.+//+// It never stands in the way: wherever it is over or beside something on the+// bar (a button, a link, the breadcrumbs), its click target is switched off,+// so a click there goes to the bar. Picked up, it drops on a dragline, legs+// drawn in, bounces and climbs back.++export const HIT_SIZE = 26;+const STEP = 1 / 120;++// The spider's walk along the bar, just inside its lower border.+const RUN_Y = BAR_HEIGHT - 7;+// The pointer this close and it runs.+const FLEE_RADIUS = 52;+// The pointer this close and it stops to watch it.+const WATCH_RADIUS = 150;+// Watching, it waits this long after the pointer has gone before moving on.+const WATCH_LINGER = 1.2;+// Hiding, it waits for the pointer to stay this far off for a while.+const SAFE_DISTANCE = 90;+const QUIET_BEFORE_RETURN = 4;++const WALK_SPEED = 34;+const RUN_SPEED = 140;+const ACCELERATION = 1800;+const TURN_RATE = 7;++// The dragline.+const GRAVITY = 1100;+const THREAD_STIFFNESS = 70;+const DANGLE_DAMPING = 0.85;+const CLIMB_RATE = 2.4;+const MAX_PULL = 90;+// The spinnerets, at the tip of the abdomen, in the spider's own frame.+const SPINNERETS = -21.8;++type Vec = { x: number; y: number };+type Mode =+ | "rest"+ | "walk"+ | "pause"+ | "watch"+ | "hide"+ | "drag"+ | "dangle"+ | "fall";++/** Something on the bar the spider must not cover with its click target. */+export type Obstacle = {+ left: number;+ top: number;+ right: number;+ bottom: number;+};++export type BarSpiderElements = {+ svg: SVGSVGElement | null;+ webs: {+ spokes: SVGPathElement | null;+ rings: SVGPathElement | null;+ torn: SVGPathElement | null;+ }[];+ dragline: SVGLineElement | null;+ body: SVGGElement | null;+ femurs: SVGPathElement | null;+ tibiae: SVGPathElement | null;+ tarsi: SVGPathElement | null;+ joints: SVGPathElement | null;+ bristles: SVGPathElement | null;+ button: HTMLButtonElement | null;+};++export type BarSpiderOptions = {+ /** The spider stays in its web and nothing moves. */+ reducedMotion?: boolean;+};++const nothing = () => undefined;++/** Shortest turn from a to b, in radians. */+function turn(from: number, to: number) {+ let delta = (to - from) % (Math.PI * 2);+ if (delta > Math.PI) delta -= Math.PI * 2;+ if (delta < -Math.PI) delta += Math.PI * 2;+ return delta;+}++/** The angle that points the spider's head along (dx, dy). */+const facing = (dx: number, dy: number) => Math.atan2(-dx, dy);++/** The page itself: a foot holds wherever it lands. */+const page: Surface = {+ grip: (x, y) => ({ x, y, hold: null }),+ locate: () => ({ x: 0, y: 0 })+};++export function createBarSpider() {+ const rig = createRig();+ const rand = seededRandom(31);++ let width = 0;+ let webs: CornerWeb[] = [];+ // The spider's path: out of the left web, along the bar, into the right one.+ let track: Vec[] = [];+ let lengths: number[] = [];+ let total = 0;+ let obstacles: Obstacle[] = [];++ const spider = {+ mode: "rest" as Mode,+ /** Distance along the track. */+ s: 0,+ target: 0,+ speed: 0,+ maxSpeed: WALK_SPEED,+ nextStop: 0,+ pause: 0,+ timer: 0,+ after: nothing as () => void,+ body: { x: 0, y: 0, angle: 0 } as Body,+ vx: 0,+ vy: 0,+ // On a dragline: the spinnerets, and where the thread is tied.+ sx: 0,+ sy: 0,+ svx: 0,+ svy: 0,+ hold: { x: 0, y: 0 } as Vec,+ holdS: 0,+ thread: 0,+ threadTarget: 0,+ spin: 0+ };++ const pointer = {+ x: -1000,+ y: -1000,+ time: 0,+ pressed: false,+ downX: 0,+ downY: 0,+ grabDX: 0,+ grabDY: 0,+ dragged: false,+ lastDragX: 0,+ lastDragY: 0,+ lastDragTime: 0,+ dragVX: 0,+ dragVY: 0+ };++ let el: BarSpiderElements | null = null;+ let options: BarSpiderOptions = {};+ let frame = 0;+ let last = 0;+ let accumulator = 0;+ let calm = 0;+ let clock = 0;+ let awake = false;+ let idleTimer = 0;+ let quietSince = 0;+ // Watching: whether the pointer is still close (else it moves on soon).+ let watching = false;+ let pointerWasNear = false;++ // ---- The track ------------------------------------------------------------++ function buildTrack() {+ const left = webs[0]?.hub() ?? { x: 25, y: 16 };+ const right = webs[1]?.hub() ?? { x: width - 25, y: 16 };+ track = [+ left,+ { x: left.x + 10, y: 30 },+ { x: left.x + 24, y: RUN_Y },+ { x: right.x - 24, y: RUN_Y },+ { x: right.x - 10, y: 30 },+ right+ ];+ lengths = track+ .slice(1)+ .map((p, i) => Math.hypot(p.x - track[i].x, p.y - track[i].y));+ total = lengths.reduce((sum, length) => sum + length, 0);+ }++ /** The point s along the track, and which way the track runs there. */+ function along(s: number) {+ let rest = Math.max(0, Math.min(total, s));+ for (let k = 0; k < lengths.length; k++) {+ if (rest <= lengths[k] || k === lengths.length - 1) {+ const a = k === 0 ? (webs[0]?.hub() ?? track[0]) : track[k];+ const b =+ k === lengths.length - 1+ ? (webs[1]?.hub() ?? track[k + 1])+ : track[k + 1];+ const t = lengths[k] ? Math.min(1, rest / lengths[k]) : 0;+ return {+ x: a.x + (b.x - a.x) * t,+ y: a.y + (b.y - a.y) * t,+ dx: b.x - a.x,+ dy: b.y - a.y+ };+ }+ rest -= lengths[k];+ }+ return { x: track[0].x, y: track[0].y, dx: 1, dy: 0 };+ }++ // Where the bottom run starts and ends along the track.+ const runStart = () => lengths[0] + lengths[1];+ const runEnd = () =>+ total - lengths[lengths.length - 1] - lengths[lengths.length - 2];+ const atHome = () => spider.s <= 0.5 || spider.s >= total - 0.5;+ const homeWeb = () => (spider.s <= total / 2 ? webs[0] : webs[1]);++ // ---- Behaviour ------------------------------------------------------------++ function clearIdle() {+ window.clearTimeout(idleTimer);+ }++ function later(seconds: number, then: () => void) {+ clearIdle();+ if (options.reducedMotion) return;+ idleTimer = window.setTimeout(() => {+ if (document.visibilityState !== "visible") {+ later(seconds, then);+ return;+ }+ then();+ wake();+ }, seconds * 1000);+ }++ /** Still for a while, in a web or out on the bar; then out for a walk. */+ function rest(seconds: number) {+ spider.mode = "rest";+ spider.speed = 0;+ later(seconds, wander);+ }++ /** Off along the bar to somewhere, in fits and starts. */+ function wander() {+ const target = runStart() + rand() * (runEnd() - runStart());+ walkTo(target, WALK_SPEED, () => {+ spider.mode = "pause";+ spider.timer = 1 + rand() * 2.4;+ // Now and then it settles where it is for a long while; otherwise+ // it moves on. (The webs sit over the bar's corner buttons, so it only+ // goes in to hide.)+ spider.after = () => (rand() < 0.35 ? rest(14 + rand() * 20) : wander());+ });+ }++ function walkTo(target: number, maxSpeed: number, then: () => void) {+ clearIdle();+ spider.mode = "walk";+ spider.target = Math.max(0, Math.min(total, target));+ spider.maxSpeed = maxSpeed;+ spider.nextStop = 14 + rand() * 30;+ spider.after = then;+ wake();+ }++ /** Something big close by: run for the nearest web the other way, and hide. */+ function flee() {+ const pointerIsLeft = pointer.x < spider.body.x;+ walkTo(pointerIsLeft ? total : 0, RUN_SPEED, () => {+ spider.mode = "hide";+ quietSince = clock;+ watchFromHiding();+ });+ }++ function watchFromHiding() {+ later(1, () => {+ if (spider.mode !== "hide") return;+ const away =+ Math.hypot(pointer.x - spider.body.x, pointer.y - spider.body.y) >+ SAFE_DISTANCE;+ if (!away) quietSince = clock;+ if (away && clock - quietSince >= QUIET_BEFORE_RETURN) {+ wander();+ return;+ }+ watchFromHiding();+ });+ }++ // ---- The loop ---------------------------------------------------------------++ function wake() {+ calm = 0;+ if (awake || !el || width === 0) return;+ awake = true;+ last = performance.now();+ accumulator = 0;+ frame = requestAnimationFrame(tick);+ }++ function sleep() {+ awake = false;+ cancelAnimationFrame(frame);+ }++ function tick(now: number) {+ const elapsed = Math.min(0.05, (now - last) / 1000);+ last = now;+ accumulator += elapsed;+ while (accumulator >= STEP) {+ step(STEP);+ accumulator -= STEP;+ }+ render();++ const resting =+ spider.mode === "rest" ||+ spider.mode === "hide" ||+ spider.mode === "watch";+ const target = restingAngle();+ const settled =+ resting &&+ !rig.stepping() &&+ webs.every((web) => web.restlessness() < 1) &&+ (target === null || Math.abs(turn(spider.body.angle, target)) < 0.01);+ calm = settled ? calm + 1 : 0;+ // Asleep after half a second of stillness: an idle page costs nothing.+ if (calm > 30) {+ awake = false;+ return;+ }+ frame = requestAnimationFrame(tick);+ }++ function step(dt: number) {+ clock += dt;+ for (const web of webs) web.step(dt);+ const before = { x: spider.body.x, y: spider.body.y };++ switch (spider.mode) {+ case "rest":+ case "hide":+ case "watch": {+ place();+ const target = restingAngle();+ if (target !== null) turnTowards(target, dt);+ if (atHome()) homeWeb()?.loadHub(0, 60);+ break;+ }+ case "pause":+ place();+ spider.timer -= dt;+ if (spider.timer <= 0) spider.after();+ break;+ case "walk":+ walkStep(dt);+ break;+ case "drag":+ break;+ case "dangle":+ case "fall":+ dangleStep(dt);+ break;+ }++ spider.vx = (spider.body.x - before.x) / dt;+ spider.vy = (spider.body.y - before.y) / dt;+ const onThread =+ spider.mode === "drag" ||+ spider.mode === "dangle" ||+ spider.mode === "fall";+ rig.update(+ dt,+ spider.body,+ { x: spider.vx, y: spider.vy },+ page,+ onThread ? "curl" : "walk"+ );+ }++ /** Whether the pointer is close enough for the spider to watch it. */+ function pointerNear() {+ return (+ Math.hypot(pointer.x - spider.body.x, pointer.y - spider.body.y) <+ WATCH_RADIUS+ );+ }++ /**+ * Where a still spider looks: at a pointer close by; otherwise, in a web,+ * head down, and out on the bar, as it stood (null).+ */+ function restingAngle() {+ if (spider.mode === "watch" || pointerNear()) {+ return facing(pointer.x - spider.body.x, pointer.y - spider.body.y);+ }+ return atHome() ? 0 : null;+ }++ /** Something moving close by: stop and face it. */+ function watch() {+ clearIdle();+ spider.mode = "watch";+ spider.speed = 0;+ spider.pause = 0;+ watching = true;+ wake();+ }++ function place() {+ const p = along(spider.s);+ spider.body.x = p.x;+ spider.body.y = p.y;+ }++ /**+ * Turn towards an angle: quickly while far off, easing in as it lines up,+ * and never past it.+ */+ function turnTowards(target: number, dt: number) {+ const delta = turn(spider.body.angle, target);+ const size = Math.min(+ Math.abs(delta),+ TURN_RATE * dt,+ Math.max(Math.abs(delta) * 0.35, 0.02)+ );+ spider.body.angle += Math.sign(delta) * size;+ if (Math.abs(turn(spider.body.angle, target)) < 0.004) {+ spider.body.angle = target;+ }+ }++ function walkStep(dt: number) {+ if (spider.pause > 0) {+ spider.pause -= dt;+ spider.speed = 0;+ place();+ return;+ }+ const direction = Math.sign(spider.target - spider.s) || 1;+ const here = along(spider.s);+ const target = facing(here.dx * direction, here.dy * direction);+ const off = Math.abs(turn(spider.body.angle, target));+ turnTowards(target, dt);+ // Turn first if facing well away; then go, braking hard to stop dead.+ const limit = off > 0.9 ? 0 : spider.maxSpeed;+ const left = Math.abs(spider.target - spider.s);+ const braking = Math.sqrt(2 * ACCELERATION * 1.2 * left);+ const wanted = Math.min(limit, braking);+ spider.speed =+ wanted > spider.speed+ ? Math.min(wanted, spider.speed + ACCELERATION * dt)+ : wanted;+ const move = Math.min(left, spider.speed * dt);+ spider.s += move * direction;+ // A walk is never one long glide: it stops now and then to feel about.+ if (spider.maxSpeed <= WALK_SPEED) {+ spider.nextStop -= move;+ if (spider.nextStop <= 0) {+ spider.nextStop = 14 + rand() * 30;+ spider.pause = 0.25 + rand() * 0.9;+ }+ }+ place();+ if (left - move <= 0.01) {+ spider.s = spider.target;+ spider.speed = 0;+ spider.mode = "pause";+ spider.timer = 0;+ const then = spider.after;+ spider.after = nothing;+ then();+ }+ }++ function dangleStep(dt: number) {+ let tension = 0;+ let ux = 0;+ let uy = 0;+ if (spider.mode === "dangle") {+ const h = spider.hold;+ const dx = spider.sx - h.x;+ const dy = spider.sy - h.y;+ const length = Math.hypot(dx, dy) || 1e-6;+ ux = dx / length;+ uy = dy / length;+ if (length > spider.thread) {+ tension = THREAD_STIFFNESS * (length - spider.thread);+ }+ spider.thread +=+ (spider.threadTarget - spider.thread) * Math.min(1, dt * CLIMB_RATE);+ spider.timer -= dt;+ if (spider.timer <= 0) spider.threadTarget = 0;+ // The last of the climb: it hauls itself back up onto the bar.+ if (spider.threadTarget === 0 && spider.thread < 3) {+ const pull = Math.min(1, dt * 9);+ spider.sx += (h.x - spider.sx) * pull;+ spider.sy += (h.y - spider.sy) * pull;+ spider.svx = 0;+ spider.svy = 0;+ placeFromSpinnerets(dt);+ if (Math.hypot(spider.sx - h.x, spider.sy - h.y) < 1.5) land();+ return;+ }+ }+ spider.svx += (-tension * ux - DANGLE_DAMPING * spider.svx) * dt;+ spider.svy += (GRAVITY - tension * uy - DANGLE_DAMPING * spider.svy) * dt;+ spider.sx += spider.svx * dt;+ spider.sy += spider.svy * dt;+ placeFromSpinnerets(dt);+ }++ /** On a thread the spider hangs from its spinnerets, head down. */+ function placeFromSpinnerets(dt: number) {+ if (spider.mode === "fall") {+ spider.body.angle += spider.spin * dt;+ } else {+ const dx = spider.hold.x - spider.sx;+ const dy = spider.hold.y - spider.sy;+ if (Math.hypot(dx, dy) > 2) turnTowards(Math.atan2(dx, -dy), dt);+ }+ const reach = -SPINNERETS * SPIDER_SCALE;+ spider.body.x = spider.sx - Math.sin(spider.body.angle) * reach;+ spider.body.y = spider.sy + Math.cos(spider.body.angle) * reach;+ }++ function land() {+ spider.s = spider.holdS;+ place();+ rig.place(spider.body, page);+ spider.mode = "pause";+ spider.timer = 0.8;+ spider.after = wander;+ }++ // ---- Drawing ------------------------------------------------------------------++ function render() {+ if (!el) return;+ webs.forEach((web, k) => {+ const p = web.paths();+ const parts = el?.webs[k];+ if (!parts) return;+ parts.spokes?.setAttribute("d", p.spokes);+ parts.rings?.setAttribute("d", p.rings);+ parts.torn?.setAttribute("d", p.torn);+ });++ const { body } = spider;+ el.body?.setAttribute(+ "transform",+ `translate(${body.x} ${body.y}) rotate(${(body.angle * 180) / Math.PI}) scale(${SPIDER_SCALE})`+ );+ drawLegs(rig.pose(body));++ const onThread = spider.mode === "drag" || spider.mode === "dangle";+ el.dragline?.setAttribute("visibility", onThread ? "visible" : "hidden");+ if (onThread) {+ const s = toWorld(body, { x: 0, y: SPINNERETS });+ el.dragline?.setAttribute("x1", String(spider.hold.x));+ el.dragline?.setAttribute("y1", String(spider.hold.y));+ el.dragline?.setAttribute("x2", String(s.x));+ el.dragline?.setAttribute("y2", String(s.y));+ }++ if (el.button) {+ const box = hitBox();+ el.button.style.transform = `translate(${box.left}px, ${box.top}px)`;+ // Over or beside anything on the bar, the spider takes no clicks: they+ // go to the bar. Being dragged, it keeps the one it has.+ el.button.style.pointerEvents =+ spider.mode === "drag" || clickable(box) ? "auto" : "none";+ }+ }++ /** The click target: on the body, inside the bar unless pulled out of it. */+ function hitBox(): Obstacle {+ const centre = toWorld(spider.body, { x: 0, y: -6 });+ const free =+ spider.mode === "drag" ||+ spider.mode === "dangle" ||+ spider.mode === "fall";+ const lowest = free ? Number.POSITIVE_INFINITY : BAR_HEIGHT - HIT_SIZE;+ const top = Math.min(lowest, Math.max(0, centre.y - HIT_SIZE / 2));+ const left = Math.min(+ Math.max(0, width - HIT_SIZE),+ Math.max(0, centre.x - HIT_SIZE / 2)+ );+ return { left, top, right: left + HIT_SIZE, bottom: top + HIT_SIZE };+ }++ function clickable(box: Obstacle) {+ const margin = 4;+ return !obstacles.some(+ (o) =>+ box.left < o.right + margin &&+ box.right > o.left - margin &&+ box.top < o.bottom + margin &&+ box.bottom > o.top - margin+ );+ }++ function drawLegs(legs: LegPose[]) {+ let femurs = "";+ let tibiae = "";+ let tarsi = "";+ let bands = "";+ let spines = "";+ // Leg detail scales with the spider.+ const k = SPIDER_SCALE / 1.15;+ // A short stretch from a toward b: the pale ring where a segment begins.+ const band = (a: Vec, b: Vec, length: number) => {+ const dx = b.x - a.x;+ const dy = b.y - a.y;+ const span = Math.hypot(dx, dy) || 1;+ const f = Math.min(1, length / span);+ return `M ${a.x} ${a.y} L ${a.x + dx * f} ${a.y + dy * f} `;+ };+ // Fine spines along a segment, raked back towards the foot.+ const rake = (a: Vec, b: Vec) => {+ const dx = b.x - a.x;+ const dy = b.y - a.y;+ const span = Math.hypot(dx, dy) || 1;+ const ux = dx / span;+ const uy = dy / span;+ const count = Math.trunc(span / (2.4 * k));+ let d = "";+ for (let n = 0; n < count; n++) {+ const t = (n + 0.6) / (count + 0.2);+ const x = a.x + dx * t;+ const y = a.y + dy * t;+ const side = n % 2 === 0 ? 1 : -1;+ d += `M ${x} ${y} l ${(ux * 0.8 - uy * 0.75 * side) * 1.15 * k} ${(uy * 0.8 + ux * 0.75 * side) * 1.15 * k} `;+ }+ return d;+ };+ for (const { hip, knee, ankle, foot } of legs) {+ femurs += `M ${hip.x} ${hip.y} L ${knee.x} ${knee.y} `;+ tibiae += `M ${knee.x} ${knee.y} L ${ankle.x} ${ankle.y} `;+ tarsi += `M ${ankle.x} ${ankle.y} L ${foot.x} ${foot.y} `;+ bands += band(knee, ankle, 1.7 * k) + band(ankle, foot, 1.2 * k);+ spines += rake(hip, knee) + rake(knee, ankle);+ }+ el?.femurs?.setAttribute("d", femurs);+ el?.tibiae?.setAttribute("d", tibiae);+ el?.tarsi?.setAttribute("d", tarsi);+ el?.joints?.setAttribute("d", bands);+ el?.bristles?.setAttribute("d", spines);+ }++ // ---- The pointer ------------------------------------------------------------++ function local(clientX: number, clientY: number) {+ const rect = el?.svg?.getBoundingClientRect();+ return rect+ ? { x: clientX - rect.left, y: clientY - rect.top }+ : { x: clientX, y: clientY };+ }++ function onPointerMove(event: PointerEvent) {+ if (!el?.svg || spider.mode === "drag") return;+ const p = local(event.clientX, event.clientY);+ const now = event.timeStamp;+ const dt = Math.max(0.008, (now - pointer.time) / 1000);+ const pvx = Math.max(-1500, Math.min(1500, (p.x - pointer.x) / dt));+ const pvy = Math.max(-1500, Math.min(1500, (p.y - pointer.y) / dt));+ pointer.x = p.x;+ pointer.y = p.y;+ pointer.time = now;+ if (options.reducedMotion) return;++ const near = Math.hypot(p.x - spider.body.x, p.y - spider.body.y);+ const wasNear = pointerWasNear;+ pointerWasNear = near < WATCH_RADIUS;+ const running = spider.mode === "walk" && spider.maxSpeed >= RUN_SPEED;+ if (+ near < FLEE_RADIUS &&+ !running &&+ (spider.mode === "walk" ||+ spider.mode === "pause" ||+ spider.mode === "rest" ||+ spider.mode === "watch")+ ) {+ // Already home and the pointer is on the open side: it stays put.+ if (!(spider.mode === "rest" && atHome() && near > FLEE_RADIUS * 0.6)) {+ flee();+ return;+ }+ }+ if (spider.mode === "hide" && near < SAFE_DISTANCE) quietSince = clock;++ // Drawing near, it stops to face the pointer and follows it round; once+ // the pointer has gone, it waits a moment and moves on.+ if (near < WATCH_RADIUS) {+ if (+ !running &&+ (spider.mode === "walk" ||+ spider.mode === "pause" ||+ (spider.mode === "rest" && !atHome()))+ ) {+ watch();+ } else if (spider.mode === "watch" && !watching) {+ watch();+ } else if (+ spider.mode === "watch" ||+ spider.mode === "rest" ||+ spider.mode === "hide"+ ) {+ // Still, it turns to follow.+ wake();+ }+ } else if (spider.mode === "watch" && watching) {+ watching = false;+ later(WATCH_LINGER, wander);+ } else if (wasNear && (spider.mode === "rest" || spider.mode === "hide")) {+ // The pointer has gone: back to how it rests.+ wake();+ }++ // A hand through a web shakes it.+ let touched = false;+ for (const web of webs) {+ if (web.brush(p.x, p.y, pvx, pvy)) touched = true;+ }+ if (touched) wake();+ }++ function release() {+ pointer.pressed = false;+ if (spider.mode !== "drag") return;+ spider.mode = "dangle";+ // Fling: it leaves with the pointer's speed, bounces on its dragline,+ // hangs a moment and climbs back.+ spider.svx = Math.max(-1600, Math.min(1600, pointer.dragVX));+ spider.svy = Math.max(-1600, Math.min(1600, pointer.dragVY));+ spider.thread = Math.max(+ 10,+ Math.hypot(spider.sx - spider.hold.x, spider.sy - spider.hold.y) * 0.85+ );+ spider.threadTarget = spider.thread;+ spider.timer = 1.3;+ wake();+ }++ return {+ attach(elements: BarSpiderElements, spiderOptions: BarSpiderOptions = {}) {+ el = elements;+ options = spiderOptions;+ window.addEventListener("pointermove", onPointerMove, { passive: true });+ },+ detach() {+ sleep();+ clearIdle();+ window.removeEventListener("pointermove", onPointerMove);+ el = null;+ },+ sleep,+ /** The bar's width changed: re-spin the corner webs to fit. */+ layout(nextWidth: number) {+ if (nextWidth === width) return;+ const fraction = total ? spider.s / total : 1;+ width = nextWidth;+ webs = [createCornerWeb("left", width), createCornerWeb("right", width)];+ buildTrack();+ spider.s = fraction * total;+ spider.target = Math.min(total, spider.target);+ if (spider.mode !== "drag" && spider.mode !== "dangle") {+ place();+ rig.place(spider.body, page);+ }+ render();+ },+ /** What on the bar the click target must keep clear of. */+ setObstacles(next: Obstacle[]) {+ obstacles = next;+ render();+ },+ /**+ * The webs, and the spider resting in the right-hand one; in a moment it+ * comes out for a walk. With reduced motion it simply stays there.+ */+ appear() {+ clearIdle();+ for (const web of webs) web.reset();+ spider.s = total;+ spider.speed = 0;+ spider.spin = 0;+ spider.body.angle = 0;+ place();+ rig.place(spider.body, page);+ render();+ spider.mode = "rest";+ if (options.reducedMotion) return;+ later(1.6, wander);+ },+ /** The webs burst and the spider drops. */+ snap() {+ clearIdle();+ for (const web of webs) web.burst(rand);+ const s = toWorld(spider.body, { x: 0, y: SPINNERETS });+ spider.sx = s.x;+ spider.sy = s.y;+ spider.svx = (rand() - 0.5) * 140;+ spider.svy = -180;+ spider.spin = (rand() < 0.5 ? -1 : 1) * 7;+ spider.mode = "fall";+ wake();+ },+ grab(clientX: number, clientY: number) {+ const p = local(clientX, clientY);+ pointer.pressed = true;+ pointer.downX = p.x;+ pointer.downY = p.y;+ pointer.grabDX = spider.body.x - p.x;+ pointer.grabDY = spider.body.y - p.y;+ pointer.dragged = false;+ pointer.lastDragX = p.x;+ pointer.lastDragY = p.y;+ pointer.lastDragTime = performance.now();+ pointer.dragVX = 0;+ pointer.dragVY = 0;+ },+ /**+ * Lift the spider off the bar on a dragline while the button is held. A+ * move with the button up means the release was never delivered (a+ * right-click's context menu, a release outside the window): let go+ * rather than stay glued to the pointer.+ */+ drag(clientX: number, clientY: number, held = true) {+ if (!pointer.pressed || spider.mode === "fall") return;+ if (!held) {+ release();+ return;+ }+ const p = local(clientX, clientY);+ if (!pointer.dragged) {+ if (Math.hypot(p.x - pointer.downX, p.y - pointer.downY) < 5) return;+ pointer.dragged = true;+ clearIdle();+ // The dragline is tied where the spider was standing.+ if (spider.mode !== "dangle") {+ spider.hold = { x: spider.body.x, y: spider.body.y };+ spider.holdS = spider.s;+ }+ spider.mode = "drag";+ }+ const now = performance.now();+ const dt = Math.max(0.008, (now - pointer.lastDragTime) / 1000);+ pointer.dragVX = (p.x - pointer.lastDragX) / dt;+ pointer.dragVY = (p.y - pointer.lastDragY) / dt;+ pointer.lastDragX = p.x;+ pointer.lastDragY = p.y;+ pointer.lastDragTime = now;++ // However hard you pull, the dragline only pays out so far.+ const h = spider.hold;+ let bx = p.x + pointer.grabDX;+ let by = Math.max(4, p.y + pointer.grabDY);+ const dx = bx - h.x;+ const dy = by - h.y;+ const length = Math.hypot(dx, dy);+ if (length > MAX_PULL) {+ bx = h.x + (dx / length) * MAX_PULL;+ by = h.y + (dy / length) * MAX_PULL;+ }+ spider.body.x = bx;+ spider.body.y = by;+ const angle = Math.atan2(h.x - bx, -(h.y - by));+ spider.body.angle += turn(spider.body.angle, angle) * 0.3;+ const s = toWorld(spider.body, { x: 0, y: SPINNERETS });+ spider.sx = s.x;+ spider.sy = s.y;+ pointer.x = p.x;+ pointer.y = p.y;+ wake();+ },+ release,+ /** Whether the press that just ended was a drag; resets for the next. */+ consumeDrag() {+ const dragged = pointer.dragged;+ pointer.dragged = false;+ return dragged;+ },+ /** For tests: what the spider is doing and where. */+ state() {+ return {+ mode: spider.mode,+ s: spider.s,+ total,+ body: { ...spider.body },+ stepping: rig.stepping(),+ hubs: webs.map((web) => web.hub()),+ hit: hitBox(),+ clickable: clickable(hitBox())+ };+ }+ };+}diff --git a/apps/erp/app/components/Halloween/corner-web.test.ts b/apps/erp/app/components/Halloween/corner-web.test.tsnew file mode 100644index 0000000000..bfe6fba025--- /dev/null+++ b/apps/erp/app/components/Halloween/corner-web.test.ts@@ -0,0 +1,66 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { describe, expect, it } from "vitest";+import { BAR_HEIGHT, createCornerWeb } from "./corner-web";+import { seededRandom } from "./scene";++// The corner cobwebs sit over the top bar all day. They must stay in their+// corner, keep inside the bar, sway when brushed and settle again.++const WIDTH = 1200;++function settle(web: ReturnType<typeof createCornerWeb>, seconds: number) {+ for (let t = 0; t < seconds; t += 1 / 120) web.step(1 / 120);+}++describe("createCornerWeb", () => {+ it.each(["left", "right"] as const)(+ "the %s web fans out from its own corner and stays inside the bar",+ (side) => {+ const web = createCornerWeb(side, WIDTH);+ const corner = side === "left" ? 0 : WIDTH;+ for (const { x, y } of web.knots()) {+ expect(Math.abs(x - corner)).toBeLessThan(40);+ expect(y).toBeGreaterThanOrEqual(0);+ expect(y).toBeLessThan(BAR_HEIGHT);+ }+ expect(web.paths().spokes.startsWith(`M ${corner} 0`)).toBe(true);+ }+ );++ it("is still until something touches it", () => {+ const web = createCornerWeb("left", WIDTH);+ settle(web, 1);+ expect(web.restlessness()).toBeLessThan(1);+ });++ it("sways when brushed, then settles back into shape", () => {+ const web = createCornerWeb("left", WIDTH);+ const before = web.hub();+ expect(web.brush(before.x, before.y, 900, 400)).toBe(true);+ settle(web, 0.05);+ expect(web.restlessness()).toBeGreaterThan(1);+ settle(web, 6);+ expect(web.restlessness()).toBeLessThan(1);+ const after = web.hub();+ expect(Math.hypot(after.x - before.x, after.y - before.y)).toBeLessThan(1);+ });++ it("a brush far from the threads leaves it alone", () => {+ const web = createCornerWeb("left", WIDTH);+ expect(web.brush(600, 20, 900, 400)).toBe(false);+ });++ it("bursts on a snap and is whole again after a reset", () => {+ const web = createCornerWeb("right", WIDTH);+ const rest = web.paths();+ web.burst(seededRandom(1));+ settle(web, 0.1);+ expect(web.paths().rings).not.toBe(rest.rings);+ web.reset();+ expect(web.paths()).toEqual(rest);+ expect(web.restlessness()).toBe(0);+ });+});diff --git a/apps/erp/app/components/Halloween/corner-web.ts b/apps/erp/app/components/Halloween/corner-web.tsnew file mode 100644index 0000000000..d298d32bea--- /dev/null+++ b/apps/erp/app/components/Halloween/corner-web.ts@@ -0,0 +1,237 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { seededRandom } from "./scene";++// The classic cobweb in a corner: spokes fanning out from where the bar's+// top edge meets its side, and rings strung between them, each span sagging+// towards the corner. One outer strand has snapped and hangs loose.+//+// It is a small mass–spring network: every strand is silk that pulls but+// never pushes, spun a little short so the web is taut, and every knot is+// tied loosely to its resting place so the web keeps its shape. A hand+// brushing it sets it swaying.+//+// Coordinates are the bar's own: its top edge is y 0, its left edge x 0, its+// lower border y BAR_HEIGHT.++export const BAR_HEIGHT = 49;++type Point = { x: number; y: number };++const SPOKE_ANGLES = [9, 24, 39, 54, 69, 82].map((d) => (d * Math.PI) / 180);+const RING_RADII = [9, 17, 26, 35];+// The outermost ring has snapped between these two spokes.+const TORN_AFTER_SPOKE = 2;+// How far each ring span sags towards the corner, as a share of its reach.+const SAG = 0.13;+const PRETENSION = 0.97;++const STIFFNESS = 140;+const SHAPE_STIFFNESS = 20;+const DAMPING = 4.8;++const SPOKES = SPOKE_ANGLES.length;+const RINGS = RING_RADII.length;+// Where the spider hides: on the middle spoke, two rings out.+const HIDE_SPOKE = 2;+const HIDE_RING = 1;++export function createCornerWeb(side: "left" | "right", width: number) {+ const rand = seededRandom(side === "left" ? 4242 : 777);+ // Out from the corner: +x along the top edge for the left corner, -x for+ // the right; +y down the side.+ const sx = side === "left" ? 1 : -1;+ const cornerX = side === "left" ? 0 : width;++ const CORNER = 0;+ const topWall = (ring: number) => 1 + ring;+ const sideWall = (ring: number) => 1 + RINGS + ring;+ const knot = (spoke: number, ring: number) =>+ 1 + 2 * RINGS + spoke * RINGS + ring;+ const points = 1 + 2 * RINGS + SPOKES * RINGS;++ const restX = new Float32Array(points);+ const restY = new Float32Array(points);+ const fixed = new Uint8Array(points);+ restX[CORNER] = cornerX;+ restY[CORNER] = 0;+ fixed[CORNER] = 1;+ RING_RADII.forEach((r, ring) => {+ restX[topWall(ring)] = cornerX + sx * r;+ restY[topWall(ring)] = 0;+ fixed[topWall(ring)] = 1;+ restX[sideWall(ring)] = cornerX;+ restY[sideWall(ring)] = r;+ fixed[sideWall(ring)] = 1;+ });+ for (let spoke = 0; spoke < SPOKES; spoke++) {+ for (let ring = 0; ring < RINGS; ring++) {+ // Hand-spun: never quite regular.+ const angle = SPOKE_ANGLES[spoke] + (rand() - 0.5) * 0.06;+ const r = RING_RADII[ring] * (1 + (rand() - 0.5) * 0.08);+ restX[knot(spoke, ring)] = cornerX + sx * Math.cos(angle) * r;+ restY[knot(spoke, ring)] = Math.sin(angle) * r;+ }+ }++ const springs: { a: number; b: number; rest: number }[] = [];+ const tie = (a: number, b: number) =>+ springs.push({+ a,+ b,+ rest: Math.hypot(restX[b] - restX[a], restY[b] - restY[a]) * PRETENSION+ });+ const spokeChains = SPOKE_ANGLES.map((_, spoke) => [+ CORNER,+ ...RING_RADII.map((_, ring) => knot(spoke, ring))+ ]);+ for (const chain of spokeChains) {+ for (let j = 0; j < chain.length - 1; j++) tie(chain[j], chain[j + 1]);+ }+ // Each ring runs from the top edge, through every spoke, to the side.+ const ringChains = RING_RADII.map((_, ring) => [+ topWall(ring),+ ...SPOKE_ANGLES.map((_, spoke) => knot(spoke, ring)),+ sideWall(ring)+ ]);+ const isTorn = (ring: number, j: number) =>+ ring === RINGS - 1 && j === TORN_AFTER_SPOKE + 1;+ ringChains.forEach((chain, ring) => {+ for (let j = 0; j < chain.length - 1; j++) {+ if (!isTorn(ring, j)) tie(chain[j], chain[j + 1]);+ }+ });++ const x = Float32Array.from(restX);+ const y = Float32Array.from(restY);+ const vx = new Float32Array(points);+ const vy = new Float32Array(points);+ const fx = new Float32Array(points);+ const fy = new Float32Array(points);+ const ex = new Float32Array(points);+ const ey = new Float32Array(points);+ const hideKnot = knot(HIDE_SPOKE, HIDE_RING);++ function step(dt: number) {+ fx.fill(0);+ fy.fill(0);+ for (const { a, b, rest } of springs) {+ const dx = x[b] - x[a];+ const dy = y[b] - y[a];+ const length = Math.hypot(dx, dy) || 1e-6;+ if (length <= rest) continue;+ const f = (STIFFNESS * (length - rest)) / length;+ fx[a] += f * dx;+ fy[a] += f * dy;+ fx[b] -= f * dx;+ fy[b] -= f * dy;+ }+ for (let i = 0; i < points; i++) {+ if (fixed[i]) continue;+ const ax =+ fx[i] + ex[i] + SHAPE_STIFFNESS * (restX[i] - x[i]) - DAMPING * vx[i];+ const ay =+ fy[i] + ey[i] + SHAPE_STIFFNESS * (restY[i] - y[i]) - DAMPING * vy[i];+ vx[i] += ax * dt;+ vy[i] += ay * dt;+ x[i] += vx[i] * dt;+ y[i] += vy[i] * dt;+ }+ ex.fill(0);+ ey.fill(0);+ }++ return {+ /** Where the spider hides, now. */+ hub: (): Point => ({ x: x[hideKnot], y: y[hideKnot] }),+ /** The spider's weight while it hides there. */+ loadHub(forceX: number, forceY: number) {+ ex[hideKnot] += forceX;+ ey[hideKnot] += forceY;+ },+ step,+ /** Brush the threads near a point, as a passing hand would. */+ brush(px: number, py: number, pvx: number, pvy: number) {+ let touched = false;+ for (let i = 0; i < points; i++) {+ if (fixed[i]) continue;+ const gap = Math.hypot(x[i] - px, y[i] - py);+ if (gap > 12) continue;+ const falloff = 1 - gap / 12;+ vx[i] += pvx * 0.2 * falloff;+ vy[i] += pvy * 0.2 * falloff;+ touched = true;+ }+ return touched;+ },+ /** Every knot flung outwards: the web bursts. */+ burst(random: () => number) {+ for (let i = 0; i < points; i++) {+ if (fixed[i]) continue;+ const dx = x[i] - cornerX;+ const dy = y[i];+ const length = Math.hypot(dx, dy) || 1;+ const kick = 120 + random() * 140;+ vx[i] += (dx / length) * kick + (random() - 0.5) * 80;+ vy[i] += (dy / length) * kick + (random() - 0.5) * 80;+ }+ },+ reset() {+ x.set(restX);+ y.set(restY);+ vx.fill(0);+ vy.fill(0);+ },+ /** The fastest knot's speed squared: how far from still the web is. */+ restlessness() {+ let fastest = 0;+ for (let i = 0; i < points; i++) {+ fastest = Math.max(fastest, vx[i] * vx[i] + vy[i] * vy[i]);+ }+ return fastest;+ },+ /** Every point of the web now, for checking it stays in its corner. */+ knots(): Point[] {+ return Array.from(x, (value, i) => ({ x: value, y: y[i] }));+ },+ /** The threads as SVG path data, from where the knots are now. */+ paths() {+ let spokes = "";+ for (const chain of spokeChains) {+ spokes += `M ${x[chain[0]]} ${y[chain[0]]}`;+ for (let j = 1; j < chain.length; j++) {+ spokes += ` L ${x[chain[j]]} ${y[chain[j]]}`;+ }+ spokes += " ";+ }+ let rings = "";+ ringChains.forEach((chain, ring) => {+ rings += `M ${x[chain[0]]} ${y[chain[0]]}`;+ for (let j = 0; j < chain.length - 1; j++) {+ const a = chain[j];+ const b = chain[j + 1];+ if (isTorn(ring, j)) {+ rings += ` M ${x[b]} ${y[b]}`;+ continue;+ }+ // Each span sags towards the corner: the classic scallop.+ const mx = (x[a] + x[b]) / 2;+ const my = (y[a] + y[b]) / 2;+ const cx = mx + (cornerX - mx) * SAG;+ const cy = my + (0 - my) * SAG;+ rings += ` Q ${cx} ${cy} ${x[b]} ${y[b]}`;+ }+ rings += " ";+ });+ // The snapped strand's two loose ends hang from their knots.+ const left = knot(TORN_AFTER_SPOKE, RINGS - 1);+ const right = knot(TORN_AFTER_SPOKE + 1, RINGS - 1);+ const torn = `M ${x[left]} ${y[left]} q ${-2 * sx} 4 ${1 * sx} 8 M ${x[right]} ${y[right]} q ${2 * sx} 3 ${-0.5 * sx} 6`;+ return { spokes, rings, torn };+ }+ };+}++export type CornerWeb = ReturnType<typeof createCornerWeb>;diff --git a/apps/erp/app/components/Halloween/scene-loops.tsx b/apps/erp/app/components/Halloween/scene-loops.tsxnew file mode 100644index 0000000000..e1163c39c0--- /dev/null+++ b/apps/erp/app/components/Halloween/scene-loops.tsx@@ -0,0 +1,46 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import type { SVGProps } from "react";+import { createContext, useContext } from "react";++// Shared by everything in the Halloween scene. Staged entrances use motion;+// the endless loops (twinkling, flickering, flapping, drifting) are SMIL,+// which the browser runs without any script.++/**+ * Animate an SVG group around its own local origin. The default fill-box+ * origin is the middle of whatever the group holds, which moves while the+ * parts inside it (a bat's wings, a pumpkin's cackling mouth) animate.+ */+export const SCENE_ORIGIN = {+ transformBox: "view-box",+ // motion's own origin props: it drops a plain transformOrigin and writes+ // 50% 50%, which with a view-box box is the middle of the screen.+ originX: "0px",+ originY: "0px"+} as const;++/** With reduced motion the scene stands still: no loops at all. */+export const StillContext = createContext(false);++export function useStill() {+ return useContext(StillContext);+}++export function Loop(props: SVGProps<SVGAnimateElement>) {+ const still = useStill();+ return still ? null : <animate repeatCount="indefinite" {...props} />;+}++export function LoopTransform(props: SVGProps<SVGAnimateTransformElement>) {+ const still = useStill();+ return still ? null : (+ <animateTransform+ attributeName="transform"+ repeatCount="indefinite"+ {...props}+ />+ );+}diff --git a/apps/erp/app/components/Halloween/scene.ts b/apps/erp/app/components/Halloween/scene.tsnew file mode 100644index 0000000000..a85fbae7fb--- /dev/null+++ b/apps/erp/app/components/Halloween/scene.ts@@ -0,0 +1,308 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++// Geometry for the Halloween scene. Everything is generated from fixed seeds,+// so the scene is identical on every open. The scene's coordinates are a+// 1600 × 900 viewBox; the ground line sits around y 700–760.++/** mulberry32: a small seeded PRNG returning [0, 1). */+export function seededRandom(seed: number) {+ let state = seed >>> 0;+ return () => {+ state = (state + 0x6d2b79f5) >>> 0;+ let t = state;+ t = Math.imul(t ^ (t >>> 15), t | 1);+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;+ };+}++export type Star = {+ id: string;+ x: number;+ y: number;+ r: number;+ opacity: number;+ twinkle: number;+ delay: number;+};++export const STARS: Star[] = (() => {+ const rand = seededRandom(1031);+ return Array.from({ length: 110 }, (_, i) => ({+ id: `star-${i}`,+ x: rand() * 1600,+ y: rand() * rand() * 560,+ r: 0.5 + rand() * rand() * 1.6,+ opacity: 0.35 + rand() * 0.6,+ twinkle: 2 + rand() * 4,+ delay: rand() * 4+ }));+})();++/**+ * A cloud: a row of puffs, tallest in the middle, over a shallow sag. Each+ * puff is more than a half circle, so neighbours overlap like real billows.+ */+function cloudPath(width: number, height: number, seed: number) {+ const rand = seededRandom(seed);+ const puffs = 6;+ const step = width / puffs;+ let d = "M 0 0";+ for (let i = 0; i < puffs; i++) {+ const swell = 0.56 + 0.3 * Math.sin((Math.PI * (i + 0.5)) / puffs);+ const r = step * swell * (0.9 + rand() * 0.25);+ d += ` A ${r} ${r} 0 1 1 ${(i + 1) * step} 0`;+ }+ return `${d} Q ${width * 0.5} ${height} 0 0 Z`;+}++export const CLOUDS = [+ {+ id: "cloud-far-left",+ x: 40,+ y: 120,+ d: cloudPath(340, 22, 7),+ opacity: 0.4,+ drift: 70+ },+ {+ id: "cloud-far-mid",+ x: 560,+ y: 66,+ d: cloudPath(260, 18, 19),+ opacity: 0.32,+ drift: 85+ },+ {+ id: "cloud-moon",+ x: 1150,+ y: 322,+ d: cloudPath(300, 20, 41),+ opacity: 0.85,+ drift: 55+ }+];++/**+ * A gnarled dead tree, grown recursively. Branches of one depth share a+ * width, so each depth is drawn as a single stroked path.+ */+export const TREE = (() => {+ const rand = seededRandom(666);+ const baseX = 1432;+ const baseY = 790;+ const byDepth: string[] = [];+ const widths: number[] = [];+ let fork = { x: baseX, y: baseY };++ function grow(+ x: number,+ y: number,+ angle: number,+ length: number,+ width: number,+ level: number+ ) {+ const x2 = x + Math.cos(angle) * length;+ const y2 = y + Math.sin(angle) * length;+ // Bend each limb off its straight line, so no branch is a ruler stroke.+ const bend = (rand() - 0.5) * length * 0.42;+ const cx = (x + x2) / 2 - Math.sin(angle) * bend;+ const cy = (y + y2) / 2 + Math.cos(angle) * bend;+ byDepth[level] =+ `${byDepth[level] ?? ""} M ${x} ${y} Q ${cx} ${cy} ${x2} ${y2}`;+ widths[level] = width;+ if (level === 0) fork = { x: x2, y: y2 };+ if (level === 6) return;++ const children = level < 2 ? 2 : rand() < 0.3 ? 3 : 2;+ for (let i = 0; i < children; i++) {+ const spread = 0.42 + rand() * 0.38;+ const offset = (i - (children - 1) / 2) * spread * 1.3;+ // Gravity: limbs droop as they thin out.+ const droop = level > 2 ? 0.08 * level : 0;+ grow(+ x2,+ y2,+ angle + offset + (rand() - 0.5) * 0.35 + droop * Math.sign(offset),+ length * (0.66 + rand() * 0.14),+ width * 0.62,+ level + 1+ );+ }+ }++ grow(baseX, baseY, -Math.PI / 2 - 0.06, 165, 30, 0);++ return {+ branches: byDepth.map((d, level) => ({+ id: `tree-${level}`,+ d,+ width: widths[level]+ })),+ roots: `M ${baseX - 46} ${baseY + 6} C ${baseX - 26} ${baseY - 4}, ${baseX - 18} ${baseY - 22}, ${baseX - 14} ${baseY - 60} L ${baseX + 12} ${baseY - 60} C ${baseX + 16} ${baseY - 20}, ${baseX + 30} ${baseY - 2}, ${baseX + 54} ${baseY + 8} Z`,+ fork+ };+})();++/** A run of iron fence posts with spear tips, a few bent or missing. */+export const FENCE = (() => {+ const rand = seededRandom(13);+ const startX = 520;+ const count = 30;+ const gap = 16;+ const baseY = 712;+ const missing = new Set([9, 10, 21]);+ const posts = [];+ for (let i = 0; i < count; i++) {+ if (missing.has(i)) continue;+ const x = startX + i * gap;+ const tilt = i === 17 ? -14 : i === 4 ? 8 : (rand() - 0.5) * 3;+ posts.push({ id: `post-${i}`, x, tilt });+ }+ return {+ baseY,+ posts,+ rails: `M ${startX - 4} ${baseY - 40} L ${startX + 8.5 * gap} ${baseY - 41} M ${startX + 11 * gap} ${baseY - 39} L ${startX + (count - 1) * gap + 4} ${baseY - 40} M ${startX - 4} ${baseY - 14} L ${startX + (count - 1) * gap + 4} ${baseY - 13}`+ };+})();++export type GravestoneShape = "round" | "cross" | "arch";++export const GRAVESTONES: {+ id: string;+ x: number;+ y: number;+ scale: number;+ tilt: number;+ shape: GravestoneShape;+}[] = [+ { id: "stone-1", x: 640, y: 786, scale: 1, tilt: -6, shape: "round" },+ { id: "stone-2", x: 758, y: 792, scale: 0.78, tilt: 5, shape: "cross" },+ { id: "stone-3", x: 892, y: 782, scale: 1.12, tilt: -2, shape: "arch" },+ { id: "stone-4", x: 1052, y: 790, scale: 0.8, tilt: 9, shape: "round" }+];++/** Spiky grass tufts along the foreground, as one path. */+export const GRASS = (() => {+ const rand = seededRandom(404);+ let d = "";+ for (let x = 0; x < 1600; x += 9 + rand() * 14) {+ const base = 772 + Math.sin(x / 140) * 10;+ const height = 6 + rand() * 16;+ const lean = (rand() - 0.5) * 8;+ d += ` M ${x} ${base + 4} L ${x + 2 + lean} ${base - height} L ${x + 5} ${base + 4} Z`;+ }+ return d;+})();++export type BatFlight = {+ id: string;+ x: number[];+ y: number[];+ scale: number[];+ rotate: number[];+ duration: number;+ delay: number;+ flap: number;+};++// The tower top, where the colony bursts out.+const TOWER = { x: 437, y: 330 };++export const BATS: BatFlight[] = [+ // Far bats crossing the moon.+ {+ id: "bat-moon-1",+ x: [1040, 1230, 1420, 1760],+ y: [262, 200, 226, 160],+ scale: [0.22, 0.24, 0.25, 0.28],+ rotate: [0, -6, 4, -4],+ duration: 6.5,+ delay: 0.9,+ flap: 0.2+ },+ {+ id: "bat-moon-2",+ x: [1760, 1500, 1300, 980],+ y: [130, 180, 160, 206],+ scale: [0.2, 0.2, 0.18, 0.17],+ rotate: [0, 6, -4, 4],+ duration: 7,+ delay: 2.8,+ flap: 0.18+ },+ // The colony bursting out of the tower, flying at the viewer.+ {+ id: "bat-tower-1",+ x: [TOWER.x, 330, 170, -180],+ y: [TOWER.y, 240, 170, 60],+ scale: [0.08, 0.34, 0.7, 1.25],+ rotate: [0, -12, -6, -18],+ duration: 3.4,+ delay: 0.8,+ flap: 0.17+ },+ {+ id: "bat-tower-2",+ x: [TOWER.x, 620, 1050, 1780],+ y: [TOWER.y, 268, 236, 120],+ scale: [0.08, 0.3, 0.62, 1.15],+ rotate: [0, 10, 4, 12],+ duration: 4.2,+ delay: 1.2,+ flap: 0.2+ },+ {+ id: "bat-tower-3",+ x: [TOWER.x, 500, 620, 880],+ y: [TOWER.y, 210, 80, -200],+ scale: [0.08, 0.28, 0.6, 1.3],+ rotate: [0, 8, 14, 20],+ duration: 3.6,+ delay: 1.6,+ flap: 0.19+ },+ {+ id: "bat-tower-4",+ x: [TOWER.x, 300, 120, -200],+ y: [TOWER.y, 340, 400, 470],+ scale: [0.08, 0.32, 0.72, 1.4],+ rotate: [0, -8, -14, -10],+ duration: 3.9,+ delay: 2.2,+ flap: 0.16+ },+ {+ id: "bat-tower-5",+ x: [TOWER.x, 700, 1150, 1800],+ y: [TOWER.y, 380, 470, 560],+ scale: [0.08, 0.4, 0.95, 1.9],+ rotate: [0, 6, 10, 8],+ duration: 4.4,+ delay: 2.9,+ flap: 0.22+ },+ {+ id: "bat-tower-6",+ x: [TOWER.x, 420, 360, 220],+ y: [TOWER.y, 200, 40, -220],+ scale: [0.08, 0.3, 0.66, 1.2],+ rotate: [0, -4, -10, -16],+ duration: 3.5,+ delay: 3.6,+ flap: 0.18+ },+ {+ id: "bat-tower-7",+ x: [TOWER.x, 760, 1300, 1760],+ y: [TOWER.y, 300, 330, 300],+ scale: [0.08, 0.26, 0.5, 0.9],+ rotate: [0, 4, -4, 6],+ duration: 4.8,+ delay: 4.3,+ flap: 0.21+ }+];diff --git a/apps/erp/app/components/Halloween/season.ts b/apps/erp/app/components/Halloween/season.tsnew file mode 100644index 0000000000..008b720dae--- /dev/null+++ b/apps/erp/app/components/Halloween/season.ts@@ -0,0 +1,69 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { getLocalTimeZone, today } from "@internationalized/date";+import { useSyncExternalStore } from "react";++// When the decorations show, and the user's choice to hide them, shared by+// everything seasonal: the spider layer and the pumpkin in the breadcrumbs.+// It shows only from October 20 to November 1 in the user's own time zone,+// so it switches itself off on time.++export function isHalloweenSeason() {+ const date = today(getLocalTimeZone());+ return (+ (date.month === 10 && date.day >= 20) ||+ (date.month === 11 && date.day === 1)+ );+}++// Hiding lasts for this Halloween only, so next year's decorations show again.+function hiddenKey(userId: string) {+ return `halloween-hidden:${today(getLocalTimeZone()).year}:${userId}`;+}++const CHANGED = "halloween-hidden-changed";+// Hidden for this visit when storage refuses the write (private mode).+const hiddenThisVisit = new Set<string>();++function readHidden(userId: string) {+ if (hiddenThisVisit.has(userId)) return true;+ try {+ return window.localStorage.getItem(hiddenKey(userId)) === "true";+ } catch {+ return false;+ }+}++export function hideDecorations(userId: string) {+ hiddenThisVisit.add(userId);+ try {+ window.localStorage.setItem(hiddenKey(userId), "true");+ } catch {+ // Storage refused: hidden for this visit only.+ }+ window.dispatchEvent(new Event(CHANGED));+}++function subscribe(onChange: () => void) {+ window.addEventListener(CHANGED, onChange);+ // Hidden in another tab.+ window.addEventListener("storage", onChange);+ return () => {+ window.removeEventListener(CHANGED, onChange);+ window.removeEventListener("storage", onChange);+ };+}++/**+ * Whether the decorations show for this user now. False on the server: the+ * season and the stored choice are the browser's, decided after hydration.+ */+export function useHalloweenDecorations(userId: string) {+ return useSyncExternalStore(+ subscribe,+ () => isHalloweenSeason() && !readHidden(userId),+ () => false+ );+}diff --git a/apps/erp/app/components/Halloween/spider-rig.test.ts b/apps/erp/app/components/Halloween/spider-rig.test.tsnew file mode 100644index 0000000000..02bbeb191b--- /dev/null+++ b/apps/erp/app/components/Halloween/spider-rig.test.ts@@ -0,0 +1,120 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++import { describe, expect, it } from "vitest";+import type { Surface } from "./spider-rig";+import { createRig, LEGS, SPIDER_SCALE, solveKnee } from "./spider-rig";++// The page: a foot holds wherever it lands.+const page: Surface = {+ grip: (x, y) => ({ x, y, hold: null }),+ locate: () => ({ x: 0, y: 0 })+};++const DT = 1 / 120;++describe("solveKnee", () => {+ it("reaches the foot, with the knee along the leg and leaning out", () => {+ const hip = { x: 0, y: 0 };+ const foot = { x: 18, y: 4 };+ const outward = { x: 0, y: -1 };+ const { knee, end } = solveKnee(hip, foot, 11, 14, outward);+ expect(end.x).toBeCloseTo(18);+ expect(end.y).toBeCloseTo(4);+ // Between hip and foot, not stuck out to the side like an elbow...+ expect(knee.x).toBeGreaterThan(0);+ expect(knee.x).toBeLessThan(18);+ // ...and on the outward side of the line from hip to foot.+ const side = (knee.x * 4 - knee.y * 18) / Math.hypot(18, 4);+ expect(side).toBeGreaterThan(0);+ });++ it("stretches straight towards a foot out of reach", () => {+ const { end } = solveKnee({ x: 0, y: 0 }, { x: 100, y: 0 }, 11, 14, {+ x: 0,+ y: 1+ });+ expect(end.x).toBeCloseTo(25, 1);+ expect(end.y).toBeCloseTo(0);+ });+});++describe("createRig", () => {+ it("keeps every foot planted while the body holds still", () => {+ const rig = createRig();+ const body = { x: 100, y: 100, angle: 0 };+ rig.place(body, page);+ const placed = rig.feet();+ for (let i = 0; i < 240; i++) {+ rig.update(DT, body, { x: 0, y: 0 }, page, "walk");+ }+ expect(rig.stepping()).toBe(false);+ expect(rig.feet()).toEqual(placed);+ });++ it("walks with an alternating gait: four feet down, the groups taking turns", () => {+ const rig = createRig();+ const body = { x: 0, y: 0, angle: 0 };+ rig.place(body, page);+ // An unhurried walk: about four body lengths a second.+ const speed = 60 * SPIDER_SCALE;+ const steps = { 0: 0, 1: 0 };+ let wasUp = new Set<number>();+ for (let i = 0; i < 360; i++) {+ body.y += speed * DT;+ rig.update(DT, body, { x: 0, y: speed }, page, "walk");+ const up = new Set(+ rig+ .feet()+ .map((foot, leg) => (foot.stepping ? leg : -1))+ .filter((leg) => leg >= 0)+ );+ expect(up.size).toBeLessThanOrEqual(4);+ // Legs in the air at once all belong to the same group.+ expect(+ new Set([...up].map((leg) => LEGS[leg].group)).size+ ).toBeLessThanOrEqual(1);+ for (const leg of up) {+ if (!wasUp.has(leg)) steps[LEGS[leg].group]++;+ }+ wasUp = up;+ }+ // Over three seconds both groups have stepped, about equally often.+ expect(steps[0]).toBeGreaterThan(8);+ expect(steps[1]).toBeGreaterThan(8);+ expect(Math.abs(steps[0] - steps[1])).toBeLessThanOrEqual(4);+ });++ it("feet holding a thread go with it as it sways", () => {+ const rig = createRig();+ let sway = 0;+ const thread: Surface = {+ grip: (x, y) => ({ x, y, hold: { x, y } }),+ locate: (hold) => {+ const p = hold as { x: number; y: number };+ return { x: p.x + sway, y: p.y };+ }+ };+ const body = { x: 50, y: 50, angle: 0 };+ rig.place(body, thread);+ const before = rig.feet();+ sway = 2;+ rig.update(DT, body, { x: 0, y: 0 }, thread, "walk");+ rig.feet().forEach((foot, i) => {+ expect(foot.x).toBeCloseTo(before[i].x + 2);+ });+ });++ it("draws its legs in when it dangles", () => {+ const rig = createRig();+ const body = { x: 0, y: 0, angle: 0 };+ rig.place(body, page);+ const spread = Math.max(...rig.feet().map((f) => Math.hypot(f.x, f.y)));+ for (let i = 0; i < 120; i++) {+ rig.update(DT, body, { x: 0, y: 0 }, page, "curl");+ }+ const drawnIn = Math.max(...rig.feet().map((f) => Math.hypot(f.x, f.y)));+ expect(drawnIn).toBeLessThan(spread * 0.6);+ });+});diff --git a/apps/erp/app/components/Halloween/spider-rig.ts b/apps/erp/app/components/Halloween/spider-rig.tsnew file mode 100644index 0000000000..70b597e841--- /dev/null+++ b/apps/erp/app/components/Halloween/spider-rig.ts@@ -0,0 +1,353 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++// The spider's legs, animated the way real legs work rather than wiggled.+//+// Each foot grips something (a thread of the web, or the page) and stays put+// while the body moves over it. Once the body has drawn too far ahead of a+// foot, the leg lifts and swings it forward to a new grip. Spiders walk with+// an alternating tetrapod gait: legs 1 and 3 on one side step together with+// legs 2 and 4 on the other, then the other four, so four feet are always+// down. Each leg's knee is placed by two-bone inverse kinematics, bent+// outward and up as a spider's are.+//+// The body's own frame has the head along +y and the spider's right along+// +x; an angle of 0 points the head down the screen.++// Sized to sit in the top bar: about 20 px from fangs to spinnerets.+export const SPIDER_SCALE = 0.72;++type Vec = { x: number; y: number };++/** Whatever a foot is holding: the caller turns it back into a live point. */+export type Hold = unknown;++export type Surface = {+ /** The grip nearest a point: where the foot goes, and what it holds. */+ grip(x: number, y: number): { x: number; y: number; hold: Hold | null };+ /** Where a hold is now (the web sways, and the feet go with it). */+ locate(hold: Hold): Vec;+};++export type Body = { x: number; y: number; angle: number };++type LegSpec = {+ side: -1 | 1;+ hip: Vec;+ rest: Vec;+ bones: readonly [number, number];+ group: 0 | 1;+};++// Pairs I to IV, front to back, for the right side. Orb weavers reach well+// forward with I and II, hold III short and out to the side, and trail IV.+const PAIRS = [+ { hip: { x: 3.6, y: 2.8 }, rest: { x: 13.5, y: 17.5 }, bones: [10.5, 14] },+ { hip: { x: 4.4, y: 1 }, rest: { x: 18.5, y: 7.5 }, bones: [9.5, 13] },+ { hip: { x: 4.4, y: -0.9 }, rest: { x: 15, y: -5 }, bones: [6.8, 8.8] },+ { hip: { x: 3.7, y: -2.7 }, rest: { x: 11.5, y: -14.5 }, bones: [9, 12] }+] as const;++/** Legs 0–3 are the left side, I to IV; legs 4–7 the right. */+export const LEGS: LegSpec[] = ([-1, 1] as const).flatMap((side) =>+ PAIRS.map((pair, n) => ({+ side,+ hip: { x: pair.hip.x * side, y: pair.hip.y },+ rest: { x: pair.rest.x * side, y: pair.rest.y },+ bones: pair.bones,+ // Left I and III with right II and IV, then the other four.+ group: ((n + (side > 0 ? 1 : 0)) % 2) as 0 | 1+ }))+);++type Foot = {+ x: number;+ y: number;+ hold: Hold | null;+ stepping: boolean;+ fromX: number;+ fromY: number;+ toX: number;+ toY: number;+ toHold: Hold | null;+ t: number;+ duration: number;+};++export type LegPose = { hip: Vec; knee: Vec; ankle: Vec; foot: Vec };++// How far ahead of the body's motion a stepping foot aims, and the most that+// can be: a stride is never longer than a leg.+const LEAD = 0.11;+const MAX_LEAD = 9;+const smooth = (t: number) => t * t * (3 - 2 * t);++export function toWorld(body: Body, p: Vec): Vec {+ const cos = Math.cos(body.angle);+ const sin = Math.sin(body.angle);+ return {+ x: body.x + (p.x * cos - p.y * sin) * SPIDER_SCALE,+ y: body.y + (p.x * sin + p.y * cos) * SPIDER_SCALE+ };+}++// How far the leg's plane leans outward: seen from above, how much the+// raised knee shows off the line from hip to foot.+const SPLAY = 0.3;++/**+ * Two-bone IK with the knee raised towards the viewer, as a spider's is, then+ * seen from above. The knee sits along the line from hip to foot, leaning+ * out a little, so the leg reads as nearly straight with a gentle bend, the+ * way spiders look from above, rather than as an elbow stuck out sideways.+ */+export function solveKnee(+ hip: Vec,+ foot: Vec,+ upper: number,+ lower: number,+ outward: Vec+) {+ const dx = foot.x - hip.x;+ const dy = foot.y - hip.y;+ const reach = Math.hypot(dx, dy) || 1e-6;+ const d = Math.max(+ Math.abs(upper - lower) + 0.01,+ Math.min(upper + lower - 0.01, reach)+ );+ const ux = dx / reach;+ const uy = dy / reach;+ const along = (upper * upper - lower * lower + d * d) / (2 * d);+ const height = Math.sqrt(Math.max(0, upper * upper - along * along));+ // The side of the hip-to-foot line that faces away from the body.+ let px = -uy;+ let py = ux;+ if (px * outward.x + py * outward.y < 0) {+ px = -px;+ py = -py;+ }+ const knee = {+ x: hip.x + ux * along + px * height * SPLAY,+ y: hip.y + uy * along + py * height * SPLAY+ };+ // Out of reach, the leg points straight at the foot, fully stretched.+ const end = { x: hip.x + ux * d, y: hip.y + uy * d };+ return { knee, end, height, outwardSide: { x: px, y: py } };+}++export function createRig() {+ const feet: Foot[] = LEGS.map(() => ({+ x: 0,+ y: 0,+ hold: null,+ stepping: false,+ fromX: 0,+ fromY: 0,+ toX: 0,+ toY: 0,+ toHold: null,+ t: 0,+ duration: 0.1+ }));+ let nextGroup: 0 | 1 = 0;++ const restAt = (body: Body, i: number) => toWorld(body, LEGS[i].rest);+ const reachOf = (i: number) =>+ (LEGS[i].bones[0] + LEGS[i].bones[1]) * SPIDER_SCALE;++ function startStep(+ i: number,+ target: Vec,+ surface: Surface,+ speed: number,+ duration?: number+ ) {+ const foot = feet[i];+ const grip = surface.grip(target.x, target.y);+ foot.stepping = true;+ foot.fromX = foot.x;+ foot.fromY = foot.y;+ foot.toX = grip.x;+ foot.toY = grip.y;+ foot.toHold = grip.hold;+ foot.t = 0;+ // Quick steps when running, deliberate ones when creeping.+ foot.duration =+ duration ?? Math.max(0.05, Math.min(0.12, 0.12 - speed / 2000));+ }++ return {+ /** Put every foot straight down where it rests, gripping the surface. */+ place(body: Body, surface: Surface) {+ feet.forEach((foot, i) => {+ const p = restAt(body, i);+ const grip = surface.grip(p.x, p.y);+ foot.x = grip.x;+ foot.y = grip.y;+ foot.hold = grip.hold;+ foot.stepping = false;+ });+ },++ /**+ * Move the feet for this step of the body. "curl" draws the legs in, as a+ * spider dangling from a thread holds them.+ */+ update(+ dt: number,+ body: Body,+ velocity: Vec,+ surface: Surface,+ mode: "walk" | "curl"+ ) {+ const speed = Math.hypot(velocity.x, velocity.y);+ for (const foot of feet) {+ if (!foot.stepping && foot.hold !== null) {+ const p = surface.locate(foot.hold);+ foot.x = p.x;+ foot.y = p.y;+ }+ }++ if (mode === "curl") {+ const ease = Math.min(1, dt * 14);+ feet.forEach((foot, i) => {+ const rest = LEGS[i].rest;+ const p = toWorld(body, { x: rest.x * 0.42, y: rest.y * 0.42 + 2 });+ foot.x += (p.x - foot.x) * ease;+ foot.y += (p.y - foot.y) * ease;+ foot.hold = null;+ foot.stepping = false;+ });+ return;+ }++ // Feet already in the air carry on to where they were going, swinging+ // out and round rather than straight across under the body.+ const lateral = { x: Math.cos(body.angle), y: Math.sin(body.angle) };+ feet.forEach((foot, i) => {+ if (!foot.stepping) return;+ foot.t = Math.min(1, foot.t + dt / foot.duration);+ const to =+ foot.toHold !== null+ ? surface.locate(foot.toHold)+ : { x: foot.toX, y: foot.toY };+ const e = smooth(foot.t);+ const stride = Math.hypot(to.x - foot.fromX, to.y - foot.fromY);+ const swing =+ Math.sin(Math.PI * foot.t) *+ Math.min(5 * SPIDER_SCALE, stride * 0.35) *+ LEGS[i].side;+ foot.x = foot.fromX + (to.x - foot.fromX) * e + lateral.x * swing;+ foot.y = foot.fromY + (to.y - foot.fromY) * e + lateral.y * swing;+ if (foot.t >= 1) {+ foot.stepping = false;+ foot.hold = foot.toHold;+ foot.x = to.x;+ foot.y = to.y;+ }+ });++ const threshold = (speed > 6 ? 4.4 : 6.5) * SPIDER_SCALE;+ const lead = Math.min(+ LEAD,+ (MAX_LEAD * SPIDER_SCALE) / Math.max(speed, 1e-6)+ );+ const targets = feet.map((_, i) => {+ const p = restAt(body, i);+ return { x: p.x + velocity.x * lead, y: p.y + velocity.y * lead };+ });+ const error = feet.map((foot, i) =>+ Math.hypot(foot.x - targets[i].x, foot.y - targets[i].y)+ );++ if (!feet.some((foot) => foot.stepping)) {+ for (const group of [nextGroup, 1 - nextGroup] as const) {+ const due = LEGS.some(+ (leg, i) => leg.group === group && error[i] > threshold+ );+ if (!due) continue;+ LEGS.forEach((leg, i) => {+ if (leg.group === group && error[i] > threshold * 0.4) {+ startStep(i, targets[i], surface, speed);+ }+ });+ nextGroup = group === 0 ? 1 : 0;+ break;+ }+ }++ // Never leave a leg stretched past its reach, or trailing far behind+ // after a sharp turn or a sudden dash, whatever the gait says.+ let airborne = feet.filter((foot) => foot.stepping).length;+ feet.forEach((foot, i) => {+ if (foot.stepping || airborne >= 5) return;+ const hip = toWorld(body, LEGS[i].hip);+ const overstretched =+ Math.hypot(foot.x - hip.x, foot.y - hip.y) > reachOf(i) * 0.97;+ if (overstretched || error[i] > threshold * 3.2) {+ startStep(i, targets[i], surface, speed);+ airborne++;+ }+ });+ },++ /** Lift one leg and set it down again a little elsewhere: idle fussing. */+ fidget(i: number, body: Body, surface: Surface, nudge: Vec) {+ if (feet[i].stepping) return;+ const p = restAt(body, i);+ startStep(i, { x: p.x + nudge.x, y: p.y + nudge.y }, surface, 0, 0.22);+ },++ stepping() {+ return feet.some((foot) => foot.stepping);+ },++ feet() {+ return feet.map((foot) => ({+ x: foot.x,+ y: foot.y,+ stepping: foot.stepping+ }));+ },++ /** Hip, knee, ankle and foot of every leg, in page coordinates. */+ pose(body: Body): LegPose[] {+ const outwardRight = { x: Math.cos(body.angle), y: Math.sin(body.angle) };+ return LEGS.map((leg, i) => {+ const foot = feet[i];+ const hip = toWorld(body, leg.hip);+ // A foot in the air is lifted towards the viewer: seen from above, the+ // leg looks a little shorter mid-step.+ const lift = foot.stepping ? Math.sin(Math.PI * foot.t) * 0.14 : 0;+ const target = {+ x: foot.x + (hip.x - foot.x) * lift,+ y: foot.y + (hip.y - foot.y) * lift+ };+ const upper = leg.bones[0] * SPIDER_SCALE;+ const lower = leg.bones[1] * SPIDER_SCALE;+ const outward = {+ x: outwardRight.x * leg.side,+ y: outwardRight.y * leg.side+ };+ const { knee, end, height, outwardSide } = solveKnee(+ hip,+ target,+ upper,+ lower,+ outward+ );+ // The metatarsus comes down from the raised knee; near the foot the+ // tarsus hooks onto the thread, a small bend just short of the end.+ const ankle = {+ x: knee.x + (end.x - knee.x) * 0.74 + outwardSide.x * height * 0.08,+ y: knee.y + (end.y - knee.y) * 0.74 + outwardSide.y * height * 0.08+ };+ return { hip, knee, ankle, foot: end };+ });+ }+ };+}++export type Rig = ReturnType<typeof createRig>;diff --git a/apps/erp/app/components/Layout/Topbar/Breadcrumbs.tsx b/apps/erp/app/components/Layout/Topbar/Breadcrumbs.tsxindex a70a739b2a..9cf28304e9 100644--- a/apps/erp/app/components/Layout/Topbar/Breadcrumbs.tsx+++ b/apps/erp/app/components/Layout/Topbar/Breadcrumbs.tsx@@ -13,6 +13,8 @@ import {BreadcrumbLink,Breadcrumbs as BreadcrumbsBase} from "~/components";+import { PumpkinHomeIcon } from "~/components/Halloween/PumpkinHomeIcon";+import { useUser } from "~/hooks";import type { BreadcrumbSegment } from "~/utils/handle";import { path } from "~/utils/path";@@ -74,6 +76,7 @@ export function useBreadcrumbs() {const Breadcrumbs = () => {const { t } = useLingui();const breadcrumbs = useBreadcrumbs();+ const user = useUser();return (<HStack className="items-center h-full hidden md:flex -ml-2" spacing={0}>@@ -85,7 +88,12 @@ const Breadcrumbs = () => {to={path.to.authenticatedRoot}aria-label={t`Home`}>- <LuHouse className="size-4" />+ {/* Seasonal: remove after Halloween with components/Halloween/. */}+ <PumpkinHomeIcon+ userId={user?.id ?? ""}+ className="size-6"+ fallback={<LuHouse className="size-4" />}+ /></BreadcrumbLink></BreadcrumbItem>{breadcrumbs.map((breadcrumb, i) => (diff --git a/apps/erp/app/routes/x+/_layout.tsx b/apps/erp/app/routes/x+/_layout.tsxindex 39cd493563..cb0351b109 100644--- a/apps/erp/app/routes/x+/_layout.tsx+++ b/apps/erp/app/routes/x+/_layout.tsx@@ -63,6 +63,7 @@ import type {import { Await, data, Outlet, useLoaderData, useNavigate } from "react-router";import { RealtimeDataProvider } from "~/components";import ChangelogPanel from "~/components/ChangelogPanel";+import { HalloweenLayer } from "~/components/Halloween/HalloweenLayer";import {ModuleSidebarLayout,PrimaryNavigation,@@ -592,6 +593,8 @@ export default function AuthenticatedRoute() {/>)}</main>+ {/* Seasonal: remove after Halloween with components/Halloween/. */}+ <HalloweenLayer userId={user?.id ?? ""} />{isPhone && (<MobileBottomChrome><MobileDock />diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.poindex de4704f5b9..fc1f463dbc 100644--- a/packages/locale/locales/de/erp.po+++ b/packages/locale/locales/de/erp.po@@ -10953,6 +10953,9 @@ msgstr "Geführt"msgid "Guided implementation"msgstr "Geführte Umsetzung"+msgid "Halloween surprise"+msgstr "Halloween-Überraschung"+msgid "Handle recurring and reversing journal entries"msgstr "Wiederkehrende und stornierte Buchungssätze verwalten"@@ -10965,6 +10968,9 @@ msgstr "Praktisch"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "Praktische, schnelle Unterstützung für die ersten 3–4 Wochen"+msgid "Happy Halloween"+msgstr "Fröhliches Halloween"+msgid "Hard to see true cost or margin on a job"msgstr "Schwer zu sehen, was die wahren Kosten oder die Marge bei einem Auftrag sind"@@ -11004,6 +11010,9 @@ msgstr "Erneut ausblenden"msgid "Hide calculation"msgstr "Berechnung ausblenden"+msgid "Hide decorations"+msgstr "Dekoration ausblenden"+msgid "Hide documents and activity"msgstr "Dokumente und Aktivität ausblenden"@@ -17061,6 +17070,9 @@ msgstr "Bestellnummer"msgid "PO PDF"msgstr "PO PDF"+msgid "Poke the spider… if you dare"+msgstr "Stupsen Sie die Spinne an… wenn Sie sich trauen"+msgid "Policy"msgstr "Richtlinie"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "Etwas ist schief gelaufen. Bitte versuchen Sie es erneut."+msgid "Something wicked this way ships."+msgstr "Etwas Böses wird gerade ausgeliefert."+msgid "Soon"msgstr "Bald"diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.poindex 5eef1d1d13..f40e4fd98a 100644--- a/packages/locale/locales/en/erp.po+++ b/packages/locale/locales/en/erp.po@@ -10953,6 +10953,9 @@ msgstr "Guided"msgid "Guided implementation"msgstr "Guided implementation"+msgid "Halloween surprise"+msgstr "Halloween surprise"+msgid "Handle recurring and reversing journal entries"msgstr "Handle recurring and reversing journal entries"@@ -10965,6 +10968,9 @@ msgstr "Hands-on"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "Hands-on, fast-response support for the first 3–4 weeks"+msgid "Happy Halloween"+msgstr "Happy Halloween"+msgid "Hard to see true cost or margin on a job"msgstr "Hard to see true cost or margin on a job"@@ -11004,6 +11010,9 @@ msgstr "Hide Again"msgid "Hide calculation"msgstr "Hide calculation"+msgid "Hide decorations"+msgstr "Hide decorations"+msgid "Hide documents and activity"msgstr "Hide documents and activity"@@ -17061,6 +17070,9 @@ msgstr "PO Number"msgid "PO PDF"msgstr "PO PDF"+msgid "Poke the spider… if you dare"+msgstr "Poke the spider… if you dare"+msgid "Policy"msgstr "Policy"@@ -21424,6 +21436,9 @@ msgstr "Something went wrong"msgid "Something went wrong. Please try again."msgstr "Something went wrong. Please try again."+msgid "Something wicked this way ships."+msgstr "Something wicked this way ships."+msgid "Soon"msgstr "Soon"diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.poindex 3e67a3a822..85e6e4079a 100644--- a/packages/locale/locales/es/erp.po+++ b/packages/locale/locales/es/erp.po@@ -10953,6 +10953,9 @@ msgstr "Guiado"msgid "Guided implementation"msgstr "Implementación guiada"+msgid "Halloween surprise"+msgstr "Sorpresa de Halloween"+msgid "Handle recurring and reversing journal entries"msgstr "Gestionar asientos de diario recurrentes e inversores"@@ -10965,6 +10968,9 @@ msgstr "Práctico"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "Soporte práctico y de respuesta rápida durante las primeras 3–4 semanas"+msgid "Happy Halloween"+msgstr "Feliz Halloween"+msgid "Hard to see true cost or margin on a job"msgstr "Difícil ver el costo real o margen en un trabajo"@@ -11004,6 +11010,9 @@ msgstr "Ocultar de nuevo"msgid "Hide calculation"msgstr "Ocultar cálculo"+msgid "Hide decorations"+msgstr "Ocultar decoración"+msgid "Hide documents and activity"msgstr "Ocultar documentos y actividad"@@ -17061,6 +17070,9 @@ msgstr "Número de OC"msgid "PO PDF"msgstr "PDF de PO"+msgid "Poke the spider… if you dare"+msgstr "Toca la araña… si te atreves"+msgid "Policy"msgstr "Política"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "Algo salió mal. Por favor, inténtalo de nuevo."+msgid "Something wicked this way ships."+msgstr "Algo malvado se está enviando."+msgid "Soon"msgstr "Pronto"diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.poindex 8af07373f8..270a80f938 100644--- a/packages/locale/locales/fr/erp.po+++ b/packages/locale/locales/fr/erp.po@@ -10953,6 +10953,9 @@ msgstr "Guidé"msgid "Guided implementation"msgstr "Mise en œuvre guidée"+msgid "Halloween surprise"+msgstr "Surprise d'Halloween"+msgid "Handle recurring and reversing journal entries"msgstr "Gérer les écritures comptables récurrentes et contrepassées"@@ -10965,6 +10968,9 @@ msgstr "Pratique"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "Support pratique et réactif pendant les 3–4 premières semaines"+msgid "Happy Halloween"+msgstr "Joyeux Halloween"+msgid "Hard to see true cost or margin on a job"msgstr "Difficile de voir le vrai coût ou la marge sur un travail"@@ -11004,6 +11010,9 @@ msgstr "Masquer à nouveau"msgid "Hide calculation"msgstr "Masquer le calcul"+msgid "Hide decorations"+msgstr "Masquer les décorations"+msgid "Hide documents and activity"msgstr "Masquer les documents et l'activité"@@ -17061,6 +17070,9 @@ msgstr "Numéro de BC"msgid "PO PDF"msgstr "PDF BC"+msgid "Poke the spider… if you dare"+msgstr "Touchez l'araignée… si vous l'osez"+msgid "Policy"msgstr "Politique"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "Quelque chose s'est mal passé. Veuillez réessayer."+msgid "Something wicked this way ships."+msgstr "Quelque chose de maléfique est en cours d'expédition."+msgid "Soon"msgstr "Bientôt"diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.poindex a84cd16a2f..3b599c0404 100644--- a/packages/locale/locales/hi/erp.po+++ b/packages/locale/locales/hi/erp.po@@ -10953,6 +10953,9 @@ msgstr "निर्देशित"msgid "Guided implementation"msgstr "निर्देशित कार्यान्वयन"+msgid "Halloween surprise"+msgstr "हैलोवीन सरप्राइज़"+msgid "Handle recurring and reversing journal entries"msgstr "आवर्ती और उलट जर्नल प्रविष्टियों को संभालें"@@ -10965,6 +10968,9 @@ msgstr "हैंड्स-ऑन"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "पहले 3–4 हफ्तों के लिए व्यावहारिक, तेज़ प्रतिक्रिया समर्थन"+msgid "Happy Halloween"+msgstr "हैप्पी हैलोवीन"+msgid "Hard to see true cost or margin on a job"msgstr "किसी काम पर सच्ची लागत या मार्जिन देखना मुश्किल है"@@ -11004,6 +11010,9 @@ msgstr "फिर से छिपाएँ"msgid "Hide calculation"msgstr "गणना छिपाएं"+msgid "Hide decorations"+msgstr "सजावट छिपाएँ"+msgid "Hide documents and activity"msgstr "दस्तावेज़ और गतिविधि छिपाएं"@@ -17061,6 +17070,9 @@ msgstr "PO संख्या"msgid "PO PDF"msgstr "पीओ पीडीएफ"+msgid "Poke the spider… if you dare"+msgstr "मकड़ी को छुएँ… अगर हिम्मत है"+msgid "Policy"msgstr "नीति"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "कुछ गलत हो गया। कृपया पुनः प्रयास करें।"+msgid "Something wicked this way ships."+msgstr "कुछ डरावना शिप हो रहा है।"+msgid "Soon"msgstr "जल्द ही"diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.poindex dc8fa7789b..006b12ceab 100644--- a/packages/locale/locales/it/erp.po+++ b/packages/locale/locales/it/erp.po@@ -10953,6 +10953,9 @@ msgstr "Guidato"msgid "Guided implementation"msgstr "Implementazione guidata"+msgid "Halloween surprise"+msgstr "Sorpresa di Halloween"+msgid "Handle recurring and reversing journal entries"msgstr "Gestisci registrazioni di prima nota ricorrenti e di storno"@@ -10965,6 +10968,9 @@ msgstr "Pratico"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "Supporto pratico e a risposta rapida per le prime 3–4 settimane"+msgid "Happy Halloween"+msgstr "Buon Halloween"+msgid "Hard to see true cost or margin on a job"msgstr "Difficile vedere il vero costo o margine su un lavoro"@@ -11004,6 +11010,9 @@ msgstr "Nascondi di nuovo"msgid "Hide calculation"msgstr "Nascondi calcolo"+msgid "Hide decorations"+msgstr "Nascondi decorazioni"+msgid "Hide documents and activity"msgstr "Nascondi documenti e attività"@@ -17061,6 +17070,9 @@ msgstr "Numero OD"msgid "PO PDF"msgstr "PDF OdA"+msgid "Poke the spider… if you dare"+msgstr "Tocca il ragno… se hai il coraggio"+msgid "Policy"msgstr "Politica"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "Qualcosa è andato storto. Riprova."+msgid "Something wicked this way ships."+msgstr "Qualcosa di malvagio sta per essere spedito."+msgid "Soon"msgstr "Presto"diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.poindex 25572248d4..872921206a 100644--- a/packages/locale/locales/ja/erp.po+++ b/packages/locale/locales/ja/erp.po@@ -10953,6 +10953,9 @@ msgstr "ガイド付き"msgid "Guided implementation"msgstr "ガイド付き実施"+msgid "Halloween surprise"+msgstr "ハロウィンのサプライズ"+msgid "Handle recurring and reversing journal entries"msgstr "繰り返しおよび逆仕訳の処理"@@ -10965,6 +10968,9 @@ msgstr "ハンズオン"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "最初の3~4週間のハンズオン、迅速対応サポート"+msgid "Happy Halloween"+msgstr "ハッピーハロウィン"+msgid "Hard to see true cost or margin on a job"msgstr "ジョブの真の原価またはマージンを確認するのが難しい"@@ -11004,6 +11010,9 @@ msgstr "もう一度非表示"msgid "Hide calculation"msgstr "計算を隠す"+msgid "Hide decorations"+msgstr "飾りを非表示"+msgid "Hide documents and activity"msgstr "ドキュメントと活動を隠す"@@ -17061,6 +17070,9 @@ msgstr "発注番号"msgid "PO PDF"msgstr "PO PDF"+msgid "Poke the spider… if you dare"+msgstr "クモをつついてみて…勇気があれば"+msgid "Policy"msgstr "ポリシー"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "何か問題が発生しました。もう一度お試しください。"+msgid "Something wicked this way ships."+msgstr "何か邪悪なものが出荷されようとしている。"+msgid "Soon"msgstr "もうすぐ"diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.poindex 21aa3ea4cd..e154e334c4 100644--- a/packages/locale/locales/ko/erp.po+++ b/packages/locale/locales/ko/erp.po@@ -10953,6 +10953,9 @@ msgstr "가이드형"msgid "Guided implementation"msgstr "안내된 실행"+msgid "Halloween surprise"+msgstr "할로윈 깜짝 선물"+msgid "Handle recurring and reversing journal entries"msgstr "반복 및 역분개 전표 처리"@@ -10965,6 +10968,9 @@ msgstr "밀착형"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "첫 3–4주간 밀착형으로 신속하게 대응하는 지원"+msgid "Happy Halloween"+msgstr "해피 할로윈"+msgid "Hard to see true cost or margin on a job"msgstr "작업의 실제 원가나 마진을 파악하기 어려움"@@ -11004,6 +11010,9 @@ msgstr "다시 숨기기"msgid "Hide calculation"msgstr "계산 숨기기"+msgid "Hide decorations"+msgstr "장식 숨기기"+msgid "Hide documents and activity"msgstr "문서 및 활동 숨기기"@@ -17061,6 +17070,9 @@ msgstr "PO 번호"msgid "PO PDF"msgstr "PO PDF"+msgid "Poke the spider… if you dare"+msgstr "거미를 찔러 보세요… 용기가 있다면"+msgid "Policy"msgstr "정책"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "문제가 발생했습니다. 다시 시도해 주세요."+msgid "Something wicked this way ships."+msgstr "무언가 사악한 것이 출하되고 있습니다."+msgid "Soon"msgstr "곧"diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.poindex 2bc77be862..9dc9d7da71 100644--- a/packages/locale/locales/pl/erp.po+++ b/packages/locale/locales/pl/erp.po@@ -10953,6 +10953,9 @@ msgstr "Wspomagane"msgid "Guided implementation"msgstr "Wdrożenie z przewodnikiem"+msgid "Halloween surprise"+msgstr "Halloweenowa niespodzianka"+msgid "Handle recurring and reversing journal entries"msgstr "Obsługuj powtarzające się i odwracające dowody księgowe"@@ -10965,6 +10968,9 @@ msgstr "Praktyczne"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "Wsparcie praktyczne i szybko reagujące przez pierwsze 3–4 tygodnie"+msgid "Happy Halloween"+msgstr "Wesołego Halloween"+msgid "Hard to see true cost or margin on a job"msgstr "Trudno zobaczyć rzeczywisty koszt lub marżę na zleceniu"@@ -11004,6 +11010,9 @@ msgstr "Ukryj ponownie"msgid "Hide calculation"msgstr "Ukryj obliczenie"+msgid "Hide decorations"+msgstr "Ukryj dekoracje"+msgid "Hide documents and activity"msgstr "Ukryj dokumenty i aktywność"@@ -17061,6 +17070,9 @@ msgstr "Numer PZ"msgid "PO PDF"msgstr "PDF PO"+msgid "Poke the spider… if you dare"+msgstr "Szturchnij pająka… jeśli się odważysz"+msgid "Policy"msgstr "Polityka"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "Coś poszło nie tak. Spróbuj ponownie."+msgid "Something wicked this way ships."+msgstr "Coś złowrogiego właśnie wysyłamy."+msgid "Soon"msgstr "Wkrótce"diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.poindex 5171af5032..0ecc1aa0c3 100644--- a/packages/locale/locales/pt/erp.po+++ b/packages/locale/locales/pt/erp.po@@ -10953,6 +10953,9 @@ msgstr "Orientado"msgid "Guided implementation"msgstr "Implementação guiada"+msgid "Halloween surprise"+msgstr "Surpresa de Halloween"+msgid "Handle recurring and reversing journal entries"msgstr "Gerenciar lançamentos diários recorrentes e de reversão"@@ -10965,6 +10968,9 @@ msgstr "Prático"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "Suporte prático e de resposta rápida nas primeiras 3–4 semanas"+msgid "Happy Halloween"+msgstr "Feliz Halloween"+msgid "Hard to see true cost or margin on a job"msgstr "Difícil ver o custo real ou margem em um trabalho"@@ -11004,6 +11010,9 @@ msgstr "Ocultar Novamente"msgid "Hide calculation"msgstr "Ocultar cálculo"+msgid "Hide decorations"+msgstr "Ocultar decorações"+msgid "Hide documents and activity"msgstr "Ocultar documentos e atividade"@@ -17061,6 +17070,9 @@ msgstr "Número da PO"msgid "PO PDF"msgstr "PDF da PO"+msgid "Poke the spider… if you dare"+msgstr "Cutuque a aranha… se tiver coragem"+msgid "Policy"msgstr "Política"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "Algo deu errado. Tente novamente."+msgid "Something wicked this way ships."+msgstr "Algo maligno está sendo enviado."+msgid "Soon"msgstr "Em breve"diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.poindex f86d12edcc..fb8a689285 100644--- a/packages/locale/locales/ru/erp.po+++ b/packages/locale/locales/ru/erp.po@@ -10953,6 +10953,9 @@ msgstr "Управляемый"msgid "Guided implementation"msgstr "Управляемое внедрение"+msgid "Halloween surprise"+msgstr "Сюрприз на Хэллоуин"+msgid "Handle recurring and reversing journal entries"msgstr "Обработка повторяющихся и сторнирующих операций"@@ -10965,6 +10968,9 @@ msgstr "Практический"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "Практическая поддержка с быстрым ответом в течение первых 3–4 недель"+msgid "Happy Halloween"+msgstr "Счастливого Хэллоуина"+msgid "Hard to see true cost or margin on a job"msgstr "Сложно увидеть истинную себестоимость или маржу производственного заказа"@@ -11004,6 +11010,9 @@ msgstr "Скрыть снова"msgid "Hide calculation"msgstr "Скрыть расчет"+msgid "Hide decorations"+msgstr "Скрыть украшения"+msgid "Hide documents and activity"msgstr "Скрыть документы и деятельность"@@ -17061,6 +17070,9 @@ msgstr "Номер ПО"msgid "PO PDF"msgstr "ПО PDF"+msgid "Poke the spider… if you dare"+msgstr "Ткните паука… если осмелитесь"+msgid "Policy"msgstr "Политика"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "Что-то пошло не так. Пожалуйста, попробуйте еще раз."+msgid "Something wicked this way ships."+msgstr "Нечто зловещее уже в отгрузке."+msgid "Soon"msgstr "Скоро"diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.poindex d110ececf0..2b3e1dfb54 100644--- a/packages/locale/locales/tr/erp.po+++ b/packages/locale/locales/tr/erp.po@@ -10953,6 +10953,9 @@ msgstr "Rehberli"msgid "Guided implementation"msgstr "Rehberli uygulama"+msgid "Halloween surprise"+msgstr "Cadılar Bayramı sürprizi"+msgid "Handle recurring and reversing journal entries"msgstr "Tekrarlanan ve tersine çevirme muhasebe fişi girişlerini yönetin."@@ -10965,6 +10968,9 @@ msgstr "Uygulamalı"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "İlk 3–4 hafta boyunca uygulamalı, hızlı yanıt veren destek"+msgid "Happy Halloween"+msgstr "Mutlu Cadılar Bayramı"+msgid "Hard to see true cost or margin on a job"msgstr "Bir işte gerçek maliyeti veya marjı görmek zor"@@ -11004,6 +11010,9 @@ msgstr "Tekrar Gizle"msgid "Hide calculation"msgstr "Hesaplamayı Gizle"+msgid "Hide decorations"+msgstr "Süslemeleri gizle"+msgid "Hide documents and activity"msgstr "Belgeler ve aktiviteyi gizle"@@ -17061,6 +17070,9 @@ msgstr "PO Numarası"msgid "PO PDF"msgstr "PO PDF"+msgid "Poke the spider… if you dare"+msgstr "Örümceği dürt… cesaretin varsa"+msgid "Policy"msgstr "Politika"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "Bir şeyler ters gitti. Lütfen tekrar deneyin."+msgid "Something wicked this way ships."+msgstr "Kötü bir şey sevk ediliyor."+msgid "Soon"msgstr "Yakında"diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.poindex 7f83b9f0e6..9dafd0eff4 100644--- a/packages/locale/locales/zh/erp.po+++ b/packages/locale/locales/zh/erp.po@@ -10953,6 +10953,9 @@ msgstr "引导式"msgid "Guided implementation"msgstr "引导式实施"+msgid "Halloween surprise"+msgstr "万圣节惊喜"+msgid "Handle recurring and reversing journal entries"msgstr "处理循环和冲销凭证"@@ -10965,6 +10968,9 @@ msgstr "动手实践"msgid "Hands-on, fast-response support for the first 3–4 weeks"msgstr "动手操作、快速响应的支持,为期前3-4周"+msgid "Happy Halloween"+msgstr "万圣节快乐"+msgid "Hard to see true cost or margin on a job"msgstr "难以看清工作的真实成本或利润"@@ -11004,6 +11010,9 @@ msgstr "再次隐藏"msgid "Hide calculation"msgstr "隐藏计算"+msgid "Hide decorations"+msgstr "隐藏装饰"+msgid "Hide documents and activity"msgstr "隐藏文档和活动"@@ -17061,6 +17070,9 @@ msgstr "采购订单号"msgid "PO PDF"msgstr "采购订单 PDF"+msgid "Poke the spider… if you dare"+msgstr "戳一下蜘蛛……如果你敢的话"+msgid "Policy"msgstr "政策"@@ -21424,6 +21436,9 @@ msgstr ""msgid "Something went wrong. Please try again."msgstr "出现问题。请重试。"+msgid "Something wicked this way ships."+msgstr "有邪恶之物正在发货。"+msgid "Soon"msgstr "即将推出"