@threepipe/plugin-tweakpane
Version:
Tweakpane UI Plugin for ThreePipe
1 lines • 501 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../node_modules/tweakpane-image-plugin/dist/index.js","../node_modules/uiconfig-tweakpane/dist/index.mjs","../src/tpImageInputGenerator.ts","../src/TweakpaneUiPlugin.ts"],"sourcesContent":["function forceCast(v) {\n return v;\n}\n\nconst PREFIX = 'tp';\nfunction ClassName(viewName) {\n const fn = (opt_elementName, opt_modifier) => {\n return [\n PREFIX,\n '-',\n viewName,\n 'v',\n opt_elementName ? `_${opt_elementName}` : '',\n opt_modifier ? `-${opt_modifier}` : '',\n ].join('');\n };\n return fn;\n}\n\nfunction parseObject(value, keyToParserMap) {\n const keys = Object.keys(keyToParserMap);\n const result = keys.reduce((tmp, key) => {\n if (tmp === undefined) {\n return undefined;\n }\n const parser = keyToParserMap[key];\n const result = parser(value[key]);\n return result.succeeded\n ? Object.assign(Object.assign({}, tmp), { [key]: result.value }) : undefined;\n }, {});\n return forceCast(result);\n}\nfunction parseArray(value, parseItem) {\n return value.reduce((tmp, item) => {\n if (tmp === undefined) {\n return undefined;\n }\n const result = parseItem(item);\n if (!result.succeeded || result.value === undefined) {\n return undefined;\n }\n return [...tmp, result.value];\n }, []);\n}\nfunction isObject(value) {\n if (value === null) {\n return false;\n }\n return typeof value === 'object';\n}\nfunction createParamsParserBuilder(parse) {\n return (optional) => (v) => {\n if (!optional && v === undefined) {\n return {\n succeeded: false,\n value: undefined,\n };\n }\n if (optional && v === undefined) {\n return {\n succeeded: true,\n value: undefined,\n };\n }\n const result = parse(v);\n return result !== undefined\n ? {\n succeeded: true,\n value: result,\n }\n : {\n succeeded: false,\n value: undefined,\n };\n };\n}\nfunction createParamsParserBuilders(optional) {\n return {\n custom: (parse) => createParamsParserBuilder(parse)(optional),\n boolean: createParamsParserBuilder((v) => typeof v === 'boolean' ? v : undefined)(optional),\n number: createParamsParserBuilder((v) => typeof v === 'number' ? v : undefined)(optional),\n string: createParamsParserBuilder((v) => typeof v === 'string' ? v : undefined)(optional),\n function: createParamsParserBuilder((v) =>\n typeof v === 'function' ? v : undefined)(optional),\n constant: (value) => createParamsParserBuilder((v) => (v === value ? value : undefined))(optional),\n raw: createParamsParserBuilder((v) => v)(optional),\n object: (keyToParserMap) => createParamsParserBuilder((v) => {\n if (!isObject(v)) {\n return undefined;\n }\n return parseObject(v, keyToParserMap);\n })(optional),\n array: (itemParser) => createParamsParserBuilder((v) => {\n if (!Array.isArray(v)) {\n return undefined;\n }\n return parseArray(v, itemParser);\n })(optional),\n };\n}\nconst ParamsParsers = {\n optional: createParamsParserBuilders(true),\n required: createParamsParserBuilders(false),\n};\nfunction parseParams(value, keyToParserMap) {\n const result = ParamsParsers.required.object(keyToParserMap)(value);\n return result.succeeded ? result.value : undefined;\n}\n\nfunction createNumberFormatter(digits) {\n return (value) => {\n return value.toFixed(Math.max(Math.min(digits, 20), 0));\n };\n}\n\nconst innerFormatter = createNumberFormatter(0);\nfunction formatPercentage(value) {\n return innerFormatter(value) + '%';\n}\n\nfunction constrainRange(value, min, max) {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction removeAlphaComponent(comps) {\n return [comps[0], comps[1], comps[2]];\n}\n\nfunction zerofill(comp) {\n const hex = constrainRange(Math.floor(comp), 0, 255).toString(16);\n return hex.length === 1 ? `0${hex}` : hex;\n}\nfunction colorToHexRgbString(value, prefix = '#') {\n const hexes = removeAlphaComponent(value.getComponents('rgb'))\n .map(zerofill)\n .join('');\n return `${prefix}${hexes}`;\n}\nfunction colorToHexRgbaString(value, prefix = '#') {\n const rgbaComps = value.getComponents('rgb');\n const hexes = [rgbaComps[0], rgbaComps[1], rgbaComps[2], rgbaComps[3] * 255]\n .map(zerofill)\n .join('');\n return `${prefix}${hexes}`;\n}\nfunction colorToFunctionalRgbString(value, opt_type) {\n const formatter = createNumberFormatter(opt_type === 'float' ? 2 : 0);\n const comps = removeAlphaComponent(value.getComponents('rgb', opt_type)).map((comp) => formatter(comp));\n return `rgb(${comps.join(', ')})`;\n}\nfunction createFunctionalRgbColorFormatter(type) {\n return (value) => {\n return colorToFunctionalRgbString(value, type);\n };\n}\nfunction colorToFunctionalRgbaString(value, opt_type) {\n const aFormatter = createNumberFormatter(2);\n const rgbFormatter = createNumberFormatter(opt_type === 'float' ? 2 : 0);\n const comps = value.getComponents('rgb', opt_type).map((comp, index) => {\n const formatter = index === 3 ? aFormatter : rgbFormatter;\n return formatter(comp);\n });\n return `rgba(${comps.join(', ')})`;\n}\nfunction createFunctionalRgbaColorFormatter(type) {\n return (value) => {\n return colorToFunctionalRgbaString(value, type);\n };\n}\nfunction colorToFunctionalHslString(value) {\n const formatters = [\n createNumberFormatter(0),\n formatPercentage,\n formatPercentage,\n ];\n const comps = removeAlphaComponent(value.getComponents('hsl')).map((comp, index) => formatters[index](comp));\n return `hsl(${comps.join(', ')})`;\n}\nfunction colorToFunctionalHslaString(value) {\n const formatters = [\n createNumberFormatter(0),\n formatPercentage,\n formatPercentage,\n createNumberFormatter(2),\n ];\n const comps = value\n .getComponents('hsl')\n .map((comp, index) => formatters[index](comp));\n return `hsla(${comps.join(', ')})`;\n}\nfunction colorToObjectRgbString(value, type) {\n const formatter = createNumberFormatter(type === 'float' ? 2 : 0);\n const names = ['r', 'g', 'b'];\n const comps = removeAlphaComponent(value.getComponents('rgb', type)).map((comp, index) => `${names[index]}: ${formatter(comp)}`);\n return `{${comps.join(', ')}}`;\n}\nfunction createObjectRgbColorFormatter(type) {\n return (value) => colorToObjectRgbString(value, type);\n}\nfunction colorToObjectRgbaString(value, type) {\n const aFormatter = createNumberFormatter(2);\n const rgbFormatter = createNumberFormatter(type === 'float' ? 2 : 0);\n const names = ['r', 'g', 'b', 'a'];\n const comps = value.getComponents('rgb', type).map((comp, index) => {\n const formatter = index === 3 ? aFormatter : rgbFormatter;\n return `${names[index]}: ${formatter(comp)}`;\n });\n return `{${comps.join(', ')}}`;\n}\nfunction createObjectRgbaColorFormatter(type) {\n return (value) => colorToObjectRgbaString(value, type);\n}\n[\n {\n format: {\n alpha: false,\n mode: 'rgb',\n notation: 'hex',\n type: 'int',\n },\n stringifier: colorToHexRgbString,\n },\n {\n format: {\n alpha: true,\n mode: 'rgb',\n notation: 'hex',\n type: 'int',\n },\n stringifier: colorToHexRgbaString,\n },\n {\n format: {\n alpha: false,\n mode: 'hsl',\n notation: 'func',\n type: 'int',\n },\n stringifier: colorToFunctionalHslString,\n },\n {\n format: {\n alpha: true,\n mode: 'hsl',\n notation: 'func',\n type: 'int',\n },\n stringifier: colorToFunctionalHslaString,\n },\n ...['int', 'float'].reduce((prev, type) => {\n return [\n ...prev,\n {\n format: {\n alpha: false,\n mode: 'rgb',\n notation: 'func',\n type: type,\n },\n stringifier: createFunctionalRgbColorFormatter(type),\n },\n {\n format: {\n alpha: true,\n mode: 'rgb',\n notation: 'func',\n type: type,\n },\n stringifier: createFunctionalRgbaColorFormatter(type),\n },\n {\n format: {\n alpha: false,\n mode: 'rgb',\n notation: 'object',\n type: type,\n },\n stringifier: createObjectRgbColorFormatter(type),\n },\n {\n format: {\n alpha: true,\n mode: 'rgb',\n notation: 'object',\n type: type,\n },\n stringifier: createObjectRgbaColorFormatter(type),\n },\n ];\n }, []),\n];\n\nfunction createPlaceholderImage() {\n const canvas = document.createElement('canvas');\n canvas.width = 320;\n canvas.height = 50;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const ctx = canvas.getContext('2d');\n ctx.fillStyle = '#00000004';\n ctx.fillRect(0, 0, canvas.width, canvas.height);\n ctx.fillStyle = '#eee';\n ctx.font =\n '1.25rem \"Roboto Mono\", \"Source Code Pro\", Menlo, Courier, monospace';\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.fillText('No image', canvas.width * 0.5, canvas.height * 0.5);\n const image = new Image();\n // if (!blob) {\n // \tresolve(image);\n // \treturn;\n // }\n image.src = canvas.toDataURL('image/png', 0.8);\n image.isPlaceholder = true;\n // image.onload = () => {\n // \tresolve(image);\n // };\n return image;\n}\nfunction loadImage(src) {\n const image = new Image();\n image.crossOrigin = 'anonymous';\n image.src = src;\n // image.onload = () => {\n // };\n // image.onerror = reject;\n return image;\n}\n\nconst className = ClassName('img');\nclass PluginView {\n constructor(doc, config) {\n this.element = doc.createElement('div');\n this.element.classList.add(className());\n config.viewProps.bindClassModifiers(this.element);\n this.input = doc.createElement('input');\n this.input.classList.add(className('input'));\n this.input.setAttribute('type', 'file');\n this.input.setAttribute('accept', config.extensions.join(','));\n this.image_ = doc.createElement('img');\n this.image_.id = 'tpimg_' + Math.random().toString(36).slice(2); // need unique for drop\n this.image_.classList.add(className('image'));\n this.image_.classList.add(className(`image_${config.imageFit}`));\n this.image_.crossOrigin = 'anonymous';\n this.image_.onclick = (event) => {\n config.clickCallback\n ? config.clickCallback(event, this.input)\n : this.input.click();\n };\n this.element.classList.add(className('area_root'));\n this.element.appendChild(this.image_);\n this.element.appendChild(this.input);\n }\n changeImage(src) {\n this.image_.src = src;\n }\n changeDraggingState(state) {\n const el = this.element;\n if (state) {\n el === null || el === void 0 ? void 0 : el.classList.add(className('area_dragging'));\n }\n else {\n el === null || el === void 0 ? void 0 : el.classList.remove(className('area_dragging'));\n }\n }\n}\n\nlet placeholderImage = null;\nclass PluginController {\n constructor(doc, config) {\n this.value = config.value;\n this.viewProps = config.viewProps;\n this.view = new PluginView(doc, {\n viewProps: this.viewProps,\n extensions: config.extensions,\n imageFit: config.imageFit,\n clickCallback: config.clickCallback,\n });\n this.onFile = this.onFile.bind(this);\n this.onDrop = this.onDrop.bind(this);\n this.onDragStart = this.onDragStart.bind(this);\n this.onDragOver = this.onDragOver.bind(this);\n this.onDragLeave = this.onDragLeave.bind(this);\n this.view.input.addEventListener('change', this.onFile);\n this.view.element.addEventListener('drop', this.onDrop);\n this.view.element.addEventListener('dragstart', this.onDragStart);\n this.view.element.addEventListener('dragover', this.onDragOver);\n this.view.element.addEventListener('dragleave', this.onDragLeave);\n this.viewProps.handleDispose(() => {\n this.view.input.removeEventListener('change', this.onFile);\n this.view.element.removeEventListener('drop', this.onDrop);\n this.view.element.removeEventListener('dragstart', this.onDragStart);\n this.view.element.removeEventListener('dragover', this.onDragOver);\n this.view.element.removeEventListener('dragleave', this.onDragLeave);\n });\n this.value.emitter.on('change', () => this.handleValueChange());\n this.handleValueChange();\n }\n onFile(event) {\n const files = (event === null || event === void 0 ? void 0 : event.target).files;\n if (!files || !files.length)\n return;\n const file = files[0];\n this.setValue(file);\n // this.updateImage(url);\n }\n onDrop(event) {\n event.preventDefault();\n try {\n const { dataTransfer } = event;\n const file = dataTransfer === null || dataTransfer === void 0 ? void 0 : dataTransfer.files[0];\n if (file) {\n // const url = URL.createObjectURL(file);\n // this.updateImage(url);\n this.setValue(file);\n }\n else {\n const imgId = dataTransfer === null || dataTransfer === void 0 ? void 0 : dataTransfer.getData('img-id');\n if (imgId) {\n const img = document.getElementById(imgId);\n this.setValue(img);\n }\n else {\n const url = dataTransfer === null || dataTransfer === void 0 ? void 0 : dataTransfer.getData('url');\n if (!url)\n throw new Error('No url');\n this.setValue(url);\n }\n // loadImage(url).then(async (image) => {\n // \tconsole.log('drop', image);\n // \tconst clone = await cloneImage(image);\n // \t// this.updateImage(clone.src);\n // \tthis.setValue(clone);\n // });\n }\n }\n catch (e) {\n console.error('Could not parse the dropped image', e);\n }\n finally {\n this.view.changeDraggingState(false);\n }\n }\n onDragStart(event) {\n var _a, _b;\n (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.setData('img-id', this.view.image_.id);\n (_b = event.dataTransfer) === null || _b === void 0 ? void 0 : _b.setDragImage(this.view.image_, 0, 0);\n }\n onDragOver(event) {\n event.preventDefault();\n this.view.changeDraggingState(true);\n }\n onDragLeave() {\n this.view.changeDraggingState(false);\n }\n handleImage(image) {\n if (image instanceof HTMLImageElement) {\n this.updateImage(image.src);\n }\n else if (typeof image === 'string' || !image) {\n if (image === 'placeholder' || !image) {\n image = this.handlePlaceholderImage().src;\n }\n this.updateImage(image);\n }\n else {\n this.setValue(image);\n }\n }\n updateImage(src) {\n this.view.changeImage(src);\n }\n setValue(src) {\n if (src instanceof HTMLImageElement) {\n this.value.setRawValue(src);\n }\n else if (src instanceof File) {\n const url = URL.createObjectURL(src) + '#' + src.name;\n src.src = url;\n const img = loadImage(url);\n // \t.catch(() => {\n // \t// URL.revokeObjectURL(url);\n // });\n // URL.revokeObjectURL(url); //todo: revoke sometime.\n this.value.setRawValue(img || src);\n }\n else if (src) {\n this.value.setRawValue(loadImage(src));\n }\n else {\n this.value.setRawValue(this.handlePlaceholderImage());\n }\n }\n handleValueChange() {\n this.handleImage(this.value.rawValue);\n }\n handlePlaceholderImage() {\n if (!placeholderImage) {\n placeholderImage = createPlaceholderImage();\n }\n return placeholderImage;\n }\n}\n\nconst DEFAULT_EXTENSIONS = ['.jpg', '.png', '.gif'];\nconst TweakpaneImagePlugin = {\n id: 'input-image',\n type: 'input',\n css: '.tp-imgv{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-imgv{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-imgv:hover{background-color:var(--in-bg-h)}.tp-imgv:focus{background-color:var(--in-bg-f)}.tp-imgv:active{background-color:var(--in-bg-a)}.tp-imgv:disabled{opacity:.5}:root{--tp-plugin-image-dragging-color: hsla(230, 100%, 66%, 1.00)}.tp-imgv{cursor:pointer;display:inline-flex;height:auto !important;max-height:calc(var(--bld-us)*3);border-radius:4px;position:relative}.tp-imgv.tp-v-disabled{opacity:.5}.tp-imgv_input{width:0;height:0;pointer-events:none;visibility:hidden}.tp-imgv_image{width:100%;height:-moz-max-content;height:max-content;max-height:calc(var(--bld-us)*3);border:0}.tp-imgv_image_contain{-o-object-fit:contain;object-fit:contain}.tp-imgv_image_cover{-o-object-fit:cover;object-fit:cover}.tp-imgv_area_root{transition:opacity .16s ease-in-out}.tp-imgv_area_dragging{border:2px dashed var(--tp-plugin-image-dragging-color);border-radius:4px;opacity:.6}',\n accept(exValue, params) {\n if (!(exValue instanceof HTMLImageElement || typeof exValue === 'string')) {\n return null;\n }\n const p = ParamsParsers;\n const result = parseParams(params, {\n view: p.required.constant('input-image'),\n acceptUrl: p.optional.boolean,\n clickCallback: p.optional.function,\n imageFit: p.optional.custom((v) => v === 'contain' || v === 'cover' ? v : undefined),\n extensions: p.optional.array(p.required.string),\n });\n if (!result) {\n return null;\n }\n return {\n initialValue: exValue,\n params: result,\n };\n },\n binding: {\n reader(_args) {\n return (exValue) => {\n if (exValue.src !== undefined) {\n return exValue.src === '' ? 'placeholder' : exValue.src;\n }\n else {\n return typeof exValue === 'string' ? exValue : exValue;\n }\n };\n },\n writer(_args) {\n return (target, inValue) => {\n target.write(inValue);\n };\n },\n },\n controller(args) {\n var _a, _b;\n return new PluginController(args.document, {\n value: args.value,\n imageFit: (_a = args.params.imageFit) !== null && _a !== void 0 ? _a : 'cover',\n clickCallback: args.params.clickCallback,\n viewProps: args.viewProps,\n extensions: (_b = args.params.extensions) !== null && _b !== void 0 ? _b : DEFAULT_EXTENSIONS,\n });\n },\n};\n\nconst plugin = TweakpaneImagePlugin;\n\nexport { plugin };\n//# sourceMappingURL=index.js.map\n","/**\n * @license\n * uiconfig-tweakpane v0.0.10\n * Copyright 2022-2024 repalash <palash@shaders.app>\n * MIT License\n * See ./dependencies.txt for bundled third-party dependencies and licenses.\n */\n/**\n * @license\n * ts-browser-helpers v0.16.0\n * Copyright 2022-2024 repalash <palash@shaders.app>\n * MIT License\n * See ./dependencies.txt for bundled third-party dependencies and licenses.\n */\nfunction ua({ innerHTML: u = \"\", id: s, classList: o, addToBody: p = !0, elementTag: l = \"div\" }) {\n const c = document.createElement(l);\n return s && (c.id = s), c.innerHTML = u, o && c.classList.add(...o), p && document.body.appendChild(c), c;\n}\nfunction ca(u, s = document.head) {\n const o = document.createElement(\"style\");\n return o.type = \"text/css\", o.innerText = u, s == null || s.appendChild(o), o;\n}\nconst ha = (u, ...s) => String.raw({ raw: u }, ...s);\nfunction va(u, s) {\n let o;\n do\n o = Object.getOwnPropertyDescriptor(u, s);\n while (!o && (u = Object.getPrototypeOf(u)));\n return o;\n}\nfunction ma(u, s, o = !0, p = !1) {\n const l = va(u, s);\n return !!(l != null && l.set) || o && (l == null ? void 0 : l.writable) !== !1 && (l == null ? void 0 : l.get) === void 0 || p && !l;\n}\nfunction ba(u, s, o, p = !0, l = !1) {\n return u && ma(u, s, p, l) ? (u[s] = o, !0) : !1;\n}\nfunction $(u, ...s) {\n return typeof u == \"function\" && (u = u(...s)), u;\n}\nfunction fa(u, s) {\n return Object.hasOwn ? Object.hasOwn(u, s) : u.hasOwnProperty(s);\n}\nvar _a = typeof globalThis < \"u\" ? globalThis : typeof window < \"u\" ? window : typeof global < \"u\" ? global : typeof self < \"u\" ? self : {}, Xe = { exports: {} };\n/*! Tweakpane 3.1.10 (c) 2016 cocopon, licensed under the MIT license. */\n(function(u, s) {\n (function(o, p) {\n p(s);\n })(_a, function(o) {\n class p {\n /**\n * @hidden\n */\n constructor(t) {\n const [e, i] = t.split(\"-\"), r = e.split(\".\");\n this.major = parseInt(r[0], 10), this.minor = parseInt(r[1], 10), this.patch = parseInt(r[2], 10), this.prerelease = i ?? null;\n }\n toString() {\n const t = [this.major, this.minor, this.patch].join(\".\");\n return this.prerelease !== null ? [t, this.prerelease].join(\"-\") : t;\n }\n }\n class l {\n constructor(t) {\n this.controller_ = t;\n }\n get element() {\n return this.controller_.view.element;\n }\n get disabled() {\n return this.controller_.viewProps.get(\"disabled\");\n }\n set disabled(t) {\n this.controller_.viewProps.set(\"disabled\", t);\n }\n get hidden() {\n return this.controller_.viewProps.get(\"hidden\");\n }\n set hidden(t) {\n this.controller_.viewProps.set(\"hidden\", t);\n }\n dispose() {\n this.controller_.viewProps.set(\"disposed\", !0);\n }\n }\n class c {\n constructor(t) {\n this.target = t;\n }\n }\n class v extends c {\n constructor(t, e, i, r) {\n super(t), this.value = e, this.presetKey = i, this.last = r ?? !0;\n }\n }\n class w extends c {\n constructor(t, e, i) {\n super(t), this.value = e, this.presetKey = i;\n }\n }\n class b extends c {\n constructor(t, e) {\n super(t), this.expanded = e;\n }\n }\n class S extends c {\n constructor(t, e) {\n super(t), this.index = e;\n }\n }\n function O(n) {\n return n;\n }\n function g(n) {\n return n == null;\n }\n function P(n, t) {\n if (n.length !== t.length)\n return !1;\n for (let e = 0; e < n.length; e++)\n if (n[e] !== t[e])\n return !1;\n return !0;\n }\n function y(n, t) {\n let e = n;\n do {\n const i = Object.getOwnPropertyDescriptor(e, t);\n if (i && (i.set !== void 0 || i.writable === !0))\n return !0;\n e = Object.getPrototypeOf(e);\n } while (e !== null);\n return !1;\n }\n const A = {\n alreadydisposed: () => \"View has been already disposed\",\n invalidparams: (n) => `Invalid parameters for '${n.name}'`,\n nomatchingcontroller: (n) => `No matching controller for '${n.key}'`,\n nomatchingview: (n) => `No matching view for '${JSON.stringify(n.params)}'`,\n notbindable: () => \"Value is not bindable\",\n propertynotfound: (n) => `Property '${n.name}' not found`,\n shouldneverhappen: () => \"This error should never happen\"\n };\n class _ {\n static alreadyDisposed() {\n return new _({ type: \"alreadydisposed\" });\n }\n static notBindable() {\n return new _({\n type: \"notbindable\"\n });\n }\n static propertyNotFound(t) {\n return new _({\n type: \"propertynotfound\",\n context: {\n name: t\n }\n });\n }\n static shouldNeverHappen() {\n return new _({ type: \"shouldneverhappen\" });\n }\n constructor(t) {\n var e;\n this.message = (e = A[t.type](t.context)) !== null && e !== void 0 ? e : \"Unexpected error\", this.name = this.constructor.name, this.stack = new Error(this.message).stack, this.type = t.type;\n }\n }\n class L {\n constructor(t, e, i) {\n this.obj_ = t, this.key_ = e, this.presetKey_ = i ?? e;\n }\n static isBindable(t) {\n return !(t === null || typeof t != \"object\" && typeof t != \"function\");\n }\n get key() {\n return this.key_;\n }\n get presetKey() {\n return this.presetKey_;\n }\n read() {\n return this.obj_[this.key_];\n }\n write(t) {\n this.obj_[this.key_] = t;\n }\n writeProperty(t, e) {\n const i = this.read();\n if (!L.isBindable(i))\n throw _.notBindable();\n if (!(t in i))\n throw _.propertyNotFound(t);\n i[t] = e;\n }\n }\n class et extends l {\n get label() {\n return this.controller_.props.get(\"label\");\n }\n set label(t) {\n this.controller_.props.set(\"label\", t);\n }\n get title() {\n var t;\n return (t = this.controller_.valueController.props.get(\"title\")) !== null && t !== void 0 ? t : \"\";\n }\n set title(t) {\n this.controller_.valueController.props.set(\"title\", t);\n }\n on(t, e) {\n const i = e.bind(this);\n return this.controller_.valueController.emitter.on(t, () => {\n i(new c(this));\n }), this;\n }\n }\n class M {\n constructor() {\n this.observers_ = {};\n }\n on(t, e) {\n let i = this.observers_[t];\n return i || (i = this.observers_[t] = []), i.push({\n handler: e\n }), this;\n }\n off(t, e) {\n const i = this.observers_[t];\n return i && (this.observers_[t] = i.filter((r) => r.handler !== e)), this;\n }\n emit(t, e) {\n const i = this.observers_[t];\n i && i.forEach((r) => {\n r.handler(e);\n });\n }\n }\n const Qt = \"tp\";\n function E(n) {\n return (e, i) => [\n Qt,\n \"-\",\n n,\n \"v\",\n e ? `_${e}` : \"\",\n i ? `-${i}` : \"\"\n ].join(\"\");\n }\n function ki(n, t) {\n return (e) => t(n(e));\n }\n function Vi(n) {\n return n.rawValue;\n }\n function Y(n, t) {\n n.emitter.on(\"change\", ki(Vi, t)), t(n.rawValue);\n }\n function H(n, t, e) {\n Y(n.value(t), e);\n }\n function Si(n, t, e) {\n e ? n.classList.add(t) : n.classList.remove(t);\n }\n function ft(n, t) {\n return (e) => {\n Si(n, t, e);\n };\n }\n function ce(n, t) {\n Y(n, (e) => {\n t.textContent = e ?? \"\";\n });\n }\n const he = E(\"btn\");\n class Li {\n constructor(t, e) {\n this.element = t.createElement(\"div\"), this.element.classList.add(he()), e.viewProps.bindClassModifiers(this.element);\n const i = t.createElement(\"button\");\n i.classList.add(he(\"b\")), e.viewProps.bindDisabled(i), this.element.appendChild(i), this.buttonElement = i;\n const r = t.createElement(\"div\");\n r.classList.add(he(\"t\")), ce(e.props.value(\"title\"), r), this.buttonElement.appendChild(r);\n }\n }\n class Ze {\n constructor(t, e) {\n this.emitter = new M(), this.onClick_ = this.onClick_.bind(this), this.props = e.props, this.viewProps = e.viewProps, this.view = new Li(t, {\n props: this.props,\n viewProps: this.viewProps\n }), this.view.buttonElement.addEventListener(\"click\", this.onClick_);\n }\n onClick_() {\n this.emitter.emit(\"click\", {\n sender: this\n });\n }\n }\n class Ai {\n constructor(t, e) {\n var i;\n this.constraint_ = e == null ? void 0 : e.constraint, this.equals_ = (i = e == null ? void 0 : e.equals) !== null && i !== void 0 ? i : (r, a) => r === a, this.emitter = new M(), this.rawValue_ = t;\n }\n get constraint() {\n return this.constraint_;\n }\n get rawValue() {\n return this.rawValue_;\n }\n set rawValue(t) {\n this.setRawValue(t, {\n forceEmit: !1,\n last: !0\n });\n }\n setRawValue(t, e) {\n const i = e ?? {\n forceEmit: !1,\n last: !0\n }, r = this.constraint_ ? this.constraint_.constrain(t) : t, a = this.rawValue_;\n this.equals_(a, r) && !i.forceEmit || (this.emitter.emit(\"beforechange\", {\n sender: this\n }), this.rawValue_ = r, this.emitter.emit(\"change\", {\n options: i,\n previousRawValue: a,\n rawValue: r,\n sender: this\n }));\n }\n }\n class Mi {\n constructor(t) {\n this.emitter = new M(), this.value_ = t;\n }\n get rawValue() {\n return this.value_;\n }\n set rawValue(t) {\n this.setRawValue(t, {\n forceEmit: !1,\n last: !0\n });\n }\n setRawValue(t, e) {\n const i = e ?? {\n forceEmit: !1,\n last: !0\n }, r = this.value_;\n r === t && !i.forceEmit || (this.emitter.emit(\"beforechange\", {\n sender: this\n }), this.value_ = t, this.emitter.emit(\"change\", {\n options: i,\n previousRawValue: r,\n rawValue: this.value_,\n sender: this\n }));\n }\n }\n function N(n, t) {\n const e = t == null ? void 0 : t.constraint, i = t == null ? void 0 : t.equals;\n return !e && !i ? new Mi(n) : new Ai(n, t);\n }\n class C {\n constructor(t) {\n this.emitter = new M(), this.valMap_ = t;\n for (const e in this.valMap_)\n this.valMap_[e].emitter.on(\"change\", () => {\n this.emitter.emit(\"change\", {\n key: e,\n sender: this\n });\n });\n }\n static createCore(t) {\n return Object.keys(t).reduce((i, r) => Object.assign(i, {\n [r]: N(t[r])\n }), {});\n }\n static fromObject(t) {\n const e = this.createCore(t);\n return new C(e);\n }\n get(t) {\n return this.valMap_[t].rawValue;\n }\n set(t, e) {\n this.valMap_[t].rawValue = e;\n }\n value(t) {\n return this.valMap_[t];\n }\n }\n function Ri(n, t) {\n const i = Object.keys(t).reduce((r, a) => {\n if (r === void 0)\n return;\n const d = t[a], h = d(n[a]);\n return h.succeeded ? Object.assign(Object.assign({}, r), { [a]: h.value }) : void 0;\n }, {});\n return i;\n }\n function Di(n, t) {\n return n.reduce((e, i) => {\n if (e === void 0)\n return;\n const r = t(i);\n if (!(!r.succeeded || r.value === void 0))\n return [...e, r.value];\n }, []);\n }\n function Oi(n) {\n return n === null ? !1 : typeof n == \"object\";\n }\n function Q(n) {\n return (t) => (e) => {\n if (!t && e === void 0)\n return {\n succeeded: !1,\n value: void 0\n };\n if (t && e === void 0)\n return {\n succeeded: !0,\n value: void 0\n };\n const i = n(e);\n return i !== void 0 ? {\n succeeded: !0,\n value: i\n } : {\n succeeded: !1,\n value: void 0\n };\n };\n }\n function Je(n) {\n return {\n custom: (t) => Q(t)(n),\n boolean: Q((t) => typeof t == \"boolean\" ? t : void 0)(n),\n number: Q((t) => typeof t == \"number\" ? t : void 0)(n),\n string: Q((t) => typeof t == \"string\" ? t : void 0)(n),\n function: Q((t) => typeof t == \"function\" ? t : void 0)(n),\n constant: (t) => Q((e) => e === t ? t : void 0)(n),\n raw: Q((t) => t)(n),\n object: (t) => Q((e) => {\n if (Oi(e))\n return Ri(e, t);\n })(n),\n array: (t) => Q((e) => {\n if (Array.isArray(e))\n return Di(e, t);\n })(n)\n };\n }\n const R = {\n optional: Je(!0),\n required: Je(!1)\n };\n function I(n, t) {\n const e = R.required.object(t)(n);\n return e.succeeded ? e.value : void 0;\n }\n function ve(n) {\n console.warn([\n `Missing '${n.key}' of ${n.target} in ${n.place}.`,\n \"Please rebuild plugins with the latest core package.\"\n ].join(\" \"));\n }\n function Ti(n) {\n return n && n.parentElement && n.parentElement.removeChild(n), null;\n }\n class me {\n constructor(t) {\n this.value_ = t;\n }\n static create(t) {\n return [\n new me(t),\n (e, i) => {\n t.setRawValue(e, i);\n }\n ];\n }\n get emitter() {\n return this.value_.emitter;\n }\n get rawValue() {\n return this.value_.rawValue;\n }\n }\n const Ni = E(\"\");\n function tn(n, t) {\n return ft(n, Ni(void 0, t));\n }\n class W extends C {\n constructor(t) {\n var e;\n super(t), this.onDisabledChange_ = this.onDisabledChange_.bind(this), this.onParentChange_ = this.onParentChange_.bind(this), this.onParentGlobalDisabledChange_ = this.onParentGlobalDisabledChange_.bind(this), [this.globalDisabled_, this.setGlobalDisabled_] = me.create(N(this.getGlobalDisabled_())), this.value(\"disabled\").emitter.on(\"change\", this.onDisabledChange_), this.value(\"parent\").emitter.on(\"change\", this.onParentChange_), (e = this.get(\"parent\")) === null || e === void 0 || e.globalDisabled.emitter.on(\"change\", this.onParentGlobalDisabledChange_);\n }\n static create(t) {\n var e, i, r;\n const a = t ?? {};\n return new W(C.createCore({\n disabled: (e = a.disabled) !== null && e !== void 0 ? e : !1,\n disposed: !1,\n hidden: (i = a.hidden) !== null && i !== void 0 ? i : !1,\n parent: (r = a.parent) !== null && r !== void 0 ? r : null\n }));\n }\n get globalDisabled() {\n return this.globalDisabled_;\n }\n bindClassModifiers(t) {\n Y(this.globalDisabled_, tn(t, \"disabled\")), H(this, \"hidden\", tn(t, \"hidden\"));\n }\n bindDisabled(t) {\n Y(this.globalDisabled_, (e) => {\n t.disabled = e;\n });\n }\n bindTabIndex(t) {\n Y(this.globalDisabled_, (e) => {\n t.tabIndex = e ? -1 : 0;\n });\n }\n handleDispose(t) {\n this.value(\"disposed\").emitter.on(\"change\", (e) => {\n e && t();\n });\n }\n getGlobalDisabled_() {\n const t = this.get(\"parent\");\n return (t ? t.globalDisabled.rawValue : !1) || this.get(\"disabled\");\n }\n updateGlobalDisabled_() {\n this.setGlobalDisabled_(this.getGlobalDisabled_());\n }\n onDisabledChange_() {\n this.updateGlobalDisabled_();\n }\n onParentGlobalDisabledChange_() {\n this.updateGlobalDisabled_();\n }\n onParentChange_(t) {\n var e;\n const i = t.previousRawValue;\n i == null || i.globalDisabled.emitter.off(\"change\", this.onParentGlobalDisabledChange_), (e = this.get(\"parent\")) === null || e === void 0 || e.globalDisabled.emitter.on(\"change\", this.onParentGlobalDisabledChange_), this.updateGlobalDisabled_();\n }\n }\n function Ii() {\n return [\"veryfirst\", \"first\", \"last\", \"verylast\"];\n }\n const en = E(\"\"), nn = {\n veryfirst: \"vfst\",\n first: \"fst\",\n last: \"lst\",\n verylast: \"vlst\"\n };\n class Vt {\n constructor(t) {\n this.parent_ = null, this.blade = t.blade, this.view = t.view, this.viewProps = t.viewProps;\n const e = this.view.element;\n this.blade.value(\"positions\").emitter.on(\"change\", () => {\n Ii().forEach((i) => {\n e.classList.remove(en(void 0, nn[i]));\n }), this.blade.get(\"positions\").forEach((i) => {\n e.classList.add(en(void 0, nn[i]));\n });\n }), this.viewProps.handleDispose(() => {\n Ti(e);\n });\n }\n get parent() {\n return this.parent_;\n }\n set parent(t) {\n if (this.parent_ = t, !(\"parent\" in this.viewProps.valMap_)) {\n ve({\n key: \"parent\",\n target: W.name,\n place: \"BladeController.parent\"\n });\n return;\n }\n this.viewProps.set(\"parent\", this.parent_ ? this.parent_.viewProps : null);\n }\n }\n const z = \"http://www.w3.org/2000/svg\";\n function Wt(n) {\n n.offsetHeight;\n }\n function Bi(n, t) {\n const e = n.style.transition;\n n.style.transition = \"none\", t(), n.style.transition = e;\n }\n function be(n) {\n return n.ontouchstart !== void 0;\n }\n function Ui() {\n return globalThis;\n }\n function ji() {\n return Ui().document;\n }\n function Fi(n) {\n const t = n.ownerDocument.defaultView;\n return t && \"document\" in t ? n.getContext(\"2d\", {\n willReadFrequently: !0\n }) : null;\n }\n const Ki = {\n check: '<path d=\"M2 8l4 4l8 -8\"/>',\n dropdown: '<path d=\"M5 7h6l-3 3 z\"/>',\n p2dpad: '<path d=\"M8 4v8\"/><path d=\"M4 8h8\"/><circle cx=\"12\" cy=\"12\" r=\"1.2\"/>'\n };\n function Xt(n, t) {\n const e = n.createElementNS(z, \"svg\");\n return e.innerHTML = Ki[t], e;\n }\n function rn(n, t, e) {\n n.insertBefore(t, n.children[e]);\n }\n function sn(n) {\n n.parentElement && n.parentElement.removeChild(n);\n }\n function on(n) {\n for (; n.children.length > 0; )\n n.removeChild(n.children[0]);\n }\n function $i(n) {\n for (; n.childNodes.length > 0; )\n n.removeChild(n.childNodes[0]);\n }\n function an(n) {\n return n.relatedTarget ? n.relatedTarget : \"explicitOriginalTarget\" in n ? n.explicitOriginalTarget : null;\n }\n const St = E(\"lbl\");\n function Hi(n, t) {\n const e = n.createDocumentFragment();\n return t.split(`\n`).map((r) => n.createTextNode(r)).forEach((r, a) => {\n a > 0 && e.appendChild(n.createElement(\"br\")), e.appendChild(r);\n }), e;\n }\n class ln {\n constructor(t, e) {\n this.element = t.createElement(\"div\"), this.element.classList.add(St()), e.viewProps.bindClassModifiers(this.element);\n const i = t.createElement(\"div\");\n i.classList.add(St(\"l\")), H(e.props, \"label\", (a) => {\n g(a) ? this.element.classList.add(St(void 0, \"nol\")) : (this.element.classList.remove(St(void 0, \"nol\")), $i(i), i.appendChild(Hi(t, a)));\n }), this.element.appendChild(i), this.labelElement = i;\n const r = t.createElement(\"div\");\n r.classList.add(St(\"v\")), this.element.appendChild(r), this.valueElement = r;\n }\n }\n class Zt extends Vt {\n constructor(t, e) {\n const i = e.valueController.viewProps;\n super(Object.assign(Object.assign({}, e), { view: new ln(t, {\n props: e.props,\n viewProps: i\n }), viewProps: i })), this.props = e.props, this.valueController = e.valueController, this.view.valueElement.appendChild(this.valueController.view.element);\n }\n }\n const zi = {\n id: \"button\",\n type: \"blade\",\n accept(n) {\n const t = R, e = I(n, {\n title: t.required.string,\n view: t.required.constant(\"button\"),\n label: t.optional.string\n });\n return e ? { params: e } : null;\n },\n controller(n) {\n return new Zt(n.document, {\n blade: n.blade,\n props: C.fromObject({\n label: n.params.label\n }),\n valueController: new Ze(n.document, {\n props: C.fromObject({\n title: n.params.title\n }),\n viewProps: n.viewProps\n })\n });\n },\n api(n) {\n return !(n.controller instanceof Zt) || !(n.controller.valueController instanceof Ze) ? null : new et(n.controller);\n }\n };\n class _t extends Vt {\n constructor(t) {\n super(t), this.value = t.value;\n }\n }\n function Lt() {\n return new C({\n positions: N([], {\n equals: P\n })\n });\n }\n class At extends C {\n constructor(t) {\n super(t);\n }\n static create(t) {\n const e = {\n completed: !0,\n expanded: t,\n expandedHeight: null,\n shouldFixHeight: !1,\n temporaryExpanded: null\n }, i = C.createCore(e);\n return new At(i);\n }\n get styleExpanded() {\n var t;\n return (t = this.get(\"temporaryExpanded\")) !== null && t !== void 0 ? t : this.get(\"expanded\");\n }\n get styleHeight() {\n if (!this.styleExpanded)\n return \"0\";\n const t = this.get(\"expandedHeight\");\n return this.get(\"shouldFixHeight\") && !g(t) ? `${t}px` : \"auto\";\n }\n bindExpandedClass(t, e) {\n const i = () => {\n this.styleExpanded ? t.classList.add(e) : t.classList.remove(e);\n };\n H(this, \"expanded\", i), H(this, \"temporaryExpanded\", i);\n }\n cleanUpTransition() {\n this.set(\"shouldFixHeight\", !1), this.set(\"expandedHeight\", null), this.set(\"completed\", !0);\n }\n }\n function Gi(n, t) {\n let e = 0;\n return Bi(t, () => {\n n.set(\"expandedHeight\", null), n.set(\"temporaryExpanded\", !0), Wt(t), e = t.clientHeight, n.set(\"temporaryExpanded\", null), Wt(t);\n }), e;\n }\n function pn(n, t) {\n t.style.height = n.styleHeight;\n }\n function fe(n, t) {\n n.value(\"expanded\").emitter.on(\"beforechange\", () => {\n if (n.set(\"completed\", !1), g(n.get(\"expandedHeight\"))) {\n const e = Gi(n, t);\n e > 0 && n.set(\"expandedHeight\", e);\n }\n n.set(\"shouldFixHeight\", !0), Wt(t);\n }), n.emitter.on(\"change\", () => {\n pn(n, t);\n }), pn(n, t), t.addEventListener(\"transitionend\", (e) => {\n e.propertyName === \"height\" && n.cleanUpTransition();\n });\n }\n class _e extends l {\n constructor(t, e) {\n super(t), this.rackApi_ = e;\n }\n }\n function qi(n, t) {\n return n.addBlade(Object.assign(Object.assign({}, t), { view: \"button\" }));\n }\n function Yi(n, t) {\n return n.addBlade(Object.assign(Object.assign({}, t), { view: \"folder\" }));\n }\n function Qi(n, t) {\n const e = t ?? {};\n return n.addBlade(Object.assign(Object.assign({}, e), { view: \"separator\" }));\n }\n function Wi(n, t) {\n return n.addBlade(Object.assign(Object.assign({}, t), { view: \"tab\" }));\n }\n class we {\n constructor(t) {\n this.emitter = new M(), this.items_ = [], this.cache_ = /* @__PURE__ */ new Set(), this.onSubListAdd_ = this.onSubListAdd_.bind(this), this.onSubListRemove_ = this.onSubListRemove_.bind(this), this.extract_ = t;\n }\n get items() {\n return this.items_;\n }\n allItems() {\n return Array.from(this.cache_);\n }\n find(t) {\n for (const e of this.allItems())\n if (t(e))\n return e;\n return null;\n }\n includes(t) {\n return this.cache_.has(t);\n }\n add(t, e) {\n if (this.includes(t))\n throw _.shouldNeverHappen();\n const i = e !== void 0 ? e : this.items_.length;\n this.items_.splice(i, 0, t), this.cache_.add(t);\n const r = this.extract_(t);\n r && (r.emitter.on(\"add\", this.onSubListAdd_), r.emitter.on(\"remove\", this.onSubListRemove_), r.allItems().forEach((a) => {\n this.cache_.add(a);\n })), this.emitter.emit(\"add\", {\n index: i,\n item: t,\n root: this,\n target: this\n });\n }\n remove(t) {\n const e = this.items_.indexOf(t);\n if (e < 0)\n return;\n this.items_.splice(e, 1), this.cache_.delete(t);\n const i = this.extract_(t);\n i && (i.emitter.off(\"add\", this.onSubListAdd_), i.emitter.off(\"remove\", this.onSubListRemove_)), this.emitter.emit(\"remove\", {\n index: e,\n item: t,\n root: this,\n target: this\n });\n }\n onSubListAdd_(t) {\n this.cache_.add(t.item), this.emitter.emit(\"add\", {\n index: t.index,\n item: t.item,\n root: this,\n target: t.target\n });\n }\n onSubListRemove_(t) {\n this.cache_.delete(t.item), this.emitter.emit(\"remove\", {\n index: t.index,\n item: t.item,\n root: this,\n target: t.target\n });\n }\n }\n class ge extends l {\n constructor(t) {\n super(t), this.onBindingChange_ = this.onBindingChange_.bind(this), this.emitter_ = new M(), this.controller_.binding.emitter.on(\"change\", this.onBindingChange_);\n }\n get label() {\n return this.controller_.props.get(\"label\");\n }\n set label(t) {\n this.controller_.props.set(\"label\", t);\n }\n on(t, e) {\n const i = e.bind(this);\n return this.emitter_.on(t, (r) => {\n i(r.event);\n }), this;\n }\n refresh() {\n this.controller_.binding.read();\n }\n onBindingChange_(t) {\n const e = t.sender.target.read();\n this.emitter_.emit(\"change\", {\n event: new v(this, e, this.controller_.binding.target.presetKey, t.options.last)\n });\n }\n }\n class G extends Zt {\n constructor(t, e) {\n super(t, e), this.binding = e.binding;\n }\n }\n class Ce extends l {\n constructor(t) {\n super(t), this.onBindingUpdate_ = this.onBindingUpdate_.bind(this), this.emitter_ = new M(), this.controller_.binding.emitter.on(\"update\", this.onBindingUpdate_);\n }\n get label() {\n return this.controller_.props.get(\"label\");\n }\n set label(t) {\n this.controller_.props.set(\"label\", t);\n }\n on(t, e) {\n const i = e.bind(this);\n return this.emitter_.on(t, (r) => {\n i(r.event);\n }), this;\n }\n refresh() {\n this.controller_.binding.read();\n }\n onBindingUpdate_(t) {\n const e = t.sender.target.read();\n this.emitter_.emit(\"update\", {\n event: new w(this, e, this.controller_.binding.target.presetKey)\n });\n }\n }\n class nt extends Zt {\n constructor(t, e) {\n super(t, e), this.binding = e.binding, this.viewProps.bindDisabled(this.binding.ticker), this.viewProps.handleDispose(() => {\n this.binding.dispose();\n });\n }\n }\n function Xi(n) {\n return n instanceof Jt ? n.apiSet_ : n instanceof _e ? n.rackApi_.apiSet_ : null;\n }\n function Mt(n, t) {\n const e = n.find((i) => i.controller_ === t);\n if (!e)\n throw _.shouldNeverHappen();\n return e;\n }\n function dn(n, t, e) {\n if (!L.isBindable(n))\n throw _.notBindable();\n return new L(n, t, e);\n }\n class Jt extends l {\n constructor(t, e) {\n super(t), this.onRackAdd_ = this.onRackAdd_.bind(this), this.onRackRemove_ = this.onRackRemove_.bind(this), this.onRac