From 0b1cc102fb408c5e9ee4499f520a147953566a77 Mon Sep 17 00:00:00 2001 From: Will Eastler <32074613+weastler@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:54:10 -0800 Subject: [PATCH 1/4] feat(hub): serve private Builds on canonical paths Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../replica-prototype/assets/canvas-bridge.js | 8 +- .../renderer-improvement-notes-prototype.js | 2 +- ...er-prototype-canvas-improvement-threads.js | 4 +- .../replica-prototype/assets/renderer.js | 2 +- actions/build/action.yml | 8 +- actions/build/screenshots/action.yml | 10 +- .../scripts/action-contract/index.test.mjs | 3 + .../scripts/capture-screenshots/index.mjs | 16 +- .../capture-screenshots/index.test.mjs | 60 +++ .../scripts/create-static-server/index.mjs | 35 +- .../create-static-server/index.test.mjs | 36 ++ .../scripts/normalize-base-path/index.mjs | 17 + hub/.env.example | 3 +- .../build-controls/controls.js | 6 +- .../hub/routes/expanded-flows.test.tsx | 3 +- .../routes/real-local-review-flow.test.tsx | 8 +- .../product-share-links-data/index.test.ts | 26 ++ .../product-share-links-data/index.ts | 5 +- .../prototype-preview-bridge/index.test.ts | 28 +- .../prototype-preview-bridge/index.ts | 9 +- .../install-replica-controls-bridge/bridge.js | 6 +- .../index.ts | 4 +- .../install-replica-preview-bridge/index.js | 14 +- .../index.test.ts | 46 ++ .../index.tsx | 8 +- .../index.test.tsx | 21 + .../use-canvas-preview-navigation/index.ts | 7 +- hub/client/hooks/use-preview-bridge/index.ts | 8 +- .../hooks/use-prototype-viewer-url/index.ts | 5 +- .../pages/prototypes-show-page/index.test.tsx | 40 +- .../pages/prototypes-show-page/index.tsx | 30 +- .../pages/replica-browse-page/index.test.tsx | 14 + .../pages/replica-browse-page/index.tsx | 3 +- .../create-preview-prototype-prompt/index.ts | 5 +- hub/client/utils/get-url-origin/index.test.ts | 25 +- hub/client/utils/get-url-origin/index.ts | 22 +- .../utils/prototype-controls/bindings.d.mts | 2 +- .../utils/prototype-controls/bindings.mjs | 5 +- .../prototype-controls/browser-entry.mjs | 8 +- .../utils/prototype-controls/browser.js | 6 +- .../preview-base-path.d.mts | 1 + .../prototype-controls/preview-base-path.mjs | 3 + hub/docs/architecture.md | 6 +- hub/docs/build-previews.md | 64 ++- hub/docs/github-actions-builds.md | 11 +- hub/docs/share-links.md | 4 +- hub/docs/testing-and-operations.md | 2 +- hub/server/assets/hosted-preview-bridge.ts | 2 +- hub/server/assets/hosted-review-bridge.ts | 2 +- hub/server/create-app/index.test.ts | 3 +- hub/server/create-app/index.ts | 2 +- .../create-preview-grant/index.ts | 24 -- .../create-preview-session/index.ts | 20 - .../inject-preview-bridge/index.ts | 4 +- .../read-build-preview-file/index.ts | 2 +- .../read-build-preview-file/types.ts | 1 + .../read-preview-grant/index.test.ts | 54 --- .../build-preview/read-preview-grant/index.ts | 32 -- .../read-preview-session/index.test.ts | 31 -- .../read-preview-session/index.ts | 22 - .../synchronize-local-builds/index.db.test.ts | 1 + hub/server/index.test.ts | 23 +- hub/server/index.ts | 15 +- .../express/create-preview-cookie/index.ts | 16 - .../find-build-preview-target/index.ts | 75 ++-- .../find-default-template-build/index.ts | 24 +- .../index.db.test.ts | 158 +++++++ .../find-path-preview-targets/index.ts | 44 ++ .../find-prototype-detail/index.db.test.ts | 22 +- .../find-prototype-detail/index.ts | 34 +- .../index.ts | 35 +- .../public-sharing/hosted-sharing.db.test.ts | 1 - .../builds/access/get/index.test.ts | 94 ++-- .../prototypes/builds/access/get/index.ts | 38 +- .../repositories/templates/index.db.test.ts | 27 +- .../api/repositories/templates/index.test.ts | 79 +++- .../api/repositories/templates/index.ts | 43 +- .../build-preview/authorize/get/index.test.ts | 170 -------- .../build-preview/authorize/get/index.ts | 66 --- .../index.test.ts | 13 + .../index.ts | 21 +- .../build-preview/path/get/index.db.test.ts | 226 ++++++++++ .../build-preview/path/get/index.test.ts | 358 +++++++++++++++ .../routes/build-preview/path/get/index.ts | 144 +++++++ .../build-preview/serve/get/index.test.ts | 406 +++--------------- .../routes/build-preview/serve/get/index.ts | 93 +--- .../share-authorize/get/index.test.ts | 1 - .../share-authorize/get/index.ts | 4 + hub/server/routes/build-preview/types.ts | 17 +- hub/server/routes/index.ts | 25 +- .../utils/create-build-preview-path/index.ts | 13 + hub/test/local-smoke/browser.js | 29 +- hub/vite.config.ts | 10 +- starter/README.md | 2 + starter/vite.config.ts | 1 + 95 files changed, 1876 insertions(+), 1310 deletions(-) create mode 100644 actions/build/scripts/normalize-base-path/index.mjs create mode 100644 hub/client/application/hub/view-models/product-share-links-data/index.test.ts create mode 100644 hub/client/utils/prototype-controls/preview-base-path.d.mts create mode 100644 hub/client/utils/prototype-controls/preview-base-path.mjs delete mode 100644 hub/server/domains/build-preview/create-preview-grant/index.ts delete mode 100644 hub/server/domains/build-preview/create-preview-session/index.ts delete mode 100644 hub/server/domains/build-preview/read-preview-grant/index.test.ts delete mode 100644 hub/server/domains/build-preview/read-preview-grant/index.ts delete mode 100644 hub/server/domains/build-preview/read-preview-session/index.test.ts delete mode 100644 hub/server/domains/build-preview/read-preview-session/index.ts delete mode 100644 hub/server/integrations/express/create-preview-cookie/index.ts create mode 100644 hub/server/repositories/build-artifacts/find-path-preview-targets/index.db.test.ts create mode 100644 hub/server/repositories/build-artifacts/find-path-preview-targets/index.ts delete mode 100644 hub/server/routes/build-preview/authorize/get/index.test.ts delete mode 100644 hub/server/routes/build-preview/authorize/get/index.ts create mode 100644 hub/server/routes/build-preview/path/get/index.db.test.ts create mode 100644 hub/server/routes/build-preview/path/get/index.test.ts create mode 100644 hub/server/routes/build-preview/path/get/index.ts create mode 100644 hub/server/utils/create-build-preview-path/index.ts diff --git a/.github/extensions/replica-prototype/assets/canvas-bridge.js b/.github/extensions/replica-prototype/assets/canvas-bridge.js index 1c8eb1781..deed7e52e 100644 --- a/.github/extensions/replica-prototype/assets/canvas-bridge.js +++ b/.github/extensions/replica-prototype/assets/canvas-bridge.js @@ -1,4 +1,4 @@ -var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=/* @__PURE__ */ ((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))((/* @__PURE__ */ o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=P;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return L.errors=a,o===0}e.number=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.slider=ee;function ee(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return ee.errors=a,l===0}e.choice=te;function te(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return te.errors=a,o===0}e.checkboxGroup=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.text=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return re.errors=a,l===0}e.color=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return z.errors=a,o===0}e.button=ie;function ie(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ie.errors=a,o===0}})))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` -`)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=/* @__PURE__ */ new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=/* @__PURE__ */ new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=/* @__PURE__ */ new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=/* @__PURE__ */ new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=/* @__PURE__ */ new Set,p=/* @__PURE__ */ new Map,m=/* @__PURE__ */ new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e,t){return JSON.stringify(e)===JSON.stringify(t)}function A(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function j(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function M(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function N(e){let t=e.binding;if(t.type===`api`){let e=M(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=j(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(/* @__PURE__ */ Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function ee(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function te(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():ee(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function ne(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=/* @__PURE__ */ new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=/* @__PURE__ */ Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=/* @__PURE__ */ new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return N(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(A()).origin!==new URL(i).origin:A()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=A(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await te(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?A():a);if(!k(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=/* @__PURE__ */ Error(`${c.message} ${L(e).message}`)}throw!l&&k(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!k(await R(()=>I(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,A());t.rejection&&!k(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=A();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function j(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!k(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&k(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` -`).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function P(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,P);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>j(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return j(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await j(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function re(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return ne(JSON.parse(t))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var ie=`replica:controls`;function ae(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function oe(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var se=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function ce(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!se.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function le(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=/* @__PURE__ */ new Map,i=!1;for(let[e,a]of n){let n=se.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??/* @__PURE__ */ new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{ce(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function ue(e,t){let n=new URL(e,window.location.href),r=le(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(ce(r.scopes)))n.searchParams.set(e,t);return n.toString()}function de(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=ce({...le(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(ue(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=le(e);if(t.notice)throw Error(t.notice);s=ce(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function fe(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var pe={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function me(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?pe.controlsActionUnavailable:``)}}function he(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>me(e,t)))}}function ge(e){let t=``,n,r,i=``,a=!1,o=/* @__PURE__ */ new Set,s=!1,c=0,l,u,d=!1,f,p=/* @__PURE__ */ new Set,m=/* @__PURE__ */ new Set,h=``,g=de(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,fe(oe(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await re(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(oe);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:ie,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(ae(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:he(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!ae(r.data))return;let i=r.data;if(i.type===`hello`){t=i.epoch,o.clear(),s=!1,m.clear();let e=i.fromFrameUrl&&g?.managed();g?.set(e?g.current():i.controlQuery??``),d||await w,x(`reply`,i.requestId,void 0,e?g?.current():void 0);return}if(i.type!==`command`||i.epoch!==t||o.has(i.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,i.requestId,`Reconnect controls before sending more commands.`);return}o.add(i.requestId);let c=i.command;function l(){if(a||t!==i.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(c?.operation===`url`){g.set(c.query??``),c.scope&&n?.list().some(e=>e.declaration.scope===c.scope&&e.mountedCount>0)&&(m.add(c.scope),g.refresh()),x(`reply`,i.requestId);return}if(!c||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(c.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(c.contexts)||c.contexts.length!==e.length||e.some(e=>!c.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,l)}else{let e=n.list().find(e=>e.declaration.scope===c.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(c.fingerprint!==JSON.stringify(e.declaration)||c.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(c.operation===`restore`){if(!z(c.values))throw Error(`Invalid saved controls.`);await u?.restore(e,c.values,l),m.add(e.declaration.scope),g?.refresh()}else if(c.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,l);else{let t=e.declaration.controls.find(e=>e.id===c.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),c.operation===`update`){let n={[t.id]:c.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,l)}else if(c.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===i.epoch&&(x(`reply`,i.requestId),u?.navigate())}catch(e){t===i.epoch&&x(`reply`,i.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var B=`data-replica-canvas-bridge`,_e=new TextEncoder,ve=null,V=null,H=null,U=null,ye=`light-dark(#0969da, #58a6ff)`,W=null,be=``,xe=``,G=/* @__PURE__ */ new Map;function Se(){let e=q();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{xe=`replicaControlsBinding`in e&&e.replicaControlsBinding?Se():``});function K(e){return e.replace(/\s+/g,` `).trim()}function Ce(e,t){let n=``,r=0;for(let i of e){let e=_e.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function q(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname,search:e?`?${e}`:``,hash:window.location.hash}}function we(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Te(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function Ee(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return Ce(K(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function De(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function Oe(e){if(e.id){let t=`#${De(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}="${De(n)}"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function ke(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&Ee(e)!==t.accessibleName?!1:!t.selectedText||K(e.textContent||``).includes(t.selectedText)}function Ae(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&ke(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&ke(r,e)){if(n)return null;n=r}return n}function je(){let e=document.createElement(`div`);return e.setAttribute(B,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,ye),document.documentElement.append(e),e}function J(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function Me(e,t=null){H?.remove(),H=e,U=t,H.style.pointerEvents=`none`}function Y(e,t){window.parent.postMessage(t,e)}function X(){V?.(),V=null}function Z(e,t,n){X(),Y(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Ne(e,t,n){let r=e.getBoundingClientRect(),i=Oe(e);if(!r.width||!r.height||!i)return null;let a=Ce(K(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:q(),selector:i,accessibleName:Ee(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:Te(r),viewport:we(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Pe(e,t){X();let n=null,r=je(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${B}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,J(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Ne(n,i.clientX,i.clientY);a?(r.style.position=$(n)?`fixed`:`absolute`,J(r,n.getBoundingClientRect()),Me(r,n),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Z(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),V=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,H!==r&&r.remove()}}function Fe(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=/* @__PURE__ */ new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(B)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=Oe(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:Ee(e),tagName:e.tagName.toLowerCase(),role:Ce(e.getAttribute(`role`)||``,64),textExcerpt:Ce(K(e.textContent||``),500),rect:Te(n)}]})}function Ie(e){return{schemaVersion:1,kind:`area`,route:q(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:Te(e),viewport:we(),elements:Fe(e)}}function Le(e,t,n=!1){X();let r=document.createElement(`div`);r.setAttribute(B,``),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let i=je();i.style.display=`none`,document.body.append(r);let a=null,o=null,s=null,c=null;function l(e,t){r.style.pointerEvents=`none`;let n=document.elementFromPoint(e,t);return r.style.pointerEvents=``,n===document.body||n===document.documentElement?null:n}function u(n,r,a){i.style.position=a&&$(a)?`fixed`:`absolute`,J(i,r),Me(i,a),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:n})}function d(e,t){if(!a)return;let n=Math.min(a.x,e),r=Math.min(a.y,t),o=Math.abs(e-a.x),s=Math.abs(t-a.y);i.style.display=`block`,J(i,new DOMRect(n,r,o,s))}function f(e){e.button!==0||a||(e.preventDefault(),a={x:e.clientX,y:e.clientY},s=e.pointerId,o=n?l(e.clientX,e.clientY):null,r.setPointerCapture(e.pointerId),d(e.clientX,e.clientY))}function p(e){if(a)e.pointerId===s&&(e.preventDefault(),d(e.clientX,e.clientY));else{if(!n)return;let t=l(e.clientX,e.clientY);i.style.display=t?`block`:`none`,t&&J(i,t.getBoundingClientRect())}}function m(r){if(!a||r.pointerId!==s)return;r.preventDefault();let i=Math.max(0,Math.min(window.innerWidth,r.clientX)),c=Math.max(0,Math.min(window.innerHeight,r.clientY)),l=new DOMRect(Math.min(a.x,i),Math.min(a.y,c),Math.abs(i-a.x),Math.abs(c-a.y));if(n&&Math.hypot(l.width,l.height)<8){let n=o?Ne(o,a.x,a.y):null;if(!n||!o){Z(e,t,`element-unavailable`);return}u(n,o.getBoundingClientRect(),o)}else(n?l.width<8||l.height<8:Math.hypot(l.width,l.height)<8)?Z(e,t,`area-too-small`):u(Ie(l),l)}function h(r){if(!n||r.detail!==0||!(r.target instanceof Element)||r.target.hasAttribute(B))return;r.preventDefault(),r.stopImmediatePropagation();let i=r.target,a=i.getBoundingClientRect(),o=Ne(i,a.left+a.width/2,a.top+a.height/2);o?u(o,a,i):Z(e,t,`element-unavailable`)}function g(n){X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t,reason:n?`interrupted`:`escape`})}function _(r){if(n&&r.shiftKey&&r.key===`Enter`)r.preventDefault(),c={x:window.innerWidth/2,y:window.innerHeight/2},a=null,i.style.display=`block`,J(i,new DOMRect(c.x,c.y,4,4));else if(c&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(r.key)){if(r.preventDefault(),r.key===`Enter`||r.key===` `){if(!a)a={...c};else{let n=new DOMRect(Math.min(a.x,c.x),Math.min(a.y,c.y),Math.abs(a.x-c.x),Math.abs(a.y-c.y));if(n.width<8||n.height<8){Z(e,t,`area-too-small`);return}u(Ie(n),n)}}else c={x:Math.max(0,Math.min(window.innerWidth,c.x+(r.key===`ArrowRight`?10:r.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(window.innerHeight,c.y+(r.key===`ArrowDown`?10:r.key===`ArrowUp`?-10:0)))},a?d(c.x,c.y):J(i,new DOMRect(c.x,c.y,4,4))}else r.key===`Escape`&&(r.preventDefault(),g())}r.addEventListener(`pointerdown`,f),r.addEventListener(`pointermove`,p),r.addEventListener(`pointerup`,m),r.addEventListener(`pointercancel`,g),r.addEventListener(`lostpointercapture`,g),n&&document.addEventListener(`click`,h,!0),document.addEventListener(`keydown`,_,!0),V=()=>{r.removeEventListener(`pointerdown`,f),r.removeEventListener(`pointermove`,p),r.removeEventListener(`pointerup`,m),r.removeEventListener(`pointercancel`,g),r.removeEventListener(`lostpointercapture`,g),n&&document.removeEventListener(`click`,h,!0),document.removeEventListener(`keydown`,_,!0),r.remove(),H!==i&&i.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function Re(e){let t=q();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=Ae({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:$(n)}}function ze(e=!1){if(!W||!ve)return;let t=q(),n=JSON.stringify(t);e&&=n===be,be=n;let r=[];for(let t of W.anchors){let n=G.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=Re(t.anchor);if(!e){G.delete(t.id);continue}G.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}Y(ve,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:W.nonce,route:t,...xe===Se()?{replaceRoute:!0}:{},results:r})}function Be(e){let t=e.data;if(document.querySelector(`script[src="/__replica/bridge/v1.js"]`)||e.source!==window.parent||e.origin!==ve||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){Y(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,improvementSelection:!0,nonce:t.nonce,route:q(),...xe===Se()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;ye=t.accent;for(let e of document.querySelectorAll(`[${B}]`))e.style.setProperty(`--replica-selection-accent`,ye);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=q(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(O(n,!0)||(Ee(n)||K(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Pe(e.origin,t.nonce):t.mode===`area`?Le(e.origin,t.nonce):t.mode===`improvement`&&Le(e.origin,t.nonce,!0);return}if(t.type===`replica:canvas:cancel-selection`){X(),Y(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce,reason:`command`});return}if(t.type===`replica:canvas:clear-selection`){H?.remove(),H=null,U=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors))return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});W={nonce:t.nonce,anchors:n},G.clear(),ze()}var Ve=Symbol.for(`replica.canvas.bridge.v1`),He=window;function Ue(e){let t=He[Ve];if(t===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof t==`function`&&t(),ye=`light-dark(#0969da, #58a6ff)`,ve=e,W=null,be=``,G.clear();let n=ge(e),r=null;function i(){r!==null&&window.cancelAnimationFrame(r),r=null,H&&U&&(H.style.position=$(U)?`fixed`:`absolute`,J(H,U.getBoundingClientRect())),ze()}function a(){r===null&&W&&(r=window.requestAnimationFrame(i))}function o(e){H&&U&&(e.target!==document&&e.target!==window||$(U))&&J(H,U.getBoundingClientRect()),r===null?ze(e.target===document||e.target===window):i()}function s(){ze()}function c(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||V||!W||t.target instanceof Element&&t.target.closest(`[role="dialog"], dialog, [role="menu"]`))return;let n=W;window.setTimeout(()=>{t.defaultPrevented||V||W!==n||Y(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,Be),window.addEventListener(`scroll`,o,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),window.addEventListener(`keydown`,c);let l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${B}], [data-replica-controls-bridge]`)))&&a()});l.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let u=typeof ResizeObserver==`function`?new ResizeObserver(a):null;u?.observe(document.documentElement),He[Ve]=()=>{window.removeEventListener(`message`,Be),window.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,s),window.removeEventListener(`keydown`,c),l.disconnect(),u?.disconnect(),r!==null&&window.cancelAnimationFrame(r),W=null,be=``,G.clear(),n(),X(),H?.remove(),H=null,U=null}}function We(e,t=`canvas`){if(t===`canvas`){if(!/^http:\/\/127\.0\.0\.1:\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`)}else{let t=URL.parse(e);if(!t||t.origin!==e||t.pathname!==`/`||t.search||t.hash||![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid Replica Hub parent.`)}Ue(e)}export{We as installBridge}; \ No newline at end of file +var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=/* @__PURE__ */ ((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))((/* @__PURE__ */ o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=ee;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return I.errors=a,o===0}e.number=L;function L(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return L.errors=a,l===0}e.slider=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.choice=te;function te(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return te.errors=a,o===0}e.checkboxGroup=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.text=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return re.errors=a,l===0}e.color=ie;function ie(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ie.errors=a,o===0}e.button=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return z.errors=a,o===0}})))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` +`)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=/* @__PURE__ */ new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=/* @__PURE__ */ new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=/* @__PURE__ */ new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=/* @__PURE__ */ new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=/* @__PURE__ */ new Set,p=/* @__PURE__ */ new Map,m=/* @__PURE__ */ new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e){return/^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(e)?.[0]??`/`}function A(e,t){return JSON.stringify(e)===JSON.stringify(t)}function j(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function M(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function N(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function ee(e){let t=e.binding;if(t.type===`api`){let e=N(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=M(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(/* @__PURE__ */ Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function te(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function ne(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():te(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function re(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=/* @__PURE__ */ new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=/* @__PURE__ */ Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=/* @__PURE__ */ new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return ee(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(j()).origin!==new URL(i).origin:j()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=j(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await ne(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?j():a);if(!A(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=/* @__PURE__ */ Error(`${c.message} ${L(e).message}`)}throw!l&&A(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!A(await R(()=>I(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,j());t.rejection&&!A(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=j();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function k(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!A(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&A(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` +`).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>k(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return k(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await k(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function ie(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return re(JSON.parse(n))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var ae=`replica:controls`;function oe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function se(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var ce=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function le(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!ce.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function ue(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=/* @__PURE__ */ new Map,i=!1;for(let[e,a]of n){let n=ce.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??/* @__PURE__ */ new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{le(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function de(e,t){let n=new URL(e,window.location.href),r=ue(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(le(r.scopes)))n.searchParams.set(e,t);return n.toString()}function fe(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=le({...ue(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(de(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=ue(e);if(t.notice)throw Error(t.notice);s=le(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function pe(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var me={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function he(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?me.controlsActionUnavailable:``)}}function ge(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>he(e,t)))}}function _e(e){let t=``,n,r,i=``,a=!1,o=/* @__PURE__ */ new Set,s=!1,c=0,l,u,d=!1,f,p=/* @__PURE__ */ new Set,m=/* @__PURE__ */ new Set,h=``,g=fe(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,pe(se(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await ie(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(se);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:ae,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(oe(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:ge(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!oe(r.data))return;let i=r.data;if(i.type===`hello`){t=i.epoch,o.clear(),s=!1,m.clear();let e=i.fromFrameUrl&&g?.managed();g?.set(e?g.current():i.controlQuery??``),d||await w,x(`reply`,i.requestId,void 0,e?g?.current():void 0);return}if(i.type!==`command`||i.epoch!==t||o.has(i.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,i.requestId,`Reconnect controls before sending more commands.`);return}o.add(i.requestId);let c=i.command;function l(){if(a||t!==i.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(c?.operation===`url`){g.set(c.query??``),c.scope&&n?.list().some(e=>e.declaration.scope===c.scope&&e.mountedCount>0)&&(m.add(c.scope),g.refresh()),x(`reply`,i.requestId);return}if(!c||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(c.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(c.contexts)||c.contexts.length!==e.length||e.some(e=>!c.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,l)}else{let e=n.list().find(e=>e.declaration.scope===c.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(c.fingerprint!==JSON.stringify(e.declaration)||c.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(c.operation===`restore`){if(!z(c.values))throw Error(`Invalid saved controls.`);await u?.restore(e,c.values,l),m.add(e.declaration.scope),g?.refresh()}else if(c.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,l);else{let t=e.declaration.controls.find(e=>e.id===c.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),c.operation===`update`){let n={[t.id]:c.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,l)}else if(c.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===i.epoch&&(x(`reply`,i.requestId),u?.navigate())}catch(e){t===i.epoch&&x(`reply`,i.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var B=`data-replica-canvas-bridge`,ve=new TextEncoder,ye=null,V=null,H=null,U=null,be=`light-dark(#0969da, #58a6ff)`,W=null,xe=``,Se=``,G=/* @__PURE__ */ new Map;function Ce(){let e=q();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{Se=`replicaControlsBinding`in e&&e.replicaControlsBinding?Ce():``});function K(e){return e.replace(/\s+/g,` `).trim()}function we(e,t){let n=``,r=0;for(let i of e){let e=ve.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function q(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname.slice(k(window.location.pathname).length-1),search:e?`?${e}`:``,hash:window.location.hash}}function Te(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Ee(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function De(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return we(K(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function Oe(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function ke(e){if(e.id){let t=`#${Oe(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}="${Oe(n)}"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function Ae(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&De(e)!==t.accessibleName?!1:!t.selectedText||K(e.textContent||``).includes(t.selectedText)}function je(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&Ae(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&Ae(r,e)){if(n)return null;n=r}return n}function Me(){let e=document.createElement(`div`);return e.setAttribute(B,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,be),document.documentElement.append(e),e}function J(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function Ne(e,t=null){H?.remove(),H=e,U=t,H.style.pointerEvents=`none`}function Y(e,t){window.parent.postMessage(t,e)}function X(){V?.(),V=null}function Z(e,t,n){X(),Y(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Pe(e,t,n){let r=e.getBoundingClientRect(),i=ke(e);if(!r.width||!r.height||!i)return null;let a=we(K(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:q(),selector:i,accessibleName:De(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:Ee(r),viewport:Te(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Fe(e,t){X();let n=null,r=Me(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${B}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,J(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Pe(n,i.clientX,i.clientY);a?(r.style.position=$(n)?`fixed`:`absolute`,J(r,n.getBoundingClientRect()),Ne(r,n),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Z(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),V=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,H!==r&&r.remove()}}function Ie(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=/* @__PURE__ */ new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(B)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=ke(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:De(e),tagName:e.tagName.toLowerCase(),role:we(e.getAttribute(`role`)||``,64),textExcerpt:we(K(e.textContent||``),500),rect:Ee(n)}]})}function Le(e){return{schemaVersion:1,kind:`area`,route:q(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:Ee(e),viewport:Te(),elements:Ie(e)}}function Re(e,t,n=!1){X();let r=document.createElement(`div`);r.setAttribute(B,``),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let i=Me();i.style.display=`none`,document.body.append(r);let a=null,o=null,s=null,c=null;function l(e,t){r.style.pointerEvents=`none`;let n=document.elementFromPoint(e,t);return r.style.pointerEvents=``,n===document.body||n===document.documentElement?null:n}function u(n,r,a){i.style.position=a&&$(a)?`fixed`:`absolute`,J(i,r),Ne(i,a),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:n})}function d(e,t){if(!a)return;let n=Math.min(a.x,e),r=Math.min(a.y,t),o=Math.abs(e-a.x),s=Math.abs(t-a.y);i.style.display=`block`,J(i,new DOMRect(n,r,o,s))}function f(e){e.button!==0||a||(e.preventDefault(),a={x:e.clientX,y:e.clientY},s=e.pointerId,o=n?l(e.clientX,e.clientY):null,r.setPointerCapture(e.pointerId),d(e.clientX,e.clientY))}function p(e){if(a)e.pointerId===s&&(e.preventDefault(),d(e.clientX,e.clientY));else{if(!n)return;let t=l(e.clientX,e.clientY);i.style.display=t?`block`:`none`,t&&J(i,t.getBoundingClientRect())}}function m(r){if(!a||r.pointerId!==s)return;r.preventDefault();let i=Math.max(0,Math.min(window.innerWidth,r.clientX)),c=Math.max(0,Math.min(window.innerHeight,r.clientY)),l=new DOMRect(Math.min(a.x,i),Math.min(a.y,c),Math.abs(i-a.x),Math.abs(c-a.y));if(n&&Math.hypot(l.width,l.height)<8){let n=o?Pe(o,a.x,a.y):null;if(!n||!o){Z(e,t,`element-unavailable`);return}u(n,o.getBoundingClientRect(),o)}else(n?l.width<8||l.height<8:Math.hypot(l.width,l.height)<8)?Z(e,t,`area-too-small`):u(Le(l),l)}function h(r){if(!n||r.detail!==0||!(r.target instanceof Element)||r.target.hasAttribute(B))return;r.preventDefault(),r.stopImmediatePropagation();let i=r.target,a=i.getBoundingClientRect(),o=Pe(i,a.left+a.width/2,a.top+a.height/2);o?u(o,a,i):Z(e,t,`element-unavailable`)}function g(n){X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t,reason:n?`interrupted`:`escape`})}function _(r){if(n&&r.shiftKey&&r.key===`Enter`)r.preventDefault(),c={x:window.innerWidth/2,y:window.innerHeight/2},a=null,i.style.display=`block`,J(i,new DOMRect(c.x,c.y,4,4));else if(c&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(r.key)){if(r.preventDefault(),r.key===`Enter`||r.key===` `){if(!a)a={...c};else{let n=new DOMRect(Math.min(a.x,c.x),Math.min(a.y,c.y),Math.abs(a.x-c.x),Math.abs(a.y-c.y));if(n.width<8||n.height<8){Z(e,t,`area-too-small`);return}u(Le(n),n)}}else c={x:Math.max(0,Math.min(window.innerWidth,c.x+(r.key===`ArrowRight`?10:r.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(window.innerHeight,c.y+(r.key===`ArrowDown`?10:r.key===`ArrowUp`?-10:0)))},a?d(c.x,c.y):J(i,new DOMRect(c.x,c.y,4,4))}else r.key===`Escape`&&(r.preventDefault(),g())}r.addEventListener(`pointerdown`,f),r.addEventListener(`pointermove`,p),r.addEventListener(`pointerup`,m),r.addEventListener(`pointercancel`,g),r.addEventListener(`lostpointercapture`,g),n&&document.addEventListener(`click`,h,!0),document.addEventListener(`keydown`,_,!0),V=()=>{r.removeEventListener(`pointerdown`,f),r.removeEventListener(`pointermove`,p),r.removeEventListener(`pointerup`,m),r.removeEventListener(`pointercancel`,g),r.removeEventListener(`lostpointercapture`,g),n&&document.removeEventListener(`click`,h,!0),document.removeEventListener(`keydown`,_,!0),r.remove(),H!==i&&i.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function ze(e){let t=q();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=je({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:$(n)}}function Be(e=!1){if(!W||!ye)return;let t=q(),n=JSON.stringify(t);e&&=n===xe,xe=n;let r=[];for(let t of W.anchors){let n=G.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=ze(t.anchor);if(!e){G.delete(t.id);continue}G.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}Y(ye,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:W.nonce,route:t,...Se===Ce()?{replaceRoute:!0}:{},results:r})}function Ve(e){let t=e.data;if(document.querySelector(`script[src="${k(window.location.pathname)}__replica/bridge/v1.js"]`)||e.source!==window.parent||e.origin!==ye||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){Y(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,improvementSelection:!0,nonce:t.nonce,route:q(),...Se===Ce()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;be=t.accent;for(let e of document.querySelectorAll(`[${B}]`))e.style.setProperty(`--replica-selection-accent`,be);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=q(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(O(n,!0)||(De(n)||K(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Fe(e.origin,t.nonce):t.mode===`area`?Re(e.origin,t.nonce):t.mode===`improvement`&&Re(e.origin,t.nonce,!0);return}if(t.type===`replica:canvas:cancel-selection`){X(),Y(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce,reason:`command`});return}if(t.type===`replica:canvas:clear-selection`){H?.remove(),H=null,U=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors))return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});W={nonce:t.nonce,anchors:n},G.clear(),Be()}var He=Symbol.for(`replica.canvas.bridge.v1`),Ue=window;function We(e){let t=Ue[He];if(t===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof t==`function`&&t(),be=`light-dark(#0969da, #58a6ff)`,ye=e,W=null,xe=``,G.clear();let n=_e(e),r=null;function i(){r!==null&&window.cancelAnimationFrame(r),r=null,H&&U&&(H.style.position=$(U)?`fixed`:`absolute`,J(H,U.getBoundingClientRect())),Be()}function a(){r===null&&W&&(r=window.requestAnimationFrame(i))}function o(e){H&&U&&(e.target!==document&&e.target!==window||$(U))&&J(H,U.getBoundingClientRect()),r===null?Be(e.target===document||e.target===window):i()}function s(){Be()}function c(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||V||!W||t.target instanceof Element&&t.target.closest(`[role="dialog"], dialog, [role="menu"]`))return;let n=W;window.setTimeout(()=>{t.defaultPrevented||V||W!==n||Y(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,Ve),window.addEventListener(`scroll`,o,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),window.addEventListener(`keydown`,c);let l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${B}], [data-replica-controls-bridge]`)))&&a()});l.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let u=typeof ResizeObserver==`function`?new ResizeObserver(a):null;u?.observe(document.documentElement),Ue[He]=()=>{window.removeEventListener(`message`,Ve),window.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,s),window.removeEventListener(`keydown`,c),l.disconnect(),u?.disconnect(),r!==null&&window.cancelAnimationFrame(r),W=null,xe=``,G.clear(),n(),X(),H?.remove(),H=null,U=null}}function Ge(e,t=`canvas`){if(t===`canvas`){if(!/^http:\/\/127\.0\.0\.1:\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`)}else{let t=URL.parse(e);if(!t||t.origin!==e||t.pathname!==`/`||t.search||t.hash||![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid Replica Hub parent.`)}We(e)}export{Ge as installBridge}; \ No newline at end of file diff --git a/.github/extensions/replica-prototype/assets/renderer-improvement-notes-prototype.js b/.github/extensions/replica-prototype/assets/renderer-improvement-notes-prototype.js index 6adc60230..b87c38b13 100644 --- a/.github/extensions/replica-prototype/assets/renderer-improvement-notes-prototype.js +++ b/.github/extensions/replica-prototype/assets/renderer-improvement-notes-prototype.js @@ -1 +1 @@ -import{n as e,r as t}from"./renderer-rolldown-runtime.js";import{K as n,M as r,X as i,Y as a,q as o}from"./renderer-vendor.js";import{a as s,c,m as l,o as u,p as d,s as f}from"./renderer.js";import{t as p}from"./renderer-prototype-canvas-improvement-threads.js";var m=t(i(),1),h=a(),g=n(),_={title:`Pick & polish`,localAuthor:`Local author`,bridgeUnavailable:`Annotation needs the updated Replica preview bridge. Reconnect or reload the preview after updating the canvas.`,sourceUnavailable:`You can still save this improvement locally, but it cannot sync without a captured source.`,annotate:`Pick & polish`,openNotes:e=>`Open improvement notes (${e})`,notes:`Pick & polish`,selectHint:`Click an element or drag a rectangle. For a keyboard region, focus the preview, press Shift+Enter, then use arrows and Enter to choose two corners. Escape exits annotation mode.`,regionSmall:`Choose a larger region, at least 8 preview pixels wide and high.`,add:`Add improvement note`,label:`What should change?`,placeholder:`Describe the improvement you want Copilot to make...`,save:`Save note`,cancel:`Cancel`,discard:`Discard draft`,keep:`Keep writing`,discardTitle:`Discard your unsaved note?`,discardBody:`Your saved notes will stay unchanged.`,editAction:`Edit`,previewUnavailable:`The preview selection is unavailable. Try selecting the target again.`,saved:`Note added.`,storageLoading:`Loading your notes...`,branchChanged:`The prototype branch changed. Close this draft and select the target again.`,workChanged:`The open improvements changed while syncing. Review them and select Fix all again.`,closeComposer:`Close note composer`,closeDiscard:`Close discard confirmation`};function v(e,t){let n=[e.thread.originalStatus,...e.thread.messages.filter(e=>e.role===`author`).map(e=>e.status)];return{id:e.id,revision:e.revision,body:e.body,author:e.thread.originalAuthor?`@${e.thread.originalAuthor.login}`:e.author===`local`?_.localAuthor:`@${e.author}`,avatarUrl:e.thread.originalAuthor?.avatarUrl,target:e.target,path:e.route,status:e.status,originalPending:e.thread.originalStatus===`open`,...n.includes(`sent`)?{retryStatus:`sent`}:n.includes(`blocked`)?{retryStatus:`blocked`}:{},messages:e.thread.messages.map(e=>({...e,...e.role===`author`&&e.author?{author:`@${e.author.login}`,avatarUrl:e.author.avatarUrl}:{author:void 0},pending:e.role===`author`&&e.status===`open`})),...t&&(t.status===`resolved`||t.status===`moved`)?{point:t.point}:{}}}function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b({frameRef:e,prototypeUrl:t,previewUrl:n,notes:r,annotating:i,composing:a,onSelect:o,onRoute:s,onCancel:l,onProblem:d}){let p=n??t,[h,g]=(0,m.useState)(null),[v,b]=(0,m.useState)(new Map),x=JSON.stringify(r.filter(e=>e.anchor).map(e=>({id:e.id,anchor:e.anchor}))),S=(0,m.useEffectEvent)(e=>{if(!i||a)return;let t=f.safeParse(e);t.success?o(t.data):(l(),d(_.previewUnavailable))}),C=(0,m.useCallback)((t,n={})=>{p&&h&&e?.current?.contentWindow&&e.current.contentWindow.postMessage({type:t,nonce:h.nonce,...n},new URL(p).origin)},[h,e,p]);return(0,m.useEffect)(()=>{let t=e?.current;if(!t||!p)return;let n=new URL(p).origin,r=crypto.randomUUID(),i=Date.now(),a=JSON.parse(x);function o(){t?.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:r},n),t?.contentWindow?.postMessage({type:`replica:canvas:resolve`,nonce:r,anchors:a},n)}function f(){r=crypto.randomUUID(),i=Date.now(),g({nonce:r,ready:!1}),b(new Map),l(),o()}function m(e){let a=e.data;if(e.source===t?.contentWindow&&e.origin===n&&y(a)&&a.nonce===r){if(a.type===`replica:canvas:ready`){let e=c.safeParse(a.route);if(a.protocolVersion!==1||a.improvementSelection!==!0||!e.success){g({nonce:r,ready:!1}),d(_.bridgeUnavailable);return}i=Date.now(),g(e=>e?.nonce===r&&e.ready?e:{nonce:r,ready:!0}),s(e.data.pathname+e.data.search+e.data.hash)}else if(a.type===`replica:canvas:selected`)S(a.anchor);else if(a.type===`replica:canvas:resolved`&&Array.isArray(a.results)){let e=new Map;for(let t of a.results){if(!y(t))continue;let n=u.safeParse({commentId:t.id,status:`resolved`,point:{x:t.x,y:t.y},rect:t.rect??{x:t.x,y:t.y,width:1,height:1}});n.success&&e.set(n.data.commentId,n.data)}b(e)}else a.type===`replica:canvas:selection-failed`||a.type===`replica:canvas:bridge-error`?(l(),d(a.reason===`area-too-small`?_.regionSmall:_.bridgeUnavailable)):a.type===`replica:canvas:selection-cancelled`?a.reason!==`command`&&l():a.type===`replica:canvas:conversation-dismiss-requested`&&window.dispatchEvent(new Event(`replica:review-dismiss`))}}t.addEventListener(`load`,f),window.addEventListener(`message`,m),g({nonce:r,ready:!1}),o();let h=window.setInterval(()=>{Date.now()-i>2e4&&(g({nonce:r,ready:!1}),b(new Map),l(),d(_.bridgeUnavailable)),o()},2e3);return()=>{t.removeEventListener(`load`,f),window.removeEventListener(`message`,m),window.clearInterval(h),t.contentWindow?.postMessage({type:`replica:canvas:cancel-selection`,nonce:r},n),t.contentWindow?.postMessage({type:`replica:canvas:clear-selection`,nonce:r},n)}},[x,e,p,l,d,s]),(0,m.useEffect)(()=>{h?.ready&&(i&&!a?C(`replica:canvas:select`,{mode:`improvement`}):C(`replica:canvas:cancel-selection`),a||C(`replica:canvas:clear-selection`))},[i,a,h?.ready,C]),{ready:h?.ready===!0,resolutions:v}}function x(e){let[t,n]=(0,m.useState)(null),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(``),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(null),d=(0,m.useRef)(!1),f=(0,m.useRef)(null),p=(0,m.useRef)(!1),h=(0,m.useRef)(0);function g(e){p.current&&(u.current=e,n(e))}(0,m.useEffect)(()=>{if(!e)return;p.current=!0;let t=!1,r=!1,a=0;async function c(){if(d.current||r)return;r=!0;let c=h.current;try{let n=await s(`/api/improvement-notes`,e);if(d.current||c!==h.current||t)return;if(g(n),Date.now()-a>15e3){a=Date.now();let r=s(`/api/improvement-notes/sync`,e,{method:`POST`,body:JSON.stringify({identity:n.identity,revision:n.revision})}).then(e=>{t||g(e)});f.current=r;try{await r}finally{f.current===r&&(f.current=null)}}t||o(``)}catch(e){t||(e instanceof Error&&`statusCode`in e&&e.statusCode===403&&(u.current=null,n(null),i(``)),o(e instanceof Error?e.message:String(e)))}finally{r=!1}}c();let l=window.setInterval(()=>void c(),3e3);return()=>{p.current=!1,t=!0,window.clearInterval(l)}},[e]);async function v(t,n={}){if(!e||!u.current||d.current)return!1;let r=u.current.identity,a=u.current.notes.filter(e=>e.status===`open`).map(e=>`${e.id}:${e.revision}`).sort().join(`,`);d.current=!0,h.current++,l(!0),i(``);try{if(await f.current,!p.current)return!1;if(!u.current||u.current.identity!==r)throw Error(_.branchChanged);if(t===`fix`&&u.current.notes.filter(e=>e.status===`open`).map(e=>`${e.id}:${e.revision}`).sort().join(`,`)!==a)throw Error(_.workChanged);return g(await s(t===`fix`?`/api/improvement-notes/fix`:`/api/improvement-notes`,e,{method:`POST`,body:JSON.stringify({identity:u.current.identity,revision:u.current.revision,operation:t,...n})})),!0}catch(e){return p.current&&i(e instanceof Error?e.message:String(e)),!1}finally{d.current=!1,p.current&&l(!1)}}async function y(){if(!e)return null;i(``);try{return await s(`/api/improvement-notes/capture`,e,{method:`POST`})}catch(e){return i(`${e instanceof Error?e.message:String(e)} ${_.sourceUnavailable}`),null}}return{state:t,error:r||a,busy:c,change:v,capture:y}}var S=e({ImprovementNotesPrototype:()=>w}),C=o();function w({canvas:e}){let t=x(e.token),n=t.state?.notes??[],[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),[c,u]=(0,m.useState)(!1),[f,y]=(0,m.useState)(null),[S,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(``),[D,O]=(0,m.useState)(!1),[k,A]=(0,m.useState)(!0),[j,M]=(0,m.useState)(``),N=(0,m.useRef)(0),P=(0,m.useRef)(null),F=(0,m.useRef)(null),I=(0,m.useRef)(null),L=S!==null&&S.identity!==t.state?.identity,R=S!==null&&!D&&t.state!==null,z=n.filter(e=>e.status!==`resolved`).length,B=t.state?.syncError===`Notes are saved locally until Hub discovers this branch.`?null:t.state?.syncError,V=(0,m.useCallback)(e=>{w({identity:f?.identity??t.state?.identity,sourceId:f?.sourceId,anchor:e}),E(``)},[t.state?.identity,f]),H=(0,m.useCallback)(()=>{N.current++,u(!1),P.current?.getAttribute(`aria-pressed`)===`true`&&P.current.focus(),s(!1)},[]),U=b({frameRef:e.frameRef,prototypeUrl:e.prototypeUrl,previewUrl:e.previewUrl,notes:n,annotating:o,composing:S!==null,onSelect:V,onRoute:a,onCancel:H,onProblem:M});(0,m.useLayoutEffect)(()=>{R&&F.current?.focus()},[R]);function W(){A(!0),e.onOpenNotes()}async function G(){let e=++N.current;u(!0);let n=await t.capture();e===N.current&&(u(!1),y(n),s(!0),A(!1),M(_.selectHint))}function K(){T===``?(w(null),H()):O(!0)}async function q(){S&&T.trim()&&!t.busy&&!L&&await t.change(`create`,{identity:S.identity,sourceId:S.sourceId,body:T.trim(),anchor:S.anchor})&&(W(),H(),w(null),M(_.saved))}return(0,C.jsxs)(`section`,{"aria-label":_.title,className:`improvement-demo`,onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&!S&&H()},children:[e.toolbarTarget&&(0,h.createPortal)((0,C.jsxs)(`div`,{role:`group`,"aria-label":_.title,className:`improvement-demo__split`,children:[(0,C.jsx)(g.Button,{ref:P,size:`small`,variant:`secondary`,className:`canvas-toolbar-compact-button`,title:_.annotate,leadingVisual:(0,C.jsx)(r,{}),"aria-pressed":o,disabled:c||!U.ready||!t.state,onClick:()=>{o?H():G()},children:(0,C.jsx)(`span`,{className:`canvas-toolbar-button-label`,children:_.annotate})}),(0,C.jsx)(g.Button,{ref:I,size:`small`,variant:`secondary`,"aria-label":_.openNotes(z),"aria-expanded":k&&!e.hubOpen,onClick:W,children:(0,C.jsx)(d,{children:z})})]}),e.toolbarTarget),(0,C.jsx)(p,{identity:t.state?.identity??``,controls:!1,returnFocusRef:I,open:k&&!e.hubOpen&&!S,active:(k||o)&&!e.hubOpen&&!S,onOpen:W,onClose:()=>{A(!1),I.current?.focus()},threads:n.map(e=>v(e,U.resolutions.get(e.id))),busy:t.busy||!t.state,activeBatch:!!t.state?.activeBatch,error:t.error||B||t.state?.profileError||(t.state?U.ready?``:_.bridgeUnavailable:_.storageLoading),onSelect:t=>{let r=n.find(e=>e.id===t);r&&r.route!==i&&e.onNavigate(new URL(r.route,e.prototypeUrl).href)},onFollowUp:(e,n)=>t.change(`follow-up`,{id:e.id,expectedNoteRevision:e.revision,body:n}),onResolve:e=>t.change(`status`,{id:e.id,expectedNoteRevision:e.revision,status:`resolved`}),onDelete:e=>t.change(`delete`,{id:e.id,expectedNoteRevision:e.revision}),onFix:()=>t.change(`fix`),onRetry:e=>t.change(`status`,{id:e.id,expectedNoteRevision:e.revision,status:`open`})}),(0,C.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:j}),R?(0,C.jsxs)(l,{title:_.add,closeLabel:_.closeComposer,returnFocusRef:P,onClose:K,className:`improvement-demo__composer`,children:[t.error?(0,C.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:t.error}):null,L?(0,C.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:_.branchChanged}):null,(0,C.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),q()},children:[(0,C.jsxs)(g.FormControl,{fullWidth:!0,children:[(0,C.jsx)(g.FormControl.Label,{children:_.label}),(0,C.jsx)(g.Textarea,{ref:F,value:T,maxLength:1e4,rows:4,placeholder:_.placeholder,onChange:e=>E(e.target.value),required:!0})]}),(0,C.jsx)(`div`,{className:`improvement-demo__dialog-actions`,children:(0,C.jsx)(g.Button,{type:`submit`,size:`small`,variant:`primary`,disabled:!T.trim()||t.busy||L,children:_.save})})]})]}):null,D&&t.state?(0,C.jsxs)(l,{title:_.discardTitle,closeLabel:_.closeDiscard,returnFocusRef:P,onClose:()=>O(!1),children:[(0,C.jsx)(`p`,{children:_.discardBody}),(0,C.jsxs)(`div`,{className:`improvement-demo__dialog-actions`,children:[(0,C.jsx)(g.Button,{size:`small`,variant:`secondary`,onClick:()=>O(!1),children:_.keep}),(0,C.jsx)(g.Button,{size:`small`,variant:`primary`,onClick:()=>{O(!1),w(null),E(``),H()},children:_.discard})]})]}):null]})}export{S as t}; \ No newline at end of file +import{n as e,r as t}from"./renderer-rolldown-runtime.js";import{K as n,M as r,X as i,Y as a,q as o}from"./renderer-vendor.js";import{c as s,h as c,l,m as u,o as d,s as f,t as p}from"./renderer.js";import{t as m}from"./renderer-prototype-canvas-improvement-threads.js";var h=t(i(),1),g=a(),_=n(),v={title:`Pick & polish`,localAuthor:`Local author`,bridgeUnavailable:`Annotation needs the updated Replica preview bridge. Reconnect or reload the preview after updating the canvas.`,sourceUnavailable:`You can still save this improvement locally, but it cannot sync without a captured source.`,annotate:`Pick & polish`,openNotes:e=>`Open improvement notes (${e})`,notes:`Pick & polish`,selectHint:`Click an element or drag a rectangle. For a keyboard region, focus the preview, press Shift+Enter, then use arrows and Enter to choose two corners. Escape exits annotation mode.`,regionSmall:`Choose a larger region, at least 8 preview pixels wide and high.`,add:`Add improvement note`,label:`What should change?`,placeholder:`Describe the improvement you want Copilot to make...`,save:`Save note`,cancel:`Cancel`,discard:`Discard draft`,keep:`Keep writing`,discardTitle:`Discard your unsaved note?`,discardBody:`Your saved notes will stay unchanged.`,editAction:`Edit`,previewUnavailable:`The preview selection is unavailable. Try selecting the target again.`,saved:`Note added.`,storageLoading:`Loading your notes...`,branchChanged:`The prototype branch changed. Close this draft and select the target again.`,workChanged:`The open improvements changed while syncing. Review them and select Fix all again.`,closeComposer:`Close note composer`,closeDiscard:`Close discard confirmation`};function y(e,t){let n=[e.thread.originalStatus,...e.thread.messages.filter(e=>e.role===`author`).map(e=>e.status)];return{id:e.id,revision:e.revision,body:e.body,author:e.thread.originalAuthor?`@${e.thread.originalAuthor.login}`:e.author===`local`?v.localAuthor:`@${e.author}`,avatarUrl:e.thread.originalAuthor?.avatarUrl,target:e.target,path:e.route,status:e.status,originalPending:e.thread.originalStatus===`open`,...n.includes(`sent`)?{retryStatus:`sent`}:n.includes(`blocked`)?{retryStatus:`blocked`}:{},messages:e.thread.messages.map(e=>({...e,...e.role===`author`&&e.author?{author:`@${e.author.login}`,avatarUrl:e.author.avatarUrl}:{author:void 0},pending:e.role===`author`&&e.status===`open`})),...t&&(t.status===`resolved`||t.status===`moved`)?{point:t.point}:{}}}function b(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function x({frameRef:e,prototypeUrl:t,previewUrl:n,notes:r,annotating:i,composing:a,onSelect:o,onRoute:c,onCancel:u,onProblem:d}){let p=n??t,[m,g]=(0,h.useState)(null),[_,y]=(0,h.useState)(new Map),x=JSON.stringify(r.filter(e=>e.anchor).map(e=>({id:e.id,anchor:e.anchor}))),S=(0,h.useEffectEvent)(e=>{if(!i||a)return;let t=s.safeParse(e);t.success?o(t.data):(u(),d(v.previewUnavailable))}),C=(0,h.useCallback)((t,n={})=>{p&&m&&e?.current?.contentWindow&&e.current.contentWindow.postMessage({type:t,nonce:m.nonce,...n},new URL(p).origin)},[m,e,p]);return(0,h.useEffect)(()=>{let t=e?.current;if(!t||!p)return;let n=new URL(p).origin,r=crypto.randomUUID(),i=Date.now(),a=JSON.parse(x);function o(){t?.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:r},n),t?.contentWindow?.postMessage({type:`replica:canvas:resolve`,nonce:r,anchors:a},n)}function s(){r=crypto.randomUUID(),i=Date.now(),g({nonce:r,ready:!1}),y(new Map),u(),o()}function m(e){let a=e.data;if(e.source===t?.contentWindow&&e.origin===n&&b(a)&&a.nonce===r){if(a.type===`replica:canvas:ready`){let e=l.safeParse(a.route);if(a.protocolVersion!==1||a.improvementSelection!==!0||!e.success){g({nonce:r,ready:!1}),d(v.bridgeUnavailable);return}i=Date.now(),g(e=>e?.nonce===r&&e.ready?e:{nonce:r,ready:!0}),c(e.data.pathname+e.data.search+e.data.hash)}else if(a.type===`replica:canvas:selected`)S(a.anchor);else if(a.type===`replica:canvas:resolved`&&Array.isArray(a.results)){let e=new Map;for(let t of a.results){if(!b(t))continue;let n=f.safeParse({commentId:t.id,status:`resolved`,point:{x:t.x,y:t.y},rect:t.rect??{x:t.x,y:t.y,width:1,height:1}});n.success&&e.set(n.data.commentId,n.data)}y(e)}else a.type===`replica:canvas:selection-failed`||a.type===`replica:canvas:bridge-error`?(u(),d(a.reason===`area-too-small`?v.regionSmall:v.bridgeUnavailable)):a.type===`replica:canvas:selection-cancelled`?a.reason!==`command`&&u():a.type===`replica:canvas:conversation-dismiss-requested`&&window.dispatchEvent(new Event(`replica:review-dismiss`))}}t.addEventListener(`load`,s),window.addEventListener(`message`,m),g({nonce:r,ready:!1}),o();let h=window.setInterval(()=>{Date.now()-i>2e4&&(g({nonce:r,ready:!1}),y(new Map),u(),d(v.bridgeUnavailable)),o()},2e3);return()=>{t.removeEventListener(`load`,s),window.removeEventListener(`message`,m),window.clearInterval(h),t.contentWindow?.postMessage({type:`replica:canvas:cancel-selection`,nonce:r},n),t.contentWindow?.postMessage({type:`replica:canvas:clear-selection`,nonce:r},n)}},[x,e,p,u,d,c]),(0,h.useEffect)(()=>{m?.ready&&(i&&!a?C(`replica:canvas:select`,{mode:`improvement`}):C(`replica:canvas:cancel-selection`),a||C(`replica:canvas:clear-selection`))},[i,a,m?.ready,C]),{ready:m?.ready===!0,resolutions:_}}function S(e){let[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(``),[a,o]=(0,h.useState)(``),[s,c]=(0,h.useState)(!1),l=(0,h.useRef)(null),u=(0,h.useRef)(!1),f=(0,h.useRef)(null),p=(0,h.useRef)(!1),m=(0,h.useRef)(0);function g(e){p.current&&(l.current=e,n(e))}(0,h.useEffect)(()=>{if(!e)return;p.current=!0;let t=!1,r=!1,a=0;async function s(){if(u.current||r)return;r=!0;let s=m.current;try{let n=await d(`/api/improvement-notes`,e);if(u.current||s!==m.current||t)return;if(g(n),Date.now()-a>15e3){a=Date.now();let r=d(`/api/improvement-notes/sync`,e,{method:`POST`,body:JSON.stringify({identity:n.identity,revision:n.revision})}).then(e=>{t||g(e)});f.current=r;try{await r}finally{f.current===r&&(f.current=null)}}t||o(``)}catch(e){t||(e instanceof Error&&`statusCode`in e&&e.statusCode===403&&(l.current=null,n(null),i(``)),o(e instanceof Error?e.message:String(e)))}finally{r=!1}}s();let c=window.setInterval(()=>void s(),3e3);return()=>{p.current=!1,t=!0,window.clearInterval(c)}},[e]);async function _(t,n={}){if(!e||!l.current||u.current)return!1;let r=l.current.identity,a=l.current.notes.filter(e=>e.status===`open`).map(e=>`${e.id}:${e.revision}`).sort().join(`,`);u.current=!0,m.current++,c(!0),i(``);try{if(await f.current,!p.current)return!1;if(!l.current||l.current.identity!==r)throw Error(v.branchChanged);if(t===`fix`&&l.current.notes.filter(e=>e.status===`open`).map(e=>`${e.id}:${e.revision}`).sort().join(`,`)!==a)throw Error(v.workChanged);return g(await d(t===`fix`?`/api/improvement-notes/fix`:`/api/improvement-notes`,e,{method:`POST`,body:JSON.stringify({identity:l.current.identity,revision:l.current.revision,operation:t,...n})})),!0}catch(e){return p.current&&i(e instanceof Error?e.message:String(e)),!1}finally{u.current=!1,p.current&&c(!1)}}async function y(){if(!e)return null;i(``);try{return await d(`/api/improvement-notes/capture`,e,{method:`POST`})}catch(e){return i(`${e instanceof Error?e.message:String(e)} ${v.sourceUnavailable}`),null}}return{state:t,error:r||a,busy:s,change:_,capture:y}}var C=e({ImprovementNotesPrototype:()=>T}),w=o();function T({canvas:e}){let t=S(e.token),n=t.state?.notes??[],[i,a]=(0,h.useState)(``),[o,s]=(0,h.useState)(!1),[l,d]=(0,h.useState)(!1),[f,b]=(0,h.useState)(null),[C,T]=(0,h.useState)(null),[E,D]=(0,h.useState)(``),[O,k]=(0,h.useState)(!1),[A,j]=(0,h.useState)(!0),[M,N]=(0,h.useState)(``),P=(0,h.useRef)(0),F=(0,h.useRef)(null),I=(0,h.useRef)(null),L=(0,h.useRef)(null),R=C!==null&&C.identity!==t.state?.identity,z=C!==null&&!O&&t.state!==null,B=n.filter(e=>e.status!==`resolved`).length,V=t.state?.syncError===`Notes are saved locally until Hub discovers this branch.`?null:t.state?.syncError,H=(0,h.useCallback)(e=>{T({identity:f?.identity??t.state?.identity,sourceId:f?.sourceId,anchor:e}),D(``)},[t.state?.identity,f]),U=(0,h.useCallback)(()=>{P.current++,d(!1),F.current?.getAttribute(`aria-pressed`)===`true`&&F.current.focus(),s(!1)},[]),W=x({frameRef:e.frameRef,prototypeUrl:e.prototypeUrl,previewUrl:e.previewUrl,notes:n,annotating:o,composing:C!==null,onSelect:H,onRoute:a,onCancel:U,onProblem:N});(0,h.useLayoutEffect)(()=>{z&&I.current?.focus()},[z]);function G(){j(!0),e.onOpenNotes()}async function K(){let e=++P.current;d(!0);let n=await t.capture();e===P.current&&(d(!1),b(n),s(!0),j(!1),N(v.selectHint))}function q(){E===``?(T(null),U()):k(!0)}async function J(){C&&E.trim()&&!t.busy&&!R&&await t.change(`create`,{identity:C.identity,sourceId:C.sourceId,body:E.trim(),anchor:C.anchor})&&(G(),U(),T(null),N(v.saved))}return(0,w.jsxs)(`section`,{"aria-label":v.title,className:`improvement-demo`,onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&!C&&U()},children:[e.toolbarTarget&&(0,g.createPortal)((0,w.jsxs)(`div`,{role:`group`,"aria-label":v.title,className:`improvement-demo__split`,children:[(0,w.jsx)(_.Button,{ref:F,size:`small`,variant:`secondary`,className:`canvas-toolbar-compact-button`,title:v.annotate,leadingVisual:(0,w.jsx)(r,{}),"aria-pressed":o,disabled:l||!W.ready||!t.state,onClick:()=>{o?U():K()},children:(0,w.jsx)(`span`,{className:`canvas-toolbar-button-label`,children:v.annotate})}),(0,w.jsx)(_.Button,{ref:L,size:`small`,variant:`secondary`,"aria-label":v.openNotes(B),"aria-expanded":A&&!e.hubOpen,onClick:G,children:(0,w.jsx)(u,{children:B})})]}),e.toolbarTarget),(0,w.jsx)(m,{identity:t.state?.identity??``,controls:!1,returnFocusRef:L,open:A&&!e.hubOpen&&!C,active:(A||o)&&!e.hubOpen&&!C,onOpen:G,onClose:()=>{j(!1),L.current?.focus()},threads:n.map(e=>y(e,W.resolutions.get(e.id))),busy:t.busy||!t.state,activeBatch:!!t.state?.activeBatch,error:t.error||V||t.state?.profileError||(t.state?W.ready?``:v.bridgeUnavailable:v.storageLoading),onSelect:t=>{let r=n.find(e=>e.id===t);r&&r.route!==i&&e.onNavigate(new URL(`${p(new URL(e.prototypeUrl).pathname)}${r.route.slice(1)}`,e.prototypeUrl).href)},onFollowUp:(e,n)=>t.change(`follow-up`,{id:e.id,expectedNoteRevision:e.revision,body:n}),onResolve:e=>t.change(`status`,{id:e.id,expectedNoteRevision:e.revision,status:`resolved`}),onDelete:e=>t.change(`delete`,{id:e.id,expectedNoteRevision:e.revision}),onFix:()=>t.change(`fix`),onRetry:e=>t.change(`status`,{id:e.id,expectedNoteRevision:e.revision,status:`open`})}),(0,w.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:M}),z?(0,w.jsxs)(c,{title:v.add,closeLabel:v.closeComposer,returnFocusRef:F,onClose:q,className:`improvement-demo__composer`,children:[t.error?(0,w.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:t.error}):null,R?(0,w.jsx)(`p`,{role:`alert`,className:`improvement-demo__notice`,children:v.branchChanged}):null,(0,w.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),J()},children:[(0,w.jsxs)(_.FormControl,{fullWidth:!0,children:[(0,w.jsx)(_.FormControl.Label,{children:v.label}),(0,w.jsx)(_.Textarea,{ref:I,value:E,maxLength:1e4,rows:4,placeholder:v.placeholder,onChange:e=>D(e.target.value),required:!0})]}),(0,w.jsx)(`div`,{className:`improvement-demo__dialog-actions`,children:(0,w.jsx)(_.Button,{type:`submit`,size:`small`,variant:`primary`,disabled:!E.trim()||t.busy||R,children:v.save})})]})]}):null,O&&t.state?(0,w.jsxs)(c,{title:v.discardTitle,closeLabel:v.closeDiscard,returnFocusRef:F,onClose:()=>k(!1),children:[(0,w.jsx)(`p`,{children:v.discardBody}),(0,w.jsxs)(`div`,{className:`improvement-demo__dialog-actions`,children:[(0,w.jsx)(_.Button,{size:`small`,variant:`secondary`,onClick:()=>k(!1),children:v.keep}),(0,w.jsx)(_.Button,{size:`small`,variant:`primary`,onClick:()=>{k(!1),T(null),D(``),U()},children:v.discard})]})]}):null]})}export{C as t}; \ No newline at end of file diff --git a/.github/extensions/replica-prototype/assets/renderer-prototype-canvas-improvement-threads.js b/.github/extensions/replica-prototype/assets/renderer-prototype-canvas-improvement-threads.js index 3ca09d89d..f53fca46f 100644 --- a/.github/extensions/replica-prototype/assets/renderer-prototype-canvas-improvement-threads.js +++ b/.github/extensions/replica-prototype/assets/renderer-prototype-canvas-improvement-threads.js @@ -1,5 +1,5 @@ -import{r as e}from"./renderer-rolldown-runtime.js";import{E as t,K as n,M as ee,P as r,X as te,Y as i,b as ne,f as re,g as ie,q as ae,u as oe,z as se}from"./renderer-vendor.js";import{d as a,f as ce,h as le,i as ue,l as o,m as de,n as s,p as fe,r as pe,t as me,u as he}from"./renderer.js";import{t as c}from"./renderer-improvement-notes-vendor.js";var l=e(te(),1),u=i(),d=n(),ge=c(),_e=` +import{r as e}from"./renderer-rolldown-runtime.js";import{E as t,K as n,M as ee,P as r,X as te,Y as i,b as ne,f as re,g as ie,q as ae,u as oe,z as se}from"./renderer-vendor.js";import{a as ce,d as le,f as a,g as ue,h as de,i as fe,m as pe,n as me,p as he,r as o,u as s}from"./renderer.js";import{t as c}from"./renderer-improvement-notes-vendor.js";var l=e(te(),1),u=i(),d=n(),ge=c(),_e=` -`,f={title:`Pick & polish`,point:e=>`Open improvement ${e}`,close:`Close improvements`,open:`Open improvements`,conversation:`Improvement`,back:`Close improvement`,copilot:`Copilot`,markResolved:`Mark as resolved`,retry:`Retry`,returnToActive:`Return to active`,followUps:e=>`${e} ${e===1?`follow-up`:`follow-ups`}`,actions:`Improvement actions`,ready:`Ready to review`,openStatus:`Open`,changedIdentity:`The prototype branch or author changed. Close this dialog and reload before making changes.`,targetUnavailable:`The saved target is not visible on this page. The conversation is shown beside the preview.`,removed:`This improvement is no longer available. Close this dialog to return to the remaining improvements.`,workStatus:e=>({open:`Open`,sent:`In progress`,ready:`Ready to review`,blocked:`Blocked`,resolved:`Resolved`})[e]??e,filter:`Filter improvement notes`,allActive:`Active notes`,empty:`No improvements in this view.`,resolved:`Resolved`,resolve:`Resolved`,fix:`Fix all`,simulate:e=>`Fix all, ${e} pending ${e===1?`request`:`requests`}`,added:`Follow-up added.`,delete:`Delete improvement`,deleteTitle:`Delete this improvement?`,comments:{...o,replyLabel:`Follow-up`,replyPlaceholder:`Request a follow-up change`,replySubmitLabel:`Add follow-up`,replySubmitTooltipMacLabel:`Add follow-up (⌘Enter)`,replySubmitTooltipOtherLabel:`Add follow-up (Ctrl+Enter)`,replyErrorLabel:`The follow-up could not be added.`,threadDiscardPromptLabel:`Your unsaved follow-up will be lost.`}},p=ae(),m=`data:image/svg+xml,${encodeURIComponent(_e)}`,ve=`data:image/svg+xml,${encodeURIComponent((0,ge.renderToStaticMarkup)((0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,children:(0,p.jsx)(r,{size:16,fill:`white`})})))}`;function h({threads:e,open:n,active:r=n,onOpen:te,onClose:i,onFollowUp:ae,onResolve:o,onDelete:c,onFix:ge,onSelect:_e,onRetry:h,identity:g,busy:_=!1,activeBatch:ye=!1,error:v=``,returnFocusRef:be,controls:xe=!0}){let[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(null),[C,w]=(0,l.useState)(``),[T,E]=(0,l.useState)(!1),[D,O]=(0,l.useState)(!1),[k,A]=(0,l.useState)(null),[j,M]=(0,l.useState)(g),[Se,Ce]=(0,l.useState)(``),[N,we]=(0,l.useState)(`active`),[P,Te]=(0,l.useState)(null),[F]=(0,l.useState)(()=>document.querySelector(`#canvas-improvement-controls`)),I=(0,l.useRef)(null),L=be??I,R=(0,l.useRef)(null),z=(0,l.useRef)(null),B=(0,l.useRef)(new Map),V=(0,l.useRef)(null),H=(0,l.useRef)(!1),Ee=e.find(e=>e.id===y),U=(y!==null||k!==null)&&g!==j,W=g===j?Ee??x:x,G=y!==null&&!Ee,K=k!==null&&!e.some(e=>e.id===k.id),{cardRef:q,position:De}=ue({anchorPoint:{x:12,y:12},anchorSelector:y===null?void 0:`[data-improvement-thread-id="${y}"]`,layoutKey:`${y}:${D}:${W?.messages.length}:${W?.status}`}),J=e.reduce((e,t)=>e+Number(t.originalPending)+t.messages.filter(e=>e.pending).length,0),Y=new TextEncoder().encode(C).length>1e4,Oe=[{value:`active`,label:f.allActive},{value:`ready`,label:f.ready},{value:`resolved`,label:f.resolved}],ke=Oe.find(e=>e.value===N).label,X=e.filter(e=>N===`resolved`?e.status===`resolved`:N===`ready`?e.status===`ready`:e.status!==`resolved`);(0,l.useLayoutEffect)(()=>{y===null?V.current!==null&&((R.current?.isConnected?R.current:B.current.get(V.current)??L.current)?.focus(),V.current=null):D?q.current?.querySelector(`.review-confirmation-panel button`)?.focus():U||G?q.current?.querySelector(`.thread-sample__close`)?.focus():q.current?.querySelector(`textarea`)?.focus()},[y,D,q,L,U,G]);let Z=(0,l.useCallback)(()=>{V.current=y,b(null),S(null),w(``),O(!1),H.current&&=(i(),L.current?.focus(),!1)},[y,i,L]),Q=(0,l.useCallback)(()=>{C.trim()?O(!0):y===null?(i(),L.current?.focus()):Z()},[C,y,Z,i,L]);(0,l.useEffect)(()=>{if(y===null)return;function e(){document.querySelector(`[role="menu"]`)||k||(D?(H.current=!1,O(!1)):Q())}function t(t){t.key!==`Escape`||t.defaultPrevented||t.isComposing||t.target instanceof Element&&t.target.closest(`[role="menu"], dialog`)||(t.preventDefault(),e())}return document.addEventListener(`keydown`,t),window.addEventListener(`replica:review-dismiss`,e),()=>{document.removeEventListener(`keydown`,t),window.removeEventListener(`replica:review-dismiss`,e)}},[y,D,k,Q]);function Ae(t,n){C.trim()||D||(R.current=n,M(g),S(e.find(e=>e.id===t)??null),b(t),_e?.(t))}async function je(){if(!W||!C.trim()||Y||U||G||_||T)return;let e=C.trim();E(!0);try{if(!await ae(W,e))return;w(t=>t.trim()===e?``:t),Ce(f.added)}finally{E(!1)}}async function Me(e){if(z.current?.identity!==g||z.current.id!==e.id||z.current.revision!==e.revision||e.status!==`ready`||_||C.trim()||D)return;let t=R.current;await o(e)&&!t?.isConnected&&L.current?.focus()}async function Ne(e){z.current?.identity!==g||z.current.id!==e.id||z.current.revision!==e.revision||!h||!e.retryStatus||_||C.trim()||D||await h(e)}let $=(0,p.jsx)(d.Button,{ref:I,size:`small`,variant:`secondary`,className:`canvas-toolbar-compact-button`,leadingVisual:(0,p.jsx)(ee,{size:16}),"aria-label":f.open,title:f.open,"aria-expanded":n,onClick:te,children:(0,p.jsx)(`span`,{className:`canvas-toolbar-button-label`,children:f.title})});return(0,p.jsxs)(p.Fragment,{children:[xe?F?(0,u.createPortal)($,F):$:null,(0,p.jsxs)(ce,{title:f.title,open:n,closeLabel:f.close,onClose:()=>{y===null?(i(),L.current?.focus()):(H.current=!0,Q())},closeDisabled:D,className:`thread-sample`,contentClassName:`thread-sample__content`,children:[v?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:v}):null,(0,p.jsx)(`div`,{className:`thread-sample__toolbar`,children:(0,p.jsxs)(`div`,{className:`thread-sample__filters`,children:[(0,p.jsxs)(d.ActionMenu,{size:`small`,selectionVariant:`single`,menuAlignment:`start`,onSelect:we,children:[(0,p.jsx)(d.ActionMenu.Button,{size:`small`,variant:`secondary`,"aria-label":`${f.filter}: ${ke}`,children:ke}),(0,p.jsx)(d.ActionMenu.Overlay,{"aria-label":f.filter,children:Oe.map(e=>(0,p.jsx)(d.ActionMenu.Item,{value:e.value,selected:N===e.value,role:`menuitemradio`,onKeyDownCapture:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())},children:e.label},e.value))})]}),N===`active`?(0,p.jsx)(d.Button,{size:`small`,variant:`primary`,className:`thread-sample__fix-all`,leadingVisual:(0,p.jsx)(ie,{size:16}),disabled:!J||!!C.trim()||D||_||ye,"aria-busy":_,"aria-label":f.simulate(J),onClick:()=>{ge()},children:(0,p.jsxs)(`span`,{className:`thread-sample__fix-label`,children:[f.fix,(0,p.jsx)(fe,{"aria-hidden":`true`,children:J})]})}):null]})}),W&&P?(0,u.createPortal)((0,p.jsx)(me,{ref:q,"aria-label":f.conversation,anchored:!0,position:De,className:`thread-sample__conversation`,onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&!e.nativeEvent.isComposing&&!(e.target instanceof Element&&e.target.closest(`[role="menu"]`))&&(e.preventDefault(),D?(H.current=!1,O(!1)):Q())},children:(0,p.jsxs)(`div`,{className:`review-thread-conversation__layout`,children:[(0,p.jsxs)(`header`,{className:`review-thread-conversation__header`,children:[(0,p.jsx)(d.Heading,{as:`h3`,size:`6`,children:f.conversation}),W.status===`ready`?(0,p.jsx)(d.Button,{size:`small`,variant:`secondary`,className:`thread-sample__resolve`,disabled:!!C.trim()||_||U||G,leadingVisual:(0,p.jsx)(se,{size:16}),onClick:()=>{o(W)},children:f.resolve}):null,(0,p.jsx)(le,{icon:oe,size:`small`,variant:`invisible`,"aria-label":f.back,className:`thread-sample__close`,onClick:Q})]}),U?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:f.changedIdentity}):null,G?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:f.removed}):null,v?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:v}):null,W.point?null:(0,p.jsx)(`p`,{role:`status`,className:`thread-sample__target-status`,children:f.targetUnavailable}),(0,p.jsxs)(`div`,{className:`review-thread-conversation__messages`,children:[(0,p.jsxs)(`article`,{className:`review-thread-message`,children:[(0,p.jsx)(s,{visual:(0,p.jsx)(a,{src:W.avatarUrl??m,size:28}),author:W.author}),(0,p.jsx)(`p`,{className:`review-thread-message__body`,children:W.body})]}),W.messages.map(e=>(0,p.jsxs)(`article`,{className:`review-thread-message`,children:[(0,p.jsx)(s,{visual:e.role===`copilot`?(0,p.jsx)(a,{src:ve,size:28,className:`thread-sample__copilot-avatar`}):(0,p.jsx)(a,{src:e.author?e.avatarUrl??m:W.avatarUrl??m,size:28}),author:e.role===`copilot`?f.copilot:e.author??W.author,metadata:e.role===`author`&&e.status&&e.status!==`ready`?(0,p.jsx)(`span`,{children:f.workStatus(e.status)}):void 0}),(0,p.jsx)(`p`,{className:`review-thread-message__body`,children:e.body})]},e.id))]}),(0,p.jsx)(`div`,{className:`review-thread-conversation__footer`,children:(0,p.jsx)(pe,{blockedLabel:null,confirmingDiscard:D,replyDraft:C,replyBodyTooLong:Y,replyFailed:!1,replyDisabled:U||G,replying:T,submitDisabled:_,copy:f.comments,onKeepDraft:()=>{H.current=!1,O(!1)},onDiscardDraft:Z,onSubmit:()=>{je()},onDraftChange:w})})]})}),P):null,(0,p.jsxs)(`div`,{className:`thread-sample__list`,children:[X.length===0?(0,p.jsx)(`p`,{className:`thread-sample__empty`,children:f.empty}):null,X.map(e=>{let n=e.messages.filter(e=>e.role===`author`).length;return(0,p.jsxs)(`article`,{className:`review-comment-row thread-sample__card${e.status===`resolved`?` thread-sample__card--resolved`:``}`,children:[(0,p.jsx)(`button`,{ref:t=>{t?B.current.set(e.id,t):B.current.delete(e.id)},className:`review-comment-row__button thread-sample__card-button`,"aria-label":`Open improvement: ${e.body}`,"aria-expanded":y===e.id,disabled:!!C.trim()||D,onClick:t=>Ae(e.id,t.currentTarget),children:(0,p.jsxs)(`span`,{className:`review-comment-row__layout`,children:[(0,p.jsx)(a,{src:e.avatarUrl??m,size:20}),(0,p.jsx)(`span`,{className:`review-comment-row__content`,children:(0,p.jsxs)(`span`,{className:`review-comment-row__copy`,children:[(0,p.jsxs)(`span`,{className:`thread-sample__heading`,children:[(0,p.jsx)(`strong`,{className:`review-comment-row__author`,children:e.author}),e.status===`open`?null:(0,p.jsx)(`span`,{className:`thread-sample__status${e.status===`ready`?` thread-sample__status--ready`:``}`,children:f.workStatus(e.status)})]}),(0,p.jsx)(`span`,{className:`review-comment-row__body`,children:e.body})]})})]})}),(0,p.jsxs)(`div`,{className:`thread-sample__metadata`,children:[(0,p.jsx)(`span`,{children:e.target}),(0,p.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,p.jsx)(`code`,{children:e.path})]}),n>0?(0,p.jsxs)(`span`,{className:`thread-sample__follow-ups`,children:[(0,p.jsx)(ne,{size:12,"aria-hidden":`true`}),f.followUps(n)]}):null,(0,p.jsx)(`div`,{className:`thread-sample__menu`,children:(0,p.jsxs)(d.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,disabled:!!C.trim()||D,children:[(0,p.jsx)(d.ActionMenu.IconButton,{icon:t,"aria-label":`${f.actions}: ${e.id}`,variant:`invisible`,onClick:t=>{R.current=t.currentTarget,z.current={identity:g,id:e.id,revision:e.revision}}}),(0,p.jsxs)(d.ActionMenu.Overlay,{"aria-label":`${f.actions}: ${e.id}`,children:[h&&e.retryStatus?(0,p.jsx)(d.ActionMenu.Item,{value:`retry`,disabled:_,className:`thread-sample__menu-item`,onClick:()=>{Ne(e)},children:e.retryStatus===`sent`?f.returnToActive:f.retry}):null,e.status===`ready`?(0,p.jsx)(d.ActionMenu.Item,{value:`resolve`,className:`thread-sample__menu-item`,disabled:_,leadingVisual:(0,p.jsx)(se,{size:16}),onClick:()=>{Me(e)},children:f.markResolved}):null,(0,p.jsx)(d.ActionMenu.Item,{value:`delete`,className:`thread-sample__menu-item thread-sample__delete`,disabled:_,leadingVisual:(0,p.jsx)(re,{size:16}),onClick:()=>{_||C.trim()||D||(M(g),A(e))},children:f.delete})]})]})})]},e.id)})]})]}),(0,p.jsx)(`div`,{ref:Te,className:`canvas-conversation-shell thread-sample__surface`,hidden:!r}),(0,p.jsx)(`div`,{className:`canvas-conversation-shell thread-sample__markers`,hidden:!r,children:e.filter(e=>e.id===y||X.includes(e)).filter(e=>e.point).map(e=>(0,p.jsx)(`button`,{type:`button`,className:`review-comment-marker thread-sample__marker${y===e.id?` review-comment-marker--selected`:``}`,"data-improvement-thread-id":e.id,"aria-label":f.point(e.id),"aria-expanded":y===e.id,disabled:!!C.trim()||D,style:{left:e.point.x,top:e.point.y},onClick:t=>Ae(e.id,t.currentTarget),children:(0,p.jsx)(he,{participants:[{login:e.author,name:null,avatarUrl:e.avatarUrl??m}],size:`small`})},e.id))}),(0,p.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:Se}),k?(0,p.jsxs)(de,{title:f.deleteTitle,closeLabel:f.comments.cancelEditLabel,onClose:()=>A(null),returnFocusRef:R,children:[U?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:f.changedIdentity}):null,K?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:f.removed}):null,v?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:v}):null,(0,p.jsx)(`blockquote`,{className:`thread-sample__quote`,children:k.body}),(0,p.jsxs)(`div`,{className:`thread-sample__delete-actions`,children:[(0,p.jsx)(d.Button,{size:`small`,variant:`secondary`,onClick:()=>A(null),children:f.comments.cancelEditLabel}),(0,p.jsx)(d.Button,{size:`small`,variant:`primary`,className:`thread-sample__delete-confirm`,disabled:_||U||K,onClick:async()=>{if(!(_||U||K)&&await c(k)){let e=X.find(e=>e.id!==k.id);R.current=(e?B.current.get(e.id):null)??L.current,y===k.id&&Z(),A(null)}},children:f.delete})]})]}):null]})}export{f as n,h as t}; \ No newline at end of file +`,f={title:`Pick & polish`,point:e=>`Open improvement ${e}`,close:`Close improvements`,open:`Open improvements`,conversation:`Improvement`,back:`Close improvement`,copilot:`Copilot`,markResolved:`Mark as resolved`,retry:`Retry`,returnToActive:`Return to active`,followUps:e=>`${e} ${e===1?`follow-up`:`follow-ups`}`,actions:`Improvement actions`,ready:`Ready to review`,openStatus:`Open`,changedIdentity:`The prototype branch or author changed. Close this dialog and reload before making changes.`,targetUnavailable:`The saved target is not visible on this page. The conversation is shown beside the preview.`,removed:`This improvement is no longer available. Close this dialog to return to the remaining improvements.`,workStatus:e=>({open:`Open`,sent:`In progress`,ready:`Ready to review`,blocked:`Blocked`,resolved:`Resolved`})[e]??e,filter:`Filter improvement notes`,allActive:`Active notes`,empty:`No improvements in this view.`,resolved:`Resolved`,resolve:`Resolved`,fix:`Fix all`,simulate:e=>`Fix all, ${e} pending ${e===1?`request`:`requests`}`,added:`Follow-up added.`,delete:`Delete improvement`,deleteTitle:`Delete this improvement?`,comments:{...s,replyLabel:`Follow-up`,replyPlaceholder:`Request a follow-up change`,replySubmitLabel:`Add follow-up`,replySubmitTooltipMacLabel:`Add follow-up (⌘Enter)`,replySubmitTooltipOtherLabel:`Add follow-up (Ctrl+Enter)`,replyErrorLabel:`The follow-up could not be added.`,threadDiscardPromptLabel:`Your unsaved follow-up will be lost.`}},p=ae(),m=`data:image/svg+xml,${encodeURIComponent(_e)}`,ve=`data:image/svg+xml,${encodeURIComponent((0,ge.renderToStaticMarkup)((0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,children:(0,p.jsx)(r,{size:16,fill:`white`})})))}`;function h({threads:e,open:n,active:r=n,onOpen:te,onClose:i,onFollowUp:ae,onResolve:s,onDelete:c,onFix:ge,onSelect:_e,onRetry:h,identity:g,busy:_=!1,activeBatch:ye=!1,error:v=``,returnFocusRef:be,controls:xe=!0}){let[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(null),[C,w]=(0,l.useState)(``),[T,E]=(0,l.useState)(!1),[D,O]=(0,l.useState)(!1),[k,A]=(0,l.useState)(null),[j,M]=(0,l.useState)(g),[Se,Ce]=(0,l.useState)(``),[N,we]=(0,l.useState)(`active`),[P,Te]=(0,l.useState)(null),[F]=(0,l.useState)(()=>document.querySelector(`#canvas-improvement-controls`)),I=(0,l.useRef)(null),L=be??I,R=(0,l.useRef)(null),z=(0,l.useRef)(null),B=(0,l.useRef)(new Map),V=(0,l.useRef)(null),H=(0,l.useRef)(!1),Ee=e.find(e=>e.id===y),U=(y!==null||k!==null)&&g!==j,W=g===j?Ee??x:x,G=y!==null&&!Ee,K=k!==null&&!e.some(e=>e.id===k.id),{cardRef:q,position:De}=ce({anchorPoint:{x:12,y:12},anchorSelector:y===null?void 0:`[data-improvement-thread-id="${y}"]`,layoutKey:`${y}:${D}:${W?.messages.length}:${W?.status}`}),J=e.reduce((e,t)=>e+Number(t.originalPending)+t.messages.filter(e=>e.pending).length,0),Y=new TextEncoder().encode(C).length>1e4,Oe=[{value:`active`,label:f.allActive},{value:`ready`,label:f.ready},{value:`resolved`,label:f.resolved}],ke=Oe.find(e=>e.value===N).label,X=e.filter(e=>N===`resolved`?e.status===`resolved`:N===`ready`?e.status===`ready`:e.status!==`resolved`);(0,l.useLayoutEffect)(()=>{y===null?V.current!==null&&((R.current?.isConnected?R.current:B.current.get(V.current)??L.current)?.focus(),V.current=null):D?q.current?.querySelector(`.review-confirmation-panel button`)?.focus():U||G?q.current?.querySelector(`.thread-sample__close`)?.focus():q.current?.querySelector(`textarea`)?.focus()},[y,D,q,L,U,G]);let Z=(0,l.useCallback)(()=>{V.current=y,b(null),S(null),w(``),O(!1),H.current&&=(i(),L.current?.focus(),!1)},[y,i,L]),Q=(0,l.useCallback)(()=>{C.trim()?O(!0):y===null?(i(),L.current?.focus()):Z()},[C,y,Z,i,L]);(0,l.useEffect)(()=>{if(y===null)return;function e(){document.querySelector(`[role="menu"]`)||k||(D?(H.current=!1,O(!1)):Q())}function t(t){t.key!==`Escape`||t.defaultPrevented||t.isComposing||t.target instanceof Element&&t.target.closest(`[role="menu"], dialog`)||(t.preventDefault(),e())}return document.addEventListener(`keydown`,t),window.addEventListener(`replica:review-dismiss`,e),()=>{document.removeEventListener(`keydown`,t),window.removeEventListener(`replica:review-dismiss`,e)}},[y,D,k,Q]);function Ae(t,n){C.trim()||D||(R.current=n,M(g),S(e.find(e=>e.id===t)??null),b(t),_e?.(t))}async function je(){if(!W||!C.trim()||Y||U||G||_||T)return;let e=C.trim();E(!0);try{if(!await ae(W,e))return;w(t=>t.trim()===e?``:t),Ce(f.added)}finally{E(!1)}}async function Me(e){if(z.current?.identity!==g||z.current.id!==e.id||z.current.revision!==e.revision||e.status!==`ready`||_||C.trim()||D)return;let t=R.current;await s(e)&&!t?.isConnected&&L.current?.focus()}async function Ne(e){z.current?.identity!==g||z.current.id!==e.id||z.current.revision!==e.revision||!h||!e.retryStatus||_||C.trim()||D||await h(e)}let $=(0,p.jsx)(d.Button,{ref:I,size:`small`,variant:`secondary`,className:`canvas-toolbar-compact-button`,leadingVisual:(0,p.jsx)(ee,{size:16}),"aria-label":f.open,title:f.open,"aria-expanded":n,onClick:te,children:(0,p.jsx)(`span`,{className:`canvas-toolbar-button-label`,children:f.title})});return(0,p.jsxs)(p.Fragment,{children:[xe?F?(0,u.createPortal)($,F):$:null,(0,p.jsxs)(he,{title:f.title,open:n,closeLabel:f.close,onClose:()=>{y===null?(i(),L.current?.focus()):(H.current=!0,Q())},closeDisabled:D,className:`thread-sample`,contentClassName:`thread-sample__content`,children:[v?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:v}):null,(0,p.jsx)(`div`,{className:`thread-sample__toolbar`,children:(0,p.jsxs)(`div`,{className:`thread-sample__filters`,children:[(0,p.jsxs)(d.ActionMenu,{size:`small`,selectionVariant:`single`,menuAlignment:`start`,onSelect:we,children:[(0,p.jsx)(d.ActionMenu.Button,{size:`small`,variant:`secondary`,"aria-label":`${f.filter}: ${ke}`,children:ke}),(0,p.jsx)(d.ActionMenu.Overlay,{"aria-label":f.filter,children:Oe.map(e=>(0,p.jsx)(d.ActionMenu.Item,{value:e.value,selected:N===e.value,role:`menuitemradio`,onKeyDownCapture:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.click())},children:e.label},e.value))})]}),N===`active`?(0,p.jsx)(d.Button,{size:`small`,variant:`primary`,className:`thread-sample__fix-all`,leadingVisual:(0,p.jsx)(ie,{size:16}),disabled:!J||!!C.trim()||D||_||ye,"aria-busy":_,"aria-label":f.simulate(J),onClick:()=>{ge()},children:(0,p.jsxs)(`span`,{className:`thread-sample__fix-label`,children:[f.fix,(0,p.jsx)(pe,{"aria-hidden":`true`,children:J})]})}):null]})}),W&&P?(0,u.createPortal)((0,p.jsx)(me,{ref:q,"aria-label":f.conversation,anchored:!0,position:De,className:`thread-sample__conversation`,onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&!e.nativeEvent.isComposing&&!(e.target instanceof Element&&e.target.closest(`[role="menu"]`))&&(e.preventDefault(),D?(H.current=!1,O(!1)):Q())},children:(0,p.jsxs)(`div`,{className:`review-thread-conversation__layout`,children:[(0,p.jsxs)(`header`,{className:`review-thread-conversation__header`,children:[(0,p.jsx)(d.Heading,{as:`h3`,size:`6`,children:f.conversation}),W.status===`ready`?(0,p.jsx)(d.Button,{size:`small`,variant:`secondary`,className:`thread-sample__resolve`,disabled:!!C.trim()||_||U||G,leadingVisual:(0,p.jsx)(se,{size:16}),onClick:()=>{s(W)},children:f.resolve}):null,(0,p.jsx)(ue,{icon:oe,size:`small`,variant:`invisible`,"aria-label":f.back,className:`thread-sample__close`,onClick:Q})]}),U?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:f.changedIdentity}):null,G?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:f.removed}):null,v?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:v}):null,W.point?null:(0,p.jsx)(`p`,{role:`status`,className:`thread-sample__target-status`,children:f.targetUnavailable}),(0,p.jsxs)(`div`,{className:`review-thread-conversation__messages`,children:[(0,p.jsxs)(`article`,{className:`review-thread-message`,children:[(0,p.jsx)(o,{visual:(0,p.jsx)(a,{src:W.avatarUrl??m,size:28}),author:W.author}),(0,p.jsx)(`p`,{className:`review-thread-message__body`,children:W.body})]}),W.messages.map(e=>(0,p.jsxs)(`article`,{className:`review-thread-message`,children:[(0,p.jsx)(o,{visual:e.role===`copilot`?(0,p.jsx)(a,{src:ve,size:28,className:`thread-sample__copilot-avatar`}):(0,p.jsx)(a,{src:e.author?e.avatarUrl??m:W.avatarUrl??m,size:28}),author:e.role===`copilot`?f.copilot:e.author??W.author,metadata:e.role===`author`&&e.status&&e.status!==`ready`?(0,p.jsx)(`span`,{children:f.workStatus(e.status)}):void 0}),(0,p.jsx)(`p`,{className:`review-thread-message__body`,children:e.body})]},e.id))]}),(0,p.jsx)(`div`,{className:`review-thread-conversation__footer`,children:(0,p.jsx)(fe,{blockedLabel:null,confirmingDiscard:D,replyDraft:C,replyBodyTooLong:Y,replyFailed:!1,replyDisabled:U||G,replying:T,submitDisabled:_,copy:f.comments,onKeepDraft:()=>{H.current=!1,O(!1)},onDiscardDraft:Z,onSubmit:()=>{je()},onDraftChange:w})})]})}),P):null,(0,p.jsxs)(`div`,{className:`thread-sample__list`,children:[X.length===0?(0,p.jsx)(`p`,{className:`thread-sample__empty`,children:f.empty}):null,X.map(e=>{let n=e.messages.filter(e=>e.role===`author`).length;return(0,p.jsxs)(`article`,{className:`review-comment-row thread-sample__card${e.status===`resolved`?` thread-sample__card--resolved`:``}`,children:[(0,p.jsx)(`button`,{ref:t=>{t?B.current.set(e.id,t):B.current.delete(e.id)},className:`review-comment-row__button thread-sample__card-button`,"aria-label":`Open improvement: ${e.body}`,"aria-expanded":y===e.id,disabled:!!C.trim()||D,onClick:t=>Ae(e.id,t.currentTarget),children:(0,p.jsxs)(`span`,{className:`review-comment-row__layout`,children:[(0,p.jsx)(a,{src:e.avatarUrl??m,size:20}),(0,p.jsx)(`span`,{className:`review-comment-row__content`,children:(0,p.jsxs)(`span`,{className:`review-comment-row__copy`,children:[(0,p.jsxs)(`span`,{className:`thread-sample__heading`,children:[(0,p.jsx)(`strong`,{className:`review-comment-row__author`,children:e.author}),e.status===`open`?null:(0,p.jsx)(`span`,{className:`thread-sample__status${e.status===`ready`?` thread-sample__status--ready`:``}`,children:f.workStatus(e.status)})]}),(0,p.jsx)(`span`,{className:`review-comment-row__body`,children:e.body})]})})]})}),(0,p.jsxs)(`div`,{className:`thread-sample__metadata`,children:[(0,p.jsx)(`span`,{children:e.target}),(0,p.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,p.jsx)(`code`,{children:e.path})]}),n>0?(0,p.jsxs)(`span`,{className:`thread-sample__follow-ups`,children:[(0,p.jsx)(ne,{size:12,"aria-hidden":`true`}),f.followUps(n)]}):null,(0,p.jsx)(`div`,{className:`thread-sample__menu`,children:(0,p.jsxs)(d.ActionMenu,{selectionVariant:`none`,size:`small`,menuAlignment:`end`,disabled:!!C.trim()||D,children:[(0,p.jsx)(d.ActionMenu.IconButton,{icon:t,"aria-label":`${f.actions}: ${e.id}`,variant:`invisible`,onClick:t=>{R.current=t.currentTarget,z.current={identity:g,id:e.id,revision:e.revision}}}),(0,p.jsxs)(d.ActionMenu.Overlay,{"aria-label":`${f.actions}: ${e.id}`,children:[h&&e.retryStatus?(0,p.jsx)(d.ActionMenu.Item,{value:`retry`,disabled:_,className:`thread-sample__menu-item`,onClick:()=>{Ne(e)},children:e.retryStatus===`sent`?f.returnToActive:f.retry}):null,e.status===`ready`?(0,p.jsx)(d.ActionMenu.Item,{value:`resolve`,className:`thread-sample__menu-item`,disabled:_,leadingVisual:(0,p.jsx)(se,{size:16}),onClick:()=>{Me(e)},children:f.markResolved}):null,(0,p.jsx)(d.ActionMenu.Item,{value:`delete`,className:`thread-sample__menu-item thread-sample__delete`,disabled:_,leadingVisual:(0,p.jsx)(re,{size:16}),onClick:()=>{_||C.trim()||D||(M(g),A(e))},children:f.delete})]})]})})]},e.id)})]})]}),(0,p.jsx)(`div`,{ref:Te,className:`canvas-conversation-shell thread-sample__surface`,hidden:!r}),(0,p.jsx)(`div`,{className:`canvas-conversation-shell thread-sample__markers`,hidden:!r,children:e.filter(e=>e.id===y||X.includes(e)).filter(e=>e.point).map(e=>(0,p.jsx)(`button`,{type:`button`,className:`review-comment-marker thread-sample__marker${y===e.id?` review-comment-marker--selected`:``}`,"data-improvement-thread-id":e.id,"aria-label":f.point(e.id),"aria-expanded":y===e.id,disabled:!!C.trim()||D,style:{left:e.point.x,top:e.point.y},onClick:t=>Ae(e.id,t.currentTarget),children:(0,p.jsx)(le,{participants:[{login:e.author,name:null,avatarUrl:e.avatarUrl??m}],size:`small`})},e.id))}),(0,p.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:Se}),k?(0,p.jsxs)(de,{title:f.deleteTitle,closeLabel:f.comments.cancelEditLabel,onClose:()=>A(null),returnFocusRef:R,children:[U?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:f.changedIdentity}):null,K?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:f.removed}):null,v?(0,p.jsx)(`p`,{role:`alert`,className:`thread-sample__error`,children:v}):null,(0,p.jsx)(`blockquote`,{className:`thread-sample__quote`,children:k.body}),(0,p.jsxs)(`div`,{className:`thread-sample__delete-actions`,children:[(0,p.jsx)(d.Button,{size:`small`,variant:`secondary`,onClick:()=>A(null),children:f.comments.cancelEditLabel}),(0,p.jsx)(d.Button,{size:`small`,variant:`primary`,className:`thread-sample__delete-confirm`,disabled:_||U||K,onClick:async()=>{if(!(_||U||K)&&await c(k)){let e=X.find(e=>e.id!==k.id);R.current=(e?B.current.get(e.id):null)??L.current,y===k.id&&Z(),A(null)}},children:f.delete})]})]}):null]})}export{f as n,h as t}; \ No newline at end of file diff --git a/.github/extensions/replica-prototype/assets/renderer.js b/.github/extensions/replica-prototype/assets/renderer.js index 70f7c025c..067028630 100644 --- a/.github/extensions/replica-prototype/assets/renderer.js +++ b/.github/extensions/replica-prototype/assets/renderer.js @@ -5,4 +5,4 @@ import{r as e,t}from"./renderer-rolldown-runtime.js";import{A as n,B as r,C as i `);a=n.pop()||``;for(let e of n)if(e.startsWith(`event: comments `)&&Jt(),e.startsWith(`event: error -`))throw Error(`Live review connection failed.`)}}catch{t.signal.aborted||ze(!0)}t.signal.aborted||(Date.now()-a>=3e4&&(r=5e3),n=window.setTimeout(()=>void i(),r),r=Math.min(r*2,6e4))}return i(),()=>{t.abort(),window.clearTimeout(n)}},[ot,Nt,e.token,Jt]);let Xt=(0,H.useCallback)((n,r={})=>{let i=t.current;return!i?.contentWindow||!qe.current?!1:(i.contentWindow.postMessage({type:n,nonce:qe.current,...r},new URL(e.previewUrl??e.prototypeUrl).origin),!0)},[e.prototypeUrl,e.previewUrl,t]),Zt=(0,H.useCallback)(async t=>{if(e.pickAndPolish||!De||!zt||Vt)return;let n=ot,i=++Ye.current;Je.current=void 0,Pe(!0),z(``),P(null),Le(null),Me(t),_();try{let a=await $(`/api/hub/status`,e.token);if($e.current!==n||Ye.current!==i)return;if(!a.repositoryAuthorized&&a.state!==`connected`||a.prototype?.id!==Nt||a.hubOrigin!==r?.hubOrigin||a.repository!==r?.repository||a.branch!==r?.branch||!a.reviewRevision)throw Error(a.reviewError||q.commentPreparationFailed);Je.current=a.reviewRevision,Xt(`replica:canvas:select`,{mode:t})}catch(e){$e.current===n&&Ye.current===i&&(Me(null),z(e instanceof Error?e.message:String(e)))}finally{Ye.current===i&&Pe(!1)}},[e.pickAndPolish,De,zt,e.token,ot,_,Nt,Vt,Xt,r]),Qt=(0,H.useCallback)(()=>{je&&(Ye.current+=1,Je.current=void 0,Pe(!1),Xt(`replica:canvas:cancel-selection`),Me(null))},[je,Xt]),$t=(0,H.useCallback)(()=>{Ye.current+=1,Je.current=void 0,Xt(`replica:canvas:clear-selection`),Fe(null),Le(null),z(``)},[Xt]);(0,H.useEffect)(()=>{let r=t.current;if(!r){Ee(new Map),Oe(!1);return}let i=new URL(e.previewUrl??e.prototypeUrl).origin,a=JSON.parse(qt),o=new Set(a.map(({id:e})=>e)),s=Date.now(),c=!1;function l(){qe.current=crypto.randomUUID(),s=Date.now(),c=!1,Oe(!1),ke(``),Ee(new Map),r?.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:qe.current},i),u()}function u(){a.length&&r?.contentWindow?.postMessage({type:`replica:canvas:resolve`,nonce:qe.current,anchors:a},i)}function d(t){let a=t.data;if(t.source===r?.contentWindow&&t.origin===i&&In(a)&&a.nonce===qe.current){if(a.type===`replica:canvas:bridge-error`)Oe(!1),ke(q.commentingMissing);else if(a.type===`replica:canvas:ready`){if(a.protocolVersion!==1){c=!0,Oe(!1),ke(q.commentingIncompatible);return}if(!Ln(a.route))return;s=Date.now(),c=!1,Oe(!0),ke(``),N(Ln(a.route)),n?.(Ln(a.route),a.replaceRoute===!0)}else if(!c){if(a.type===`replica:canvas:conversation-dismiss-requested`)window.dispatchEvent(new Event(`replica:review-dismiss`));else if(a.type===`replica:canvas:resolved`){if(a.protocolVersion!==1||!Ln(a.route)||!Array.isArray(a.results))return;s=Date.now(),Oe(!0),ke(``),N(Ln(a.route)),n?.(Ln(a.route),a.replaceRoute===!0);let e=new Map;for(let t of a.results){if(!In(t)||typeof t.id!=`number`||typeof t.x!=`number`||typeof t.y!=`number`||!o.has(t.id)||!Number.isFinite(t.x)||!Number.isFinite(t.y)||t.x<0||t.y<0||t.x>r.clientWidth||t.y>r.clientHeight)continue;let n=In(t.rect)&&typeof t.rect.x==`number`&&typeof t.rect.y==`number`&&typeof t.rect.width==`number`&&typeof t.rect.height==`number`&&Number.isFinite(t.rect.x)&&Number.isFinite(t.rect.y)&&Number.isFinite(t.rect.width)&&Number.isFinite(t.rect.height)&&t.rect.width>=0&&t.rect.height>=0?{x:t.rect.x,y:t.rect.y,width:t.rect.width,height:t.rect.height}:{x:t.x,y:t.y,width:0,height:0};e.set(t.id,{x:t.x,y:t.y,rect:n})}Ee(e)}else if(a.type===`replica:canvas:selected`){if(e.pickAndPolish)return;let t=Gt.safeParse(a.anchor);if(!t.success){Xt(`replica:canvas:cancel-selection`),Xt(`replica:canvas:clear-selection`),Me(null),Le(In(a.anchor)&&a.anchor.kind===`area`?`area-unavailable`:`element-unavailable`);return}Fe(t.data),Me(null),Le(null)}else a.type===`replica:canvas:selection-failed`&&(a.reason===`element-unavailable`||a.reason===`area-too-small`||a.reason===`area-unavailable`)?(Me(null),Le(a.reason)):a.type===`replica:canvas:selection-cancelled`&&Me(null)}}}function f(){Ye.current+=1,Pe(!1),Me(null),Le(null),l()}r.addEventListener(`load`,f),window.addEventListener(`message`,d),l();let p=window.setInterval(()=>{Date.now()-s>=2e4&&(Oe(!1),Ee(new Map),ke(c?q.commentingIncompatible:q.commentingMissing)),r.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:qe.current},i),u()},2e3);return()=>{r.removeEventListener(`load`,f),window.removeEventListener(`message`,d),window.clearInterval(p)}},[ot,qt,e.prototypeUrl,e.pickAndPolish,e.previewUrl,t,n,Xt]);async function en(t,n,r,i){let a=ot,o=dt,s=i?.kind===`add-reaction`||i?.kind===`remove-reaction`||i?.kind===`mark-unread`;if(i){if(He.current)return!1;He.current=!0,Ve(i)}s&&(We.current=!0,Ue.current+=1),V(``);try{let i=await $(`/api/hub/comments/${t}`,e.token,{method:n,...r?{body:JSON.stringify(r)}:{}});if($e.current!==a)return!1;if(s){let e=an.parse(i);y(t=>{if(t.identity!==o)return t;let n=new Map(t.items.map(e=>[e.id,e]));for(let t of e.comments)n.set(t.id,t);return{identity:o,items:[...n.values()]}})}return s||(at.current=window.setTimeout(()=>void Yt.current(),0)),!0}catch(e){return $e.current===a&&(L(e instanceof Error?e.message:String(e)),e instanceof Error&&`statusCode`in e&&e.statusCode===429&&V(e.message)),!1}finally{i&&$e.current===a&&(s&&(We.current=!1,Ue.current+=1,at.current=window.setTimeout(()=>void Yt.current(),0)),He.current=!1,Ve(null))}}async function tn(t){let n=Je.current;if(!n||!Z||He.current)return!1;let r=ot,a=dt;He.current=!0,Ve({kind:`create`}),V(``),z(``);try{let o=an.parse(await $(`/api/hub/comments`,e.token,{method:`POST`,body:JSON.stringify({review_revision:n,review_comment:{body:t,anchor:Z}})}));if($e.current!==r)return!1;let s=o.comments.find(e=>e.kind===`root`);if(!s)return!1;let c=s.buildNumber!==null||s.draftRevisionId===ut;c&&y(e=>{if(e.identity!==a)return e;let t=new Map(e.items.map(e=>[e.id,e]));for(let e of o.comments)t.set(e.id,e);return{identity:a,items:[...t.values()]}});let l=c&&Ke.current===a;return Qe.current=!l,$t(),l&&P(s.id),i().then(()=>{if($e.current===r)return Yt.current()}).catch(e=>{if($e.current===r){let t=e instanceof Error?e.message:String(e);L(q.commentRefreshFailed(t))}}),!0}catch(e){if($e.current===r){let t=e instanceof Error?e.message:String(e);L(t),z(t),e instanceof Error&&`statusCode`in e&&e.statusCode===429&&V(e.message)}return!1}finally{$e.current===r&&(He.current=!1,Ve(null))}}function nn(){Vt||(T?(P(null),E(!1)):(E(!0),g&&_()))}let un=r?.repository&&r.branch?`https://github.com/${r.repository.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}/tree/${encodeURIComponent(r.branch)}`:null,dn=r?.branch&&un?(0,W.jsxs)(`a`,{className:`canvas-hub-publication__branch`,href:un,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open ${r.branch} on GitHub`,children:[(0,W.jsx)(M,{size:16,"aria-hidden":`true`}),(0,W.jsx)(`span`,{children:r.branch})]}):r?.branch?(0,W.jsxs)(`span`,{className:`canvas-hub-publication__branch`,children:[(0,W.jsx)(M,{size:16,"aria-hidden":`true`}),(0,W.jsx)(`span`,{children:r.branch})]}):null,fn=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(U.Heading,{as:`h3`,size:`subhead-medium`,id:`canvas-hub-origin-title`,children:`Hub`}),r&&r.state!==`unconfigured`?(0,W.jsx)(`div`,{className:`canvas-hub-origin`,children:r.hubOrigin?(0,W.jsx)(`a`,{href:Q?new URL(`/repositories/${Q.repositoryId}/prototypes/${Q.id}`,r.hubOrigin).href:r.hubOrigin,target:`_blank`,rel:`noopener noreferrer`,children:r.hubOrigin}):(0,W.jsx)(`span`,{children:`URL unavailable`})}):null,se||r?.state===`disconnected`||r?.state===`unconfigured`?(0,W.jsxs)(`form`,{className:`canvas-hub-origin-form`,onSubmit:e=>{e.preventDefault(),!(le||de)&&(ue(!0),G(!0),L(``),a(K).then(()=>{G(!1)}).catch(e=>L(e.message)).finally(()=>ue(!1)))},children:[(0,W.jsxs)(`div`,{className:`canvas-hub-origin-field`,children:[(0,W.jsxs)(`label`,{children:[q.hubUrl,(0,W.jsx)(`input`,{type:`url`,required:!0,value:K,placeholder:`https://hub.example.com`,disabled:le||de,onChange:e=>ce(e.target.value)})]}),(0,W.jsx)(U.Button,{type:`button`,size:`small`,variant:`subtle`,className:`canvas-icon-button`,leadingVisual:(0,W.jsx)(I,{size:16}),"aria-label":q.resetHubUrl,title:q.resetHubUrl,disabled:le||de,"aria-busy":de,onClick:()=>{pe(!0),L(``),$(`/api/hub/discovery`,e.token,{method:`POST`,body:`{}`}).then(async e=>{if(e.discovery?.state!==`valid`||!e.discovery.origin)throw Error(e.discovery?.message||q.resetHubUnavailable);ce(e.discovery.origin),await i()}).catch(e=>L(e.message)).finally(()=>pe(!1))},children:(0,W.jsx)(`span`,{className:`visually-hidden`,children:q.resetHubUrl})})]}),(0,W.jsx)(`p`,{children:q.hubHttpsHint}),(0,W.jsxs)(`div`,{className:`canvas-hub-form-actions`,children:[(0,W.jsx)(U.Button,{type:`submit`,size:`small`,disabled:le||de,children:`Save Hub`}),se&&r?.state!==`unconfigured`&&r?.state!==`disconnected`?(0,W.jsx)(U.Button,{type:`button`,size:`small`,variant:`subtle`,disabled:le||de,onClick:()=>G(!1),children:`Cancel`}):null]})]}):null]});return(0,W.jsxs)(rt,{source:w,children:[_t.visible?(0,W.jsx)(cn,{..._t}):null,Bt&&Ut&&!e.pickAndPolish?(0,et.createPortal)((0,W.jsxs)(`div`,{className:`canvas-review-controls review-shell__comment-actions`,role:`group`,"aria-label":xt.heading,children:[(0,W.jsx)(yt,{bridgeReady:De&&zt,copy:xt,selectionBlocked:Vt,selecting:je!==null,onCancelSelection:Qt,onStartAreaSelection:()=>void Zt(`area`),onStartElementSelection:()=>void Zt(`element`)}),(0,W.jsx)(U.Tooltip,{ref:Ze,text:Vt?xt.selectionBlockedLabel:`${xt.heading} (${xt.sidebarShortcutLabel})`,type:`description`,children:(0,W.jsxs)(U.Button,{className:`canvas-comments-toggle review-shell__comments-toggle`,variant:`secondary`,size:`small`,"aria-label":`${xt.heading}, ${Lt}${Rt?`, ${xt.unreadLabel}`:``}`,"aria-expanded":T,"aria-keyshortcuts":`Shift+C`,disabled:Vt,onClick:nn,children:[(0,W.jsx)(tt,{children:Lt}),Rt?(0,W.jsx)(`span`,{className:`canvas-comments-unread-badge review-shell__unread-badge`,"aria-hidden":`true`}):null]})})]}),Ut):null,k&&It.length&&De&&!je?(0,W.jsx)(`div`,{className:`canvas-marker-layer`,children:(0,W.jsx)(ct,{threads:It,resolutions:Et,selectedThreadId:ee,selectionBlocked:Ce,focusSelectedMarker:!1,showAreaHighlightsOnlyWhenSelected:!0,copy:xt,onSelect:e=>P(e.root.id)})}):null,(0,W.jsxs)(it,{className:`canvas-hub-panel`,contentClassName:`canvas-hub-content`,title:`Replica Hub`,label:`Hub`,open:Ht,closeLabel:`Close Hub`,closeRef:Xe,onClose:_,children:[F?(0,W.jsx)(`p`,{role:`alert`,children:F}):null,te?(0,W.jsx)(`p`,{role:`alert`,children:te}):null,r?null:(0,W.jsx)(`p`,{children:`Checking Hub connection…`}),!Ot&&!ht&&r?.message?(0,W.jsx)(`p`,{role:`status`,children:r.message}):null,ht?(0,W.jsxs)(`div`,{className:`canvas-hub-status`,children:[(0,W.jsx)(fe,{variant:`warning`,layout:`compact`,title:r?.message||X.hubUnavailable}),(0,W.jsx)(U.Button,{variant:`primary`,size:`small`,disabled:d,"aria-busy":d,leadingVisual:d?(0,W.jsx)(I,{size:16}):void 0,onClick:m||(()=>void i()),children:X.retry})]}):null,!Ot&&!ht&&u&&p&&m?(0,W.jsx)(Ae,{publication:u,busy:d,dirty:f,onPublish:p,onRetry:m}):null,Ot?(0,W.jsxs)(`section`,{className:`canvas-hub-connection`,children:[(0,W.jsx)(`p`,{children:q.connectionBeforePublishing}),(0,W.jsx)(U.Button,{ref:c,variant:`primary`,onClick:o,disabled:l,children:l?q.connectionOpeningBrowser:q.connectToHub})]}):null,!Ot&&(!se&&(r?.discovery?.mismatch||[`invalid`,`unreachable`].includes(r?.discovery?.state||``))||r?.state===`unconfigured`)?(0,W.jsxs)(`div`,{className:`canvas-hub-settings`,children:[!se&&r?.discovery?.mismatch?(0,W.jsx)(`p`,{role:`alert`,children:`The repository configuration differs from your selected Hub. Your connection has not changed. Disconnect Hub before selecting another URL.`}):null,!se&&[`invalid`,`unreachable`].includes(r?.discovery?.state||``)?(0,W.jsx)(`p`,{role:`alert`,children:r?.discovery?.message}):null,r?.state===`unconfigured`?(0,W.jsx)(`p`,{children:`Enter your Hub URL to connect.`}):null]}):null,r?.state===`undiscovered`&&!u?(0,W.jsxs)(`p`,{children:[`Connected to `,r.repository,`. Hub has not discovered`,` `,r.branch||`a prototype branch`,`. Your repository connection is ready. Push a named branch to make its Builds and reviews available.`]}):null,Q?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`section`,{className:u&&u.kind!==`ready`&&p&&m?`canvas-hub-publication canvas-hub-publication--after-status`:`canvas-hub-publication`,"aria-label":`Prototype`,children:Mt&&Kt?(0,W.jsxs)(`form`,{className:`canvas-hub-publication__form`,onSubmit:t=>{t.preventDefault(),$(`/api/hub/metadata`,e.token,{method:`PATCH`,body:JSON.stringify({name:me,description:ge,startPage:ve})}).then(async()=>{J(!1),await i()}).catch(e=>L(e.message))},children:[(0,W.jsxs)(`div`,{className:`canvas-hub-publication__title`,children:[(0,W.jsxs)(`label`,{className:`canvas-hub-publication__name-field`,children:[(0,W.jsx)(`span`,{className:`visually-hidden`,children:`Name`}),(0,W.jsx)(`input`,{required:!0,maxLength:255,value:me,onChange:e=>he(e.target.value)})]}),(0,W.jsx)(`span`,{className:`canvas-hub-publication__status`,children:Q.published?`Published`:Q.registered?`Registered`:`Not registered`})]}),dn,(0,W.jsxs)(`label`,{className:`canvas-hub-publication__description-field`,children:[(0,W.jsx)(`span`,{className:`visually-hidden`,children:`Description`}),(0,W.jsx)(`textarea`,{value:ge,placeholder:`Add a description`,onChange:e=>_e(e.target.value)})]}),(0,W.jsxs)(`label`,{className:`canvas-hub-publication__start-page-field`,children:[q.startPage,(0,W.jsx)(`input`,{value:ve,placeholder:`/`,"aria-describedby":`canvas-start-page-hint`,onChange:e=>ye(e.target.value)})]}),(0,W.jsx)(`p`,{id:`canvas-start-page-hint`,className:`canvas-hub-publication__hint`,children:q.startPageHint}),(0,W.jsxs)(`div`,{className:`canvas-hub-form-actions`,children:[(0,W.jsx)(U.Button,{type:`submit`,size:`small`,children:`Save metadata`}),(0,W.jsx)(U.Button,{type:`button`,size:`small`,variant:`subtle`,onClick:()=>J(!1),children:`Cancel`})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`canvas-hub-publication__title`,children:[(0,W.jsx)(U.Heading,{as:`h3`,size:`subhead-large`,children:Q.name||r?.branch}),(0,W.jsx)(`span`,{className:`canvas-hub-publication__status`,children:Q.published?`Published`:Q.registered?`Registered`:`Not registered`})]}),dn,Q.description?(0,W.jsx)(`p`,{className:`canvas-hub-publication__description`,children:Q.description}):null,(0,W.jsxs)(`p`,{className:`canvas-hub-publication__description canvas-hub-publication__start-page`,children:[q.startPage,`: `,(0,W.jsx)(`code`,{children:Q.startPage||`/`})]}),Mt?(0,W.jsx)(U.Button,{size:`small`,variant:`subtle`,onClick:()=>{he(Q.name||``),_e(Q.description||``),ye(Q.startPage||``),Se(ot),J(!0)},children:q.editDetails}):null]})}),(0,W.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":`canvas-hub-build-title`,children:[(0,W.jsx)(U.Heading,{as:`h3`,size:`subhead-medium`,id:`canvas-hub-build-title`,children:q.latestBuild}),Q.build?(0,W.jsxs)(`div`,{className:`canvas-hub-build`,children:[(0,W.jsxs)(`div`,{className:`canvas-hub-build__identity`,children:[(0,W.jsx)(`a`,{href:Q.build.url,target:`_blank`,rel:`noopener noreferrer`,children:q.buildTitle(Q.build.number)}),(0,W.jsx)(`code`,{title:Q.build.commitSha,"aria-label":`${q.buildCommit} ${Q.build.commitSha}`,children:Q.build.commitSha.slice(0,7)})]}),(0,W.jsx)(`p`,{children:At?(0,W.jsx)(`a`,{className:`canvas-hub-build__author`,href:At,target:`_blank`,rel:`noopener noreferrer`,children:jt}):(0,W.jsx)(`span`,{children:jt})}),r?.commitSha&&r.commitSha!==Q.build.commitSha?(0,W.jsx)(`p`,{className:`canvas-hub-build__notice`,children:`Local checkout differs from this Build`}):null]}):(0,W.jsxs)(`p`,{children:[`No successful imported Build yet. Current Build: `,Q.buildState||`none`,`.`]}),Q.build&&r?.hubOrigin?(0,W.jsx)(`a`,{className:`canvas-hub-build__history`,href:new URL(`/repositories/${Q.repositoryId}/prototypes/${Q.id}/builds`,r.hubOrigin).href,target:`_blank`,rel:`noopener noreferrer`,children:q.showBuildHistory}):null]})]}):null,Ot?null:(0,W.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":`canvas-hub-origin-title`,children:[fn,r?.hubOrigin&&[`connected`,`undiscovered`,`pairing`,`denied`,`unavailable`].includes(r.state)?(0,W.jsx)(`div`,{className:`canvas-hub-disconnect`,children:(0,W.jsx)(U.Button,{size:`small`,variant:`subtle`,onClick:()=>{ne(``),$(`/api/hub/disconnect`,e.token,{method:`POST`,body:`{}`}).then(async()=>{ce(r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``),G(!0),await i(),s?.()}).catch(e=>{ne(q.disconnectFailed(r.hubOrigin||``,e.message)),ce(r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``),G(!0)})},children:`Disconnect Hub`})}):null]}),Q?.registered&&Q.build&&h?(0,W.jsx)(Fn,{preference:h,disabled:d}):null]}),Bt?(0,W.jsx)(vt,{frame:{open:T,className:`canvas-comments-sidebar-shell`,contentClassName:`canvas-comments-sidebar-content`},threads:It,currentBuildNumber:Pt?.number||0,buildLinkOrigin:r?.hubOrigin,totalCount:It.length,hasThreads:wt.length>0,filters:D,participants:Tt,resolutions:Et,selectedThreadId:ee,selectionBlocked:Vt,closeBlocked:Ce,showPins:k,loading:re,loadFailed:ae,notice:Re||r?.reviewError||r?.localCommentsError||ut?(0,W.jsxs)(`div`,{className:`canvas-comments-live-notices`,children:[Re?(0,W.jsx)(`p`,{className:`canvas-comments-live-status`,role:`status`,children:q.commentLiveUpdatesPaused}):null,r?.reviewError?(0,W.jsx)(`p`,{className:`canvas-comments-live-status`,children:r.reviewError}):null,r?.localCommentsError?(0,W.jsx)(`p`,{className:`canvas-comments-live-status`,role:`alert`,children:r.localCommentsError}):null,ut?(0,W.jsx)(`p`,{className:`canvas-comments-live-status`,children:q.localCommentsSaved}):null]}):null,copy:xt,onClose:nn,onFiltersChange:O,onShowPinsChange:A,onRetry:()=>void Jt(),onSelect:e=>P(e.root.id)}):null,(0,W.jsx)(Pn,{selectionNotice:Ie?Ie===`area-too-small`?xt.areaTooSmallLabel:Ie===`area-unavailable`?xt.areaUnavailableLabel:xt.selectionFailedLabel:null,rateLimitNotice:Ht?null:B||!Z&&R||null,composer:Z&&Wt?{anchorPoint:Wt,bodyMaximumBytes:1e4,copy:xt,creating:Be?.kind===`create`,submitError:R,onSubmit:tn,onDiscard:$t}:null,conversation:Dt?{thread:Dt,anchorPoint:Te.get(Dt.root.id)??null,bodyMaximumBytes:1e4,mutation:Be,copy:xt,onClose:()=>P(null),onDraftStateChange:we,onReply:e=>en(`${Dt.root.id}/replies`,`POST`,{review_comment:{body:e}},{kind:`reply`,commentId:Dt.root.id}),onEdit:(e,t)=>en(`${e}`,`PATCH`,{review_comment:{body:t}},{kind:`edit`,commentId:e}),onDelete:e=>en(`${e}`,`DELETE`,void 0,{kind:`delete`,commentId:e}),onResolve:()=>en(`${Dt.root.id}/resolution`,`POST`,void 0,{kind:`resolve`,commentId:Dt.root.id}),onReopen:()=>en(`${Dt.root.id}/resolution`,`DELETE`,void 0,{kind:`reopen`,commentId:Dt.root.id}),onAddReaction:(e,t)=>en(`${e}/reactions`,`POST`,{review_comment_reaction:{content:t,activity_version:Dt.root.activityVersion}},{kind:`add-reaction`,commentId:e,content:t}),onRemoveReaction:(e,t)=>en(`${e}/reactions/${encodeURIComponent(t)}`,`DELETE`,{review_comment_reaction:{activity_version:Dt.root.activityVersion}},{kind:`remove-reaction`,commentId:e,content:t}),onMarkRead:e=>en(`${Dt.root.id}/read`,`POST`,{review_thread_read:{activity_version:e}}),onMarkUnread:()=>en(`${Dt.root.id}/read`,`DELETE`,void 0,{kind:`mark-unread`,commentId:Dt.root.id})}:null})]})}function zn(e,t,n){function r(e,t,n){return{kind:e,title:t,detail:n}}if(!e||!t)return n.kind===`unknown`?r(`retry`,Y.unavailable,n.detail):r(`checking`,Y.checking,Y.checkingDetail);if(!e.stats.branch)return r(`restricted`,Y.restricted,n.detail);if(t.repository&&t.repository!==e.stats.repository||t.branch&&t.branch!==e.stats.branch)return r(`retry`,Y.unavailable,Y.changedDetail);if(t.discovery?.state===`local`||e.stats.repository?.startsWith(`local/`))return r(`restricted`,Y.restricted,Y.local);if(t.registrationReason===`branch_not_reviewable`||e.stats.branch===t.discovery?.defaultBranch)return r(`restricted`,Y.restricted,X.registrationReasons.get(`branch_not_reviewable`).description);if([`disconnected`,`pairing`,`unconfigured`].includes(t.state))return r(`connect`,Y.connect,Y.connectDetail);if([`denied`,`unavailable`].includes(t.state))return r(`retry`,Y.unavailable,t.message||Y.unavailableDetail);if(t.repository!==e.stats.repository||t.branch!==e.stats.branch)return r(`retry`,Y.unavailable,Y.unavailableDetail);let i=t.prototype;if(t.state===`connected`&&i?.branch===e.stats.branch&&i.registered&&i.published&&i.build&&Number.isSafeInteger(i.build.number)&&i.build.number>0)return r(`ready`,Y.ready,Y.readyDetail);if(t.state===`connected`&&(!i||i.branch!==e.stats.branch||typeof i.published!=`boolean`||i.published))return r(`retry`,Y.unavailable,Y.unavailableDetail);let a=t.state===`connected`?i?.canEdit:t.canPublish;if(a===!1)return r(`restricted`,Y.restricted,Y.publishDenied);let o=e.stats.remoteBranch,s=t.state===`undiscovered`&&t.repositoryAuthorized===!0&&!i&&(!t.commitSha||t.commitSha===e.stats.commitSha)&&o?.repository===e.stats.repository&&o?.branch===e.stats.branch&&o?.commitSha===e.stats.commitSha&&(o?.state===`absent`||o?.state===`present`&&e.publishRequest?.commitSha===e.stats.commitSha&&([`requested`,`in_progress`].includes(e.publishRequest?.state??``)||e.publishRequest?.state===`idle`&&e.publishRequest.remoteState===`absent`))&&![`loading`,`unknown`,`detached`,`workflow_missing`].includes(n.kind),c=a===void 0&&s;if(a!==!0&&!c)return r(`retry`,Y.unavailable,Y.permissionUnknown);let l=t.registrationReason||i?.registrationReason;if(n.error&&(l!==`remote_branch_missing`||!s)){let e=[`successful_build_required`,`already_registered`].includes(l||``),t=[`write_access_required`,`repository_mismatch`,`branch_not_reviewable`,`remote_branch_missing`,`branch_authorship_required`].includes(l||``);return{...r(e?`progress`:t?`restricted`:`retry`,n.error.title,n.error.description),...e?{publication:{...n,action:`retry`,label:X.retry}}:{}}}if(n.kind===`detached`)return r(`restricted`,Y.restricted,n.detail);if(n.action===`retry`)return r(`retry`,Y.unavailable,n.detail);if(n.kind===`loading`)return r(`checking`,Y.checking,n.detail);let u=c?`${Y.publishDetail} ${Y.publishPermissionUnverified}`:Y.publishDetail,d=s&&l===`remote_branch_missing`?{...n,error:void 0}:n;return n.action===`publish`?{...r(`publish`,Y.publish,u),publication:d}:{...r(`progress`,Y.preparing,u),publication:d}}function Bn({open:e,onToggle:t,buttonRef:n}){return(0,W.jsx)(K,{icon:te,"aria-label":q.controls,description:q.controls,ref:n,size:`small`,variant:`default`,className:`canvas-controls-toggle`,"aria-expanded":e,onClick:t})}function Vn({toolbarRef:e,improvementControlsRef:t,config:n,onPublish:r,publishButtonRef:i,hubButtonRef:a,titleButtonRef:o,onBuildDetails:s,publishing:c,state:l,prototypeName:u,hubOpen:d,onHub:f,publication:p,onControls:m,controlsOpen:h,controlsButtonRef:g,onShare:_,shareButtonRef:y}){let b=l?.publishStatus??{state:`unavailable`,detail:q.statusUnavailable},x=u?.trim()||l?.stats.branch||l?.name||n.name,S=l?[x,l.stats.repository,l.stats.commitSha?.slice(0,7),l.stats.workingTree===`changed`?q.workingTreeChanged:q.workingTreeClean,l.stats.urlHost].filter(Boolean).join(` · `):x,C=c||(p?p.action===`none`:b.state===`requested`||b.state===`in_progress`||b.state===`published`),w=c||(p?p.kind===`requested`||p.kind===`queued`||p.kind===`building`||p.kind===`importing`||p.kind===`awaiting_build`||p.kind===`registration`:b.state===`requested`||b.state===`in_progress`),T=!w&&(p?p.kind===`ready`:b.state===`published`),E=(0,W.jsx)(U.Button,{type:`button`,ref:i,className:`canvas-publish-button`,variant:`secondary`,size:`small`,leadingVisual:w?(0,W.jsx)(I,{size:16}):Hn(b.state),disabled:C&&!T,"aria-busy":w,title:T?void 0:p?.detail||b.detail,onClick:C||T?void 0:r,children:p?.label||q.publishLabels[b.state]});return(0,W.jsxs)(`header`,{ref:e,className:`canvas-toolbar`,children:[(0,W.jsx)(U.Button,{type:`button`,className:`canvas-title`,ref:o,variant:`subtle`,size:`small`,title:S,disabled:!l,onClick:s,children:x}),(0,W.jsx)(`div`,{id:`canvas-review-controls`,className:`canvas-review-controls-slot`}),n.pickAndPolish?(0,W.jsx)(`div`,{ref:t,id:`canvas-improvement-controls`}):null,m?(0,W.jsx)(Bn,{buttonRef:g,open:h,onToggle:m}):null,f?(0,W.jsx)(U.Button,{type:`button`,ref:a,size:`small`,variant:`secondary`,className:`canvas-toolbar-compact-button`,leadingVisual:(0,W.jsx)(re,{size:16}),"aria-label":q.editDetails,title:q.editDetails,"aria-expanded":d,onClick:f,children:(0,W.jsx)(`span`,{className:`canvas-toolbar-button-label`,children:q.editDetails})}):null,(0,W.jsxs)(`div`,{className:`canvas-publish-share`,role:`group`,"aria-label":J.group,children:[T?(0,W.jsx)(U.Tooltip,{ref:i,text:X.alreadyPublished,type:`description`,children:E}):E,_?(0,W.jsx)(K,{ref:y,icon:v,size:`small`,"aria-label":J.title,description:J.title,onClick:_}):null]})]})}function Hn(e){return e===`published`?(0,W.jsx)(ae,{size:16}):e===`failed`||e===`in_progress`||e===`requested`?(0,W.jsx)(I,{size:16}):(0,W.jsx)(D,{size:16})}function Un(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>Je(e,t)))}}var Wn={bridgeUnavailable:`The prototype bridge is not ready on this page.`,routeChanged:`The prototype route changed. Inspect the live canvas again.`,reloaded:`The prototype reloaded before confirming the click. Inspect the live canvas and retry.`,unconfirmed:`The prototype did not confirm the click. Check its bridge and retry.`,clickFailed:`The target could not be clicked.`,addressUnavailable:`The canvas address field is unavailable.`,unknownAction:`Unknown canvas action.`,replyRejected:`The live canvas rejected the action reply. Check its transport diagnostics.`,actionInterrupted:`The canvas changed before the action could run. Inspect the live canvas and retry.`,statusInterrupted:`The canvas changed while collecting Controls status. Inspect the live canvas and retry.`};function Gn(e){let{token:t,prototypeUrl:n,previewUrl:r,cancelClick:i}=e,a=(0,H.useRef)(e),o=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{a.current=e}),(0,H.useEffect)(()=>{o.current??=crypto.randomUUID();let e={"X-Replica-Renderer-Id":o.current},s=!1,c=!1,l=new AbortController,u=new URL(r??n).origin;async function d(e){let t=a.current.frameRef.current,n=a.current.liveRoute;if(!t?.contentWindow||!n)throw Error(Wn.bridgeUnavailable);if(e.route.pathname!==n.pathname||e.route.search!==n.search||e.route.hash!==n.hash)throw Error(Wn.routeChanged);let r=crypto.randomUUID();return await new Promise((n,a)=>{function o(){window.clearTimeout(c),window.removeEventListener(`message`,l),i.current===s&&(i.current=null)}function s(){o(),a(Error(Wn.reloaded))}let c=window.setTimeout(()=>{o(),a(Error(Wn.unconfirmed))},2e3);function l(i){let s=i.data;i.source===t?.contentWindow&&i.origin===u&&s&&typeof s==`object`&&`type`in s&&s.type===`replica:canvas:click-result`&&`nonce`in s&&s.nonce===r&&(o(),`clicked`in s&&s.clicked===!0?n({clicked:!0,route:e.route}):a(Error(Wn.clickFailed)))}i.current=s,window.addEventListener(`message`,l),t.contentWindow.postMessage({type:`replica:canvas:click`,nonce:r,...e},u)})}async function f(e){let t=a.current.frameRef.current,r=crypto.randomUUID(),i=Date.now()+e,o=await new Promise((n,o)=>{function s(){window.clearTimeout(d),window.removeEventListener(`message`,p),t?.removeEventListener(`load`,m),l.signal.removeEventListener(`abort`,c)}function c(){s(),o(Error(Wn.statusInterrupted))}let d=window.setTimeout(()=>{if(s(),a.current.liveRoute)o(Error(Wn.bridgeUnavailable));else{let e=new URL(a.current.navigation.entries[a.current.navigation.index]);e.protocol=new URL(u).protocol,e.host=new URL(u).host,n({status:`pending`,url:e.href,error:``,controls:[]})}},e+1500),f=!1;function p(e){let i=e.data;e.source===t?.contentWindow&&t===a.current.frameRef.current&&e.origin===u&&i&&typeof i==`object`&&`type`in i&&(i.type===`replica:canvas:ready`&&!f&&(f=!0,m()),i.type===`replica:controls:status-result`&&`nonce`in i&&i.nonce===r&&`value`in i&&(s(),n(i.value)))}function m(){t===a.current.frameRef.current&&t?.contentWindow?.postMessage({type:`replica:controls:status`,nonce:r,timeoutMs:Math.max(0,i-Date.now())},u)}window.addEventListener(`message`,p),t?.addEventListener(`load`,m),l.signal.addEventListener(`abort`,c),m()});if(!o||typeof o!=`object`||!(`url`in o)||typeof o.url!=`string`||!(`status`in o)||typeof o.status!=`string`||!(`error`in o)||typeof o.error!=`string`||!(`controls`in o)||!Array.isArray(o.controls))throw Error(Wn.bridgeUnavailable);let s=new URL(o.url);if(s.origin!==u)throw Error(Wn.routeChanged);let c=new URL(n);s.protocol=c.protocol,s.host=c.host;let d=await p(i);return!d&&a.current.controlsConnection===void 0?{...o,url:s.href}:{...d?Un(d,d.loading,s.href):{status:`pending`,url:s.href,error:``,controls:[]},runtime:{status:o.status,error:o.error,controls:o.controls}}}function p(e){let t=a.current.controlsConnection;if(!t)return Promise.resolve(null);let n=t.getSnapshot,r=t.subscribe,i=n();return!i.loading||e<=Date.now()?Promise.resolve(i):new Promise(t=>{let i={};function a(e){window.clearTimeout(c),i.unsubscribe?.(),l.signal.removeEventListener(`abort`,s),t(e)}function o(){let e=n();e.loading||a(e)}function s(){a(null)}let c=window.setTimeout(()=>a(n()),e-Date.now());i.unsubscribe=r(o),l.signal.addEventListener(`abort`,s,{once:!0}),o()})}async function m(){if(!(s||c)){s=!0;try{let{command:r,prototypeUrl:i}=await $(`/api/agent/next`,t,{headers:{...e,"X-Replica-Prototype-Url":n}});if(!c&&i&&i!==n){window.location.reload();return}if(!r)return;let o;try{if(await $(`/api/agent/progress`,t,{method:`POST`,headers:e,body:JSON.stringify({id:r.id,stage:`handler started`})}),c)throw Error(Wn.actionInterrupted);let n;if(r.type===`inspect`){let{appearance:e,navigation:t,liveRoute:r,addressRef:i}=a.current,o=i.current?.value;if(o===void 0)throw Error(Wn.addressUnavailable);n={address:t.entries[t.index],addressDraft:o,appearance:e,canGoBack:t.index>0,canGoForward:t.indexvoid m(),300);return()=>{c=!0,l.abort(),window.clearInterval(h),i.current?.()}},[n,r,t,i])}function Kn(e,t,n){let r=t?.repository===e?.stats.repository&&t?.branch===e?.stats.branch,i=!e?.stats.branch&&!!e?.stats.branchError,a=i?void 0:t?.branch,o=!!(e&&!i&&(t?.repository&&t.repository!==e.stats.repository||t?.branch&&t.branch!==e.stats.branch||t?.commitSha&&t.commitSha!==e.stats.commitSha)),s=!!(n.kind===`ready`&&r&&t?.state===`connected`&&t.prototype?.published&&t.prototype.build?.commitSha===e?.stats.commitSha);return{state:e&&{...e,publishStatus:!s&&[`requested`,`in_progress`].includes(e.publishStatus?.state??``)||t?.state===`connected`&&!r?e.publishStatus:s&&t?.prototype?.build?{state:`published`,detail:q.hubBuildImported,versionCount:t.prototype.versionCount,lastUpdatedAt:t.prototype.build.publishedAt,run:{url:t.prototype.build.url,actor:t.prototype.build.author.login||t.prototype.build.author.name?{login:t.prototype.build.author.login||void 0,name:t.prototype.build.author.name||void 0,avatarUrl:t.prototype.build.author.avatarUrl||void 0}:null}}:{state:t?.state===`connected`?`not_published`:`unavailable`,detail:t?.state===`connected`?q.hubBuildMissing:q.hubPublicationUnavailable},stats:{...e.stats,branch:a||e.stats.branch,branchError:a&&a!==e.stats.branch?null:e.stats.branchError,repository:t?.repository||e.stats.repository,commitSha:e.stats.commitSha,comparison:o?{branch:null,source:null,behind:null,error:q.comparisonNeedsRefresh}:e.stats.comparison,publishedUrl:s?t?.prototype?.build?.url:void 0}},hubPublished:s,comparisonOutdated:o}}function qn(e,t){let n;function r(e,t,r,i=`none`){return{kind:e,detail:t,label:r,action:i,...n?{error:n}:{}}}if(!e)return r(`loading`,X.initial,X.checking);let{stats:i}=e,a=i.remoteBranch;if(!a||a.state===`loading`)return r(`loading`,X.checkingRemote,X.checking);if(!i.branch||a.state===`detached`)return r(`detached`,X.detached,X.retry,`retry`);if(a.repository!==i.repository||a.branch!==i.branch||a.commitSha!==i.commitSha)return r(`unknown`,X.changed,X.retry,`retry`);if(a.state===`unknown`)return r(`unknown`,X.unknown(a.error),X.retry,`retry`);let o=t?.state===`connected`?t.prototype:void 0,s=o?.build?.commitSha===i.commitSha&&o?.branch===i.branch,c=e.publishRequest,l=t?.state===`connected`&&t.repository===i.repository&&t.branch===i.branch&&(!t.commitSha||t.commitSha===i.commitSha)&&t.prototype?.branch===i.branch&&t.prototype.build?.commitSha===i.commitSha?t.prototype.build:null,u=!!(l&&(c?.commitSha!==i.commitSha||c.buildNumber===void 0||typeof c.buildNumber==`number`&&l.number>c.buildNumber)),d=u&&o?.registered&&o.published,f=t!==null&&t.repository===i.repository&&(!t.branch||t.branch===i.branch)&&(!t.commitSha||t.commitSha===i.commitSha);if(t&&f&&(t.state===`connected`||t.state===`undiscovered`)&&!o?.registered&&(!o||o.branch===i.branch)){let e=t.registrationReason||o?.registrationReason,r=i.branch===t.discovery?.defaultBranch;if(e||t.registrationError||o?.canRegister===!1||r){let i=e||(r?`branch_not_reviewable`:o?.canEdit===!1?`write_access_required`:o?.canRegister===!1&&a.state===`absent`?`remote_branch_missing`:void 0);n=i&&X.registrationReasons.get(i)||{title:X.registrationErrorTitle,description:t.registrationError||X.registrationDenied}}}if(c?.state===`requested`&&(!c.commitSha||c.commitSha===i.commitSha)&&(a.state===`absent`||a.remoteSha!==i.commitSha)&&!u){let e=Date.now()-Date.parse(c.requestedAt||``);if(Number.isFinite(e)&&e<6e5)return r(`requested`,X.pending,X.awaitingCopilot)}if(!t)return r(`loading`,X.checkingHub,X.checking);if(t.state===`disconnected`||t.state===`pairing`||t.state===`unconfigured`)return r(`disconnected`,t.message||X.disconnected,X.connect);if(t.state===`denied`||t.state===`unavailable`)return{...r(`unknown`,t.message||X.hubUnavailable,X.retry,`retry`),error:{title:X.hubUnavailableTitle,description:t.message||X.hubUnavailable}};if(!f)return r(`unknown`,X.staleHub,X.retry,`retry`);if(!i.replicaWorkflowExists)return r(`workflow_missing`,X.workflowMissing,X.retry,`retry`);if(c?.state===`failed`&&!d&&(!c.commitSha||c.commitSha===i.commitSha))return r(`failed`,c.error||X.dispatchFailed,X.retryPublish,`publish`);if(a.state===`absent`)return r(`unpublished`,X.absent,X.publishBranch,`publish`);if(a.remoteSha!==i.commitSha)return r(`needs_push`,X.needsPush,X.publishChanges,`publish`);if(s){if(!o.registered)return r(`registration`,t.registrationError||(o.canEdit&&o.canRegister?X.needsRegistration:X.registrationDenied),t.registrationError?X.registrationFailed:X.registration);if(o.published&&u)return r(`ready`,X.ready,X.published)}if(o?.currentBuild?.commitSha===i.commitSha&&o.branch===i.branch&&o.currentBuild.state===`failed`)return r(`failed`,X.importFailed,X.retryPublish,`publish`);let p=i.workflow;if(!p||p.state===`unavailable`)return r(`unknown`,p?.detail||X.workflowUnavailable,X.retry,`retry`);let m=p.run;if(m&&(m.headSha!==i.commitSha||m.headBranch!==i.branch))return r(`unknown`,X.staleWorkflow,X.retry,`retry`);if(c?.commitSha===i.commitSha&&c.workflowRunId!=null&&m?.databaseId===c.workflowRunId&&!u)return r(`awaiting_build`,X.noBuild,X.awaitingBuild);let h;if(p.state===`in_progress`&&m){let e=[`queued`,`waiting`,`pending`,`requested`].includes(m.status||``);h=r(e?`queued`:`building`,e?X.workflowQueued:X.workflowBuilding,e?X.queued:X.building)}else h=p.state===`failed`&&m?r(`failed`,X.workflowFailed(m.conclusion),X.retryPublish,`publish`):p.state===`succeeded`&&m?r(`importing`,X.importing,X.awaitingHub):r(`awaiting_build`,X.noBuild,X.awaitingBuild);return m?.url?.startsWith(`https://github.com/`)&&(h.runUrl=m.url),h}function Jn({token:e,state:t,hubStatus:n,error:r,setError:i,refresh:a,refreshHub:o,preferenceSaving:s=!1}){let[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),m=(0,H.useRef)(!1),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(``),[y,b]=(0,H.useState)(!1),x=!t&&r?{kind:`unknown`,action:`retry`,label:X.retry,detail:r}:qn(t,n),S=`${t?.stats.repository}/${t?.stats.branch}/${t?.stats.commitSha}`,C=f?.identity===S&&x.action===`publish`?{...x,kind:`failed`,detail:f.message,label:X.retryPublish}:x.kind===`ready`&&t?.stats.workingTree===`changed`?{...x,kind:`needs_push`,action:`publish`,label:X.publishChanges,detail:X.localChanges}:x,w=Kn(t,n,x);(0,H.useEffect)(()=>{w.comparisonOutdated&&a(!0)},[w.comparisonOutdated,n?.branch,n?.commitSha,n?.repository,a]);async function T(){if(!y){b(!0);try{await Promise.all([a(!0),o()])}finally{b(!1)}}}async function E(){s||(C.action===`retry`?await T():C.action===`none`||m.current||h||await D())}async function D(){if(!(s||m.current)){m.current=!0,d(!0),i(``),v(``);try{let t=await $(`/api/publish/prepare`,e,{method:`POST`,body:`{}`});t.workingTree===`unavailable`||t.workingTree===`changed`&&!t.remember?g({preparation:t}):(g(null),await O(t,t.workingTree===`changed`?`commit-changes`:`committed-only`))}catch(e){let t=e instanceof Error?e.message:String(e);i(t),v(t)}finally{m.current=!1,d(!1)}}}async function O(r,s,c){if(s===`committed-only`&&n?.state===`connected`&&n.repository===r.target.repository&&n.branch===r.target.branch&&n.prototype?.registered&&n.prototype.published&&n.prototype.build?.commitSha===r.target.commitSha&&t?.stats.remoteBranch?.state===`present`&&t.stats.remoteBranch.remoteSha===r.target.commitSha)g(null);else{p(null),v(``),i(``);try{let t=await $(`/api/publish`,e,{method:`POST`,body:JSON.stringify({target:r.target,workingTree:r.workingTree,mode:s,remember:c})});g(null),l(t.message),await o(),await a(!1)}catch(e){let t=e instanceof Error?e.message:String(e);p({message:t,identity:S}),i(t),v(t)}}}async function k(e,t){if(!(s||!h||m.current)){if(h.preparation.workingTree===`unavailable`&&e!==`committed-only`)v(pe.checkFailed);else{m.current=!0,d(!0);try{await O(h.preparation,e,t)}finally{m.current=!1,d(!1)}}}}return{publication:C,presentedState:w.state,busy:u||y||s,notice:c,publishDialog:h,publishDialogError:_,closePublishDialog:()=>g(null),choosePublish:k,retryPublishCheck:D,publish:E,retry:T}}var Yn=`replica:controls`;function Xn(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&Se(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||Se({[r.id]:r.value}))}catch{return!1}}function Zn(e){return Array.isArray(e)&&e.length<=100&&e.every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`scope`in e&&typeof e.scope==`string`&&e.scope.length>0&&e.scope.length<=64&&`error`in e&&typeof e.error==`string`&&e.error.length>0&&e.error.length<=500)}function Qn(e){if(!e||typeof e!=`object`)return!1;let t=e;if(typeof t.runtimeAvailable!=`boolean`||t.reconnectRequired!==void 0&&typeof t.reconnectRequired!=`boolean`||t.status===`ready`&&(!t.runtimeAvailable||!t.scopes?.length)||t.error!==void 0&&(typeof t.error!=`string`||t.error.length>1e3)||t.scopeErrors!==void 0&&!Zn(t.scopeErrors)||![`ready`,`no-controls`,`missing-runtime`,`unsupported-runtime`,`invalid-config`].includes(t.status)||!Array.isArray(t.scopes)||t.scopes.length>100||t.status!==`ready`&&t.scopes.length>0)return!1;try{let e=new Set;for(let n of t.scopes){if(Ue(n.declaration),e.has(n.declaration.scope)||(e.add(n.declaration.scope),n.fingerprint!==JSON.stringify(n.declaration)||!Number.isSafeInteger(n.snapshot.revision)||n.snapshot.revision<0))return!1;let t=n.snapshot;if(!t.values||!t.visible||!t.groups||!t.actions)return!1;function r(e,t){return typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}if(!r(t.values,n.declaration.controls.filter(e=>e.type!==`button`).map(e=>e.id))||!r(t.visible,n.declaration.controls.map(e=>e.id))||!r(t.groups,(n.declaration.groups??[]).map(e=>e.id))||!r(t.actions,n.declaration.controls.filter(e=>e.type===`button`).map(e=>e.id))||Object.values(t.groups).some(e=>typeof e!=`boolean`))return!1;if(t.bindings!==void 0){if(!t.bindings||typeof t.bindings!=`object`||Array.isArray(t.bindings))return!1;for(let[e,r]of Object.entries(t.bindings))if(!n.declaration.controls.some(t=>t.id===e)||!r||typeof r.error!=`string`||r.error.length>500||typeof r.busy!=`boolean`||r.available!==void 0&&typeof r.available!=`boolean`)return!1}for(let e of n.declaration.controls){if(typeof t.visible[e.id]!=`boolean`)return!1;if(e.type===`button`){let n=t.actions[e.id];if(!n||typeof n.available!=`boolean`||typeof n.busy!=`boolean`)return!1}else if(ze(e,t.values[e.id]))return!1}}return!0}catch{return!1}}function $n(){return{runtimeAvailable:!1,status:`missing-runtime`,scopes:[],scopeErrors:[],loading:!0,notice:``,error:``,storageError:``,resetting:!1}}var er=class{frame;origin;api;surface;epoch=``;sequence=-1;state=$n();listeners=new Set;pending=new Map;saved;storageReady=!1;restored=new Set;preparing=new Set;persisted=new Map;cachedScopes=new Map;retryState;resetForIdentity=!1;fromFrameUrl=!1;requests=new AbortController;poll;deadline;saveQueue=Promise.resolve();editQueue=Promise.resolve();stopped=!0;constructor(e,t,n,r=`canvas`){this.frame=e,this.origin=t,this.api=n,this.surface=r}getSnapshot=()=>this.state;getControlValues=()=>{let e=structuredClone(this.saved?.scopes??{}),t=new Map(this.cachedScopes);for(let e of this.state.scopes)t.set(e.declaration.scope,e);for(let[n,r]of t)e[n]=Xe(r);return e};subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(e){this.state={...this.state,...e},this.state.hasResettableValues=Object.values(this.getControlValues()).some(e=>Object.keys(e).length>0);for(let e of[...this.listeners])e()}hasBindingError(e,t){return this.state.scopes.some(n=>(!e||n.declaration.scope===e)&&Object.entries(n.snapshot.bindings??{}).some(([e,n])=>(!t||e===t)&&!!n.error))}checkSaved(e){let t=e,n=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;if(!t||typeof t!=`object`||typeof t.identity!=`string`||!t.identity||t.identity.length>128||!t.scopes||typeof t.scopes!=`object`||Array.isArray(t.scopes)||t.storageError!==void 0&&(typeof t.storageError!=`string`||t.storageError.length>1e3)||t.notice!==void 0&&(typeof t.notice!=`string`||t.notice.length>1e3)||new Blob([JSON.stringify(t)]).size>27e4)throw Error(`Invalid controls storage response.`);for(let[e,r]of Object.entries(t.scopes)){if(!n.test(e)||!r||typeof r!=`object`||Array.isArray(r))throw Error(`Invalid controls storage scope.`);for(let[e,t]of Object.entries(r))if(!n.test(e)||!(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))throw Error(`Invalid saved control value.`)}}start=e=>{this.fromFrameUrl=e?.type===`load`&&this.sequence>=0;let t=[...this.pending.values()].some(e=>e.action);this.stop(),this.requests=new AbortController,this.stopped=!1,this.epoch=crypto.randomUUID(),this.sequence=-1,this.saved=void 0,this.storageReady=!1,this.restored.clear(),this.preparing.clear(),this.persisted.clear(),this.editQueue=Promise.resolve(),this.cachedScopes.clear(),this.retryState=void 0,this.resetForIdentity=!1,this.state=$n(),t&&(this.state.notice=`The preview reconnected during an action. Its outcome is unknown; it was not replayed.`),this.publish({});let n=this.epoch;window.addEventListener(`message`,this.receive),this.frame.addEventListener(`load`,this.start);let r=()=>{this.storageReady&&(this.surface===`canvas`&&this.frame.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:n},this.origin),this.send(`hello`).catch(()=>{}))};r(),this.poll=setInterval(()=>{this.state.status===`missing-runtime`&&r()},1e3),this.deadline=setTimeout(()=>{this.state.loading&&this.publish({loading:!1,error:this.surface===`build`?`Build Controls did not connect. Reload the preview or check its definitions.`:q.controlsLocalConnectionFailed})},6e3),this.api().then(e=>{if(!(this.epoch!==n||this.stopped)){if(this.checkSaved(e),this.saved=e,this.retryState?.identity===e.identity)for(let[e,t]of this.retryState.scopes)this.restored.add(`${e}:${t.fingerprint}`),this.cachedScopes.set(e,t);else this.retryState?.identity&&(this.resetForIdentity=!0,this.publish({notice:`The checkout identity changed. Controls will use this branch's saved values or defaults.`}));this.retryState=void 0,this.storageReady=!0,this.publish({storageError:e.storageError||``,notice:e.notice||this.state.notice}),this.prepare(this.state),r()}}).catch(e=>{this.epoch!==n||this.stopped||(this.storageReady=!0,this.publish({storageError:this.surface===`build`?e instanceof Error?e.message:`Control settings could not be read from the URL.`:q.controlsLocalStorageFailed}),this.prepare(this.state),r())})};retry=()=>{let e={identity:this.saved?.identity,scopes:new Map(this.cachedScopes)};this.start(),this.retryState=e};stop=()=>{this.stopped=!0,this.requests.abort(),clearInterval(this.poll),clearTimeout(this.deadline),window.removeEventListener(`message`,this.receive),this.frame.removeEventListener(`load`,this.start);for(let e of this.pending.values())clearTimeout(e.timer),e.reject(Error(`The preview navigated. The command outcome is unknown; it will not be replayed.`));this.pending.clear()};receive=e=>{if(this.stopped||e.source!==this.frame.contentWindow||e.origin!==this.origin||!Xn(e.data))return;let t=e.data;if(t.epoch!==this.epoch||!Qn(t.state)||!Number.isSafeInteger(t.sequence)||(t.sequence??-1)<0||t.type!==`snapshot`&&t.type!==`reply`)return;let n=this.pending.get(t.requestId);if(t.type!==`reply`||n){if((t.sequence??-1)>this.sequence){if(t.type===`snapshot`&&t.controlQuery!==void 0&&this.saved){let e=Ee(t.controlQuery),n=this.saved.identity,r=this.epoch;this.stop();let i=new AbortController;this.requests=i,this.publish({loading:!0}),this.api({method:`POST`,signal:i.signal,body:JSON.stringify({identity:n,replace:!0,scopes:e.scopes})}).then(()=>{this.epoch!==r||i.signal.aborted||(this.start(),e.notice&&this.publish({notice:e.notice}))}).catch(e=>{this.epoch!==r||i.signal.aborted||this.publish({loading:!1,storageError:e instanceof Error?e.message:`Controls history could not be restored.`})});return}if(t.controlQuery!==void 0&&this.saved){let e=this.epoch,n=this.requests,r=Ee(t.controlQuery);this.saved.scopes=r.scopes,this.restored.clear(),this.persisted.clear(),this.cachedScopes.clear(),this.publish({notice:r.notice,loading:!0}),this.api({method:`POST`,signal:n.signal,body:JSON.stringify({identity:this.saved.identity,replace:!0,scopes:r.scopes})}).catch(t=>{this.epoch!==e||this.stopped||n.signal.aborted||this.publish({storageError:t instanceof Error?t.message:`Controls history could not be restored.`})})}this.sequence=t.sequence;let e=t.state.status;this.publish({...t.state,scopeErrors:t.state.scopeErrors??[],reconnectRequired:t.state.reconnectRequired===!0,status:e,error:t.state.error||(this.state.status===`missing-runtime`&&t.state.status!==`missing-runtime`?``:this.state.error),loading:!this.storageReady||this.state.resetting||this.preparing.size>0||this.state.loading&&e===`missing-runtime`}),this.prepare(this.state)}n&&(this.pending.delete(t.requestId),clearTimeout(n.timer),t.error?n.reject(Error(t.error)):n.resolve(this.state))}};send(e,t){let n=crypto.randomUUID(),r={protocol:Yn,version:1,epoch:this.epoch,requestId:n,type:e,...t?{command:t}:{},...e===`hello`?{controlQuery:Te(this.saved?.scopes??{}),fromFrameUrl:this.fromFrameUrl}:{}};return Xn(r)?new Promise((i,a)=>{let o=setTimeout(()=>{this.pending.delete(n),a(Error(`The command timed out. Its outcome is unknown; it will not be retried automatically.`))},e===`hello`?1200:3e4);this.pending.set(n,{resolve:i,reject:a,timer:o,action:t?.operation===`action`}),this.frame.contentWindow?.postMessage(r,this.origin)}):Promise.reject(Error(`The controls command is invalid or exceeds the size limit.`))}async prepare(e){if(!this.saved&&!this.state.storageError||this.state.resetting||e.reconnectRequired)return;let t=this.epoch;if(this.resetForIdentity&&(e.status===`ready`||e.status===`no-controls`)){this.resetForIdentity=!1,this.publish({loading:!0,resetting:!0});try{await this.send(`command`,{operation:`reset-all`,contexts:e.scopes.map(e=>({scope:e.declaration.scope,fingerprint:e.fingerprint,revision:e.snapshot.revision}))})}catch{this.epoch===t&&this.publish({error:`The checkout changed, but runtime defaults could not be restored. Reload the preview before saving.`,storageError:`Saving is paused until the new checkout's runtime reconnects.`,loading:!1});return}finally{this.epoch===t&&this.publish({resetting:!1})}return this.epoch!==t||this.stopped?void 0:this.prepare(this.state)}for(let n of e.scopes){let e=n.declaration.scope,r=`${e}:${n.fingerprint}`;if(!this.preparing.has(r)){if(!this.restored.has(r)){this.preparing.add(r),this.publish({loading:!0});try{let i=this.saved?.scopes&&Object.hasOwn(this.saved.scopes,e)?this.saved.scopes[e]:{},a=Object.fromEntries(n.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)])),o=!1;for(let[e,t]of Object.entries(i)){let r=n.declaration.controls.find(t=>t.id===e);!r||ze(r,t)?o=!0:a[e]=t}if(Object.keys(a).length&&await this.send(`command`,{operation:`restore`,scope:e,fingerprint:n.fingerprint,revision:this.state.scopes.find(e=>e.fingerprint===n.fingerprint)?.snapshot.revision,values:a}),this.stopped||this.epoch!==t)return;this.restored.add(r),o&&this.publish({notice:this.surface===`build`?`Some URL control settings no longer match this page. Defaults were used.`:`Some saved controls no longer match this declaration and were discarded.`})}catch(n){if(this.epoch!==t||this.stopped)return;this.hasBindingError(e)||this.publish({error:n instanceof Error?n.message:`Saved controls could not be restored.`}),this.restored.add(r)}finally{this.epoch===t&&this.preparing.delete(r)}}if(this.epoch===t&&!this.stopped){let t=this.state.scopes.find(t=>t.declaration.scope===e);t&&(this.cachedScopes.set(e,t),this.persist(t))}}}this.epoch===t&&!this.stopped&&this.state.status!==`missing-runtime`&&this.publish({loading:this.preparing.size>0})}persist(e){if(!this.saved||this.state.storageError)return;let t=Xe(e),n=JSON.stringify(t);if(this.persisted.get(e.declaration.scope)===n)return;this.persisted.set(e.declaration.scope,n);let r=this.saved.identity,i=this.epoch,a=this.requests.signal;this.saveQueue=this.saveQueue.catch(()=>{}).then(async()=>{if(!(this.epoch!==i||this.stopped))try{if(await this.api({method:`POST`,signal:a,body:JSON.stringify({identity:r,scope:e.declaration.scope,values:t})}),this.epoch===i&&!this.stopped){let t=await this.api();if(this.checkSaved(t),this.epoch!==i||this.stopped)return;this.saved=t,await this.send(`command`,{operation:`url`,scope:e.declaration.scope,query:Te(t.scopes)})}}catch(e){this.epoch===i&&!this.stopped&&this.publish({storageError:this.surface===`build`&&e instanceof Error?`${e.message} Changes remain in memory and are not in the URL.`:`Controls could not be saved. Changes remain in memory; use Retry to reconnect storage.`})}})}async command(e,t,n,r){if(this.state.loading||this.state.resetting||this.stopped)return;let i=this.epoch,a=this.state.scopes.find(e=>e.declaration.scope===t);if(!a){this.publish({error:`This controls scope is no longer active.`});return}let o=()=>this.applyCommand(e,t,a.fingerprint,i,n,r);if(e!==`update`)return o();let s=this.editQueue.catch(()=>{}).then(o);return this.editQueue=s.then(()=>{}),s}async applyCommand(e,t,n,r,i,a){if(this.epoch!==r||this.stopped||this.state.resetting)return;let o=this.state.scopes.find(e=>e.declaration.scope===t);if(!o||o.fingerprint!==n)this.publish({error:`The controls scope or declaration changed. The command was not applied.`});else{this.publish({error:``});try{if(this.state.reconnectRequired)throw Error(`Reconnect controls before sending more commands.`);if(e===`update`||e===`action`){let t=o.declaration.controls.find(e=>e.id===i);if(!t||!o.snapshot.visible[t.id])throw Error(`This control is unknown or hidden.`);if(e===`update`){let e=ze(t,a);if(e)throw Error(`Control "${t.id}": ${e}`)}else if(t.type!==`button`||!o.snapshot.actions[t.id]?.available||o.snapshot.actions[t.id]?.busy)throw Error(`This action is unavailable or busy.`)}let n=await this.send(`command`,{operation:e,scope:t,fingerprint:o.fingerprint,revision:o.snapshot.revision,...i?{id:i}:{},...e===`update`?{value:a}:{}});if(e===`update`&&i)return{value:n.scopes.find(e=>e.declaration.scope===t)?.snapshot.values[i]}}catch(e){!this.stopped&&this.epoch===r&&!this.hasBindingError(t,i)&&this.publish({error:e instanceof Error?e.message:`Controls command failed.`})}}}async resetAll(){if(this.state.resetting||this.stopped)return;let e=this.epoch;this.publish({resetting:!0});try{let t=``;await this.editQueue.catch(()=>{});let n=this.state.runtimeAvailable&&(this.state.status===`ready`||this.state.status===`no-controls`);if(n)try{await this.send(`command`,{operation:`reset-all`,contexts:this.state.scopes.map(e=>({scope:e.declaration.scope,fingerprint:e.fingerprint,revision:e.snapshot.revision}))})}catch(e){t=e instanceof Error?e.message:`Some app defaults could not be restored.`}if(this.epoch!==e||this.stopped)return;if(!this.saved){let e=await this.api();this.checkSaved(e),this.saved=e}await this.saveQueue.catch(()=>{}),await this.api({method:`POST`,signal:this.requests.signal,body:JSON.stringify({identity:this.saved.identity,reset:!0})}),this.saved.scopes={},await this.send(`command`,{operation:`url`,query:``}),this.cachedScopes.clear(),this.persisted.clear(),this.publish({storageError:``,error:this.hasBindingError()?``:t,notice:n?``:`Saved controls were cleared. Runtime defaults could not be restored until the preview reconnects.`})}catch(t){this.epoch===e&&this.publish({storageError:t instanceof Error?t.message:`Reset could not be saved.`})}finally{this.epoch===e&&this.publish({resetting:!1,loading:!1})}}};function tr(e,t=()=>window.location.href,n=e=>{window.history.replaceState(window.history.state,``,e),window.dispatchEvent(new Event(Ce))}){return r=>Promise.resolve().then(()=>{r?.signal?.throwIfAborted();let i=Ee(new URL(t()).search);if(!r)return{identity:e,...i};if(r.method!==`POST`||typeof r.body!=`string`)throw Error(`Invalid URL controls request.`);let a=JSON.parse(r.body);if(!a||typeof a!=`object`||!(`identity`in a)||a.identity!==e)throw Error(`The controls URL identity changed.`);let o=i.scopes;if(`reset`in a&&a.reset===!0)o={};else if(`replace`in a&&a.replace===!0&&`scopes`in a){if(!a.scopes||typeof a.scopes!=`object`||Array.isArray(a.scopes))throw Error(`Invalid controls history settings.`);let e={};for(let[t,n]of Object.entries(a.scopes)){if(!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(t)||!Se(n))throw Error(`Invalid controls history settings.`);e[t]=n}o=Ee(Te(e)).scopes}else{if(!(`scope`in a)||typeof a.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(a.scope)||!(`values`in a)||!Se(a.values))throw Error(`Invalid URL control settings.`);o={...o,[a.scope]:a.values}}let s=De(t(),Te(o));s!==t()&&n(s)})}function nr({frameRef:e,prototypeUrl:t,previewUrl:n,address:r,replaceAddress:i}){let[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(null),l=(0,H.useRef)({address:r,replaceAddress:i});return(0,H.useLayoutEffect)(()=>{l.current={address:r,replaceAddress:i}},[r,i]),(0,H.useEffect)(()=>{if(!e.current)return;let r=new er(e.current,new URL(n??t).origin,tr(`prototype:${new URL(t).origin}`,()=>l.current.address,e=>{l.current.address=e,l.current.replaceAddress(e)}));o(r);let i=r.subscribe(()=>c(r.getSnapshot()));return r.start(),()=>{i(),r.stop()}},[t,n,e]),{connection:a,state:s}}function rr({token:e,status:t,onStatusChange:n,onSelectHub:r}){let[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),m=(0,H.useRef)(!1),h=(0,H.useRef)(!1),g=t?.state===`connected`||t?.state===`undiscovered`,_=t?.state===`disconnected`||t?.state===`pairing`||t?.state===`unconfigured`,v=g?null:t?.pairing||(f?.repository===t?.repository&&f?.hubOrigin===t?.hubOrigin?f?.pairing:null),y=v?.verificationUrl;(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{g?(a(!1),p(null),l(``)):_&&t?.repository&&!m.current&&(m.current=!0,a(!0))},0);return()=>window.clearTimeout(e)},[g,_,t?.repository]),(0,H.useEffect)(()=>{if(!y||u)return;let t=!1,r=!1;async function i(){if(!r){r=!0;try{let r=await $(`/api/hub/poll`,e,{method:`POST`,body:`{}`});if(t)return;r.status!==`pending`&&(p(null),r.status!==`approved`&&l(q.connectionApprovalExpired),await n())}catch(e){t||(l(e instanceof Error?e.message:String(e)),d(!0))}finally{r=!1}}}let a=window.setInterval(()=>void i(),3e3);return()=>{t=!0,window.clearInterval(a)}},[y,u,e,n,t?.repository,t?.hubOrigin]);async function b(i){if(m.current=!0,!h.current){if(!t?.repository)l(q.connectionRepositoryRequired);else if(!t.hubOrigin&&!i)l(q.connectionHubRequired);else{h.current=!0,s(!0),l(``),d(!1);try{!t.hubOrigin&&i&&await r(i);let a=await $(`/api/hub/connect`,e,{method:`POST`,body:`{}`});p({repository:t.repository,hubOrigin:new URL(a.verificationUrl).origin,pairing:a}),a.browserError&&l(q.connectionBrowserFailed(a.browserError)),await n()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h.current=!1,s(!1)}}}}function x(){a(!0),t?.hubOrigin&&b()}return{open:i,close:()=>a(!1),show:()=>a(!0),showAndConnect:x,connect:b,connecting:o,error:c,pairing:v}}function ir({token:e,onStatus:t,onError:n}){let[r,i]=(0,H.useState)(null),a=(0,H.useRef)(0),o=(0,H.useRef)(0),s=(0,H.useRef)(!1),c=(0,H.useCallback)(async(r,c=!1)=>{if(s.current||c&&o.current>0)return;o.current+=1;let l=++a.current;try{let o=r===`open`||r===`interaction`,c=await $(o?r===`open`?`/api/hub/open`:`/api/hub/activity`:`/api/hub/status`,e,o?{method:`POST`,body:`{}`}:{});if(l!==a.current||s.current)return;i(c);let u=c.prototype?.startPageImportError||c.localStartPageError;u&&n(u),t(c)}catch(e){if(l!==a.current||s.current)return;let t=e instanceof Error?e.message:String(e);i(e=>({state:`unavailable`,repository:e?.repository,branch:e?.branch,hubOrigin:e?.hubOrigin,message:q.hubStatusUnavailable(t)})),n(t)}finally{--o.current}},[e,t,n]),l=(0,H.useCallback)(async t=>{s.current=!0,a.current+=1,i(null);try{await $(`/api/hub/origin`,e,{method:`POST`,body:JSON.stringify({origin:t})})}finally{s.current=!1,await c()}},[e,c]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>void c(`open`),0),t=window.setInterval(()=>void c(void 0,!0),15e3);function n(){c(`interaction`)}return window.addEventListener(`focus`,n),()=>{a.current+=1,window.clearTimeout(e),window.clearInterval(t),window.removeEventListener(`focus`,n)}},[c]);async function u(){let t=await $(`/api/hub/discovery`,e,{method:`POST`,body:`{}`});if(t.discovery?.state!==`valid`||!t.discovery.origin)throw Error(t.discovery?.message||q.resetHubUnavailable);return await c(),t.discovery.origin}return{status:r,refresh:c,select:l,reset:u}}function ar({prototypeUrl:e,previewUrl:t,shellRef:n,cancelClick:r}){let[{key:i,ref:a},o]=(0,H.useState)(()=>({key:0,ref:(0,H.createRef)()})),[s,c]=(0,H.useState)({input:e,url:e}),[l,u]=(0,H.useState)({input:e,entries:[e],index:0}),[d,f]=(0,H.useState)(()=>window.matchMedia?.(`(prefers-color-scheme: dark)`)?.matches?`dark`:`light`),[p,m]=(0,H.useState)(null),h=(0,H.useRef)(null),g=l.input===e?l:{input:e,entries:[e],index:0},_=g.entries[g.index],v=(0,H.useCallback)(()=>r.current?.(),[r]),y=(0,H.useCallback)(t=>{if(new URL(t).origin!==new URL(e).origin)throw Error(q.startPageOrigin);u(e=>{let n=[...e.entries];return n[e.index]=t,{...e,entries:n}})},[e]),b=(0,H.useCallback)(t=>{if(h.current===e)return;h.current=e;let n=new URL(e),r=t.state===`connected`&&(t.prototype?.startPageSet??t.prototype?.startPage!==void 0)?t.prototype?.startPage:t.localStartPage;if(n.pathname!==`/`||n.search||n.hash||!r)return;let i=new URL(r,n);if(i.origin!==n.origin)throw Error(q.startPageOrigin);c({input:e,url:i.href}),u({input:e,entries:[i.href],index:0})},[e]);function x(){v(),m(null),c({input:e,url:_}),o(e=>({key:e.key+1,ref:(0,H.createRef)()}))}function S(t){t===_?x():(u(n=>{let r=n.input===e?n:g;return{...r,entries:[...r.entries.slice(0,r.index+1),t],index:r.index+1}}),c({input:e,url:t}))}function C(t){let n=g.entries[t];n&&(u({...g,index:t}),c({input:e,url:n}))}let w=(0,H.useCallback)((t,n=!1)=>{m(t);let r=new URL(e);r.pathname=t.pathname,r.search=t.search,r.hash=t.hash,u(t=>{let i=t.input===e?t:{input:e,entries:[e],index:0},a=new URL(i.entries[i.index]),o=[...a.searchParams].filter(([e])=>e.startsWith(`rc.`));for(let e of[r,a])for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);if(a.pathname===r.pathname&&a.searchParams.toString()===r.searchParams.toString()&&a.hash===r.hash)return i;for(let[e,t]of o)r.searchParams.append(e,t);let s=r.href;if(n){let e=[...i.entries];return e[i.index]=s,{...i,entries:e}}return{...i,entries:[...i.entries.slice(0,i.index+1),s],index:i.index+1}})},[e]);(0,H.useEffect)(()=>{let e=a.current;if(!e)return;function t(){v(),m(null)}return e.addEventListener(`load`,t),()=>{v(),e.removeEventListener(`load`,t)}},[v,a]),(0,H.useEffect)(()=>{let r=a.current;if(!r)return;let i=new URL(t??e).origin,o=crypto.randomUUID();function s(){let e=n.current?.closest(`.canvas-base`);e&&r?.contentWindow?.postMessage({type:`replica:canvas:theme`,nonce:o,accent:window.getComputedStyle(e).getPropertyValue(`--hub-accent`).trim()},i)}function c(e){e.source===r?.contentWindow&&e.origin===i&&e.data?.type===`replica:canvas:ready`&&s()}return r.addEventListener(`load`,s),window.addEventListener(`message`,c),s(),()=>{r.removeEventListener(`load`,s),window.removeEventListener(`message`,c)}},[d,e,t,a,n]);let T=new URL(s.input===e?s.url:e);if(t){let e=new URL(t);T.protocol=e.protocol,T.host=e.host}return{frameRef:a,frameKey:i,source:T.href,navigation:g,address:_,replaceAddress:y,appearance:d,setAppearance:f,liveRoute:p,initialize:b,reportRoute:w,reload:x,navigate:S,travel:C}}function or(e){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(``),a=(0,H.useRef)(null),o=(0,H.useRef)(0),s=(0,H.useRef)(0),c=(0,H.useCallback)(async(t,r=!1)=>{if(r&&s.current>0)return;s.current+=1;let c=++o.current;try{let r=await $(t?`/api/refresh`:`/api/state`,e,t?{method:`POST`,body:`{}`}:{});if(c!==o.current)return;a.current=r,n(r),i(``)}catch(e){if(c!==o.current)return;n(t=>t&&{...t,stats:{...t.stats,remoteBranch:{state:`unknown`,repository:t.stats.repository||null,branch:t.stats.branch||null,commitSha:t.stats.commitSha||null,error:sr(e)}}}),i(sr(e))}finally{--s.current}},[e]);return(0,H.useEffect)(()=>{let e=window.setTimeout(()=>void c(!0),0),t=window.setInterval(()=>{let e=a.current?.publishStatus?.state,t=a.current?.publishRequest,n=e===`requested`||e===`in_progress`||t?.state===`requested`||!!t?.requestedAt&&(e===`not_published`||e===`unavailable`);c(n,!0)},15e3);function n(){c(!0)}return window.addEventListener(`focus`,n),()=>{o.current+=1,window.clearTimeout(e),window.clearInterval(t),window.removeEventListener(`focus`,n)}},[c]),{state:t,error:r,setError:i,refresh:c}}function sr(e){return e instanceof Error?e.message:String(e)}function cr({token:e,enabled:t,repository:n,branch:r,commitSha:i,publicationRevision:a}){let o=`${n}/${r}/${i}/${a}`,[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),p=(0,H.useRef)(null),m=(0,H.useRef)(0),h=t&&s?.identity===o?s:null,g=(0,H.useCallback)(async()=>{if(!t)return;let i=++m.current;u(!0);try{if(await p.current,i!==m.current)return;let t=await $(`/api/publish/prepare`,e,{method:`POST`,body:`{}`});if(i!==m.current)return;if(t.target.repository!==n||t.target.branch!==r)throw Error(pe.preferenceTargetChanged);if(typeof t.remember!=`boolean`)throw Error(pe.invalidPreference);c({identity:o,preparation:t,error:``})}catch(e){i===m.current&&c({identity:o,preparation:null,error:e instanceof Error?e.message:String(e)})}finally{i===m.current&&u(!1)}},[t,e,n,r,o]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>void g(),0);return()=>{m.current+=1,window.clearTimeout(e)}},[g]);async function _(n){if(!t||!h?.preparation||l||p.current)return;f(!0);let r=m.current,i=h.preparation,a=(async()=>{try{if((await $(`/api/publish/preference`,e,{method:`POST`,body:JSON.stringify({target:i.target,remember:n})})).remember!==n)throw Error(pe.invalidPreference);r===m.current&&c({identity:o,preparation:{...i,remember:n},error:``})}catch(e){r===m.current&&c({identity:o,preparation:i,error:e instanceof Error?e.message:String(e)})}})();p.current=a;try{await a}finally{p.current=null,f(!1)}}return{remember:h?.preparation?.remember??null,loading:l||!h,saving:d,error:h?.error||``,save:_,retry:g}}function lr(e,t,n){let r=n?.included,i=n?.error,a=n?.revision,o=(0,H.useMemo)(()=>{if(r!==void 0)return{identity:e,revision:a,included:r,error:i??``,pending:!1};let t=!1,n=``;if(e)try{let n=localStorage.getItem(`replica:share-controls:v1:${e}`);if(n!==null&&n!==`true`&&n!==`false`)throw Error(`Invalid saved share preference.`);t=n===`true`}catch{n=`The share preference could not be read. Control settings are off by default.`}return{identity:e,revision:a,included:t,error:n,pending:!1}},[e,a,r,i]),[s,c]=(0,H.useState)(o),l=s.identity===e&&s.revision===a?s:o,u=``,d=``;if(l.included)try{u=Te(t)}catch(e){d=e instanceof Error?e.message:`Control settings could not be shared.`}return{included:l.included,query:u,error:d||l.error,blocked:!!d,...n?{pending:l.pending}:{},onChange:t=>{if(n){c({identity:e,revision:a,included:t,error:``,pending:!0});function r(n){c(r=>r.identity===e&&r.revision===a&&r.included===t?{...r,error:n,pending:!1}:r)}n.onChange(t).then(()=>r(``),e=>r(e instanceof Error?e.message:`This preference could not be saved. It will only apply while this page is open.`));return}let r=``;if(e)try{localStorage.setItem(`replica:share-controls:v1:${e}`,String(t))}catch{r=`This preference could not be saved. It will only apply while this page is open.`}c({identity:e,revision:a,included:t,error:r,pending:!1})}}}function ur({token:e,state:t,hubStatus:n}){let[r,i]=(0,H.useState)(null),a=!!(r&&(r.stale||r.repository!==void 0&&r.repository!==t?.stats.repository||r.branch!==void 0&&r.branch!==t?.stats.branch||n?.hubOrigin!==void 0&&r.hubOrigin!==void 0&&r.hubOrigin!==n.hubOrigin||r.token!==e));(0,H.useEffect)(()=>{if(!r||r.stale)return;let e=r.repository??t?.stats.repository,o=r.branch??t?.stats.branch,s=r.hubOrigin??n?.hubOrigin;if(!a&&e===r.repository&&o===r.branch&&s===r.hubOrigin)return;let c=window.setTimeout(()=>{i(t=>t&&{...t,repository:e,branch:o,hubOrigin:s,stale:a,connecting:!a&&t.connecting})},0);return()=>window.clearTimeout(c)},[r,a,t?.stats.repository,t?.stats.branch,n?.hubOrigin]);function o(){i({repository:t?.stats.repository,branch:t?.stats.branch,hubOrigin:n?.hubOrigin,token:e,connecting:!1,stale:!1})}function s(e){i(t=>t&&{...t,connecting:e})}return{intent:r,targetChanged:a,begin:o,close:()=>i(null),setConnecting:s}}var dr={open:!1,context:null,links:[],loading:!1,busy:!1,stale:!0,error:``,notice:``,created:null};function fr({token:e,hubStatus:t,prototypeState:n}){let[r,i]=(0,H.useState)(dr),a=(0,H.useRef)(r);a.current=r;let o=(0,H.useRef)(0),s=(0,H.useRef)(!1),c=(0,H.useRef)(!1),l=(0,H.useRef)(!1),u=(0,H.useRef)(!1),d=(0,H.useRef)(null),f=`${t?.hubOrigin}/${t?.repository}/${t?.branch}/${t?.state}`,p=(0,H.useRef)(f);p.current=f;let m=(0,H.useCallback)(()=>{!u.current||s.current||c.current||l.current||!d.current||(u.current=!1,d.current())},[]);(0,H.useLayoutEffect)(()=>{o.current+=1,i(e=>e.open?{...dr,open:!0,error:J.stale}:dr)},[f,e]),(0,H.useEffect)(()=>()=>{o.current+=1,u.current=!1},[]),(0,H.useEffect)(()=>{let e=t?.prototype;e&&e.canManageShareLinks!==!0&&a.current.context?.prototype.canManageShareLinks===!0&&(o.current+=1,i(t=>t.open&&t.context?.prototype.id===e.id?{...dr,open:!0,stale:!1,context:{...t.context,prototype:{...t.context.prototype,canManageShareLinks:e.canManageShareLinks}}}:t))},[t?.prototype]),(0,H.useEffect)(()=>{t?.prototype?.publicSharingEnabled===!1&&(o.current+=1,i(e=>e.open?{...dr,open:!0,sharingDisabled:!0,error:J.disabled,context:e.context?{...e.context,prototype:{...e.context.prototype,publicSharingEnabled:!1}}:null}:dr))},[t?.prototype?.publicSharingEnabled]);let h=(0,H.useCallback)((t,n)=>$(`/api/hub/share-links/${t}`,e,{method:`POST`,body:JSON.stringify(n)}),[e]),g=(0,H.useCallback)(e=>{e instanceof Error&&`code`in e&&(e.code===`public_sharing_disabled`||e.code===`public_sharing_changed`||e.code===`creator_access_changed`)&&(o.current+=1,i(t=>({...t,busy:!1,loading:!1,stale:!0,sharingDisabled:e.code===`public_sharing_disabled`,links:[],created:null,authorization:void 0})))},[]),_=(0,H.useCallback)(async(e=a.current.context)=>{if(!e||!e.prototype.canManageShareLinks||e.prototype.publicSharingEnabled===!1||c.current)return;c.current=!0;let t=o.current,n=p.current;i(e=>({...e,loading:!0,stale:!0,error:``}));try{let r=new Map,a=new Set,s=null;do{let i=await h(`list`,{target:e.target,...s?{cursor:s}:{}});if(t!==o.current||n!==p.current)return;for(let e of i.shareLinks)r.set(e.id,e);if(s=i.nextCursor,s){if(a.has(s))throw Error(J.paginationFailed);a.add(s)}}while(s);i(e=>({...e,links:[...r.values()],created:e.created?r.get(e.created.id)??null:null,loading:u.current,stale:u.current,sharingDisabled:!1}))}catch(e){t===o.current&&n===p.current&&(i(t=>({...t,loading:!1,stale:!0,error:e instanceof Error?e.message:J.failed})),g(e))}finally{c.current=!1,m()}},[h,m,g]),v=(0,H.useCallback)(async()=>{if(s.current||l.current||c.current){u.current=!0,i(e=>({...e,open:!0,stale:!0,loading:!0}));return}l.current=!0;let e=++o.current,r=p.current;i({...dr,open:!0,loading:!0});let a=t?.repository===n?.stats.repository&&t?.branch===n?.stats.branch,d=``;if(!t||[`disconnected`,`pairing`,`unconfigured`].includes(t.state)?d=J.disconnected:[`unavailable`,`denied`].includes(t.state)?d=J.unavailable:(t.state!==`connected`||!a)&&(d=J.branch),d)i({...dr,open:!0,error:d}),l.current=!1;else try{let t=await h(`context`,{});if(e!==o.current||r!==p.current)return;i(e=>({...e,context:t,loading:!1,stale:t.prototype.canManageShareLinks===!0})),await _(t)}catch(t){e===o.current&&r===p.current&&i(e=>({...e,loading:!1,error:t instanceof Error?t.message:J.failed}))}finally{l.current=!1,m()}},[t,n,_,h,m]);d.current=v;let y=(0,H.useCallback)(async(e,t)=>{let n=a.current;if(s.current||l.current||c.current||u.current||n.stale||!n.context||n.context.prototype.canManageShareLinks!==!0||n.sharingDisabled||n.context.prototype.publicSharingEnabled===!1)return!1;s.current=!0;let r=o.current;i(e=>({...e,busy:!0,error:``,notice:``}));try{let a=await h(e,{target:n.context.target,...t});return r===o.current&&(i(n=>({...n,notice:e===`delete`?J.deleted:``,authorization:void 0,created:`id`in a?a:e===`delete`&&`id`in t&&n.created?.id===t.id?null:n.created,links:e===`delete`&&`id`in t?n.links.filter(e=>e.id!==t.id):n.links})),await _(n.context),!0)}catch(e){if(r!==o.current)return!1;let t=e instanceof Error&&`code`in e&&e.code===`fresh_authorization_required`&&`authorization`in e&&e.authorization&&typeof e.authorization==`object`&&`url`in e.authorization&&typeof e.authorization.url==`string`&&`expiresAt`in e.authorization&&typeof e.authorization.expiresAt==`string`?{url:e.authorization.url,expiresAt:e.authorization.expiresAt}:void 0,n=e instanceof Error&&(!(`statusCode`in e)||`code`in e&&e.code===`share_delivery_unknown`);return i(r=>({...r,stale:!0,authorization:t,error:n?J.unknown:e instanceof Error?e.message:J.failed})),g(e),!1}finally{s.current=!1,r===o.current&&i(e=>({...e,busy:!1})),m()}},[_,h,m,g]),b=(0,H.useCallback)(async e=>{let t=a.current;if(!t.context||l.current||c.current||u.current)throw Error(J.stale);let n=o.current,r=await h(`controls-preference`,{target:t.context.target,included:e});if(n!==o.current)throw Error(J.stale);if(r.included!==e)throw Error(`The share preference could not be saved.`)},[h]),x=(0,H.useCallback)(async(e,t)=>{let n=a.current;if(!n.context||n.stale||l.current||c.current||u.current)return;let r=o.current;try{await h(`open`,{target:n.context.target,id:e,...t?{controlsQuery:t}:{}})}catch(e){r===o.current&&(i(t=>({...t,error:e instanceof Error?e.message:J.failed})),g(e))}},[h,g]),S=(0,H.useCallback)(async()=>{let e=a.current;if(!e.context||!e.authorization||e.busy)return;let t=o.current;try{await h(`authorize`,{target:e.context.target}),t===o.current&&i(e=>({...e,notice:J.authorizationRetry}))}catch(e){t===o.current&&(i(t=>({...t,error:e instanceof Error?e.message:J.failed})),g(e))}},[h,g]);return(0,H.useEffect)(()=>{if(!r.open||!r.context)return;function e(){s.current||_()}let t=window.setInterval(e,3e4);return window.addEventListener(`focus`,e),()=>{window.clearInterval(t),window.removeEventListener(`focus`,e)}},[r.open,r.context,_]),{state:r,open:v,close:()=>{u.current=!1,i(e=>({...e,open:!1}))},refresh:()=>r.context&&!r.sharingDisabled&&r.context.prototype.publicSharingEnabled!==!1?_():v(),create:(e,t)=>y(`create`,{label:e,expiration:t,buildNumber:r.context?.prototype.build?.number}),remove:e=>y(`delete`,{id:e}),openLink:x,setControlPreference:b,authorize:S}}var pr=`modulepreload`,mr=function(e){return`/assets/`+e},hr={},gr=function(e){return e.pathname.endsWith(`.css`)},_r=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},vr=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=mr(t,n);let r=s(t),i=gr(r);return _r(hr,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:pr,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},yr=(0,H.lazy)(()=>vr(()=>import(`./renderer-improvement-notes-prototype.js`).then(e=>e.t).then(e=>({default:e.ImprovementNotesPrototype})),__vite__mapDeps([0,1,2,3,4]))),br=(0,H.lazy)(()=>vr(()=>import(`./renderer-prototype-canvas-thread-sample.js`).then(e=>({default:e.PrototypeCanvasThreadSample})),__vite__mapDeps([5,1,2,3,4])));function xr({config:e}){let t=(0,H.useRef)(null),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useRef)(null),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useRef)(null),u=(0,H.useRef)(null),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)({position:null,collapsed:!1,collapsedGroups:{}}),[h,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!1),x=(0,H.useCallback)(()=>{g(!1),o.current?.focus()},[]),{frameRef:S,frameKey:C,source:w,navigation:T,address:E,replaceAddress:D,appearance:O,setAppearance:k,liveRoute:A,initialize:j,reportRoute:M,reload:N,navigate:ee,travel:P}=ar({prototypeUrl:e.prototypeUrl,previewUrl:e.previewUrl,shellRef:t,cancelClick:u}),F=nr({...e,frameRef:S,address:E,replaceAddress:D}),I=F.state;Gn({...e,frameRef:S,addressRef:r,appearance:O,navigation:T,liveRoute:A,cancelClick:u,reload:N,controlsConnection:F.connection});let{state:L,error:R,setError:z,refresh:B}=or(e.token),V=ir({token:e.token,onStatus:j,onError:z}),te=rr({token:e.token,status:V.status,onStatusChange:V.refresh,onSelectHub:V.select}),ne=fr({token:e.token,hubStatus:V.status,prototypeState:L}),re=ur({token:e.token,state:L,hubStatus:V.status}),ie=cr({token:e.token,enabled:h&&V.status?.state===`connected`&&V.status.prototype?.registered===!0&&!!V.status.prototype.build&&V.status.repository===L?.stats.repository&&V.status.branch===L?.stats.branch,repository:L?.stats.repository,branch:L?.stats.branch,commitSha:L?.stats.commitSha,publicationRevision:L?.publishRequest?.requestedAt}),ae=Jn({token:e.token,state:L,hubStatus:V.status,error:R,setError:z,refresh:B,refreshHub:V.refresh,preferenceSaving:ie.saving}),oe=zn(L,V.status,ae.publication),se=ne.state.context,G=lr(se?`${se.hubOrigin}:${se.prototype.repositoryId}:${se.prototype.id}`:void 0,F.connection?.getControlValues()??{},{included:se?.controlSettingsIncluded??!1,error:se?.controlSettingsError,revision:se?.target,onChange:ne.setControlPreference});(0,H.useLayoutEffect)(()=>{document.body.classList.remove(`renderer-loading`);let e=t.current,r=n.current;if(!e||!r)return;function i(){let t=r?.getBoundingClientRect().height;t&&e?.style.setProperty(`--canvas-toolbar-height`,`${t}px`)}let a=new ResizeObserver(i);return a.observe(r),i(),()=>a.disconnect()},[]);function K(){te.close(),oe.kind===`ready`?ne.open():re.begin()}return(0,W.jsxs)(U.ThemeProvider,{colorMode:O,className:`canvas-base`,children:[(0,W.jsxs)(`main`,{ref:t,className:`canvas-shell${ne.state.open?` canvas-shell--inactive`:``}`,inert:ne.state.open,"aria-hidden":ne.state.open?!0:void 0,children:[(0,W.jsx)(Ne,{address:E,addressRef:r,canGoBack:T.index>0,canGoForward:T.indexP(T.index-1),onForward:()=>P(T.index+1),onNavigate:ee,onOpenTab:async()=>{await $(`/api/prototype/open`,e.token,{method:`POST`,body:JSON.stringify({url:E})})},onReload:N}),(0,W.jsx)(Vn,{toolbarRef:n,improvementControlsRef:v,config:e,state:ae.presentedState,prototypeName:V.status?.state===`connected`&&V.status.prototype?.name||void 0,publishing:ae.busy,publication:ae.publication,publishButtonRef:i,hubButtonRef:o,titleButtonRef:c,onBuildDetails:()=>b(!0),controlsButtonRef:l,controlsOpen:d,onControls:()=>f(!d),onPublish:()=>void ae.publish(),onShare:K,shareButtonRef:a,hubOpen:h,onHub:()=>{g(!h),V.refresh(`interaction`)}}),(0,W.jsx)(`iframe`,{ref:S,className:`prototype-frame`,title:q.prototypeFrameTitle(e.name),src:w,style:{colorScheme:O,backgroundColor:`var(--hub-canvas-default)`}},C),(0,W.jsx)(Rn,{config:e,frameRef:S,onRouteChange:M,status:V.status,onStatusChange:V.refresh,onSelectHub:V.select,onConnect:te.showAndConnect,onDisconnected:te.show,connectionButtonRef:s,connecting:te.connecting,publication:ae.publication,publicationBusy:ae.busy,dirty:L?.stats.workingTree===`changed`,onPublish:()=>void ae.publish(),onRetryPublication:()=>void ae.retry(),publishPreference:ie,open:h,onClose:x}),e.improvementThreadsSample?(0,W.jsx)(H.Suspense,{fallback:(0,W.jsx)(`p`,{role:`status`,children:q.improvementNotesLoading}),children:(0,W.jsx)(br,{})}):e.pickAndPolish?(0,W.jsx)(H.Suspense,{fallback:(0,W.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:q.improvementNotesLoading}),children:(0,W.jsx)(yr,{canvas:{token:e.token,frameRef:S,toolbarTarget:_,prototypeUrl:e.prototypeUrl,previewUrl:e.previewUrl,hubOpen:h,onOpenNotes:()=>g(!1),onNavigate:ee}})}):null,d&&F.connection&&I?(0,W.jsx)($e,{state:I,connection:F.connection,layout:p,onLayoutChange:m,diagnosisTarget:E,onDiagnose:()=>$(`/api/controls/diagnose`,e.token,{method:`POST`,body:JSON.stringify({status:I.status,runtimeAvailable:I.runtimeAvailable,reconnectRequired:I.reconnectRequired===!0,hasError:!!I.error||Un(I,I.loading,E).controls.some(e=>e.visible&&!!e.error),hasStorageError:!!I.storageError,previewUrl:E})})}):null]}),(0,W.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`visually-hidden`,children:R||ae.notice}),(0,W.jsx)(Me,{hub:V,connection:te,publication:ae,sharing:ne,shareIntent:re,controlSettings:G,readiness:oe,state:L,hubOpen:h,buildDetailsOpen:y,onCloseBuildDetails:()=>b(!1),shareButtonRef:a,hubButtonRef:o,connectionButtonRef:s,publishButtonRef:i,titleButtonRef:c})]})}var Sr=document.querySelector(`#root`);if(!Sr)throw Error(`Replica prototype renderer root is missing.`);(0,oe.createRoot)(Sr).render((0,W.jsx)(xr,{config:window.__REPLICA_CANVAS__}));export{$ as a,zt as c,at as d,it as f,K as h,mn as i,xt as l,ce as m,xn as n,Kt as o,tt as p,yn as r,Gt as s,On as t,ot as u}; \ No newline at end of file +`))throw Error(`Live review connection failed.`)}}catch{t.signal.aborted||ze(!0)}t.signal.aborted||(Date.now()-a>=3e4&&(r=5e3),n=window.setTimeout(()=>void i(),r),r=Math.min(r*2,6e4))}return i(),()=>{t.abort(),window.clearTimeout(n)}},[ot,Nt,e.token,Jt]);let Xt=(0,H.useCallback)((n,r={})=>{let i=t.current;return!i?.contentWindow||!qe.current?!1:(i.contentWindow.postMessage({type:n,nonce:qe.current,...r},new URL(e.previewUrl??e.prototypeUrl).origin),!0)},[e.prototypeUrl,e.previewUrl,t]),Zt=(0,H.useCallback)(async t=>{if(e.pickAndPolish||!De||!zt||Vt)return;let n=ot,i=++Ye.current;Je.current=void 0,Pe(!0),z(``),P(null),Le(null),Me(t),_();try{let a=await $(`/api/hub/status`,e.token);if($e.current!==n||Ye.current!==i)return;if(!a.repositoryAuthorized&&a.state!==`connected`||a.prototype?.id!==Nt||a.hubOrigin!==r?.hubOrigin||a.repository!==r?.repository||a.branch!==r?.branch||!a.reviewRevision)throw Error(a.reviewError||q.commentPreparationFailed);Je.current=a.reviewRevision,Xt(`replica:canvas:select`,{mode:t})}catch(e){$e.current===n&&Ye.current===i&&(Me(null),z(e instanceof Error?e.message:String(e)))}finally{Ye.current===i&&Pe(!1)}},[e.pickAndPolish,De,zt,e.token,ot,_,Nt,Vt,Xt,r]),Qt=(0,H.useCallback)(()=>{je&&(Ye.current+=1,Je.current=void 0,Pe(!1),Xt(`replica:canvas:cancel-selection`),Me(null))},[je,Xt]),$t=(0,H.useCallback)(()=>{Ye.current+=1,Je.current=void 0,Xt(`replica:canvas:clear-selection`),Fe(null),Le(null),z(``)},[Xt]);(0,H.useEffect)(()=>{let r=t.current;if(!r){Ee(new Map),Oe(!1);return}let i=new URL(e.previewUrl??e.prototypeUrl).origin,a=JSON.parse(qt),o=new Set(a.map(({id:e})=>e)),s=Date.now(),c=!1;function l(){qe.current=crypto.randomUUID(),s=Date.now(),c=!1,Oe(!1),ke(``),Ee(new Map),r?.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:qe.current},i),u()}function u(){a.length&&r?.contentWindow?.postMessage({type:`replica:canvas:resolve`,nonce:qe.current,anchors:a},i)}function d(t){let a=t.data;if(t.source===r?.contentWindow&&t.origin===i&&In(a)&&a.nonce===qe.current){if(a.type===`replica:canvas:bridge-error`)Oe(!1),ke(q.commentingMissing);else if(a.type===`replica:canvas:ready`){if(a.protocolVersion!==1){c=!0,Oe(!1),ke(q.commentingIncompatible);return}if(!Ln(a.route))return;s=Date.now(),c=!1,Oe(!0),ke(``),N(Ln(a.route)),n?.(Ln(a.route),a.replaceRoute===!0)}else if(!c){if(a.type===`replica:canvas:conversation-dismiss-requested`)window.dispatchEvent(new Event(`replica:review-dismiss`));else if(a.type===`replica:canvas:resolved`){if(a.protocolVersion!==1||!Ln(a.route)||!Array.isArray(a.results))return;s=Date.now(),Oe(!0),ke(``),N(Ln(a.route)),n?.(Ln(a.route),a.replaceRoute===!0);let e=new Map;for(let t of a.results){if(!In(t)||typeof t.id!=`number`||typeof t.x!=`number`||typeof t.y!=`number`||!o.has(t.id)||!Number.isFinite(t.x)||!Number.isFinite(t.y)||t.x<0||t.y<0||t.x>r.clientWidth||t.y>r.clientHeight)continue;let n=In(t.rect)&&typeof t.rect.x==`number`&&typeof t.rect.y==`number`&&typeof t.rect.width==`number`&&typeof t.rect.height==`number`&&Number.isFinite(t.rect.x)&&Number.isFinite(t.rect.y)&&Number.isFinite(t.rect.width)&&Number.isFinite(t.rect.height)&&t.rect.width>=0&&t.rect.height>=0?{x:t.rect.x,y:t.rect.y,width:t.rect.width,height:t.rect.height}:{x:t.x,y:t.y,width:0,height:0};e.set(t.id,{x:t.x,y:t.y,rect:n})}Ee(e)}else if(a.type===`replica:canvas:selected`){if(e.pickAndPolish)return;let t=Gt.safeParse(a.anchor);if(!t.success){Xt(`replica:canvas:cancel-selection`),Xt(`replica:canvas:clear-selection`),Me(null),Le(In(a.anchor)&&a.anchor.kind===`area`?`area-unavailable`:`element-unavailable`);return}Fe(t.data),Me(null),Le(null)}else a.type===`replica:canvas:selection-failed`&&(a.reason===`element-unavailable`||a.reason===`area-too-small`||a.reason===`area-unavailable`)?(Me(null),Le(a.reason)):a.type===`replica:canvas:selection-cancelled`&&Me(null)}}}function f(){Ye.current+=1,Pe(!1),Me(null),Le(null),l()}r.addEventListener(`load`,f),window.addEventListener(`message`,d),l();let p=window.setInterval(()=>{Date.now()-s>=2e4&&(Oe(!1),Ee(new Map),ke(c?q.commentingIncompatible:q.commentingMissing)),r.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:qe.current},i),u()},2e3);return()=>{r.removeEventListener(`load`,f),window.removeEventListener(`message`,d),window.clearInterval(p)}},[ot,qt,e.prototypeUrl,e.pickAndPolish,e.previewUrl,t,n,Xt]);async function en(t,n,r,i){let a=ot,o=dt,s=i?.kind===`add-reaction`||i?.kind===`remove-reaction`||i?.kind===`mark-unread`;if(i){if(He.current)return!1;He.current=!0,Ve(i)}s&&(We.current=!0,Ue.current+=1),V(``);try{let i=await $(`/api/hub/comments/${t}`,e.token,{method:n,...r?{body:JSON.stringify(r)}:{}});if($e.current!==a)return!1;if(s){let e=an.parse(i);y(t=>{if(t.identity!==o)return t;let n=new Map(t.items.map(e=>[e.id,e]));for(let t of e.comments)n.set(t.id,t);return{identity:o,items:[...n.values()]}})}return s||(at.current=window.setTimeout(()=>void Yt.current(),0)),!0}catch(e){return $e.current===a&&(L(e instanceof Error?e.message:String(e)),e instanceof Error&&`statusCode`in e&&e.statusCode===429&&V(e.message)),!1}finally{i&&$e.current===a&&(s&&(We.current=!1,Ue.current+=1,at.current=window.setTimeout(()=>void Yt.current(),0)),He.current=!1,Ve(null))}}async function tn(t){let n=Je.current;if(!n||!Z||He.current)return!1;let r=ot,a=dt;He.current=!0,Ve({kind:`create`}),V(``),z(``);try{let o=an.parse(await $(`/api/hub/comments`,e.token,{method:`POST`,body:JSON.stringify({review_revision:n,review_comment:{body:t,anchor:Z}})}));if($e.current!==r)return!1;let s=o.comments.find(e=>e.kind===`root`);if(!s)return!1;let c=s.buildNumber!==null||s.draftRevisionId===ut;c&&y(e=>{if(e.identity!==a)return e;let t=new Map(e.items.map(e=>[e.id,e]));for(let e of o.comments)t.set(e.id,e);return{identity:a,items:[...t.values()]}});let l=c&&Ke.current===a;return Qe.current=!l,$t(),l&&P(s.id),i().then(()=>{if($e.current===r)return Yt.current()}).catch(e=>{if($e.current===r){let t=e instanceof Error?e.message:String(e);L(q.commentRefreshFailed(t))}}),!0}catch(e){if($e.current===r){let t=e instanceof Error?e.message:String(e);L(t),z(t),e instanceof Error&&`statusCode`in e&&e.statusCode===429&&V(e.message)}return!1}finally{$e.current===r&&(He.current=!1,Ve(null))}}function nn(){Vt||(T?(P(null),E(!1)):(E(!0),g&&_()))}let un=r?.repository&&r.branch?`https://github.com/${r.repository.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}/tree/${encodeURIComponent(r.branch)}`:null,dn=r?.branch&&un?(0,W.jsxs)(`a`,{className:`canvas-hub-publication__branch`,href:un,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open ${r.branch} on GitHub`,children:[(0,W.jsx)(M,{size:16,"aria-hidden":`true`}),(0,W.jsx)(`span`,{children:r.branch})]}):r?.branch?(0,W.jsxs)(`span`,{className:`canvas-hub-publication__branch`,children:[(0,W.jsx)(M,{size:16,"aria-hidden":`true`}),(0,W.jsx)(`span`,{children:r.branch})]}):null,fn=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(U.Heading,{as:`h3`,size:`subhead-medium`,id:`canvas-hub-origin-title`,children:`Hub`}),r&&r.state!==`unconfigured`?(0,W.jsx)(`div`,{className:`canvas-hub-origin`,children:r.hubOrigin?(0,W.jsx)(`a`,{href:Q?new URL(`/repositories/${Q.repositoryId}/prototypes/${Q.id}`,r.hubOrigin).href:r.hubOrigin,target:`_blank`,rel:`noopener noreferrer`,children:r.hubOrigin}):(0,W.jsx)(`span`,{children:`URL unavailable`})}):null,se||r?.state===`disconnected`||r?.state===`unconfigured`?(0,W.jsxs)(`form`,{className:`canvas-hub-origin-form`,onSubmit:e=>{e.preventDefault(),!(le||de)&&(ue(!0),G(!0),L(``),a(K).then(()=>{G(!1)}).catch(e=>L(e.message)).finally(()=>ue(!1)))},children:[(0,W.jsxs)(`div`,{className:`canvas-hub-origin-field`,children:[(0,W.jsxs)(`label`,{children:[q.hubUrl,(0,W.jsx)(`input`,{type:`url`,required:!0,value:K,placeholder:`https://hub.example.com`,disabled:le||de,onChange:e=>ce(e.target.value)})]}),(0,W.jsx)(U.Button,{type:`button`,size:`small`,variant:`subtle`,className:`canvas-icon-button`,leadingVisual:(0,W.jsx)(I,{size:16}),"aria-label":q.resetHubUrl,title:q.resetHubUrl,disabled:le||de,"aria-busy":de,onClick:()=>{pe(!0),L(``),$(`/api/hub/discovery`,e.token,{method:`POST`,body:`{}`}).then(async e=>{if(e.discovery?.state!==`valid`||!e.discovery.origin)throw Error(e.discovery?.message||q.resetHubUnavailable);ce(e.discovery.origin),await i()}).catch(e=>L(e.message)).finally(()=>pe(!1))},children:(0,W.jsx)(`span`,{className:`visually-hidden`,children:q.resetHubUrl})})]}),(0,W.jsx)(`p`,{children:q.hubHttpsHint}),(0,W.jsxs)(`div`,{className:`canvas-hub-form-actions`,children:[(0,W.jsx)(U.Button,{type:`submit`,size:`small`,disabled:le||de,children:`Save Hub`}),se&&r?.state!==`unconfigured`&&r?.state!==`disconnected`?(0,W.jsx)(U.Button,{type:`button`,size:`small`,variant:`subtle`,disabled:le||de,onClick:()=>G(!1),children:`Cancel`}):null]})]}):null]});return(0,W.jsxs)(rt,{source:w,children:[_t.visible?(0,W.jsx)(cn,{..._t}):null,Bt&&Ut&&!e.pickAndPolish?(0,et.createPortal)((0,W.jsxs)(`div`,{className:`canvas-review-controls review-shell__comment-actions`,role:`group`,"aria-label":xt.heading,children:[(0,W.jsx)(yt,{bridgeReady:De&&zt,copy:xt,selectionBlocked:Vt,selecting:je!==null,onCancelSelection:Qt,onStartAreaSelection:()=>void Zt(`area`),onStartElementSelection:()=>void Zt(`element`)}),(0,W.jsx)(U.Tooltip,{ref:Ze,text:Vt?xt.selectionBlockedLabel:`${xt.heading} (${xt.sidebarShortcutLabel})`,type:`description`,children:(0,W.jsxs)(U.Button,{className:`canvas-comments-toggle review-shell__comments-toggle`,variant:`secondary`,size:`small`,"aria-label":`${xt.heading}, ${Lt}${Rt?`, ${xt.unreadLabel}`:``}`,"aria-expanded":T,"aria-keyshortcuts":`Shift+C`,disabled:Vt,onClick:nn,children:[(0,W.jsx)(tt,{children:Lt}),Rt?(0,W.jsx)(`span`,{className:`canvas-comments-unread-badge review-shell__unread-badge`,"aria-hidden":`true`}):null]})})]}),Ut):null,k&&It.length&&De&&!je?(0,W.jsx)(`div`,{className:`canvas-marker-layer`,children:(0,W.jsx)(ct,{threads:It,resolutions:Et,selectedThreadId:ee,selectionBlocked:Ce,focusSelectedMarker:!1,showAreaHighlightsOnlyWhenSelected:!0,copy:xt,onSelect:e=>P(e.root.id)})}):null,(0,W.jsxs)(it,{className:`canvas-hub-panel`,contentClassName:`canvas-hub-content`,title:`Replica Hub`,label:`Hub`,open:Ht,closeLabel:`Close Hub`,closeRef:Xe,onClose:_,children:[F?(0,W.jsx)(`p`,{role:`alert`,children:F}):null,te?(0,W.jsx)(`p`,{role:`alert`,children:te}):null,r?null:(0,W.jsx)(`p`,{children:`Checking Hub connection…`}),!Ot&&!ht&&r?.message?(0,W.jsx)(`p`,{role:`status`,children:r.message}):null,ht?(0,W.jsxs)(`div`,{className:`canvas-hub-status`,children:[(0,W.jsx)(fe,{variant:`warning`,layout:`compact`,title:r?.message||X.hubUnavailable}),(0,W.jsx)(U.Button,{variant:`primary`,size:`small`,disabled:d,"aria-busy":d,leadingVisual:d?(0,W.jsx)(I,{size:16}):void 0,onClick:m||(()=>void i()),children:X.retry})]}):null,!Ot&&!ht&&u&&p&&m?(0,W.jsx)(Ae,{publication:u,busy:d,dirty:f,onPublish:p,onRetry:m}):null,Ot?(0,W.jsxs)(`section`,{className:`canvas-hub-connection`,children:[(0,W.jsx)(`p`,{children:q.connectionBeforePublishing}),(0,W.jsx)(U.Button,{ref:c,variant:`primary`,onClick:o,disabled:l,children:l?q.connectionOpeningBrowser:q.connectToHub})]}):null,!Ot&&(!se&&(r?.discovery?.mismatch||[`invalid`,`unreachable`].includes(r?.discovery?.state||``))||r?.state===`unconfigured`)?(0,W.jsxs)(`div`,{className:`canvas-hub-settings`,children:[!se&&r?.discovery?.mismatch?(0,W.jsx)(`p`,{role:`alert`,children:`The repository configuration differs from your selected Hub. Your connection has not changed. Disconnect Hub before selecting another URL.`}):null,!se&&[`invalid`,`unreachable`].includes(r?.discovery?.state||``)?(0,W.jsx)(`p`,{role:`alert`,children:r?.discovery?.message}):null,r?.state===`unconfigured`?(0,W.jsx)(`p`,{children:`Enter your Hub URL to connect.`}):null]}):null,r?.state===`undiscovered`&&!u?(0,W.jsxs)(`p`,{children:[`Connected to `,r.repository,`. Hub has not discovered`,` `,r.branch||`a prototype branch`,`. Your repository connection is ready. Push a named branch to make its Builds and reviews available.`]}):null,Q?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`section`,{className:u&&u.kind!==`ready`&&p&&m?`canvas-hub-publication canvas-hub-publication--after-status`:`canvas-hub-publication`,"aria-label":`Prototype`,children:Mt&&Kt?(0,W.jsxs)(`form`,{className:`canvas-hub-publication__form`,onSubmit:t=>{t.preventDefault(),$(`/api/hub/metadata`,e.token,{method:`PATCH`,body:JSON.stringify({name:me,description:ge,startPage:ve})}).then(async()=>{J(!1),await i()}).catch(e=>L(e.message))},children:[(0,W.jsxs)(`div`,{className:`canvas-hub-publication__title`,children:[(0,W.jsxs)(`label`,{className:`canvas-hub-publication__name-field`,children:[(0,W.jsx)(`span`,{className:`visually-hidden`,children:`Name`}),(0,W.jsx)(`input`,{required:!0,maxLength:255,value:me,onChange:e=>he(e.target.value)})]}),(0,W.jsx)(`span`,{className:`canvas-hub-publication__status`,children:Q.published?`Published`:Q.registered?`Registered`:`Not registered`})]}),dn,(0,W.jsxs)(`label`,{className:`canvas-hub-publication__description-field`,children:[(0,W.jsx)(`span`,{className:`visually-hidden`,children:`Description`}),(0,W.jsx)(`textarea`,{value:ge,placeholder:`Add a description`,onChange:e=>_e(e.target.value)})]}),(0,W.jsxs)(`label`,{className:`canvas-hub-publication__start-page-field`,children:[q.startPage,(0,W.jsx)(`input`,{value:ve,placeholder:`/`,"aria-describedby":`canvas-start-page-hint`,onChange:e=>ye(e.target.value)})]}),(0,W.jsx)(`p`,{id:`canvas-start-page-hint`,className:`canvas-hub-publication__hint`,children:q.startPageHint}),(0,W.jsxs)(`div`,{className:`canvas-hub-form-actions`,children:[(0,W.jsx)(U.Button,{type:`submit`,size:`small`,children:`Save metadata`}),(0,W.jsx)(U.Button,{type:`button`,size:`small`,variant:`subtle`,onClick:()=>J(!1),children:`Cancel`})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`canvas-hub-publication__title`,children:[(0,W.jsx)(U.Heading,{as:`h3`,size:`subhead-large`,children:Q.name||r?.branch}),(0,W.jsx)(`span`,{className:`canvas-hub-publication__status`,children:Q.published?`Published`:Q.registered?`Registered`:`Not registered`})]}),dn,Q.description?(0,W.jsx)(`p`,{className:`canvas-hub-publication__description`,children:Q.description}):null,(0,W.jsxs)(`p`,{className:`canvas-hub-publication__description canvas-hub-publication__start-page`,children:[q.startPage,`: `,(0,W.jsx)(`code`,{children:Q.startPage||`/`})]}),Mt?(0,W.jsx)(U.Button,{size:`small`,variant:`subtle`,onClick:()=>{he(Q.name||``),_e(Q.description||``),ye(Q.startPage||``),Se(ot),J(!0)},children:q.editDetails}):null]})}),(0,W.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":`canvas-hub-build-title`,children:[(0,W.jsx)(U.Heading,{as:`h3`,size:`subhead-medium`,id:`canvas-hub-build-title`,children:q.latestBuild}),Q.build?(0,W.jsxs)(`div`,{className:`canvas-hub-build`,children:[(0,W.jsxs)(`div`,{className:`canvas-hub-build__identity`,children:[(0,W.jsx)(`a`,{href:Q.build.url,target:`_blank`,rel:`noopener noreferrer`,children:q.buildTitle(Q.build.number)}),(0,W.jsx)(`code`,{title:Q.build.commitSha,"aria-label":`${q.buildCommit} ${Q.build.commitSha}`,children:Q.build.commitSha.slice(0,7)})]}),(0,W.jsx)(`p`,{children:At?(0,W.jsx)(`a`,{className:`canvas-hub-build__author`,href:At,target:`_blank`,rel:`noopener noreferrer`,children:jt}):(0,W.jsx)(`span`,{children:jt})}),r?.commitSha&&r.commitSha!==Q.build.commitSha?(0,W.jsx)(`p`,{className:`canvas-hub-build__notice`,children:`Local checkout differs from this Build`}):null]}):(0,W.jsxs)(`p`,{children:[`No successful imported Build yet. Current Build: `,Q.buildState||`none`,`.`]}),Q.build&&r?.hubOrigin?(0,W.jsx)(`a`,{className:`canvas-hub-build__history`,href:new URL(`/repositories/${Q.repositoryId}/prototypes/${Q.id}/builds`,r.hubOrigin).href,target:`_blank`,rel:`noopener noreferrer`,children:q.showBuildHistory}):null]})]}):null,Ot?null:(0,W.jsxs)(`section`,{className:`canvas-hub-section`,"aria-labelledby":`canvas-hub-origin-title`,children:[fn,r?.hubOrigin&&[`connected`,`undiscovered`,`pairing`,`denied`,`unavailable`].includes(r.state)?(0,W.jsx)(`div`,{className:`canvas-hub-disconnect`,children:(0,W.jsx)(U.Button,{size:`small`,variant:`subtle`,onClick:()=>{ne(``),$(`/api/hub/disconnect`,e.token,{method:`POST`,body:`{}`}).then(async()=>{ce(r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``),G(!0),await i(),s?.()}).catch(e=>{ne(q.disconnectFailed(r.hubOrigin||``,e.message)),ce(r.discovery?.mismatch&&r.discovery.origin||r.hubOrigin||``),G(!0)})},children:`Disconnect Hub`})}):null]}),Q?.registered&&Q.build&&h?(0,W.jsx)(Fn,{preference:h,disabled:d}):null]}),Bt?(0,W.jsx)(vt,{frame:{open:T,className:`canvas-comments-sidebar-shell`,contentClassName:`canvas-comments-sidebar-content`},threads:It,currentBuildNumber:Pt?.number||0,buildLinkOrigin:r?.hubOrigin,totalCount:It.length,hasThreads:wt.length>0,filters:D,participants:Tt,resolutions:Et,selectedThreadId:ee,selectionBlocked:Vt,closeBlocked:Ce,showPins:k,loading:re,loadFailed:ae,notice:Re||r?.reviewError||r?.localCommentsError||ut?(0,W.jsxs)(`div`,{className:`canvas-comments-live-notices`,children:[Re?(0,W.jsx)(`p`,{className:`canvas-comments-live-status`,role:`status`,children:q.commentLiveUpdatesPaused}):null,r?.reviewError?(0,W.jsx)(`p`,{className:`canvas-comments-live-status`,children:r.reviewError}):null,r?.localCommentsError?(0,W.jsx)(`p`,{className:`canvas-comments-live-status`,role:`alert`,children:r.localCommentsError}):null,ut?(0,W.jsx)(`p`,{className:`canvas-comments-live-status`,children:q.localCommentsSaved}):null]}):null,copy:xt,onClose:nn,onFiltersChange:O,onShowPinsChange:A,onRetry:()=>void Jt(),onSelect:e=>P(e.root.id)}):null,(0,W.jsx)(Pn,{selectionNotice:Ie?Ie===`area-too-small`?xt.areaTooSmallLabel:Ie===`area-unavailable`?xt.areaUnavailableLabel:xt.selectionFailedLabel:null,rateLimitNotice:Ht?null:B||!Z&&R||null,composer:Z&&Wt?{anchorPoint:Wt,bodyMaximumBytes:1e4,copy:xt,creating:Be?.kind===`create`,submitError:R,onSubmit:tn,onDiscard:$t}:null,conversation:Dt?{thread:Dt,anchorPoint:Te.get(Dt.root.id)??null,bodyMaximumBytes:1e4,mutation:Be,copy:xt,onClose:()=>P(null),onDraftStateChange:we,onReply:e=>en(`${Dt.root.id}/replies`,`POST`,{review_comment:{body:e}},{kind:`reply`,commentId:Dt.root.id}),onEdit:(e,t)=>en(`${e}`,`PATCH`,{review_comment:{body:t}},{kind:`edit`,commentId:e}),onDelete:e=>en(`${e}`,`DELETE`,void 0,{kind:`delete`,commentId:e}),onResolve:()=>en(`${Dt.root.id}/resolution`,`POST`,void 0,{kind:`resolve`,commentId:Dt.root.id}),onReopen:()=>en(`${Dt.root.id}/resolution`,`DELETE`,void 0,{kind:`reopen`,commentId:Dt.root.id}),onAddReaction:(e,t)=>en(`${e}/reactions`,`POST`,{review_comment_reaction:{content:t,activity_version:Dt.root.activityVersion}},{kind:`add-reaction`,commentId:e,content:t}),onRemoveReaction:(e,t)=>en(`${e}/reactions/${encodeURIComponent(t)}`,`DELETE`,{review_comment_reaction:{activity_version:Dt.root.activityVersion}},{kind:`remove-reaction`,commentId:e,content:t}),onMarkRead:e=>en(`${Dt.root.id}/read`,`POST`,{review_thread_read:{activity_version:e}}),onMarkUnread:()=>en(`${Dt.root.id}/read`,`DELETE`,void 0,{kind:`mark-unread`,commentId:Dt.root.id})}:null})]})}function zn(e,t,n){function r(e,t,n){return{kind:e,title:t,detail:n}}if(!e||!t)return n.kind===`unknown`?r(`retry`,Y.unavailable,n.detail):r(`checking`,Y.checking,Y.checkingDetail);if(!e.stats.branch)return r(`restricted`,Y.restricted,n.detail);if(t.repository&&t.repository!==e.stats.repository||t.branch&&t.branch!==e.stats.branch)return r(`retry`,Y.unavailable,Y.changedDetail);if(t.discovery?.state===`local`||e.stats.repository?.startsWith(`local/`))return r(`restricted`,Y.restricted,Y.local);if(t.registrationReason===`branch_not_reviewable`||e.stats.branch===t.discovery?.defaultBranch)return r(`restricted`,Y.restricted,X.registrationReasons.get(`branch_not_reviewable`).description);if([`disconnected`,`pairing`,`unconfigured`].includes(t.state))return r(`connect`,Y.connect,Y.connectDetail);if([`denied`,`unavailable`].includes(t.state))return r(`retry`,Y.unavailable,t.message||Y.unavailableDetail);if(t.repository!==e.stats.repository||t.branch!==e.stats.branch)return r(`retry`,Y.unavailable,Y.unavailableDetail);let i=t.prototype;if(t.state===`connected`&&i?.branch===e.stats.branch&&i.registered&&i.published&&i.build&&Number.isSafeInteger(i.build.number)&&i.build.number>0)return r(`ready`,Y.ready,Y.readyDetail);if(t.state===`connected`&&(!i||i.branch!==e.stats.branch||typeof i.published!=`boolean`||i.published))return r(`retry`,Y.unavailable,Y.unavailableDetail);let a=t.state===`connected`?i?.canEdit:t.canPublish;if(a===!1)return r(`restricted`,Y.restricted,Y.publishDenied);let o=e.stats.remoteBranch,s=t.state===`undiscovered`&&t.repositoryAuthorized===!0&&!i&&(!t.commitSha||t.commitSha===e.stats.commitSha)&&o?.repository===e.stats.repository&&o?.branch===e.stats.branch&&o?.commitSha===e.stats.commitSha&&(o?.state===`absent`||o?.state===`present`&&e.publishRequest?.commitSha===e.stats.commitSha&&([`requested`,`in_progress`].includes(e.publishRequest?.state??``)||e.publishRequest?.state===`idle`&&e.publishRequest.remoteState===`absent`))&&![`loading`,`unknown`,`detached`,`workflow_missing`].includes(n.kind),c=a===void 0&&s;if(a!==!0&&!c)return r(`retry`,Y.unavailable,Y.permissionUnknown);let l=t.registrationReason||i?.registrationReason;if(n.error&&(l!==`remote_branch_missing`||!s)){let e=[`successful_build_required`,`already_registered`].includes(l||``),t=[`write_access_required`,`repository_mismatch`,`branch_not_reviewable`,`remote_branch_missing`,`branch_authorship_required`].includes(l||``);return{...r(e?`progress`:t?`restricted`:`retry`,n.error.title,n.error.description),...e?{publication:{...n,action:`retry`,label:X.retry}}:{}}}if(n.kind===`detached`)return r(`restricted`,Y.restricted,n.detail);if(n.action===`retry`)return r(`retry`,Y.unavailable,n.detail);if(n.kind===`loading`)return r(`checking`,Y.checking,n.detail);let u=c?`${Y.publishDetail} ${Y.publishPermissionUnverified}`:Y.publishDetail,d=s&&l===`remote_branch_missing`?{...n,error:void 0}:n;return n.action===`publish`?{...r(`publish`,Y.publish,u),publication:d}:{...r(`progress`,Y.preparing,u),publication:d}}function Bn({open:e,onToggle:t,buttonRef:n}){return(0,W.jsx)(K,{icon:te,"aria-label":q.controls,description:q.controls,ref:n,size:`small`,variant:`default`,className:`canvas-controls-toggle`,"aria-expanded":e,onClick:t})}function Vn({toolbarRef:e,improvementControlsRef:t,config:n,onPublish:r,publishButtonRef:i,hubButtonRef:a,titleButtonRef:o,onBuildDetails:s,publishing:c,state:l,prototypeName:u,hubOpen:d,onHub:f,publication:p,onControls:m,controlsOpen:h,controlsButtonRef:g,onShare:_,shareButtonRef:y}){let b=l?.publishStatus??{state:`unavailable`,detail:q.statusUnavailable},x=u?.trim()||l?.stats.branch||l?.name||n.name,S=l?[x,l.stats.repository,l.stats.commitSha?.slice(0,7),l.stats.workingTree===`changed`?q.workingTreeChanged:q.workingTreeClean,l.stats.urlHost].filter(Boolean).join(` · `):x,C=c||(p?p.action===`none`:b.state===`requested`||b.state===`in_progress`||b.state===`published`),w=c||(p?p.kind===`requested`||p.kind===`queued`||p.kind===`building`||p.kind===`importing`||p.kind===`awaiting_build`||p.kind===`registration`:b.state===`requested`||b.state===`in_progress`),T=!w&&(p?p.kind===`ready`:b.state===`published`),E=(0,W.jsx)(U.Button,{type:`button`,ref:i,className:`canvas-publish-button`,variant:`secondary`,size:`small`,leadingVisual:w?(0,W.jsx)(I,{size:16}):Hn(b.state),disabled:C&&!T,"aria-busy":w,title:T?void 0:p?.detail||b.detail,onClick:C||T?void 0:r,children:p?.label||q.publishLabels[b.state]});return(0,W.jsxs)(`header`,{ref:e,className:`canvas-toolbar`,children:[(0,W.jsx)(U.Button,{type:`button`,className:`canvas-title`,ref:o,variant:`subtle`,size:`small`,title:S,disabled:!l,onClick:s,children:x}),(0,W.jsx)(`div`,{id:`canvas-review-controls`,className:`canvas-review-controls-slot`}),n.pickAndPolish?(0,W.jsx)(`div`,{ref:t,id:`canvas-improvement-controls`}):null,m?(0,W.jsx)(Bn,{buttonRef:g,open:h,onToggle:m}):null,f?(0,W.jsx)(U.Button,{type:`button`,ref:a,size:`small`,variant:`secondary`,className:`canvas-toolbar-compact-button`,leadingVisual:(0,W.jsx)(re,{size:16}),"aria-label":q.editDetails,title:q.editDetails,"aria-expanded":d,onClick:f,children:(0,W.jsx)(`span`,{className:`canvas-toolbar-button-label`,children:q.editDetails})}):null,(0,W.jsxs)(`div`,{className:`canvas-publish-share`,role:`group`,"aria-label":J.group,children:[T?(0,W.jsx)(U.Tooltip,{ref:i,text:X.alreadyPublished,type:`description`,children:E}):E,_?(0,W.jsx)(K,{ref:y,icon:v,size:`small`,"aria-label":J.title,description:J.title,onClick:_}):null]})]})}function Hn(e){return e===`published`?(0,W.jsx)(ae,{size:16}):e===`failed`||e===`in_progress`||e===`requested`?(0,W.jsx)(I,{size:16}):(0,W.jsx)(D,{size:16})}function Un(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>Je(e,t)))}}var Wn={bridgeUnavailable:`The prototype bridge is not ready on this page.`,routeChanged:`The prototype route changed. Inspect the live canvas again.`,reloaded:`The prototype reloaded before confirming the click. Inspect the live canvas and retry.`,unconfirmed:`The prototype did not confirm the click. Check its bridge and retry.`,clickFailed:`The target could not be clicked.`,addressUnavailable:`The canvas address field is unavailable.`,unknownAction:`Unknown canvas action.`,replyRejected:`The live canvas rejected the action reply. Check its transport diagnostics.`,actionInterrupted:`The canvas changed before the action could run. Inspect the live canvas and retry.`,statusInterrupted:`The canvas changed while collecting Controls status. Inspect the live canvas and retry.`};function Gn(e){let{token:t,prototypeUrl:n,previewUrl:r,cancelClick:i}=e,a=(0,H.useRef)(e),o=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{a.current=e}),(0,H.useEffect)(()=>{o.current??=crypto.randomUUID();let e={"X-Replica-Renderer-Id":o.current},s=!1,c=!1,l=new AbortController,u=new URL(r??n).origin;async function d(e){let t=a.current.frameRef.current,n=a.current.liveRoute;if(!t?.contentWindow||!n)throw Error(Wn.bridgeUnavailable);if(e.route.pathname!==n.pathname||e.route.search!==n.search||e.route.hash!==n.hash)throw Error(Wn.routeChanged);let r=crypto.randomUUID();return await new Promise((n,a)=>{function o(){window.clearTimeout(c),window.removeEventListener(`message`,l),i.current===s&&(i.current=null)}function s(){o(),a(Error(Wn.reloaded))}let c=window.setTimeout(()=>{o(),a(Error(Wn.unconfirmed))},2e3);function l(i){let s=i.data;i.source===t?.contentWindow&&i.origin===u&&s&&typeof s==`object`&&`type`in s&&s.type===`replica:canvas:click-result`&&`nonce`in s&&s.nonce===r&&(o(),`clicked`in s&&s.clicked===!0?n({clicked:!0,route:e.route}):a(Error(Wn.clickFailed)))}i.current=s,window.addEventListener(`message`,l),t.contentWindow.postMessage({type:`replica:canvas:click`,nonce:r,...e},u)})}async function f(e){let t=a.current.frameRef.current,r=crypto.randomUUID(),i=Date.now()+e,o=await new Promise((n,o)=>{function s(){window.clearTimeout(d),window.removeEventListener(`message`,p),t?.removeEventListener(`load`,m),l.signal.removeEventListener(`abort`,c)}function c(){s(),o(Error(Wn.statusInterrupted))}let d=window.setTimeout(()=>{if(s(),a.current.liveRoute)o(Error(Wn.bridgeUnavailable));else{let e=new URL(a.current.navigation.entries[a.current.navigation.index]);e.protocol=new URL(u).protocol,e.host=new URL(u).host,n({status:`pending`,url:e.href,error:``,controls:[]})}},e+1500),f=!1;function p(e){let i=e.data;e.source===t?.contentWindow&&t===a.current.frameRef.current&&e.origin===u&&i&&typeof i==`object`&&`type`in i&&(i.type===`replica:canvas:ready`&&!f&&(f=!0,m()),i.type===`replica:controls:status-result`&&`nonce`in i&&i.nonce===r&&`value`in i&&(s(),n(i.value)))}function m(){t===a.current.frameRef.current&&t?.contentWindow?.postMessage({type:`replica:controls:status`,nonce:r,timeoutMs:Math.max(0,i-Date.now())},u)}window.addEventListener(`message`,p),t?.addEventListener(`load`,m),l.signal.addEventListener(`abort`,c),m()});if(!o||typeof o!=`object`||!(`url`in o)||typeof o.url!=`string`||!(`status`in o)||typeof o.status!=`string`||!(`error`in o)||typeof o.error!=`string`||!(`controls`in o)||!Array.isArray(o.controls))throw Error(Wn.bridgeUnavailable);let s=new URL(o.url);if(s.origin!==u)throw Error(Wn.routeChanged);let c=new URL(n);s.protocol=c.protocol,s.host=c.host;let d=await p(i);return!d&&a.current.controlsConnection===void 0?{...o,url:s.href}:{...d?Un(d,d.loading,s.href):{status:`pending`,url:s.href,error:``,controls:[]},runtime:{status:o.status,error:o.error,controls:o.controls}}}function p(e){let t=a.current.controlsConnection;if(!t)return Promise.resolve(null);let n=t.getSnapshot,r=t.subscribe,i=n();return!i.loading||e<=Date.now()?Promise.resolve(i):new Promise(t=>{let i={};function a(e){window.clearTimeout(c),i.unsubscribe?.(),l.signal.removeEventListener(`abort`,s),t(e)}function o(){let e=n();e.loading||a(e)}function s(){a(null)}let c=window.setTimeout(()=>a(n()),e-Date.now());i.unsubscribe=r(o),l.signal.addEventListener(`abort`,s,{once:!0}),o()})}async function m(){if(!(s||c)){s=!0;try{let{command:r,prototypeUrl:i}=await $(`/api/agent/next`,t,{headers:{...e,"X-Replica-Prototype-Url":n}});if(!c&&i&&i!==n){window.location.reload();return}if(!r)return;let o;try{if(await $(`/api/agent/progress`,t,{method:`POST`,headers:e,body:JSON.stringify({id:r.id,stage:`handler started`})}),c)throw Error(Wn.actionInterrupted);let n;if(r.type===`inspect`){let{appearance:e,navigation:t,liveRoute:r,addressRef:i}=a.current,o=i.current?.value;if(o===void 0)throw Error(Wn.addressUnavailable);n={address:t.entries[t.index],addressDraft:o,appearance:e,canGoBack:t.index>0,canGoForward:t.indexvoid m(),300);return()=>{c=!0,l.abort(),window.clearInterval(h),i.current?.()}},[n,r,t,i])}function Kn(e,t,n){let r=t?.repository===e?.stats.repository&&t?.branch===e?.stats.branch,i=!e?.stats.branch&&!!e?.stats.branchError,a=i?void 0:t?.branch,o=!!(e&&!i&&(t?.repository&&t.repository!==e.stats.repository||t?.branch&&t.branch!==e.stats.branch||t?.commitSha&&t.commitSha!==e.stats.commitSha)),s=!!(n.kind===`ready`&&r&&t?.state===`connected`&&t.prototype?.published&&t.prototype.build?.commitSha===e?.stats.commitSha);return{state:e&&{...e,publishStatus:!s&&[`requested`,`in_progress`].includes(e.publishStatus?.state??``)||t?.state===`connected`&&!r?e.publishStatus:s&&t?.prototype?.build?{state:`published`,detail:q.hubBuildImported,versionCount:t.prototype.versionCount,lastUpdatedAt:t.prototype.build.publishedAt,run:{url:t.prototype.build.url,actor:t.prototype.build.author.login||t.prototype.build.author.name?{login:t.prototype.build.author.login||void 0,name:t.prototype.build.author.name||void 0,avatarUrl:t.prototype.build.author.avatarUrl||void 0}:null}}:{state:t?.state===`connected`?`not_published`:`unavailable`,detail:t?.state===`connected`?q.hubBuildMissing:q.hubPublicationUnavailable},stats:{...e.stats,branch:a||e.stats.branch,branchError:a&&a!==e.stats.branch?null:e.stats.branchError,repository:t?.repository||e.stats.repository,commitSha:e.stats.commitSha,comparison:o?{branch:null,source:null,behind:null,error:q.comparisonNeedsRefresh}:e.stats.comparison,publishedUrl:s?t?.prototype?.build?.url:void 0}},hubPublished:s,comparisonOutdated:o}}function qn(e,t){let n;function r(e,t,r,i=`none`){return{kind:e,detail:t,label:r,action:i,...n?{error:n}:{}}}if(!e)return r(`loading`,X.initial,X.checking);let{stats:i}=e,a=i.remoteBranch;if(!a||a.state===`loading`)return r(`loading`,X.checkingRemote,X.checking);if(!i.branch||a.state===`detached`)return r(`detached`,X.detached,X.retry,`retry`);if(a.repository!==i.repository||a.branch!==i.branch||a.commitSha!==i.commitSha)return r(`unknown`,X.changed,X.retry,`retry`);if(a.state===`unknown`)return r(`unknown`,X.unknown(a.error),X.retry,`retry`);let o=t?.state===`connected`?t.prototype:void 0,s=o?.build?.commitSha===i.commitSha&&o?.branch===i.branch,c=e.publishRequest,l=t?.state===`connected`&&t.repository===i.repository&&t.branch===i.branch&&(!t.commitSha||t.commitSha===i.commitSha)&&t.prototype?.branch===i.branch&&t.prototype.build?.commitSha===i.commitSha?t.prototype.build:null,u=!!(l&&(c?.commitSha!==i.commitSha||c.buildNumber===void 0||typeof c.buildNumber==`number`&&l.number>c.buildNumber)),d=u&&o?.registered&&o.published,f=t!==null&&t.repository===i.repository&&(!t.branch||t.branch===i.branch)&&(!t.commitSha||t.commitSha===i.commitSha);if(t&&f&&(t.state===`connected`||t.state===`undiscovered`)&&!o?.registered&&(!o||o.branch===i.branch)){let e=t.registrationReason||o?.registrationReason,r=i.branch===t.discovery?.defaultBranch;if(e||t.registrationError||o?.canRegister===!1||r){let i=e||(r?`branch_not_reviewable`:o?.canEdit===!1?`write_access_required`:o?.canRegister===!1&&a.state===`absent`?`remote_branch_missing`:void 0);n=i&&X.registrationReasons.get(i)||{title:X.registrationErrorTitle,description:t.registrationError||X.registrationDenied}}}if(c?.state===`requested`&&(!c.commitSha||c.commitSha===i.commitSha)&&(a.state===`absent`||a.remoteSha!==i.commitSha)&&!u){let e=Date.now()-Date.parse(c.requestedAt||``);if(Number.isFinite(e)&&e<6e5)return r(`requested`,X.pending,X.awaitingCopilot)}if(!t)return r(`loading`,X.checkingHub,X.checking);if(t.state===`disconnected`||t.state===`pairing`||t.state===`unconfigured`)return r(`disconnected`,t.message||X.disconnected,X.connect);if(t.state===`denied`||t.state===`unavailable`)return{...r(`unknown`,t.message||X.hubUnavailable,X.retry,`retry`),error:{title:X.hubUnavailableTitle,description:t.message||X.hubUnavailable}};if(!f)return r(`unknown`,X.staleHub,X.retry,`retry`);if(!i.replicaWorkflowExists)return r(`workflow_missing`,X.workflowMissing,X.retry,`retry`);if(c?.state===`failed`&&!d&&(!c.commitSha||c.commitSha===i.commitSha))return r(`failed`,c.error||X.dispatchFailed,X.retryPublish,`publish`);if(a.state===`absent`)return r(`unpublished`,X.absent,X.publishBranch,`publish`);if(a.remoteSha!==i.commitSha)return r(`needs_push`,X.needsPush,X.publishChanges,`publish`);if(s){if(!o.registered)return r(`registration`,t.registrationError||(o.canEdit&&o.canRegister?X.needsRegistration:X.registrationDenied),t.registrationError?X.registrationFailed:X.registration);if(o.published&&u)return r(`ready`,X.ready,X.published)}if(o?.currentBuild?.commitSha===i.commitSha&&o.branch===i.branch&&o.currentBuild.state===`failed`)return r(`failed`,X.importFailed,X.retryPublish,`publish`);let p=i.workflow;if(!p||p.state===`unavailable`)return r(`unknown`,p?.detail||X.workflowUnavailable,X.retry,`retry`);let m=p.run;if(m&&(m.headSha!==i.commitSha||m.headBranch!==i.branch))return r(`unknown`,X.staleWorkflow,X.retry,`retry`);if(c?.commitSha===i.commitSha&&c.workflowRunId!=null&&m?.databaseId===c.workflowRunId&&!u)return r(`awaiting_build`,X.noBuild,X.awaitingBuild);let h;if(p.state===`in_progress`&&m){let e=[`queued`,`waiting`,`pending`,`requested`].includes(m.status||``);h=r(e?`queued`:`building`,e?X.workflowQueued:X.workflowBuilding,e?X.queued:X.building)}else h=p.state===`failed`&&m?r(`failed`,X.workflowFailed(m.conclusion),X.retryPublish,`publish`):p.state===`succeeded`&&m?r(`importing`,X.importing,X.awaitingHub):r(`awaiting_build`,X.noBuild,X.awaitingBuild);return m?.url?.startsWith(`https://github.com/`)&&(h.runUrl=m.url),h}function Jn({token:e,state:t,hubStatus:n,error:r,setError:i,refresh:a,refreshHub:o,preferenceSaving:s=!1}){let[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),m=(0,H.useRef)(!1),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(``),[y,b]=(0,H.useState)(!1),x=!t&&r?{kind:`unknown`,action:`retry`,label:X.retry,detail:r}:qn(t,n),S=`${t?.stats.repository}/${t?.stats.branch}/${t?.stats.commitSha}`,C=f?.identity===S&&x.action===`publish`?{...x,kind:`failed`,detail:f.message,label:X.retryPublish}:x.kind===`ready`&&t?.stats.workingTree===`changed`?{...x,kind:`needs_push`,action:`publish`,label:X.publishChanges,detail:X.localChanges}:x,w=Kn(t,n,x);(0,H.useEffect)(()=>{w.comparisonOutdated&&a(!0)},[w.comparisonOutdated,n?.branch,n?.commitSha,n?.repository,a]);async function T(){if(!y){b(!0);try{await Promise.all([a(!0),o()])}finally{b(!1)}}}async function E(){s||(C.action===`retry`?await T():C.action===`none`||m.current||h||await D())}async function D(){if(!(s||m.current)){m.current=!0,d(!0),i(``),v(``);try{let t=await $(`/api/publish/prepare`,e,{method:`POST`,body:`{}`});t.workingTree===`unavailable`||t.workingTree===`changed`&&!t.remember?g({preparation:t}):(g(null),await O(t,t.workingTree===`changed`?`commit-changes`:`committed-only`))}catch(e){let t=e instanceof Error?e.message:String(e);i(t),v(t)}finally{m.current=!1,d(!1)}}}async function O(r,s,c){if(s===`committed-only`&&n?.state===`connected`&&n.repository===r.target.repository&&n.branch===r.target.branch&&n.prototype?.registered&&n.prototype.published&&n.prototype.build?.commitSha===r.target.commitSha&&t?.stats.remoteBranch?.state===`present`&&t.stats.remoteBranch.remoteSha===r.target.commitSha)g(null);else{p(null),v(``),i(``);try{let t=await $(`/api/publish`,e,{method:`POST`,body:JSON.stringify({target:r.target,workingTree:r.workingTree,mode:s,remember:c})});g(null),l(t.message),await o(),await a(!1)}catch(e){let t=e instanceof Error?e.message:String(e);p({message:t,identity:S}),i(t),v(t)}}}async function k(e,t){if(!(s||!h||m.current)){if(h.preparation.workingTree===`unavailable`&&e!==`committed-only`)v(pe.checkFailed);else{m.current=!0,d(!0);try{await O(h.preparation,e,t)}finally{m.current=!1,d(!1)}}}}return{publication:C,presentedState:w.state,busy:u||y||s,notice:c,publishDialog:h,publishDialogError:_,closePublishDialog:()=>g(null),choosePublish:k,retryPublishCheck:D,publish:E,retry:T}}var Yn=`replica:controls`;function Xn(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&Se(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||Se({[r.id]:r.value}))}catch{return!1}}function Zn(e){return Array.isArray(e)&&e.length<=100&&e.every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`scope`in e&&typeof e.scope==`string`&&e.scope.length>0&&e.scope.length<=64&&`error`in e&&typeof e.error==`string`&&e.error.length>0&&e.error.length<=500)}function Qn(e){if(!e||typeof e!=`object`)return!1;let t=e;if(typeof t.runtimeAvailable!=`boolean`||t.reconnectRequired!==void 0&&typeof t.reconnectRequired!=`boolean`||t.status===`ready`&&(!t.runtimeAvailable||!t.scopes?.length)||t.error!==void 0&&(typeof t.error!=`string`||t.error.length>1e3)||t.scopeErrors!==void 0&&!Zn(t.scopeErrors)||![`ready`,`no-controls`,`missing-runtime`,`unsupported-runtime`,`invalid-config`].includes(t.status)||!Array.isArray(t.scopes)||t.scopes.length>100||t.status!==`ready`&&t.scopes.length>0)return!1;try{let e=new Set;for(let n of t.scopes){if(Ue(n.declaration),e.has(n.declaration.scope)||(e.add(n.declaration.scope),n.fingerprint!==JSON.stringify(n.declaration)||!Number.isSafeInteger(n.snapshot.revision)||n.snapshot.revision<0))return!1;let t=n.snapshot;if(!t.values||!t.visible||!t.groups||!t.actions)return!1;function r(e,t){return typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}if(!r(t.values,n.declaration.controls.filter(e=>e.type!==`button`).map(e=>e.id))||!r(t.visible,n.declaration.controls.map(e=>e.id))||!r(t.groups,(n.declaration.groups??[]).map(e=>e.id))||!r(t.actions,n.declaration.controls.filter(e=>e.type===`button`).map(e=>e.id))||Object.values(t.groups).some(e=>typeof e!=`boolean`))return!1;if(t.bindings!==void 0){if(!t.bindings||typeof t.bindings!=`object`||Array.isArray(t.bindings))return!1;for(let[e,r]of Object.entries(t.bindings))if(!n.declaration.controls.some(t=>t.id===e)||!r||typeof r.error!=`string`||r.error.length>500||typeof r.busy!=`boolean`||r.available!==void 0&&typeof r.available!=`boolean`)return!1}for(let e of n.declaration.controls){if(typeof t.visible[e.id]!=`boolean`)return!1;if(e.type===`button`){let n=t.actions[e.id];if(!n||typeof n.available!=`boolean`||typeof n.busy!=`boolean`)return!1}else if(ze(e,t.values[e.id]))return!1}}return!0}catch{return!1}}function $n(){return{runtimeAvailable:!1,status:`missing-runtime`,scopes:[],scopeErrors:[],loading:!0,notice:``,error:``,storageError:``,resetting:!1}}var er=class{frame;origin;api;surface;epoch=``;sequence=-1;state=$n();listeners=new Set;pending=new Map;saved;storageReady=!1;restored=new Set;preparing=new Set;persisted=new Map;cachedScopes=new Map;retryState;resetForIdentity=!1;fromFrameUrl=!1;requests=new AbortController;poll;deadline;saveQueue=Promise.resolve();editQueue=Promise.resolve();stopped=!0;constructor(e,t,n,r=`canvas`){this.frame=e,this.origin=t,this.api=n,this.surface=r}getSnapshot=()=>this.state;getControlValues=()=>{let e=structuredClone(this.saved?.scopes??{}),t=new Map(this.cachedScopes);for(let e of this.state.scopes)t.set(e.declaration.scope,e);for(let[n,r]of t)e[n]=Xe(r);return e};subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});publish(e){this.state={...this.state,...e},this.state.hasResettableValues=Object.values(this.getControlValues()).some(e=>Object.keys(e).length>0);for(let e of[...this.listeners])e()}hasBindingError(e,t){return this.state.scopes.some(n=>(!e||n.declaration.scope===e)&&Object.entries(n.snapshot.bindings??{}).some(([e,n])=>(!t||e===t)&&!!n.error))}checkSaved(e){let t=e,n=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;if(!t||typeof t!=`object`||typeof t.identity!=`string`||!t.identity||t.identity.length>128||!t.scopes||typeof t.scopes!=`object`||Array.isArray(t.scopes)||t.storageError!==void 0&&(typeof t.storageError!=`string`||t.storageError.length>1e3)||t.notice!==void 0&&(typeof t.notice!=`string`||t.notice.length>1e3)||new Blob([JSON.stringify(t)]).size>27e4)throw Error(`Invalid controls storage response.`);for(let[e,r]of Object.entries(t.scopes)){if(!n.test(e)||!r||typeof r!=`object`||Array.isArray(r))throw Error(`Invalid controls storage scope.`);for(let[e,t]of Object.entries(r))if(!n.test(e)||!(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))throw Error(`Invalid saved control value.`)}}start=e=>{this.fromFrameUrl=e?.type===`load`&&this.sequence>=0;let t=[...this.pending.values()].some(e=>e.action);this.stop(),this.requests=new AbortController,this.stopped=!1,this.epoch=crypto.randomUUID(),this.sequence=-1,this.saved=void 0,this.storageReady=!1,this.restored.clear(),this.preparing.clear(),this.persisted.clear(),this.editQueue=Promise.resolve(),this.cachedScopes.clear(),this.retryState=void 0,this.resetForIdentity=!1,this.state=$n(),t&&(this.state.notice=`The preview reconnected during an action. Its outcome is unknown; it was not replayed.`),this.publish({});let n=this.epoch;window.addEventListener(`message`,this.receive),this.frame.addEventListener(`load`,this.start);let r=()=>{this.storageReady&&(this.surface===`canvas`&&this.frame.contentWindow?.postMessage({type:`replica:canvas:request-ready`,nonce:n},this.origin),this.send(`hello`).catch(()=>{}))};r(),this.poll=setInterval(()=>{this.state.status===`missing-runtime`&&r()},1e3),this.deadline=setTimeout(()=>{this.state.loading&&this.publish({loading:!1,error:this.surface===`build`?`Build Controls did not connect. Reload the preview or check its definitions.`:q.controlsLocalConnectionFailed})},6e3),this.api().then(e=>{if(!(this.epoch!==n||this.stopped)){if(this.checkSaved(e),this.saved=e,this.retryState?.identity===e.identity)for(let[e,t]of this.retryState.scopes)this.restored.add(`${e}:${t.fingerprint}`),this.cachedScopes.set(e,t);else this.retryState?.identity&&(this.resetForIdentity=!0,this.publish({notice:`The checkout identity changed. Controls will use this branch's saved values or defaults.`}));this.retryState=void 0,this.storageReady=!0,this.publish({storageError:e.storageError||``,notice:e.notice||this.state.notice}),this.prepare(this.state),r()}}).catch(e=>{this.epoch!==n||this.stopped||(this.storageReady=!0,this.publish({storageError:this.surface===`build`?e instanceof Error?e.message:`Control settings could not be read from the URL.`:q.controlsLocalStorageFailed}),this.prepare(this.state),r())})};retry=()=>{let e={identity:this.saved?.identity,scopes:new Map(this.cachedScopes)};this.start(),this.retryState=e};stop=()=>{this.stopped=!0,this.requests.abort(),clearInterval(this.poll),clearTimeout(this.deadline),window.removeEventListener(`message`,this.receive),this.frame.removeEventListener(`load`,this.start);for(let e of this.pending.values())clearTimeout(e.timer),e.reject(Error(`The preview navigated. The command outcome is unknown; it will not be replayed.`));this.pending.clear()};receive=e=>{if(this.stopped||e.source!==this.frame.contentWindow||e.origin!==this.origin||!Xn(e.data))return;let t=e.data;if(t.epoch!==this.epoch||!Qn(t.state)||!Number.isSafeInteger(t.sequence)||(t.sequence??-1)<0||t.type!==`snapshot`&&t.type!==`reply`)return;let n=this.pending.get(t.requestId);if(t.type!==`reply`||n){if((t.sequence??-1)>this.sequence){if(t.type===`snapshot`&&t.controlQuery!==void 0&&this.saved){let e=Ee(t.controlQuery),n=this.saved.identity,r=this.epoch;this.stop();let i=new AbortController;this.requests=i,this.publish({loading:!0}),this.api({method:`POST`,signal:i.signal,body:JSON.stringify({identity:n,replace:!0,scopes:e.scopes})}).then(()=>{this.epoch!==r||i.signal.aborted||(this.start(),e.notice&&this.publish({notice:e.notice}))}).catch(e=>{this.epoch!==r||i.signal.aborted||this.publish({loading:!1,storageError:e instanceof Error?e.message:`Controls history could not be restored.`})});return}if(t.controlQuery!==void 0&&this.saved){let e=this.epoch,n=this.requests,r=Ee(t.controlQuery);this.saved.scopes=r.scopes,this.restored.clear(),this.persisted.clear(),this.cachedScopes.clear(),this.publish({notice:r.notice,loading:!0}),this.api({method:`POST`,signal:n.signal,body:JSON.stringify({identity:this.saved.identity,replace:!0,scopes:r.scopes})}).catch(t=>{this.epoch!==e||this.stopped||n.signal.aborted||this.publish({storageError:t instanceof Error?t.message:`Controls history could not be restored.`})})}this.sequence=t.sequence;let e=t.state.status;this.publish({...t.state,scopeErrors:t.state.scopeErrors??[],reconnectRequired:t.state.reconnectRequired===!0,status:e,error:t.state.error||(this.state.status===`missing-runtime`&&t.state.status!==`missing-runtime`?``:this.state.error),loading:!this.storageReady||this.state.resetting||this.preparing.size>0||this.state.loading&&e===`missing-runtime`}),this.prepare(this.state)}n&&(this.pending.delete(t.requestId),clearTimeout(n.timer),t.error?n.reject(Error(t.error)):n.resolve(this.state))}};send(e,t){let n=crypto.randomUUID(),r={protocol:Yn,version:1,epoch:this.epoch,requestId:n,type:e,...t?{command:t}:{},...e===`hello`?{controlQuery:Te(this.saved?.scopes??{}),fromFrameUrl:this.fromFrameUrl}:{}};return Xn(r)?new Promise((i,a)=>{let o=setTimeout(()=>{this.pending.delete(n),a(Error(`The command timed out. Its outcome is unknown; it will not be retried automatically.`))},e===`hello`?1200:3e4);this.pending.set(n,{resolve:i,reject:a,timer:o,action:t?.operation===`action`}),this.frame.contentWindow?.postMessage(r,this.origin)}):Promise.reject(Error(`The controls command is invalid or exceeds the size limit.`))}async prepare(e){if(!this.saved&&!this.state.storageError||this.state.resetting||e.reconnectRequired)return;let t=this.epoch;if(this.resetForIdentity&&(e.status===`ready`||e.status===`no-controls`)){this.resetForIdentity=!1,this.publish({loading:!0,resetting:!0});try{await this.send(`command`,{operation:`reset-all`,contexts:e.scopes.map(e=>({scope:e.declaration.scope,fingerprint:e.fingerprint,revision:e.snapshot.revision}))})}catch{this.epoch===t&&this.publish({error:`The checkout changed, but runtime defaults could not be restored. Reload the preview before saving.`,storageError:`Saving is paused until the new checkout's runtime reconnects.`,loading:!1});return}finally{this.epoch===t&&this.publish({resetting:!1})}return this.epoch!==t||this.stopped?void 0:this.prepare(this.state)}for(let n of e.scopes){let e=n.declaration.scope,r=`${e}:${n.fingerprint}`;if(!this.preparing.has(r)){if(!this.restored.has(r)){this.preparing.add(r),this.publish({loading:!0});try{let i=this.saved?.scopes&&Object.hasOwn(this.saved.scopes,e)?this.saved.scopes[e]:{},a=Object.fromEntries(n.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)])),o=!1;for(let[e,t]of Object.entries(i)){let r=n.declaration.controls.find(t=>t.id===e);!r||ze(r,t)?o=!0:a[e]=t}if(Object.keys(a).length&&await this.send(`command`,{operation:`restore`,scope:e,fingerprint:n.fingerprint,revision:this.state.scopes.find(e=>e.fingerprint===n.fingerprint)?.snapshot.revision,values:a}),this.stopped||this.epoch!==t)return;this.restored.add(r),o&&this.publish({notice:this.surface===`build`?`Some URL control settings no longer match this page. Defaults were used.`:`Some saved controls no longer match this declaration and were discarded.`})}catch(n){if(this.epoch!==t||this.stopped)return;this.hasBindingError(e)||this.publish({error:n instanceof Error?n.message:`Saved controls could not be restored.`}),this.restored.add(r)}finally{this.epoch===t&&this.preparing.delete(r)}}if(this.epoch===t&&!this.stopped){let t=this.state.scopes.find(t=>t.declaration.scope===e);t&&(this.cachedScopes.set(e,t),this.persist(t))}}}this.epoch===t&&!this.stopped&&this.state.status!==`missing-runtime`&&this.publish({loading:this.preparing.size>0})}persist(e){if(!this.saved||this.state.storageError)return;let t=Xe(e),n=JSON.stringify(t);if(this.persisted.get(e.declaration.scope)===n)return;this.persisted.set(e.declaration.scope,n);let r=this.saved.identity,i=this.epoch,a=this.requests.signal;this.saveQueue=this.saveQueue.catch(()=>{}).then(async()=>{if(!(this.epoch!==i||this.stopped))try{if(await this.api({method:`POST`,signal:a,body:JSON.stringify({identity:r,scope:e.declaration.scope,values:t})}),this.epoch===i&&!this.stopped){let t=await this.api();if(this.checkSaved(t),this.epoch!==i||this.stopped)return;this.saved=t,await this.send(`command`,{operation:`url`,scope:e.declaration.scope,query:Te(t.scopes)})}}catch(e){this.epoch===i&&!this.stopped&&this.publish({storageError:this.surface===`build`&&e instanceof Error?`${e.message} Changes remain in memory and are not in the URL.`:`Controls could not be saved. Changes remain in memory; use Retry to reconnect storage.`})}})}async command(e,t,n,r){if(this.state.loading||this.state.resetting||this.stopped)return;let i=this.epoch,a=this.state.scopes.find(e=>e.declaration.scope===t);if(!a){this.publish({error:`This controls scope is no longer active.`});return}let o=()=>this.applyCommand(e,t,a.fingerprint,i,n,r);if(e!==`update`)return o();let s=this.editQueue.catch(()=>{}).then(o);return this.editQueue=s.then(()=>{}),s}async applyCommand(e,t,n,r,i,a){if(this.epoch!==r||this.stopped||this.state.resetting)return;let o=this.state.scopes.find(e=>e.declaration.scope===t);if(!o||o.fingerprint!==n)this.publish({error:`The controls scope or declaration changed. The command was not applied.`});else{this.publish({error:``});try{if(this.state.reconnectRequired)throw Error(`Reconnect controls before sending more commands.`);if(e===`update`||e===`action`){let t=o.declaration.controls.find(e=>e.id===i);if(!t||!o.snapshot.visible[t.id])throw Error(`This control is unknown or hidden.`);if(e===`update`){let e=ze(t,a);if(e)throw Error(`Control "${t.id}": ${e}`)}else if(t.type!==`button`||!o.snapshot.actions[t.id]?.available||o.snapshot.actions[t.id]?.busy)throw Error(`This action is unavailable or busy.`)}let n=await this.send(`command`,{operation:e,scope:t,fingerprint:o.fingerprint,revision:o.snapshot.revision,...i?{id:i}:{},...e===`update`?{value:a}:{}});if(e===`update`&&i)return{value:n.scopes.find(e=>e.declaration.scope===t)?.snapshot.values[i]}}catch(e){!this.stopped&&this.epoch===r&&!this.hasBindingError(t,i)&&this.publish({error:e instanceof Error?e.message:`Controls command failed.`})}}}async resetAll(){if(this.state.resetting||this.stopped)return;let e=this.epoch;this.publish({resetting:!0});try{let t=``;await this.editQueue.catch(()=>{});let n=this.state.runtimeAvailable&&(this.state.status===`ready`||this.state.status===`no-controls`);if(n)try{await this.send(`command`,{operation:`reset-all`,contexts:this.state.scopes.map(e=>({scope:e.declaration.scope,fingerprint:e.fingerprint,revision:e.snapshot.revision}))})}catch(e){t=e instanceof Error?e.message:`Some app defaults could not be restored.`}if(this.epoch!==e||this.stopped)return;if(!this.saved){let e=await this.api();this.checkSaved(e),this.saved=e}await this.saveQueue.catch(()=>{}),await this.api({method:`POST`,signal:this.requests.signal,body:JSON.stringify({identity:this.saved.identity,reset:!0})}),this.saved.scopes={},await this.send(`command`,{operation:`url`,query:``}),this.cachedScopes.clear(),this.persisted.clear(),this.publish({storageError:``,error:this.hasBindingError()?``:t,notice:n?``:`Saved controls were cleared. Runtime defaults could not be restored until the preview reconnects.`})}catch(t){this.epoch===e&&this.publish({storageError:t instanceof Error?t.message:`Reset could not be saved.`})}finally{this.epoch===e&&this.publish({resetting:!1,loading:!1})}}};function tr(e,t=()=>window.location.href,n=e=>{window.history.replaceState(window.history.state,``,e),window.dispatchEvent(new Event(Ce))}){return r=>Promise.resolve().then(()=>{r?.signal?.throwIfAborted();let i=Ee(new URL(t()).search);if(!r)return{identity:e,...i};if(r.method!==`POST`||typeof r.body!=`string`)throw Error(`Invalid URL controls request.`);let a=JSON.parse(r.body);if(!a||typeof a!=`object`||!(`identity`in a)||a.identity!==e)throw Error(`The controls URL identity changed.`);let o=i.scopes;if(`reset`in a&&a.reset===!0)o={};else if(`replace`in a&&a.replace===!0&&`scopes`in a){if(!a.scopes||typeof a.scopes!=`object`||Array.isArray(a.scopes))throw Error(`Invalid controls history settings.`);let e={};for(let[t,n]of Object.entries(a.scopes)){if(!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(t)||!Se(n))throw Error(`Invalid controls history settings.`);e[t]=n}o=Ee(Te(e)).scopes}else{if(!(`scope`in a)||typeof a.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(a.scope)||!(`values`in a)||!Se(a.values))throw Error(`Invalid URL control settings.`);o={...o,[a.scope]:a.values}}let s=De(t(),Te(o));s!==t()&&n(s)})}function nr({frameRef:e,prototypeUrl:t,previewUrl:n,address:r,replaceAddress:i}){let[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(null),l=(0,H.useRef)({address:r,replaceAddress:i});return(0,H.useLayoutEffect)(()=>{l.current={address:r,replaceAddress:i}},[r,i]),(0,H.useEffect)(()=>{if(!e.current)return;let r=new er(e.current,new URL(n??t).origin,tr(`prototype:${new URL(t).origin}`,()=>l.current.address,e=>{l.current.address=e,l.current.replaceAddress(e)}));o(r);let i=r.subscribe(()=>c(r.getSnapshot()));return r.start(),()=>{i(),r.stop()}},[t,n,e]),{connection:a,state:s}}function rr({token:e,status:t,onStatusChange:n,onSelectHub:r}){let[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),m=(0,H.useRef)(!1),h=(0,H.useRef)(!1),g=t?.state===`connected`||t?.state===`undiscovered`,_=t?.state===`disconnected`||t?.state===`pairing`||t?.state===`unconfigured`,v=g?null:t?.pairing||(f?.repository===t?.repository&&f?.hubOrigin===t?.hubOrigin?f?.pairing:null),y=v?.verificationUrl;(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{g?(a(!1),p(null),l(``)):_&&t?.repository&&!m.current&&(m.current=!0,a(!0))},0);return()=>window.clearTimeout(e)},[g,_,t?.repository]),(0,H.useEffect)(()=>{if(!y||u)return;let t=!1,r=!1;async function i(){if(!r){r=!0;try{let r=await $(`/api/hub/poll`,e,{method:`POST`,body:`{}`});if(t)return;r.status!==`pending`&&(p(null),r.status!==`approved`&&l(q.connectionApprovalExpired),await n())}catch(e){t||(l(e instanceof Error?e.message:String(e)),d(!0))}finally{r=!1}}}let a=window.setInterval(()=>void i(),3e3);return()=>{t=!0,window.clearInterval(a)}},[y,u,e,n,t?.repository,t?.hubOrigin]);async function b(i){if(m.current=!0,!h.current){if(!t?.repository)l(q.connectionRepositoryRequired);else if(!t.hubOrigin&&!i)l(q.connectionHubRequired);else{h.current=!0,s(!0),l(``),d(!1);try{!t.hubOrigin&&i&&await r(i);let a=await $(`/api/hub/connect`,e,{method:`POST`,body:`{}`});p({repository:t.repository,hubOrigin:new URL(a.verificationUrl).origin,pairing:a}),a.browserError&&l(q.connectionBrowserFailed(a.browserError)),await n()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h.current=!1,s(!1)}}}}function x(){a(!0),t?.hubOrigin&&b()}return{open:i,close:()=>a(!1),show:()=>a(!0),showAndConnect:x,connect:b,connecting:o,error:c,pairing:v}}function ir({token:e,onStatus:t,onError:n}){let[r,i]=(0,H.useState)(null),a=(0,H.useRef)(0),o=(0,H.useRef)(0),s=(0,H.useRef)(!1),c=(0,H.useCallback)(async(r,c=!1)=>{if(s.current||c&&o.current>0)return;o.current+=1;let l=++a.current;try{let o=r===`open`||r===`interaction`,c=await $(o?r===`open`?`/api/hub/open`:`/api/hub/activity`:`/api/hub/status`,e,o?{method:`POST`,body:`{}`}:{});if(l!==a.current||s.current)return;i(c);let u=c.prototype?.startPageImportError||c.localStartPageError;u&&n(u),t(c)}catch(e){if(l!==a.current||s.current)return;let t=e instanceof Error?e.message:String(e);i(e=>({state:`unavailable`,repository:e?.repository,branch:e?.branch,hubOrigin:e?.hubOrigin,message:q.hubStatusUnavailable(t)})),n(t)}finally{--o.current}},[e,t,n]),l=(0,H.useCallback)(async t=>{s.current=!0,a.current+=1,i(null);try{await $(`/api/hub/origin`,e,{method:`POST`,body:JSON.stringify({origin:t})})}finally{s.current=!1,await c()}},[e,c]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>void c(`open`),0),t=window.setInterval(()=>void c(void 0,!0),15e3);function n(){c(`interaction`)}return window.addEventListener(`focus`,n),()=>{a.current+=1,window.clearTimeout(e),window.clearInterval(t),window.removeEventListener(`focus`,n)}},[c]);async function u(){let t=await $(`/api/hub/discovery`,e,{method:`POST`,body:`{}`});if(t.discovery?.state!==`valid`||!t.discovery.origin)throw Error(t.discovery?.message||q.resetHubUnavailable);return await c(),t.discovery.origin}return{status:r,refresh:c,select:l,reset:u}}function ar(e){return/^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(e)?.[0]??`/`}function or({prototypeUrl:e,previewUrl:t,shellRef:n,cancelClick:r}){let[{key:i,ref:a},o]=(0,H.useState)(()=>({key:0,ref:(0,H.createRef)()})),[s,c]=(0,H.useState)({input:e,url:e}),[l,u]=(0,H.useState)({input:e,entries:[e],index:0}),[d,f]=(0,H.useState)(()=>window.matchMedia?.(`(prefers-color-scheme: dark)`)?.matches?`dark`:`light`),[p,m]=(0,H.useState)(null),h=(0,H.useRef)(null),g=l.input===e?l:{input:e,entries:[e],index:0},_=g.entries[g.index],v=(0,H.useCallback)(()=>r.current?.(),[r]),y=(0,H.useCallback)(t=>{if(new URL(t).origin!==new URL(e).origin)throw Error(q.startPageOrigin);u(e=>{let n=[...e.entries];return n[e.index]=t,{...e,entries:n}})},[e]),b=(0,H.useCallback)(t=>{if(h.current===e)return;h.current=e;let n=new URL(e),r=t.state===`connected`&&(t.prototype?.startPageSet??t.prototype?.startPage!==void 0)?t.prototype?.startPage:t.localStartPage,i=ar(n.pathname);if(n.pathname!==i||n.search||n.hash||!r)return;let a=new URL(r,n);if(a.origin!==n.origin)throw Error(q.startPageOrigin);a.pathname=`${i}${a.pathname.slice(1)}`,c({input:e,url:a.href}),u({input:e,entries:[a.href],index:0})},[e]);function x(){v(),m(null),c({input:e,url:_}),o(e=>({key:e.key+1,ref:(0,H.createRef)()}))}function S(t){t===_?x():(u(n=>{let r=n.input===e?n:g;return{...r,entries:[...r.entries.slice(0,r.index+1),t],index:r.index+1}}),c({input:e,url:t}))}function C(t){let n=g.entries[t];n&&(u({...g,index:t}),c({input:e,url:n}))}let w=(0,H.useCallback)((t,n=!1)=>{m(t);let r=new URL(e);r.pathname=`${ar(r.pathname)}${t.pathname.slice(1)}`,r.search=t.search,r.hash=t.hash,u(t=>{let i=t.input===e?t:{input:e,entries:[e],index:0},a=new URL(i.entries[i.index]),o=[...a.searchParams].filter(([e])=>e.startsWith(`rc.`));for(let e of[r,a])for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);if(a.pathname===r.pathname&&a.searchParams.toString()===r.searchParams.toString()&&a.hash===r.hash)return i;for(let[e,t]of o)r.searchParams.append(e,t);let s=r.href;if(n){let e=[...i.entries];return e[i.index]=s,{...i,entries:e}}return{...i,entries:[...i.entries.slice(0,i.index+1),s],index:i.index+1}})},[e]);(0,H.useEffect)(()=>{let e=a.current;if(!e)return;function t(){v(),m(null)}return e.addEventListener(`load`,t),()=>{v(),e.removeEventListener(`load`,t)}},[v,a]),(0,H.useEffect)(()=>{let r=a.current;if(!r)return;let i=new URL(t??e).origin,o=crypto.randomUUID();function s(){let e=n.current?.closest(`.canvas-base`);e&&r?.contentWindow?.postMessage({type:`replica:canvas:theme`,nonce:o,accent:window.getComputedStyle(e).getPropertyValue(`--hub-accent`).trim()},i)}function c(e){e.source===r?.contentWindow&&e.origin===i&&e.data?.type===`replica:canvas:ready`&&s()}return r.addEventListener(`load`,s),window.addEventListener(`message`,c),s(),()=>{r.removeEventListener(`load`,s),window.removeEventListener(`message`,c)}},[d,e,t,a,n]);let T=new URL(s.input===e?s.url:e);if(t){let e=new URL(t);T.protocol=e.protocol,T.host=e.host}return{frameRef:a,frameKey:i,source:T.href,navigation:g,address:_,replaceAddress:y,appearance:d,setAppearance:f,liveRoute:p,initialize:b,reportRoute:w,reload:x,navigate:S,travel:C}}function sr(e){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(``),a=(0,H.useRef)(null),o=(0,H.useRef)(0),s=(0,H.useRef)(0),c=(0,H.useCallback)(async(t,r=!1)=>{if(r&&s.current>0)return;s.current+=1;let c=++o.current;try{let r=await $(t?`/api/refresh`:`/api/state`,e,t?{method:`POST`,body:`{}`}:{});if(c!==o.current)return;a.current=r,n(r),i(``)}catch(e){if(c!==o.current)return;n(t=>t&&{...t,stats:{...t.stats,remoteBranch:{state:`unknown`,repository:t.stats.repository||null,branch:t.stats.branch||null,commitSha:t.stats.commitSha||null,error:cr(e)}}}),i(cr(e))}finally{--s.current}},[e]);return(0,H.useEffect)(()=>{let e=window.setTimeout(()=>void c(!0),0),t=window.setInterval(()=>{let e=a.current?.publishStatus?.state,t=a.current?.publishRequest,n=e===`requested`||e===`in_progress`||t?.state===`requested`||!!t?.requestedAt&&(e===`not_published`||e===`unavailable`);c(n,!0)},15e3);function n(){c(!0)}return window.addEventListener(`focus`,n),()=>{o.current+=1,window.clearTimeout(e),window.clearInterval(t),window.removeEventListener(`focus`,n)}},[c]),{state:t,error:r,setError:i,refresh:c}}function cr(e){return e instanceof Error?e.message:String(e)}function lr({token:e,enabled:t,repository:n,branch:r,commitSha:i,publicationRevision:a}){let o=`${n}/${r}/${i}/${a}`,[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),p=(0,H.useRef)(null),m=(0,H.useRef)(0),h=t&&s?.identity===o?s:null,g=(0,H.useCallback)(async()=>{if(!t)return;let i=++m.current;u(!0);try{if(await p.current,i!==m.current)return;let t=await $(`/api/publish/prepare`,e,{method:`POST`,body:`{}`});if(i!==m.current)return;if(t.target.repository!==n||t.target.branch!==r)throw Error(pe.preferenceTargetChanged);if(typeof t.remember!=`boolean`)throw Error(pe.invalidPreference);c({identity:o,preparation:t,error:``})}catch(e){i===m.current&&c({identity:o,preparation:null,error:e instanceof Error?e.message:String(e)})}finally{i===m.current&&u(!1)}},[t,e,n,r,o]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>void g(),0);return()=>{m.current+=1,window.clearTimeout(e)}},[g]);async function _(n){if(!t||!h?.preparation||l||p.current)return;f(!0);let r=m.current,i=h.preparation,a=(async()=>{try{if((await $(`/api/publish/preference`,e,{method:`POST`,body:JSON.stringify({target:i.target,remember:n})})).remember!==n)throw Error(pe.invalidPreference);r===m.current&&c({identity:o,preparation:{...i,remember:n},error:``})}catch(e){r===m.current&&c({identity:o,preparation:i,error:e instanceof Error?e.message:String(e)})}})();p.current=a;try{await a}finally{p.current=null,f(!1)}}return{remember:h?.preparation?.remember??null,loading:l||!h,saving:d,error:h?.error||``,save:_,retry:g}}function ur(e,t,n){let r=n?.included,i=n?.error,a=n?.revision,o=(0,H.useMemo)(()=>{if(r!==void 0)return{identity:e,revision:a,included:r,error:i??``,pending:!1};let t=!1,n=``;if(e)try{let n=localStorage.getItem(`replica:share-controls:v1:${e}`);if(n!==null&&n!==`true`&&n!==`false`)throw Error(`Invalid saved share preference.`);t=n===`true`}catch{n=`The share preference could not be read. Control settings are off by default.`}return{identity:e,revision:a,included:t,error:n,pending:!1}},[e,a,r,i]),[s,c]=(0,H.useState)(o),l=s.identity===e&&s.revision===a?s:o,u=``,d=``;if(l.included)try{u=Te(t)}catch(e){d=e instanceof Error?e.message:`Control settings could not be shared.`}return{included:l.included,query:u,error:d||l.error,blocked:!!d,...n?{pending:l.pending}:{},onChange:t=>{if(n){c({identity:e,revision:a,included:t,error:``,pending:!0});function r(n){c(r=>r.identity===e&&r.revision===a&&r.included===t?{...r,error:n,pending:!1}:r)}n.onChange(t).then(()=>r(``),e=>r(e instanceof Error?e.message:`This preference could not be saved. It will only apply while this page is open.`));return}let r=``;if(e)try{localStorage.setItem(`replica:share-controls:v1:${e}`,String(t))}catch{r=`This preference could not be saved. It will only apply while this page is open.`}c({identity:e,revision:a,included:t,error:r,pending:!1})}}}function dr({token:e,state:t,hubStatus:n}){let[r,i]=(0,H.useState)(null),a=!!(r&&(r.stale||r.repository!==void 0&&r.repository!==t?.stats.repository||r.branch!==void 0&&r.branch!==t?.stats.branch||n?.hubOrigin!==void 0&&r.hubOrigin!==void 0&&r.hubOrigin!==n.hubOrigin||r.token!==e));(0,H.useEffect)(()=>{if(!r||r.stale)return;let e=r.repository??t?.stats.repository,o=r.branch??t?.stats.branch,s=r.hubOrigin??n?.hubOrigin;if(!a&&e===r.repository&&o===r.branch&&s===r.hubOrigin)return;let c=window.setTimeout(()=>{i(t=>t&&{...t,repository:e,branch:o,hubOrigin:s,stale:a,connecting:!a&&t.connecting})},0);return()=>window.clearTimeout(c)},[r,a,t?.stats.repository,t?.stats.branch,n?.hubOrigin]);function o(){i({repository:t?.stats.repository,branch:t?.stats.branch,hubOrigin:n?.hubOrigin,token:e,connecting:!1,stale:!1})}function s(e){i(t=>t&&{...t,connecting:e})}return{intent:r,targetChanged:a,begin:o,close:()=>i(null),setConnecting:s}}var fr={open:!1,context:null,links:[],loading:!1,busy:!1,stale:!0,error:``,notice:``,created:null};function pr({token:e,hubStatus:t,prototypeState:n}){let[r,i]=(0,H.useState)(fr),a=(0,H.useRef)(r);a.current=r;let o=(0,H.useRef)(0),s=(0,H.useRef)(!1),c=(0,H.useRef)(!1),l=(0,H.useRef)(!1),u=(0,H.useRef)(!1),d=(0,H.useRef)(null),f=`${t?.hubOrigin}/${t?.repository}/${t?.branch}/${t?.state}`,p=(0,H.useRef)(f);p.current=f;let m=(0,H.useCallback)(()=>{!u.current||s.current||c.current||l.current||!d.current||(u.current=!1,d.current())},[]);(0,H.useLayoutEffect)(()=>{o.current+=1,i(e=>e.open?{...fr,open:!0,error:J.stale}:fr)},[f,e]),(0,H.useEffect)(()=>()=>{o.current+=1,u.current=!1},[]),(0,H.useEffect)(()=>{let e=t?.prototype;e&&e.canManageShareLinks!==!0&&a.current.context?.prototype.canManageShareLinks===!0&&(o.current+=1,i(t=>t.open&&t.context?.prototype.id===e.id?{...fr,open:!0,stale:!1,context:{...t.context,prototype:{...t.context.prototype,canManageShareLinks:e.canManageShareLinks}}}:t))},[t?.prototype]),(0,H.useEffect)(()=>{t?.prototype?.publicSharingEnabled===!1&&(o.current+=1,i(e=>e.open?{...fr,open:!0,sharingDisabled:!0,error:J.disabled,context:e.context?{...e.context,prototype:{...e.context.prototype,publicSharingEnabled:!1}}:null}:fr))},[t?.prototype?.publicSharingEnabled]);let h=(0,H.useCallback)((t,n)=>$(`/api/hub/share-links/${t}`,e,{method:`POST`,body:JSON.stringify(n)}),[e]),g=(0,H.useCallback)(e=>{e instanceof Error&&`code`in e&&(e.code===`public_sharing_disabled`||e.code===`public_sharing_changed`||e.code===`creator_access_changed`)&&(o.current+=1,i(t=>({...t,busy:!1,loading:!1,stale:!0,sharingDisabled:e.code===`public_sharing_disabled`,links:[],created:null,authorization:void 0})))},[]),_=(0,H.useCallback)(async(e=a.current.context)=>{if(!e||!e.prototype.canManageShareLinks||e.prototype.publicSharingEnabled===!1||c.current)return;c.current=!0;let t=o.current,n=p.current;i(e=>({...e,loading:!0,stale:!0,error:``}));try{let r=new Map,a=new Set,s=null;do{let i=await h(`list`,{target:e.target,...s?{cursor:s}:{}});if(t!==o.current||n!==p.current)return;for(let e of i.shareLinks)r.set(e.id,e);if(s=i.nextCursor,s){if(a.has(s))throw Error(J.paginationFailed);a.add(s)}}while(s);i(e=>({...e,links:[...r.values()],created:e.created?r.get(e.created.id)??null:null,loading:u.current,stale:u.current,sharingDisabled:!1}))}catch(e){t===o.current&&n===p.current&&(i(t=>({...t,loading:!1,stale:!0,error:e instanceof Error?e.message:J.failed})),g(e))}finally{c.current=!1,m()}},[h,m,g]),v=(0,H.useCallback)(async()=>{if(s.current||l.current||c.current){u.current=!0,i(e=>({...e,open:!0,stale:!0,loading:!0}));return}l.current=!0;let e=++o.current,r=p.current;i({...fr,open:!0,loading:!0});let a=t?.repository===n?.stats.repository&&t?.branch===n?.stats.branch,d=``;if(!t||[`disconnected`,`pairing`,`unconfigured`].includes(t.state)?d=J.disconnected:[`unavailable`,`denied`].includes(t.state)?d=J.unavailable:(t.state!==`connected`||!a)&&(d=J.branch),d)i({...fr,open:!0,error:d}),l.current=!1;else try{let t=await h(`context`,{});if(e!==o.current||r!==p.current)return;i(e=>({...e,context:t,loading:!1,stale:t.prototype.canManageShareLinks===!0})),await _(t)}catch(t){e===o.current&&r===p.current&&i(e=>({...e,loading:!1,error:t instanceof Error?t.message:J.failed}))}finally{l.current=!1,m()}},[t,n,_,h,m]);d.current=v;let y=(0,H.useCallback)(async(e,t)=>{let n=a.current;if(s.current||l.current||c.current||u.current||n.stale||!n.context||n.context.prototype.canManageShareLinks!==!0||n.sharingDisabled||n.context.prototype.publicSharingEnabled===!1)return!1;s.current=!0;let r=o.current;i(e=>({...e,busy:!0,error:``,notice:``}));try{let a=await h(e,{target:n.context.target,...t});return r===o.current&&(i(n=>({...n,notice:e===`delete`?J.deleted:``,authorization:void 0,created:`id`in a?a:e===`delete`&&`id`in t&&n.created?.id===t.id?null:n.created,links:e===`delete`&&`id`in t?n.links.filter(e=>e.id!==t.id):n.links})),await _(n.context),!0)}catch(e){if(r!==o.current)return!1;let t=e instanceof Error&&`code`in e&&e.code===`fresh_authorization_required`&&`authorization`in e&&e.authorization&&typeof e.authorization==`object`&&`url`in e.authorization&&typeof e.authorization.url==`string`&&`expiresAt`in e.authorization&&typeof e.authorization.expiresAt==`string`?{url:e.authorization.url,expiresAt:e.authorization.expiresAt}:void 0,n=e instanceof Error&&(!(`statusCode`in e)||`code`in e&&e.code===`share_delivery_unknown`);return i(r=>({...r,stale:!0,authorization:t,error:n?J.unknown:e instanceof Error?e.message:J.failed})),g(e),!1}finally{s.current=!1,r===o.current&&i(e=>({...e,busy:!1})),m()}},[_,h,m,g]),b=(0,H.useCallback)(async e=>{let t=a.current;if(!t.context||l.current||c.current||u.current)throw Error(J.stale);let n=o.current,r=await h(`controls-preference`,{target:t.context.target,included:e});if(n!==o.current)throw Error(J.stale);if(r.included!==e)throw Error(`The share preference could not be saved.`)},[h]),x=(0,H.useCallback)(async(e,t)=>{let n=a.current;if(!n.context||n.stale||l.current||c.current||u.current)return;let r=o.current;try{await h(`open`,{target:n.context.target,id:e,...t?{controlsQuery:t}:{}})}catch(e){r===o.current&&(i(t=>({...t,error:e instanceof Error?e.message:J.failed})),g(e))}},[h,g]),S=(0,H.useCallback)(async()=>{let e=a.current;if(!e.context||!e.authorization||e.busy)return;let t=o.current;try{await h(`authorize`,{target:e.context.target}),t===o.current&&i(e=>({...e,notice:J.authorizationRetry}))}catch(e){t===o.current&&(i(t=>({...t,error:e instanceof Error?e.message:J.failed})),g(e))}},[h,g]);return(0,H.useEffect)(()=>{if(!r.open||!r.context)return;function e(){s.current||_()}let t=window.setInterval(e,3e4);return window.addEventListener(`focus`,e),()=>{window.clearInterval(t),window.removeEventListener(`focus`,e)}},[r.open,r.context,_]),{state:r,open:v,close:()=>{u.current=!1,i(e=>({...e,open:!1}))},refresh:()=>r.context&&!r.sharingDisabled&&r.context.prototype.publicSharingEnabled!==!1?_():v(),create:(e,t)=>y(`create`,{label:e,expiration:t,buildNumber:r.context?.prototype.build?.number}),remove:e=>y(`delete`,{id:e}),openLink:x,setControlPreference:b,authorize:S}}var mr=`modulepreload`,hr=function(e){return`/assets/`+e},gr={},_r=function(e){return e.pathname.endsWith(`.css`)},vr=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},yr=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=hr(t,n);let r=s(t),i=_r(r);return vr(gr,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:mr,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},br=(0,H.lazy)(()=>yr(()=>import(`./renderer-improvement-notes-prototype.js`).then(e=>e.t).then(e=>({default:e.ImprovementNotesPrototype})),__vite__mapDeps([0,1,2,3,4]))),xr=(0,H.lazy)(()=>yr(()=>import(`./renderer-prototype-canvas-thread-sample.js`).then(e=>({default:e.PrototypeCanvasThreadSample})),__vite__mapDeps([5,1,2,3,4])));function Sr({config:e}){let t=(0,H.useRef)(null),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useRef)(null),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useRef)(null),u=(0,H.useRef)(null),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)({position:null,collapsed:!1,collapsedGroups:{}}),[h,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!1),x=(0,H.useCallback)(()=>{g(!1),o.current?.focus()},[]),{frameRef:S,frameKey:C,source:w,navigation:T,address:E,replaceAddress:D,appearance:O,setAppearance:k,liveRoute:A,initialize:j,reportRoute:M,reload:N,navigate:ee,travel:P}=or({prototypeUrl:e.prototypeUrl,previewUrl:e.previewUrl,shellRef:t,cancelClick:u}),F=nr({...e,frameRef:S,address:E,replaceAddress:D}),I=F.state;Gn({...e,frameRef:S,addressRef:r,appearance:O,navigation:T,liveRoute:A,cancelClick:u,reload:N,controlsConnection:F.connection});let{state:L,error:R,setError:z,refresh:B}=sr(e.token),V=ir({token:e.token,onStatus:j,onError:z}),te=rr({token:e.token,status:V.status,onStatusChange:V.refresh,onSelectHub:V.select}),ne=pr({token:e.token,hubStatus:V.status,prototypeState:L}),re=dr({token:e.token,state:L,hubStatus:V.status}),ie=lr({token:e.token,enabled:h&&V.status?.state===`connected`&&V.status.prototype?.registered===!0&&!!V.status.prototype.build&&V.status.repository===L?.stats.repository&&V.status.branch===L?.stats.branch,repository:L?.stats.repository,branch:L?.stats.branch,commitSha:L?.stats.commitSha,publicationRevision:L?.publishRequest?.requestedAt}),ae=Jn({token:e.token,state:L,hubStatus:V.status,error:R,setError:z,refresh:B,refreshHub:V.refresh,preferenceSaving:ie.saving}),oe=zn(L,V.status,ae.publication),se=ne.state.context,G=ur(se?`${se.hubOrigin}:${se.prototype.repositoryId}:${se.prototype.id}`:void 0,F.connection?.getControlValues()??{},{included:se?.controlSettingsIncluded??!1,error:se?.controlSettingsError,revision:se?.target,onChange:ne.setControlPreference});(0,H.useLayoutEffect)(()=>{document.body.classList.remove(`renderer-loading`);let e=t.current,r=n.current;if(!e||!r)return;function i(){let t=r?.getBoundingClientRect().height;t&&e?.style.setProperty(`--canvas-toolbar-height`,`${t}px`)}let a=new ResizeObserver(i);return a.observe(r),i(),()=>a.disconnect()},[]);function K(){te.close(),oe.kind===`ready`?ne.open():re.begin()}return(0,W.jsxs)(U.ThemeProvider,{colorMode:O,className:`canvas-base`,children:[(0,W.jsxs)(`main`,{ref:t,className:`canvas-shell${ne.state.open?` canvas-shell--inactive`:``}`,inert:ne.state.open,"aria-hidden":ne.state.open?!0:void 0,children:[(0,W.jsx)(Ne,{address:E,addressRef:r,canGoBack:T.index>0,canGoForward:T.indexP(T.index-1),onForward:()=>P(T.index+1),onNavigate:ee,onOpenTab:async()=>{await $(`/api/prototype/open`,e.token,{method:`POST`,body:JSON.stringify({url:E})})},onReload:N}),(0,W.jsx)(Vn,{toolbarRef:n,improvementControlsRef:v,config:e,state:ae.presentedState,prototypeName:V.status?.state===`connected`&&V.status.prototype?.name||void 0,publishing:ae.busy,publication:ae.publication,publishButtonRef:i,hubButtonRef:o,titleButtonRef:c,onBuildDetails:()=>b(!0),controlsButtonRef:l,controlsOpen:d,onControls:()=>f(!d),onPublish:()=>void ae.publish(),onShare:K,shareButtonRef:a,hubOpen:h,onHub:()=>{g(!h),V.refresh(`interaction`)}}),(0,W.jsx)(`iframe`,{ref:S,className:`prototype-frame`,title:q.prototypeFrameTitle(e.name),src:w,style:{colorScheme:O,backgroundColor:`var(--hub-canvas-default)`}},C),(0,W.jsx)(Rn,{config:e,frameRef:S,onRouteChange:M,status:V.status,onStatusChange:V.refresh,onSelectHub:V.select,onConnect:te.showAndConnect,onDisconnected:te.show,connectionButtonRef:s,connecting:te.connecting,publication:ae.publication,publicationBusy:ae.busy,dirty:L?.stats.workingTree===`changed`,onPublish:()=>void ae.publish(),onRetryPublication:()=>void ae.retry(),publishPreference:ie,open:h,onClose:x}),e.improvementThreadsSample?(0,W.jsx)(H.Suspense,{fallback:(0,W.jsx)(`p`,{role:`status`,children:q.improvementNotesLoading}),children:(0,W.jsx)(xr,{})}):e.pickAndPolish?(0,W.jsx)(H.Suspense,{fallback:(0,W.jsx)(`p`,{className:`visually-hidden`,role:`status`,children:q.improvementNotesLoading}),children:(0,W.jsx)(br,{canvas:{token:e.token,frameRef:S,toolbarTarget:_,prototypeUrl:e.prototypeUrl,previewUrl:e.previewUrl,hubOpen:h,onOpenNotes:()=>g(!1),onNavigate:ee}})}):null,d&&F.connection&&I?(0,W.jsx)($e,{state:I,connection:F.connection,layout:p,onLayoutChange:m,diagnosisTarget:E,onDiagnose:()=>$(`/api/controls/diagnose`,e.token,{method:`POST`,body:JSON.stringify({status:I.status,runtimeAvailable:I.runtimeAvailable,reconnectRequired:I.reconnectRequired===!0,hasError:!!I.error||Un(I,I.loading,E).controls.some(e=>e.visible&&!!e.error),hasStorageError:!!I.storageError,previewUrl:E})})}):null]}),(0,W.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`visually-hidden`,children:R||ae.notice}),(0,W.jsx)(Me,{hub:V,connection:te,publication:ae,sharing:ne,shareIntent:re,controlSettings:G,readiness:oe,state:L,hubOpen:h,buildDetailsOpen:y,onCloseBuildDetails:()=>b(!1),shareButtonRef:a,hubButtonRef:o,connectionButtonRef:s,publishButtonRef:i,titleButtonRef:c})]})}var Cr=document.querySelector(`#root`);if(!Cr)throw Error(`Replica prototype renderer root is missing.`);(0,oe.createRoot)(Cr).render((0,W.jsx)(Sr,{config:window.__REPLICA_CANVAS__}));export{mn as a,Gt as c,ot as d,at as f,K as g,ce as h,yn as i,zt as l,tt as m,On as n,$ as o,it as p,xn as r,Kt as s,ar as t,xt as u}; \ No newline at end of file diff --git a/actions/build/action.yml b/actions/build/action.yml index 6a1dcc8e3..3a1043848 100644 --- a/actions/build/action.yml +++ b/actions/build/action.yml @@ -2,6 +2,10 @@ name: Replica build description: Build a Replica prototype and upload its package, with screenshots inline or in a later job inputs: + base-path: + description: Path where the compiled app is mounted during screenshot capture; configure the app's build base separately + required: false + default: / build-only: description: Build static output without packaging, uploading, or capturing screenshots; publish it with a later actions/build/publish step required: false @@ -110,7 +114,9 @@ runs: - name: Capture screenshots if: inputs.build-only != 'true' && inputs.screenshots == 'inline' - run: node "$GITHUB_ACTION_PATH/scripts/capture-screenshots/index.mjs" --root "$RUNNER_TEMP/replica-build-root" --config-root "$GITHUB_WORKSPACE" --screenshots "$RUNNER_TEMP/replica-screenshots" + env: + REPLICA_BASE_PATH: ${{ inputs.base-path }} + run: node "$GITHUB_ACTION_PATH/scripts/capture-screenshots/index.mjs" --root "$RUNNER_TEMP/replica-build-root" --config-root "$GITHUB_WORKSPACE" --screenshots "$RUNNER_TEMP/replica-screenshots" --base-path "$REPLICA_BASE_PATH" shell: bash - name: Create Replica package diff --git a/actions/build/screenshots/action.yml b/actions/build/screenshots/action.yml index eb1c49833..0481935e1 100644 --- a/actions/build/screenshots/action.yml +++ b/actions/build/screenshots/action.yml @@ -1,6 +1,12 @@ name: Replica screenshots description: Capture screenshots for a replica-build-v1 package uploaded earlier in the same workflow run +inputs: + base-path: + description: Original compiled app base path, including the owning repository and run when using Hub private previews + required: false + default: / + runs: using: composite steps: @@ -33,7 +39,9 @@ runs: shell: bash - name: Capture screenshots - run: node "$GITHUB_ACTION_PATH/../scripts/capture-screenshots/index.mjs" --root "$RUNNER_TEMP/replica-build-v1" --config-root "$RUNNER_TEMP/replica-build-v1" --config-file templates.json --screenshots "$RUNNER_TEMP/replica-screenshots" + env: + REPLICA_BASE_PATH: ${{ inputs.base-path }} + run: node "$GITHUB_ACTION_PATH/../scripts/capture-screenshots/index.mjs" --root "$RUNNER_TEMP/replica-build-v1" --config-root "$RUNNER_TEMP/replica-build-v1" --config-file templates.json --screenshots "$RUNNER_TEMP/replica-screenshots" --base-path "$REPLICA_BASE_PATH" shell: bash - name: Create Replica screenshot package diff --git a/actions/build/scripts/action-contract/index.test.mjs b/actions/build/scripts/action-contract/index.test.mjs index 5f6b2a488..0e844926f 100644 --- a/actions/build/scripts/action-contract/index.test.mjs +++ b/actions/build/scripts/action-contract/index.test.mjs @@ -88,6 +88,7 @@ appendFileSync(process.env.TRACE, JSON.stringify({ command: process.argv[1].spli REPLICA_BUILD_ONLY: inputs.buildOnly ?? "false", REPLICA_OUTPUT_DIRECTORY: inputs.outputDirectory, REPLICA_SCREENSHOTS: inputs.screenshots, + REPLICA_BASE_PATH: inputs.basePath ?? "/", }, }) } @@ -168,6 +169,8 @@ describe("Replica composite action", () => { workspace, "--screenshots", path.join(runner, "replica-screenshots"), + "--base-path", + "/", ]) assert.deepEqual(called("create-package").args.slice(1), [ "--root", diff --git a/actions/build/scripts/capture-screenshots/index.mjs b/actions/build/scripts/capture-screenshots/index.mjs index dff6c347c..d3cf7efc9 100644 --- a/actions/build/scripts/capture-screenshots/index.mjs +++ b/actions/build/scripts/capture-screenshots/index.mjs @@ -12,6 +12,7 @@ import { listenOnLoopback } from "../listen-on-loopback/index.mjs" import { readTemplates } from "../read-templates/index.mjs" import { requiredPathArgument } from "../required-path-argument/index.mjs" import { validateBuildOutput } from "../validate-build-output/index.mjs" +import { normalizeBasePath } from "../normalize-base-path/index.mjs" async function createCaptureProxy(allowedOrigin) { const proxy = createServer((incoming, response) => { @@ -49,7 +50,9 @@ export async function captureScreenshots( screenshots, configRoot = root, configFile = ".github/replica.json", + basePath = "/", ) { + const base = normalizeBasePath(basePath) await validateBuildOutput(root) const manifest = await readTemplates(configRoot, configFile) const controlsAdapter = await readFile( @@ -62,6 +65,7 @@ export async function captureScreenshots( const server = createStaticServer( path.join(root, "dist"), manifest?.templates.map((template) => template.path), + base, ) const port = await listenOnLoopback(server) const allowedOrigin = `http://127.0.0.1:${port}` @@ -74,7 +78,7 @@ export async function captureScreenshots( proxy: { server: captureProxy.address }, args: ["--proxy-bypass-list=<-loopback>"], }) - const adapterUrl = `${allowedOrigin}/__replica/capture-controls.js` + const adapterUrl = `${allowedOrigin}${base}__replica/capture-controls.js` const destinations = [ { path: START_ROUTE, directory: "" }, @@ -113,7 +117,7 @@ export async function captureScreenshots( } }) - let address = `${allowedOrigin}${destination.path}` + let address = `${allowedOrigin}${base}${destination.path.slice(1)}` for (let attempt = 0; ; attempt++) { if (attempt === 4) throw new Error("Controls URL defaults did not settle after navigation.") @@ -132,7 +136,10 @@ export async function captureScreenshots( return bindings?.takeNavigation() }) if (!navigation) break - if (new URL(navigation).origin !== allowedOrigin) + if ( + new URL(navigation).origin !== allowedOrigin || + !new URL(navigation).pathname.startsWith(base) + ) throw new Error("Controls URL defaults cannot leave the retained Build.") address = navigation } @@ -176,6 +183,9 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) { process.argv.includes("--config-file") ? requiredPathArgument("config-file", { resolve: false }) : undefined, + process.argv.includes("--base-path") + ? requiredPathArgument("base-path", { resolve: false }) + : undefined, ) console.log( "Captured light and dark desktop and narrow screenshots for the root page and declared templates.", diff --git a/actions/build/scripts/capture-screenshots/index.test.mjs b/actions/build/scripts/capture-screenshots/index.test.mjs index 9c55e8afe..efcf85d11 100644 --- a/actions/build/scripts/capture-screenshots/index.test.mjs +++ b/actions/build/scripts/capture-screenshots/index.test.mjs @@ -14,6 +14,66 @@ import { MAX_SCREENSHOT_HEIGHT } from "../constants.mjs" import { captureScreenshots } from "./index.mjs" describe("captureScreenshots()", () => { + it("boots a fixed-base app and its lazy module with Controls at root and a deep template", async () => { + const root = await temporaryDirectory() + const screenshots = await temporaryDirectory() + const base = "/previews/github/123/456/" + await mkdir(path.join(root, "dist")) + await mkdir(path.join(root, ".github")) + await writeFile( + path.join(root, "dist/index.html"), + ``, + ) + await writeFile( + path.join(root, "dist/app.js"), + `const base=${JSON.stringify(base)}; + const { ready } = await import(base+"lazy.js"); + const route = location.pathname.slice(base.length-1); + if (ready && (route === "/" || (route === "/build/agents/v2.0" && location.search === "?q=a%20b&q=second" && location.hash === "#details"))) + document.querySelector("input").addEventListener("input", event => document.body.style.background=event.target.value);`, + ) + await writeFile(path.join(root, "dist/lazy.js"), "export const ready=true") + await writeFile( + path.join(root, "dist/controls.replica.json"), + JSON.stringify({ + version: 1, + scope: "page", + controls: [ + { + id: "accent", + label: "Accent", + type: "color", + default: "#ff0000", + binding: { type: "field", selector: "#accent" }, + }, + ], + }), + ) + await writeFile( + path.join(root, ".github/replica.json"), + JSON.stringify({ + version: 1, + templates: [ + { + id: "agents", + name: "Agents", + category: "Build", + description: "Agent details.", + path: "/build/agents/v2.0?q=a%20b&q=second#details", + }, + ], + }), + ) + await captureScreenshots(root, screenshots, root, ".github/replica.json", base) + for (const directory of ["", "templates/agents"]) { + const image = pngjs.PNG.sync.read( + await readFile(path.join(screenshots, directory, "desktop.png")), + ) + const bottom = (image.height - 1) * image.width * 4 + assert.deepEqual([...image.data.subarray(bottom, bottom + 3)], [255, 0, 0], directory) + } + }) + it("blocks prototype WebSocket connections during capture", async () => { let connected = false const socketServer = createServer((socket) => { diff --git a/actions/build/scripts/create-static-server/index.mjs b/actions/build/scripts/create-static-server/index.mjs index d4055ad87..0aba204e3 100644 --- a/actions/build/scripts/create-static-server/index.mjs +++ b/actions/build/scripts/create-static-server/index.mjs @@ -4,16 +4,36 @@ import { createServer } from "node:http" import path from "node:path" import { CONTENT_TYPES } from "../constants.mjs" +import { normalizeBasePath } from "../normalize-base-path/index.mjs" /** Serves checked dist files and falls back to the app entry for browser routes. */ -export function createStaticServer(dist, templatePaths = []) { +export function createStaticServer(dist, templatePaths = [], basePath = "/") { + const base = normalizeBasePath(basePath) const templatePathnames = new Set( templatePaths.map((route) => decodeURIComponent(new URL(route, "http://localhost").pathname)), ) return createServer(async (request, response) => { try { - const requestPath = decodeURIComponent(new URL(request.url, "http://localhost").pathname) + const rawPath = request.url.split("?")[0] + const decoded = decodeURIComponent(rawPath) + if ( + /%2f|%5c/i.test(rawPath) || + /[\\%\p{Cc}]/u.test(decoded) || + decoded.split("/").some((part) => part === "." || part === "..") + ) { + response.writeHead(400).end() + return + } + if (base !== "/" && decoded === base.slice(0, -1)) { + response.writeHead(308, { Location: `${base}${request.url.slice(rawPath.length)}` }).end() + return + } + if (!decoded.startsWith(base)) { + response.writeHead(404).end() + return + } + const requestPath = `/${decoded.slice(base.length)}` const templateNavigation = templatePathnames.has(requestPath) const acceptsHtml = request.headers.accept?.includes("text/html") @@ -33,6 +53,17 @@ export function createStaticServer(dist, templatePaths = []) { let details try { details = await lstat(filePath) + if (details.isDirectory()) { + const index = path.join(filePath, "index.html") + const indexDetails = await lstat(index).catch((error) => { + if (!["ENOENT", "ENOTDIR"].includes(error.code)) throw error + return undefined + }) + if (indexDetails?.isFile()) { + filePath = index + details = indexDetails + } + } } catch (error) { if (!["ENOENT", "ENOTDIR", "ENAMETOOLONG"].includes(error.code)) { throw error diff --git a/actions/build/scripts/create-static-server/index.test.mjs b/actions/build/scripts/create-static-server/index.test.mjs index 29eb76c95..40ca3b814 100644 --- a/actions/build/scripts/create-static-server/index.test.mjs +++ b/actions/build/scripts/create-static-server/index.test.mjs @@ -11,6 +11,42 @@ import { listenOnLoopback } from "../listen-on-loopback/index.mjs" import { createStaticServer } from "./index.mjs" describe("createStaticServer()", () => { + it("serves only the compiled base with nested documents and logical template routes", async () => { + const dist = await temporaryDirectory() + const base = "/previews/github/123/456/" + await mkdir(path.join(dist, "docs")) + await writeFile( + path.join(dist, "index.html"), + '', + ) + await writeFile(path.join(dist, "docs/index.html"), "

Nested document

") + await writeFile(path.join(dist, "app.js"), "export const app = true") + const server = createStaticServer(dist, ["/release/v2.0?tab=notes#details"], base) + const port = await listenOnLoopback(server) + const origin = `http://127.0.0.1:${port}` + try { + const redirect = await fetch(`${origin}${base.slice(0, -1)}?tab=all`, { redirect: "manual" }) + assert.equal(redirect.status, 308) + assert.equal(redirect.headers.get("location"), `${base}?tab=all`) + const nested = await fetch(`${origin}${base}docs/`) + assert.equal(await nested.text(), "

Nested document

") + const route = await fetch(`${origin}${base}release/v2.0?tab=notes`, { + headers: { Accept: "text/html" }, + }) + assert.equal(route.status, 200) + assert.match(await route.text(), /src="\/previews\/github\/123\/456\/app.js"/) + assert.equal((await fetch(`${origin}${base}app.js`)).status, 200) + for (const path of ["/", "/app.js", `${base}missing.js`, "/previews/github/123/4567/app.js"]) + assert.equal( + (await fetch(`${origin}${path}`, { headers: { Accept: "text/html" } })).status, + 404, + path, + ) + } finally { + await closeServer(server) + } + }) + it("serves client-side browser routes but never replaces missing assets with HTML", async () => { const dist = await temporaryDirectory() await writeFile(path.join(dist, "index.html"), "

App

") diff --git a/actions/build/scripts/normalize-base-path/index.mjs b/actions/build/scripts/normalize-base-path/index.mjs new file mode 100644 index 000000000..71ddef7cf --- /dev/null +++ b/actions/build/scripts/normalize-base-path/index.mjs @@ -0,0 +1,17 @@ +export function normalizeBasePath(value = "/") { + if ( + typeof value !== "string" || + !value.startsWith("/") || + /[\s\\%?#\p{Cc}]/u.test(value) || + (value + .slice(1) + .replace(/\/$/, "") + .split("/") + .some((part) => [".", "..", ""].includes(part)) && + value !== "/") + ) + throw new Error( + "base-path must be a root-relative path without empty or encoded segments, query, or fragment.", + ) + return value.endsWith("/") ? value : `${value}/` +} diff --git a/hub/.env.example b/hub/.env.example index bd3b130e5..c8d92eb91 100644 --- a/hub/.env.example +++ b/hub/.env.example @@ -66,7 +66,8 @@ TEST_DATABASE_URL=postgresql://replica:replica@127.0.0.1:5432/postgres # Set these and at least one complete provider profile. `npm run env:init` generates the # encryption key and bootstrap secret without replacing existing values. # HUB_APPLICATION_ORIGIN=http://127.0.0.1:5173 -# Dedicated wildcard preview base. Build previews use .preview.localhost locally. +# Optional wildcard base for existing public shares only. +# Private GitHub previews use /previews/github/// without it. # HUB_PREVIEW_ORIGIN=http://preview.localhost:3001 # Hosted public sharing is off by default. It requires GitHub proof and Build previews. # HUB_HOSTED_PUBLIC_SHARING_ENABLED=false diff --git a/hub/.storybook/preview-fixtures/build-controls/controls.js b/hub/.storybook/preview-fixtures/build-controls/controls.js index 0e00ce8b9..265f47c03 100644 --- a/hub/.storybook/preview-fixtures/build-controls/controls.js +++ b/hub/.storybook/preview-fixtures/build-controls/controls.js @@ -1,4 +1,4 @@ (function(){var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))(o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=P;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return L.errors=a,o===0}e.number=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.slider=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return z.errors=a,l===0}e.choice=B;function B(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return B.errors=a,o===0}e.checkboxGroup=V;function V(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return V.errors=a,o===0}e.text=H;function H(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return H.errors=a,l===0}e.color=U;function U(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return U.errors=a,o===0}e.button=W;function W(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return W.errors=a,o===0}}))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` -`)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e,t){return JSON.stringify(e)===JSON.stringify(t)}function A(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function j(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function M(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function N(e){let t=e.binding;if(t.type===`api`){let e=M(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=j(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function z(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function B(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():z(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function V(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return N(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(A()).origin!==new URL(i).origin:A()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=A(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await B(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?A():a);if(!k(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${L(e).message}`)}throw!l&&k(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!k(await R(()=>I(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,A());t.rejection&&!k(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=A();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function j(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!k(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&k(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` -`).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function P(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,P);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>j(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return j(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await j(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function H(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return V(JSON.parse(t))}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var W=`replica:controls`;function G(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&U(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||U({[r.id]:r.value}))}catch{return!1}}function K(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var q=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function J(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!U(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!q.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function Y(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=q.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!U({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{J(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function X(e,t){let n=new URL(e,window.location.href),r=Y(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(J(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Z(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=J({...Y(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(X(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=Y(e);if(t.notice)throw Error(t.notice);s=J(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function ee(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var te={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ne(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?te.controlsActionUnavailable:``)}}function re(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>ne(e,t)))}}function ie(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=Z(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,ee(K(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await H(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(K);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:W,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(G(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:re(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!G(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!U(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!U(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var Q={enabled:!0,title:`Build preview`,items:3};function $(){let e=document.querySelector(`h1`),t=document.querySelector(`p`),n=document.querySelector(`ul`);if(!e||!t||!n)throw Error(`Build controls story markup is missing.`);e.textContent=Q.title,t.hidden=!Q.enabled,n.replaceChildren(...Array.from({length:Q.items},(e,t)=>{let n=document.createElement(`li`);return n.textContent=`Item ${t+1}`,n}))}Object.assign(window,{buildPreview:{readEnabled:()=>Q.enabled,writeEnabled:e=>{Q.enabled=e,$()},readTitle:()=>Q.title,writeTitle:e=>{Q.title=e,$()},readItems:()=>Q.items,writeItems:e=>{Q.items=e,$()},add:()=>{Q.items=Math.min(8,Q.items+1),$()}}}),$(),ie(window.location.origin)})(); \ No newline at end of file +`)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e){return/^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(e)?.[0]??`/`}function A(e,t){return JSON.stringify(e)===JSON.stringify(t)}function j(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function M(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function N(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function P(e){let t=e.binding;if(t.type===`api`){let e=N(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=M(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function F(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function I(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function L(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):F(e,t.value);if(n.type===`style`)return F(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):F(e,i)}function R(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function z(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw R(e)}finally{window.clearTimeout(n)}}function B(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function V(e,t,n){let r=e.binding;if(r.type===`api`){await z(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[I(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():B(t,`value`,I(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,I(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,I(n)):i.hash=`#${I(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function H(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${R(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(I(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return P(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(j()).origin!==new URL(i).origin:j()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await z(()=>L(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=j(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await V(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?j():a);if(!A(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=R(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${R(e).message}`)}throw!l&&A(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!A(await z(()=>L(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,j());t.rejection&&!A(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,R(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=j();t.control.binding.type===`api`?await z(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function k(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!A(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&A(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` +`).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=L(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>k(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return k(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await k(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function U(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return H(JSON.parse(n))}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var G=`replica:controls`;function K(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&W(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||W({[r.id]:r.value}))}catch{return!1}}function q(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var J=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function Y(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!W(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!J.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function X(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=J.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!W({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{Y(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function Z(e,t){let n=new URL(e,window.location.href),r=X(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(Y(r.scopes)))n.searchParams.set(e,t);return n.toString()}function ee(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=Y({...X(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(Z(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=X(e);if(t.notice)throw Error(t.notice);s=Y(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function te(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var ne={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function re(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?ne.controlsActionUnavailable:``)}}function ie(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>re(e,t)))}}function ae(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=ee(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,te(q(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await U(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(q);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:G,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(K(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:ie(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!K(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!W(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!W(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var Q={enabled:!0,title:`Build preview`,items:3};function $(){let e=document.querySelector(`h1`),t=document.querySelector(`p`),n=document.querySelector(`ul`);if(!e||!t||!n)throw Error(`Build controls story markup is missing.`);e.textContent=Q.title,t.hidden=!Q.enabled,n.replaceChildren(...Array.from({length:Q.items},(e,t)=>{let n=document.createElement(`li`);return n.textContent=`Item ${t+1}`,n}))}Object.assign(window,{buildPreview:{readEnabled:()=>Q.enabled,writeEnabled:e=>{Q.enabled=e,$()},readTitle:()=>Q.title,writeTitle:e=>{Q.title=e,$()},readItems:()=>Q.items,writeItems:e=>{Q.items=e,$()},add:()=>{Q.items=Math.min(8,Q.items+1),$()}}}),$(),ae(window.location.origin)})(); \ No newline at end of file diff --git a/hub/client/application/hub/routes/expanded-flows.test.tsx b/hub/client/application/hub/routes/expanded-flows.test.tsx index 304f575f2..7d9eed806 100644 --- a/hub/client/application/hub/routes/expanded-flows.test.tsx +++ b/hub/client/application/hub/routes/expanded-flows.test.tsx @@ -384,7 +384,8 @@ describe("Hub expanded frontend flows", () => { ) fireEvent.click(screen.getByRole("button", { name: "Choose build, v3" })) const menu = screen.getByRole("menu", { name: "Choose build" }) - expect(within(menu).getAllByRole("menuitem")).toHaveLength(2) + expect(within(menu).queryByRole("menuitem", { name: /v4/i })).not.toBeInTheDocument() + expect(within(menu).getByRole("menuitem", { name: /v5/i })).toBeVisible() const first = within(menu).getByRole("menuitem", { name: /v1/i }) expect(within(menu).getByRole("menuitem", { name: /v3/i })).toBeVisible() const firstLink = within(first).getByRole("link") diff --git a/hub/client/application/hub/routes/real-local-review-flow.test.tsx b/hub/client/application/hub/routes/real-local-review-flow.test.tsx index 703a62f83..460940844 100644 --- a/hub/client/application/hub/routes/real-local-review-flow.test.tsx +++ b/hub/client/application/hub/routes/real-local-review-flow.test.tsx @@ -126,12 +126,8 @@ describe("real local review flow", () => { const userId = "33333333-3333-4333-8333-333333333333" const prototypePath = `/repositories/${repositoryId}/prototypes/${prototypeId}` const reviewPath = `/api${prototypePath}/review-comments` - const previewOrigin = "https://build.preview.example.test" - const previewUrl = new URL( - `/api${prototypePath}/builds/3/access?target=preview`, - window.location.origin, - ) - previewUrl.searchParams.set("preview_origin", previewOrigin) + const previewOrigin = window.location.origin + const previewUrl = new URL("/previews/github/123/456/", window.location.origin) const repository = { id: repositoryId, nameWithOwner: "local/review-prototype", diff --git a/hub/client/application/hub/view-models/product-share-links-data/index.test.ts b/hub/client/application/hub/view-models/product-share-links-data/index.test.ts new file mode 100644 index 000000000..b1e17125d --- /dev/null +++ b/hub/client/application/hub/view-models/product-share-links-data/index.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, it } from "vitest" + +import { createMockStore } from "@application/hub/mocks/create-mock-store" + +import { productShareLinksData } from "." + +describe("productShareLinksData()", () => { + it("keeps existing share management available when a Build has no private preview mount", () => { + const origin = "http://localhost:3000" + const store = createMockStore({ origin }) + const response = store.product.getShareLinks("2001", "1") + if (!response.resource.selectedBuild) throw new Error("Expected a successful fixture Build.") + const number = response.resource.selectedBuild.number + response.resource.selectedBuild.previewUrl = null + for (const build of response.resource.prototype.builds) build.previewUrl = null + const page = productShareLinksData( + store.getWorkspace(), + response, + new URLSearchParams(), + origin, + ) + expect(page.managementBuildNumber).toBe(number) + expect(page.buildOptions.some((build) => build.number === number)).toBe(true) + expect(page.shareLinks.length).toBeGreaterThan(0) + }) +}) diff --git a/hub/client/application/hub/view-models/product-share-links-data/index.ts b/hub/client/application/hub/view-models/product-share-links-data/index.ts index b047df314..2e7c7172a 100644 --- a/hub/client/application/hub/view-models/product-share-links-data/index.ts +++ b/hub/client/application/hub/view-models/product-share-links-data/index.ts @@ -16,8 +16,7 @@ export function productShareLinksData( const { repository, prototype, selectedBuild } = resource const hosted = prototype.canManageShareLinks !== undefined const base = `/repositories/${repository.id}/prototypes/${prototype.id}` - const selected = - selectedBuild?.state === "successful" && selectedBuild.previewUrl ? selectedBuild : null + const selected = selectedBuild?.state === "successful" ? selectedBuild : null const now = Date.now() const active = response.links.filter( (link) => response.enabled && !link.revokedAt && Date.parse(link.expiresAt) > now, @@ -35,7 +34,7 @@ export function productShareLinksData( ? { newPrototypePath: resourcePath(`/repositories/${repository.id}/new`, search) } : {}), buildOptions: prototype.builds - .filter((build) => build.state === "successful" && build.previewUrl) + .filter((build) => build.state === "successful") .map((build) => ({ number: build.number, label: `v${build.number}`, diff --git a/hub/client/application/prototype-preview-bridge/index.test.ts b/hub/client/application/prototype-preview-bridge/index.test.ts index 15a5ecbe1..a7bb68a94 100644 --- a/hub/client/application/prototype-preview-bridge/index.test.ts +++ b/hub/client/application/prototype-preview-bridge/index.test.ts @@ -239,18 +239,22 @@ it("ignores another window even when it claims the registered parent origin", () expect(post).not.toHaveBeenCalled() }) -it("does not activate local canvas review on a Hub-served preview", () => { - document.body.innerHTML = '' - const post = vi.spyOn(window, "postMessage") - window.dispatchEvent( - new MessageEvent("message", { - origin: "http://127.0.0.1:1234", - source: window, - data: { type: "replica:canvas:request-ready", nonce: "hub-preview" }, - }), - ) - expect(post).not.toHaveBeenCalled() -}) +it.each(["/", "/previews/github/123/456/"])( + "leaves review ownership with the hosted bridge at %s", + (base) => { + window.history.replaceState({}, "", `${base}settings`) + document.body.innerHTML = `` + const post = vi.spyOn(window, "postMessage") + window.dispatchEvent( + new MessageEvent("message", { + origin: "http://127.0.0.1:1234", + source: window, + data: { type: "replica:canvas:request-ready", nonce: "hub-preview" }, + }), + ) + expect(post).not.toHaveBeenCalled() + }, +) it("places a marker only for a uniquely matched element from the local canvas", () => { document.body.innerHTML = diff --git a/hub/client/application/prototype-preview-bridge/index.ts b/hub/client/application/prototype-preview-bridge/index.ts index 0da8422f0..177ac2083 100644 --- a/hub/client/application/prototype-preview-bridge/index.ts +++ b/hub/client/application/prototype-preview-bridge/index.ts @@ -1,5 +1,6 @@ import { installControlsBridge } from "./controls" import { targetIssue } from "@utils/prototype-controls/dom-target.mjs" +import { getPreviewBasePath } from "@utils/prototype-controls/preview-base-path.mjs" type ReviewRoute = { pathname: string; search: string; hash: string } type AnchorRect = { x: number; y: number; width: number; height: number } @@ -98,7 +99,9 @@ function currentRoute(): ReviewRoute { }) .join("&") return { - pathname: window.location.pathname, + pathname: window.location.pathname.slice( + getPreviewBasePath(window.location.pathname).length - 1, + ), search: search ? `?${search}` : "", hash: window.location.hash, } @@ -729,7 +732,9 @@ function sendResolvedGeometry(documentScroll = false) { function receiveCanvasMessage(event: MessageEvent) { const data = event.data if ( - document.querySelector('script[src="/__replica/bridge/v1.js"]') || + document.querySelector( + `script[src="${getPreviewBasePath(window.location.pathname)}__replica/bridge/v1.js"]`, + ) || event.source !== window.parent || event.origin !== parentOrigin || !isRecord(data) || diff --git a/hub/client/features/install-replica-controls-bridge/bridge.js b/hub/client/features/install-replica-controls-bridge/bridge.js index 7c8f3620a..e1079a8aa 100644 --- a/hub/client/features/install-replica-controls-bridge/bridge.js +++ b/hub/client/features/install-replica-controls-bridge/bridge.js @@ -1,4 +1,4 @@ (function(){var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))(o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=P;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return L.errors=a,o===0}e.number=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.slider=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return z.errors=a,l===0}e.choice=B;function B(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return B.errors=a,o===0}e.checkboxGroup=V;function V(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return V.errors=a,o===0}e.text=H;function H(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return H.errors=a,l===0}e.color=U;function U(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return U.errors=a,o===0}e.button=W;function W(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return W.errors=a,o===0}}))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` -`)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e,t){return JSON.stringify(e)===JSON.stringify(t)}function A(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function j(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function M(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function N(e){let t=e.binding;if(t.type===`api`){let e=M(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=j(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function z(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function B(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():z(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function V(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return N(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(A()).origin!==new URL(i).origin:A()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=A(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await B(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?A():a);if(!k(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${L(e).message}`)}throw!l&&k(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!k(await R(()=>I(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,A());t.rejection&&!k(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=A();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function j(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!k(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&k(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` -`).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function P(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,P);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>j(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return j(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await j(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function H(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return V(JSON.parse(t))}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var W=`replica:controls`;function G(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&U(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||U({[r.id]:r.value}))}catch{return!1}}function K(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var q=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function J(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!U(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!q.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function Y(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=q.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!U({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{J(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function X(e,t){let n=new URL(e,window.location.href),r=Y(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(J(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Z(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=J({...Y(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(X(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=Y(e);if(t.notice)throw Error(t.notice);s=J(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function Q(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var $={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ee(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?$.controlsActionUnavailable:``)}}function te(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>ee(e,t)))}}function ne(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=Z(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,Q(K(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await H(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(K);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:W,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(G(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:te(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!G(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!U(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!U(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}ne(`__REPLICA_CONTROLS_PARENT_ORIGIN__`)})(); \ No newline at end of file +`)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e){return/^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(e)?.[0]??`/`}function A(e,t){return JSON.stringify(e)===JSON.stringify(t)}function j(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function M(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function N(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function P(e){let t=e.binding;if(t.type===`api`){let e=N(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=M(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function F(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function I(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function L(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):F(e,t.value);if(n.type===`style`)return F(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):F(e,i)}function R(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function z(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw R(e)}finally{window.clearTimeout(n)}}function B(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function V(e,t,n){let r=e.binding;if(r.type===`api`){await z(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[I(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():B(t,`value`,I(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,I(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,I(n)):i.hash=`#${I(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function H(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${R(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(I(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return P(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(j()).origin!==new URL(i).origin:j()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await z(()=>L(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=j(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await V(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?j():a);if(!A(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=R(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${R(e).message}`)}throw!l&&A(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!A(await z(()=>L(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,j());t.rejection&&!A(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,R(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=j();t.control.binding.type===`api`?await z(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function k(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!A(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&A(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` +`).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=L(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>k(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return k(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await k(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function U(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return H(JSON.parse(n))}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var G=`replica:controls`;function K(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&W(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||W({[r.id]:r.value}))}catch{return!1}}function q(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var J=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function Y(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!W(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!J.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function X(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=J.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!W({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{Y(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function Z(e,t){let n=new URL(e,window.location.href),r=X(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(Y(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Q(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=Y({...X(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(Z(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=X(e);if(t.notice)throw Error(t.notice);s=Y(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function $(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var ee={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function te(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?ee.controlsActionUnavailable:``)}}function ne(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>te(e,t)))}}function re(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=Q(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,$(q(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await U(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(q);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:G,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(K(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:ne(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!K(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!W(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!W(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}re(`__REPLICA_CONTROLS_PARENT_ORIGIN__`)})(); \ No newline at end of file diff --git a/hub/client/features/install-replica-preview-bridge/create-preview-bridge-test-harness/index.ts b/hub/client/features/install-replica-preview-bridge/create-preview-bridge-test-harness/index.ts index cb8964b0f..dbc8932c4 100644 --- a/hub/client/features/install-replica-preview-bridge/create-preview-bridge-test-harness/index.ts +++ b/hub/client/features/install-replica-preview-bridge/create-preview-bridge-test-harness/index.ts @@ -15,12 +15,12 @@ export function createPreviewBridgeTestHarness() { const windows: JSDOM[] = [] const animationFrameTimers = new Map>() - function bridgeWindow({ reviewEnabled = true } = {}) { + function bridgeWindow({ reviewEnabled = true, url = PREVIEW_ORIGIN } = {}) { const parent = new JSDOM("", { url: HUB_ORIGIN }) const preview = new JSDOM("", { pretendToBeVisual: true, runScripts: "outside-only", - url: PREVIEW_ORIGIN, + url, }) windows.push(parent, preview) Object.defineProperty(preview.window, "parent", { value: parent.window }) diff --git a/hub/client/features/install-replica-preview-bridge/index.js b/hub/client/features/install-replica-preview-bridge/index.js index f67a03224..5f1f21773 100644 --- a/hub/client/features/install-replica-preview-bridge/index.js +++ b/hub/client/features/install-replica-preview-bridge/index.js @@ -29,6 +29,14 @@ const BRIDGE_NODE_ATTRIBUTE = "data-replica-bridge" const textEncoder = new TextEncoder() const nativeReplaceState = History.prototype.replaceState + const previewBase = + /^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(location.pathname)?.[0] ?? "/" + + function logicalPathname() { + return location.pathname.startsWith(previewBase) + ? location.pathname.slice(previewBase.length - 1) + : location.pathname + } let selectionMode = null let selectionRequestId = null @@ -304,7 +312,7 @@ function currentRoute() { return { - pathname: truncate(location.pathname, PATHNAME_MAXIMUM_BYTES), + pathname: truncate(logicalPathname(), PATHNAME_MAXIMUM_BYTES), search: truncate(controlFreeSearch(), SEARCH_MAXIMUM_BYTES), hash: truncate(location.hash, HASH_MAXIMUM_BYTES), } @@ -1462,7 +1470,7 @@ function clearPendingFragmentOnNavigation() { if ( pendingFragmentRoute && - (pendingFragmentRoute.pathname !== location.pathname || + (pendingFragmentRoute.pathname !== logicalPathname() || pendingFragmentRoute.search !== controlFreeSearch() || pendingFragmentRoute.hash !== location.hash) ) { @@ -1487,7 +1495,7 @@ fragmentRestoreToken = token pendingFragmentRoute = null const matchesDocument = () => - route.pathname === location.pathname && route.search === controlFreeSearch() + route.pathname === logicalPathname() && route.search === controlFreeSearch() if (!matchesDocument()) return const acknowledge = () => { diff --git a/hub/client/features/install-replica-preview-bridge/index.test.ts b/hub/client/features/install-replica-preview-bridge/index.test.ts index 5878809c7..07537b0da 100644 --- a/hub/client/features/install-replica-preview-bridge/index.test.ts +++ b/hub/client/features/install-replica-preview-bridge/index.test.ts @@ -11,6 +11,52 @@ const { anchor, areaAnchor, bridgeWindow, dispatchMessage, message, postedMessag beforeEach(() => onTestFinished(harness.close)) describe("installReplicaPreviewBridge()", () => { + it("matches root-relative anchors across owning-run mounts and restores their fragment", async () => { + for (const run of [456, 789]) { + const { parent, preview, postMessage } = bridgeWindow({ + url: `http://replica.localhost:19500/previews/github/123/${run}/settings?tab=a%20b&rc=1#details`, + }) + preview.document.body.innerHTML = + '

Details

' + const scroll = vi.fn() + preview.document.querySelector("#details")!.scrollIntoView = scroll + dispatchMessage(preview, parent, message("replica:bridge:request-ready")) + expect(postedMessages(postMessage).at(-1)).toMatchObject({ + payload: { route: { pathname: "/settings", search: "?tab=a%20b", hash: "#details" } }, + }) + dispatchMessage( + preview, + parent, + message("replica:bridge:resolve-anchors", { + replace: true, + anchors: [ + { + commentId: 1, + originBuild: false, + anchor: anchor({ + route: { pathname: "/settings", search: "?tab=a%20b", hash: "#details" }, + }), + }, + ], + }), + ) + await renderFrames(preview) + expect(postedMessages(postMessage).at(-1)).toMatchObject({ + payload: { results: [{ commentId: 1, status: "moved" }] }, + }) + dispatchMessage( + preview, + parent, + message("replica:bridge:restore-fragment", { + route: { pathname: "/settings", search: "?tab=a%20b", hash: "#details" }, + }), + ) + await renderFrames(preview) + expect(scroll).toHaveBeenCalled() + expect(preview.location.pathname).toBe(`/previews/github/123/${run}/settings`) + } + }) + it.each(["static", "fixed", "sticky"])( "keeps a pin attached during document scrolling with a %s ancestor", async (position) => { diff --git a/hub/client/features/prototype-canvas-improvement-notes/index.tsx b/hub/client/features/prototype-canvas-improvement-notes/index.tsx index 7a7173f8c..35acb63bf 100644 --- a/hub/client/features/prototype-canvas-improvement-notes/index.tsx +++ b/hub/client/features/prototype-canvas-improvement-notes/index.tsx @@ -7,6 +7,7 @@ import { HubCounter } from "@components/hub-counter" import { CanvasDialog } from "@components/prototype-canvas-dialog" import { ImprovementThreads } from "@features/prototype-canvas-improvement-threads" import type { ReviewAnchor } from "@utils/review-anchor/types" +import { getPreviewBasePath } from "@utils/prototype-controls/preview-base-path.mjs" import { copy } from "./en" import { improvementThreadView } from "./thread-view" import { usePreviewSelection } from "./use-preview-selection" @@ -194,7 +195,12 @@ export function ImprovementNotesPrototype({ canvas }: Props) { onSelect={(id) => { const note = notes.find((item) => item.id === id) if (note && note.route !== route) - canvas.onNavigate(new URL(note.route, canvas.prototypeUrl).href) + canvas.onNavigate( + new URL( + `${getPreviewBasePath(new URL(canvas.prototypeUrl).pathname)}${note.route.slice(1)}`, + canvas.prototypeUrl, + ).href, + ) }} onFollowUp={(thread, body) => saved.change("follow-up", { diff --git a/hub/client/hooks/use-canvas-preview-navigation/index.test.tsx b/hub/client/hooks/use-canvas-preview-navigation/index.test.tsx index f1446868d..bb322e794 100644 --- a/hub/client/hooks/use-canvas-preview-navigation/index.test.tsx +++ b/hub/client/hooks/use-canvas-preview-navigation/index.test.tsx @@ -21,6 +21,27 @@ function mount() { } describe("usePreviewNavigation()", () => { + it("reapplies the immutable mount to logical routes and history travel", () => { + const base = "http://localhost:4321/previews/github/123/456/" + const { result } = renderHook(() => + usePreviewNavigation({ + prototypeUrl: base, + shellRef: createRef(), + cancelClick: createRef<(() => void) | null>(), + }), + ) + act(() => + result.current.initialize({ ...publicationHub, localStartPage: "/settings?q=a%20b#details" }), + ) + expect(result.current.address).toBe(`${base}settings?q=a%20b#details`) + act(() => + result.current.reportRoute({ pathname: "/agents", search: "?q=one&q=two", hash: "#draft" }), + ) + expect(result.current.address).toBe(`${base}agents?q=one&q=two#draft`) + act(() => result.current.travel(0)) + expect(result.current.source).toBe(`${base}settings?q=a%20b#details`) + }) + it("keeps invalid URL overrides available for diagnosis without breaking route reporting", () => { const { result } = mount() act(() => diff --git a/hub/client/hooks/use-canvas-preview-navigation/index.ts b/hub/client/hooks/use-canvas-preview-navigation/index.ts index 2f6dddbfa..e89a8bb14 100644 --- a/hub/client/hooks/use-canvas-preview-navigation/index.ts +++ b/hub/client/hooks/use-canvas-preview-navigation/index.ts @@ -2,6 +2,7 @@ import { createRef, useCallback, useEffect, useRef, useState, type RefObject } f import { copy } from "@utils/prototype-canvas/en" import type { HubStatus } from "@utils/prototype-canvas/types" +import { getPreviewBasePath } from "@utils/prototype-controls/preview-base-path.mjs" import type { PendingPreviewClick, PreviewNavigation, PreviewRoute } from "./types" type Props = { @@ -56,10 +57,12 @@ export function usePreviewNavigation({ prototypeUrl, previewUrl, shellRef, cance status.state === "connected" && (status.prototype?.startPageSet ?? status.prototype?.startPage !== undefined) const startPage = ownsStartPage ? status.prototype?.startPage : status.localStartPage - if (url.pathname !== "/" || url.search || url.hash || !startPage) return + const base = getPreviewBasePath(url.pathname) + if (url.pathname !== base || url.search || url.hash || !startPage) return const destination = new URL(startPage, url) if (destination.origin !== url.origin) throw new Error(copy.startPageOrigin) + destination.pathname = `${base}${destination.pathname.slice(1)}` setPreview({ input: prototypeUrl, url: destination.href }) setNavigation({ input: prototypeUrl, entries: [destination.href], index: 0 }) @@ -106,7 +109,7 @@ export function usePreviewNavigation({ prototypeUrl, previewUrl, shellRef, cance (route: PreviewRoute, replace = false) => { setLiveRoute(route) const url = new URL(prototypeUrl) - url.pathname = route.pathname + url.pathname = `${getPreviewBasePath(url.pathname)}${route.pathname.slice(1)}` url.search = route.search url.hash = route.hash setNavigation((current) => { diff --git a/hub/client/hooks/use-preview-bridge/index.ts b/hub/client/hooks/use-preview-bridge/index.ts index b4815cbb9..322307504 100644 --- a/hub/client/hooks/use-preview-bridge/index.ts +++ b/hub/client/hooks/use-preview-bridge/index.ts @@ -3,6 +3,7 @@ import { useCallback, useEffect, useRef, useState } from "react" import { chunkArray } from "@utils/chunk-array" import { getPreviewFrameUrl } from "@utils/get-preview-frame-url" import { getUrlOrigin } from "@utils/get-url-origin" +import { getPreviewBasePath } from "@utils/prototype-controls/preview-base-path.mjs" import { PREVIEW_BRIDGE_ANCHORS_PER_MESSAGE, PREVIEW_BRIDGE_PROTOCOL_VERSION, @@ -220,13 +221,16 @@ export function usePreviewBridge({ restoration.pending = false } else if (restoration?.previewUrl !== previewUrl) { const destination = new URL(previewUrl) + const pathname = destination.pathname.slice( + getPreviewBasePath(destination.pathname).length - 1, + ) if ( - message.payload.route.pathname === destination.pathname && + message.payload.route.pathname === pathname && message.payload.route.search === destination.search ) { const requestId = post("replica:bridge:restore-fragment", { route: { - pathname: destination.pathname, + pathname, search: destination.search, hash: destination.hash, }, diff --git a/hub/client/hooks/use-prototype-viewer-url/index.ts b/hub/client/hooks/use-prototype-viewer-url/index.ts index 22d6344b0..db88e6b71 100644 --- a/hub/client/hooks/use-prototype-viewer-url/index.ts +++ b/hub/client/hooks/use-prototype-viewer-url/index.ts @@ -2,6 +2,7 @@ import { useEffect, useState } from "react" import type { ReviewRoute } from "@utils/review-anchor/types" import { controlsUrlEvent } from "@utils/prototype-controls-url/constants" +import { getPreviewBasePath } from "@utils/prototype-controls/preview-base-path.mjs" export function usePrototypeViewerUrl({ selectedBuild, @@ -54,7 +55,9 @@ export function usePrototypeViewerUrl({ : null const destination = route ? `${route.pathname}${route.search}${route.hash}` - : (initialRoute ?? previousPath ?? `${preview.pathname}${preview.search}${preview.hash}`) + : (initialRoute ?? + previousPath ?? + `${preview.pathname.slice(getPreviewBasePath(preview.pathname).length - 1)}${preview.search}${preview.hash}`) url.searchParams.set("return_path", destination) if (minimized) url.searchParams.set("view", "minimized") else url.searchParams.delete("view") diff --git a/hub/client/pages/prototypes-show-page/index.test.tsx b/hub/client/pages/prototypes-show-page/index.test.tsx index b3486bec8..c867048b8 100644 --- a/hub/client/pages/prototypes-show-page/index.test.tsx +++ b/hub/client/pages/prototypes-show-page/index.test.tsx @@ -1291,36 +1291,30 @@ describe("PrototypesShowPage()", () => { expect(document.querySelector("iframe")).toHaveAttribute("src", build.previewUrl) }) - it("shows a Build-origin route while keeping deep links on the authorization flow", () => { + it("copies the current canonical Build route without dropping its immutable prefix", () => { const writeText = vi.fn().mockResolvedValue(undefined) vi.stubGlobal("navigator", { ...navigator, clipboard: { writeText } }) - const build = PROTOTYPES_SHOW_PAGE_DATA.selectedBuild - if (!build) throw new Error("Expected successful fixture Build") - const authorizationUrl = new URL( - "/api/repositories/repository/prototypes/prototype/builds/2/access", - window.location.origin, - ) - authorizationUrl.searchParams.set("target", "preview") - authorizationUrl.searchParams.set("preview_origin", "http://build-id.preview.localhost:3001") - BRIDGE.route = { - pathname: "/checkout", - search: "?step=shipping", - hash: "#address", - } - + const base = `${window.location.origin}/previews/github/123/456/` + BRIDGE.route = { pathname: "/checkout", search: "?q=a%20b&q=second", hash: "#address" } render( - + , ) - - expect(screen.getByRole("textbox", { name: "Preview URL" })).toHaveValue( - "http://build-id.preview.localhost:3001/checkout?step=shipping#address", - ) + const address = `${base}checkout?q=a%20b&q=second#address` + expect(screen.getByRole("textbox", { name: "Preview URL" })).toHaveValue(address) fireEvent.click(screen.getByRole("button", { name: "Copy preview URL" })) - const externalUrl = new URL(String(writeText.mock.calls.at(-1)![0]), window.location.origin) - expect(externalUrl.pathname).toContain("/builds/2/access") - expect(externalUrl.searchParams.get("route")).toBe("/checkout?step=shipping#address") + expect(writeText).toHaveBeenLastCalledWith(address) + expect(document.querySelector("iframe")).toHaveAttribute("src", base) + expect(new URL(window.location.href).searchParams.get("return_path")).toBe( + "/checkout?q=a%20b&q=second#address", + ) }) it("copies the current route inside a Hub link without reloading the preview", () => { diff --git a/hub/client/pages/prototypes-show-page/index.tsx b/hub/client/pages/prototypes-show-page/index.tsx index dbc9e8188..4a92c0916 100644 --- a/hub/client/pages/prototypes-show-page/index.tsx +++ b/hub/client/pages/prototypes-show-page/index.tsx @@ -19,6 +19,7 @@ import { ReviewThreadConversation } from "@features/review-thread-conversation" import { useCopilotHandoff } from "@hooks/use-copilot-handoff" import { createPrototypeSubmission } from "@utils/create-prototype-submission" import { createPreviewPrototypePrompt } from "@utils/create-preview-prototype-prompt" +import { getPreviewBasePath } from "@utils/prototype-controls/preview-base-path.mjs" import { PrototypeDescriptionDialog } from "./prototype-description-dialog" import type { PrototypePreviewOnlyPageProps, PrototypesShowPageProps } from "./types" @@ -103,31 +104,16 @@ export function PrototypesShowPage(props: PrototypesShowPageProps | PrototypePre let address = data.selectedBuild?.previewUrl ?? "" let externalAddress = address - let isolatedPreview = false + const directPreview = Boolean(address && getPreviewBasePath(new URL(address).pathname) !== "/") if (address && bridge.route) { const authorizationUrl = new URL(address) - const previewOrigin = authorizationUrl.searchParams.get("preview_origin") - if (previewOrigin) { - isolatedPreview = true - const viewerUrl = new URL(previewOrigin) - viewerUrl.pathname = bridge.route.pathname - viewerUrl.search = bridge.route.search - viewerUrl.hash = bridge.route.hash - address = viewerUrl.toString() - authorizationUrl.searchParams.set( - "route", - `${bridge.route.pathname}${bridge.route.search}${bridge.route.hash}`, - ) - externalAddress = authorizationUrl.toString() - } else { - authorizationUrl.pathname = bridge.route.pathname - authorizationUrl.search = bridge.route.search - authorizationUrl.hash = bridge.route.hash - address = authorizationUrl.toString() - externalAddress = address - } + authorizationUrl.pathname = `${getPreviewBasePath(authorizationUrl.pathname)}${bridge.route.pathname.slice(1)}` + authorizationUrl.search = bridge.route.search + authorizationUrl.hash = bridge.route.hash + address = authorizationUrl.toString() + externalAddress = address } - if (!isolatedPreview) { + if (!directPreview) { address = viewerUrl ?? address externalAddress = viewerUrl ?? externalAddress } diff --git a/hub/client/pages/replica-browse-page/index.test.tsx b/hub/client/pages/replica-browse-page/index.test.tsx index f867f1d46..cbc18825d 100644 --- a/hub/client/pages/replica-browse-page/index.test.tsx +++ b/hub/client/pages/replica-browse-page/index.test.tsx @@ -22,6 +22,20 @@ function renderPage(overrides: Partial = {}) { } describe("ReplicaBrowsePage()", () => { + it("keeps a direct template address under its owning-run mount after navigation", () => { + const base = `${window.location.origin}/previews/github/123/456/` + renderPage({ + data: { + ...replicaBrowseData, + selectedBuild: { number: 1, frameTitle: "Template preview", previewUrl: base }, + }, + route: { pathname: "/settings", search: "?q=a%20b", hash: "#details" }, + }) + expect(screen.getByRole("textbox", { name: replicaBrowseData.previewUrlLabel })).toHaveValue( + `${base}settings?q=a%20b#details`, + ) + }) + it("matches the browse payload without prototype-only metadata", () => { expect(replicaBrowseData).not.toHaveProperty("author") expect(replicaBrowseData).not.toHaveProperty("buildOptions") diff --git a/hub/client/pages/replica-browse-page/index.tsx b/hub/client/pages/replica-browse-page/index.tsx index 3d2f7fcb0..014e7bd8c 100644 --- a/hub/client/pages/replica-browse-page/index.tsx +++ b/hub/client/pages/replica-browse-page/index.tsx @@ -15,6 +15,7 @@ import { PrototypeWorkspace } from "@features/prototype-workspace" import { useCopilotHandoff } from "@hooks/use-copilot-handoff" import { createPrototypeSubmission } from "@utils/create-prototype-submission" import { createPreviewPrototypePrompt } from "@utils/create-preview-prototype-prompt" +import { getPreviewBasePath } from "@utils/prototype-controls/preview-base-path.mjs" import type { ReplicaBrowsePageProps } from "./types" @@ -82,7 +83,7 @@ export function ReplicaBrowsePage({ let address = data.selectedBuild?.previewUrl ?? "" if (address && route) { const url = new URL(address) - url.pathname = route.pathname + url.pathname = `${getPreviewBasePath(url.pathname)}${route.pathname.slice(1)}` url.search = route.search url.hash = route.hash address = url.toString() diff --git a/hub/client/utils/create-preview-prototype-prompt/index.ts b/hub/client/utils/create-preview-prototype-prompt/index.ts index dc26c2642..cc9670356 100644 --- a/hub/client/utils/create-preview-prototype-prompt/index.ts +++ b/hub/client/utils/create-preview-prototype-prompt/index.ts @@ -1,4 +1,5 @@ import type { ReviewRoute } from "@utils/review-anchor/types" +import { getPreviewBasePath } from "@utils/prototype-controls/preview-base-path.mjs" const URI_PATH = /^(?:[a-z0-9._~!$&'()*+,;=:@/-]|%[0-9a-f]{2})*$/i const URI_FRAGMENT = /^(?:[a-z0-9._~!$&'()*+,;=:@/?-]|%[0-9a-f]{2})*$/i @@ -25,7 +26,9 @@ export function createPreviewPrototypePrompt({ if (previewUrl) { try { const url = new URL(previewUrl) - const startingRoute = initialRoute ?? `${url.pathname}${url.search}${url.hash}` + const startingRoute = + initialRoute ?? + `${url.pathname.slice(getPreviewBasePath(url.pathname).length - 1)}${url.search}${url.hash}` const reportedRoute = route ? `${route.pathname}${route.search}${route.hash}` : startingRoute const viewedRoute = initialRoute !== undefined || templateLandingPageInstructions diff --git a/hub/client/utils/get-url-origin/index.test.ts b/hub/client/utils/get-url-origin/index.test.ts index 3fc3124e6..7951d0eb1 100644 --- a/hub/client/utils/get-url-origin/index.test.ts +++ b/hub/client/utils/get-url-origin/index.test.ts @@ -3,26 +3,13 @@ import { describe, expect, it } from "vitest" import { getUrlOrigin } from "." describe("getUrlOrigin()", () => { - it("uses the authorized Build origin for Hub access URLs", () => { - const url = new URL( - "https://hub.example.test/api/repositories/repository/prototypes/prototype/builds/7/access", - ) - url.searchParams.set("target", "preview") - url.searchParams.set( - "preview_origin", - "https://00000000-0000-4000-8000-000000000007.preview.example.test", - ) - - expect(getUrlOrigin(url.toString())).toBe( - "https://00000000-0000-4000-8000-000000000007.preview.example.test", - ) + it("uses the Hub origin for canonical preview URLs", () => { + const url = new URL("https://hub.example.test/previews/github/123/456/settings?q=one#details") + expect(getUrlOrigin(url.toString())).toBe("https://hub.example.test") }) - it("does not accept an embedded origin on unrelated URLs", () => { - expect( - getUrlOrigin( - "https://untrusted.example.test/page?preview_origin=https://preview.example.test", - ), - ).toBe("https://untrusted.example.test") + it("rejects missing and malformed addresses", () => { + expect(getUrlOrigin(undefined)).toBeNull() + expect(getUrlOrigin("not a URL")).toBeNull() }) }) diff --git a/hub/client/utils/get-url-origin/index.ts b/hub/client/utils/get-url-origin/index.ts index b29f3bf99..5ed623f0f 100644 --- a/hub/client/utils/get-url-origin/index.ts +++ b/hub/client/utils/get-url-origin/index.ts @@ -2,27 +2,7 @@ export function getUrlOrigin(url: string | undefined) { if (!url) return null try { - const parsed = new URL(url) - if ( - /^\/api\/repositories\/[^/]+\/(?:prototypes\/[^/]+\/builds\/\d+|template-builds\/[^/]+)\/access$/.test( - parsed.pathname, - ) - ) { - const previewOrigin = parsed.searchParams.get("preview_origin") - if (previewOrigin) { - const preview = new URL(previewOrigin) - if ( - preview.origin === previewOrigin && - preview.pathname === "/" && - !preview.search && - !preview.hash && - ["http:", "https:"].includes(preview.protocol) - ) { - return preview.origin - } - } - } - return parsed.origin + return new URL(url).origin } catch { return null } diff --git a/hub/client/utils/prototype-controls/bindings.d.mts b/hub/client/utils/prototype-controls/bindings.d.mts index 76e4e67a7..7132d1eb7 100644 --- a/hub/client/utils/prototype-controls/bindings.d.mts +++ b/hub/client/utils/prototype-controls/bindings.d.mts @@ -22,4 +22,4 @@ export type Bindings = { dispose(): void } export function installBindings(input: unknown): Bindings -export function loadBindings(): Promise +export function loadBindings(basePath?: string): Promise diff --git a/hub/client/utils/prototype-controls/bindings.mjs b/hub/client/utils/prototype-controls/bindings.mjs index 4fa4ba2f5..7bb3fb669 100644 --- a/hub/client/utils/prototype-controls/bindings.mjs +++ b/hub/client/utils/prototype-controls/bindings.mjs @@ -6,6 +6,7 @@ import { } from "./controls.mjs" import { targetIssue } from "./dom-target.mjs" import { controlOrder } from "./controls-validation.mjs" +import { getPreviewBasePath } from "./preview-base-path.mjs" export const CONTROLS_DOCUMENT_BYTES = 256_000 @@ -642,8 +643,8 @@ export function installBindings(input) { } /** Reads only this page's static definitions; ordinary apps can omit the document. */ -export async function loadBindings() { - const response = await fetch("/controls.replica.json", { +export async function loadBindings(basePath = getPreviewBasePath(window.location.pathname)) { + const response = await fetch(`${basePath}controls.replica.json`, { credentials: "same-origin", redirect: "error", }) diff --git a/hub/client/utils/prototype-controls/browser-entry.mjs b/hub/client/utils/prototype-controls/browser-entry.mjs index 1d897b0aa..75d7d5120 100644 --- a/hub/client/utils/prototype-controls/browser-entry.mjs +++ b/hub/client/utils/prototype-controls/browser-entry.mjs @@ -1,8 +1,14 @@ import { loadBindings } from "./bindings.mjs" +const scriptPath = document.currentScript?.src +const capturePath = scriptPath ? new URL(scriptPath).pathname : "" +const basePath = capturePath.endsWith("/__replica/capture-controls.js") + ? capturePath.slice(0, -"__replica/capture-controls.js".length) + : undefined + // Screenshot capture waits for the same adapter used by the interactive hosts. globalThis.ReplicaControls = { - ready: loadBindings().then(async (bindings) => { + ready: loadBindings(basePath).then(async (bindings) => { await bindings?.settled() const errors = (bindings?.runtime.list() ?? []).flatMap((controller) => { const states = controller.getSnapshot().bindings ?? {} diff --git a/hub/client/utils/prototype-controls/browser.js b/hub/client/utils/prototype-controls/browser.js index ee5d6c23a..6c13ff575 100644 --- a/hub/client/utils/prototype-controls/browser.js +++ b/hub/client/utils/prototype-controls/browser.js @@ -1,4 +1,4 @@ (function(){var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))(o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=P;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return L.errors=a,o===0}e.number=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.slider=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return z.errors=a,l===0}e.choice=B;function B(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return B.errors=a,o===0}e.checkboxGroup=V;function V(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return V.errors=a,o===0}e.text=H;function H(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return H.errors=a,l===0}e.color=U;function U(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return U.errors=a,o===0}e.button=W;function W(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return W.errors=a,o===0}}))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` -`)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e,t){return JSON.stringify(e)===JSON.stringify(t)}function A(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function j(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function M(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function N(e){let t=e.binding;if(t.type===`api`){let e=M(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=j(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function z(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function B(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():z(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function V(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return N(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(A()).origin!==new URL(i).origin:A()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=A(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await B(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?A():a);if(!k(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${L(e).message}`)}throw!l&&k(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!k(await R(()=>I(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,A());t.rejection&&!k(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=A();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function j(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!k(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&k(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` -`).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function P(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,P);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>j(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return j(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await j(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,P);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function H(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(t)))return V(JSON.parse(t))}globalThis.ReplicaControls={ready:H().then(async e=>{await e?.settled();let t=(e?.runtime.list()??[]).flatMap(e=>{let t=e.getSnapshot().bindings??{};return e.declaration.controls.filter(e=>e.type!==`button`&&t[e.id]?.error).map(n=>`${e.declaration.scope}.${n.id}: ${t[n.id].error}`)});if(t.length)throw Error(`Controls defaults could not be applied: ${t.join(`; `)}`);return e})}})(); \ No newline at end of file +`)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e){return/^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(e)?.[0]??`/`}function A(e,t){return JSON.stringify(e)===JSON.stringify(t)}function j(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function M(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function N(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function P(e){let t=e.binding;if(t.type===`api`){let e=N(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=M(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function F(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function I(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function L(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):F(e,t.value);if(n.type===`style`)return F(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):F(e,i)}function R(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function z(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw R(e)}finally{window.clearTimeout(n)}}function B(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function V(e,t,n){let r=e.binding;if(r.type===`api`){await z(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[I(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():B(t,`value`,I(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,I(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,I(n)):i.hash=`#${I(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function H(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${R(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(I(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return P(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(j()).origin!==new URL(i).origin:j()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await z(()=>L(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=j(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await V(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?j():a);if(!A(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=R(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${R(e).message}`)}throw!l&&A(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!A(await z(()=>L(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,j());t.rejection&&!A(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,R(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=j();t.control.binding.type===`api`?await z(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function k(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!A(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&A(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` +`).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=L(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>k(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return k(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await k(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function U(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return H(JSON.parse(n))}var W=document.currentScript?.src,G=W?new URL(W).pathname:``,K=G.endsWith(`/__replica/capture-controls.js`)?G.slice(0,-29):void 0;globalThis.ReplicaControls={ready:U(K).then(async e=>{await e?.settled();let t=(e?.runtime.list()??[]).flatMap(e=>{let t=e.getSnapshot().bindings??{};return e.declaration.controls.filter(e=>e.type!==`button`&&t[e.id]?.error).map(n=>`${e.declaration.scope}.${n.id}: ${t[n.id].error}`)});if(t.length)throw Error(`Controls defaults could not be applied: ${t.join(`; `)}`);return e})}})(); \ No newline at end of file diff --git a/hub/client/utils/prototype-controls/preview-base-path.d.mts b/hub/client/utils/prototype-controls/preview-base-path.d.mts new file mode 100644 index 000000000..ef0c6f09b --- /dev/null +++ b/hub/client/utils/prototype-controls/preview-base-path.d.mts @@ -0,0 +1 @@ +export function getPreviewBasePath(pathname: string): string diff --git a/hub/client/utils/prototype-controls/preview-base-path.mjs b/hub/client/utils/prototype-controls/preview-base-path.mjs new file mode 100644 index 000000000..cdb159b3e --- /dev/null +++ b/hub/client/utils/prototype-controls/preview-base-path.mjs @@ -0,0 +1,3 @@ +export function getPreviewBasePath(pathname) { + return /^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(pathname)?.[0] ?? "/" +} diff --git a/hub/docs/architecture.md b/hub/docs/architecture.md index b421f4b9d..60960115a 100644 --- a/hub/docs/architecture.md +++ b/hub/docs/architecture.md @@ -12,7 +12,7 @@ Hub uses PostgreSQL and Prisma with provider-neutral identities, GitHub and sing [Review collaboration](review-collaboration.md) includes persisted reactions, mentions, unread state, Inbox, and live review refreshes. -The development API can explicitly enable local mode without a GitHub App. Startup prepares an ignored prototype root and the shared Build action dependencies, and seeds one deterministic Starter repository only while that root is empty. Local discovery and Build synchronization persist successful package artifacts, which the authenticated preview layer serves from Build-specific origins. +The development API can explicitly enable local mode without a GitHub App. Startup prepares an ignored prototype root and the shared Build action dependencies, and seeds one deterministic Starter repository only while that root is empty. Local discovery and Build synchronization persist successful package artifacts. Private hosted previews currently require GitHub repository and owning-run IDs; local Builds have no supported private mount. The [production runtime](deployment.md) serves the built frontend and API and runs both workers in one image. Deployment runs database and job setup separately before starting that image. The Azure installation uses an explicit startup entrypoint to retrieve configured Key Vault values through each workload's managed identity before importing provisioning, setup, or runtime code. Local entrypoints and direct environment configuration remain unchanged. @@ -32,9 +32,9 @@ The [background-job foundation](background-jobs.md) uses BullMQ with PostgreSQL The [development local Build flow](development.md#build-local-prototype-repositories) scans immediate child Git repositories under one configured root. It records local repositories, branch prototypes, exact commit Builds, branch-head observations, and immutable package files through the normal Prisma and artifact-storage boundaries. It checks out committed revisions in isolated Git worktrees and runs the shared Replica build action without GitHub or GitHub Actions. This flow is not enabled in hosted or production modes. -The [artifact storage domain](artifact-storage.md) selects filesystem or managed-identity Azure Blob storage behind one immutable-byte contract. Product domains call this provider-neutral API, not SDK integrations directly. Startup validates explicitly configured storage. Local Build synchronization writes package files, and the [Build preview layer](build-previews.md) reads successful Build files and screenshots through the same contract after authenticated Hub authorization, then serves them from Build-specific origins. [Public Build sharing](share-links.md) uses the same serving path with a separate public grant and cookie, Build-pinned links, and live revocation checks. Hosted sharing requires deployment opt-in and fresh GitHub repository permission; local sharing keeps its existing policy. +The [artifact storage domain](artifact-storage.md) selects filesystem or managed-identity Azure Blob storage behind one immutable-byte contract. Product domains call this provider-neutral API, not SDK integrations directly. Startup validates explicitly configured storage. The [Build preview layer](build-previews.md) reads successful Build files and screenshots through that contract after authenticated Hub authorization. Private GitHub Builds use immutable repository/owning-run paths on the Hub origin under the accepted trusted-publisher model. Configured wildcard origins remain only for existing [public Build sharing](share-links.md), with its grants, cookies, and live revocation checks. Hosted sharing requires deployment opt-in and fresh GitHub repository permission; local sharing keeps its existing policy. -The [review collaboration flow](review-collaboration.md) stores Build-pinned element and area conversations without changing immutable artifacts. The retained prototype screen uses the isolated preview bridge and real review API. Local sessions can review configured local repositories, while GitHub sessions can review only connected repositories visible through their current installation access. +The [review collaboration flow](review-collaboration.md) stores Build-pinned element and area conversations without changing immutable artifacts. The retained prototype screen uses the preview bridge and real review API. Local sessions can review configured local repositories, while GitHub sessions can review only connected repositories visible through their current installation access. The [telemetry integration](telemetry.md) sends explicit server-side OpenTelemetry spans to an optional operator-configured recipient. [Repository analytics](analytics.md) separately retains product events and can deliver them to repository destinations when an operator enables delivery. Security audit data never enters the analytics pipeline. diff --git a/hub/docs/build-previews.md b/hub/docs/build-previews.md index afca860aa..bcb4d5a8f 100644 --- a/hub/docs/build-previews.md +++ b/hub/docs/build-previews.md @@ -1,37 +1,63 @@ # Build previews -Hub serves successful Build artifacts without a GitHub App. The preview layer consumes the shared `BuildArtifact` contract: each immutable package file has a `kind`, package-relative `path`, opaque artifact-storage `storageKey`, and `byteLength`. Build producers write the bytes through `ArtifactStorage`, then commit those records with the successful Build. Preview serving does not discover repositories, run Builds, or [import GitHub artifacts](github-actions-builds.md). +Signed-in users can open successful GitHub Builds on the Hub origin at `/previews/github///`. Private previews need configured [artifact storage](artifact-storage.md), not wildcard DNS, TLS, or `HUB_PREVIEW_ORIGIN`. Hub reads immutable artifact records by storage key; preview serving does not run Builds or change their bytes, identities, reviews, or share links. -## Access flow +## Build and workflow contract -The prototype response keeps Build selection on `/repositories/:repositoryId/prototypes/:prototypeId?build=N`. A Build with `dist/index.html` receives an authenticated Hub access URL. Screenshot records receive equivalent desktop and narrow URLs. +Compile each app for its canonical base before uploading it: -1. The browser requests the access URL on the Hub origin with its Hub session. -2. Hub checks the live session again after locating the requested successful Build artifact. -3. Hub issues a 30-second encrypted grant and redirects to that Build's wildcard preview origin. -4. The preview origin exchanges the grant for a 15-minute, host-only, HTTP-only cookie. -5. Preview files are read by opaque storage key. Hub session cookies and provider credentials never enter the Build origin. +```yaml +- run: npm run build + env: + VITE_BASE: /previews/github/${{ github.repository_id }}/${{ github.run_id }}/ +``` -`HUB_PREVIEW_ORIGIN` is the wildcard base. For example, `https://preview.example.net` serves one Build from `https://.preview.example.net` while Hub runs on `https://hub.example.com`. Outside local development, the preview and Hub origins must use separate registrable domains so untrusted preview content cannot shadow Hub cookies through a parent domain. Operators must configure wildcard DNS and TLS. Local development uses `http://preview.localhost:3001`. +The app must actually use that setting for its bundler base and router basename. For example, a Vite app can read `process.env.VITE_BASE` in its configuration, and React Router can use the same basename. Hub adds no base tag, relocation adapter, router patch, or resource rewriting. The Starter instead uses relative Vite output and hash routing. -The [template catalog](frontend.md#create-templates-and-welcome) selects one successful Build from the repository's current default branch. Its preview and declared desktop screenshots use `/api/repositories/:repositoryId/template-builds/:buildId/access` so each request stays on that snapshot. Hub rechecks repository visibility before granting access and on the Build origin. A template grant cannot open a prototype Build, and a template preview does not enable the review bridge. The dark theme uses the saved dark screenshot when present and falls back to the light one. +Pass the same base to `actions/build/screenshots` using its `base-path` input. The optional all-in-one `actions/build` action accepts that input for inline screenshots too; it does not configure the app's compiler. Upgrade to a reviewed action revision containing this input before enabling it in another repository. The publish action and package format stay unchanged. See [GitHub Actions Builds](github-actions-builds.md) for workflow setup. -## File behavior +The path uses the numeric GitHub repository ID and the successful Build's **owning** workflow run ID. It never uses the branch head, current selected run, commit SHA, or attempt number. A later redundant run can select an existing successful Build but gets no new preview mount. Same-run retries keep the original base. Capture a downloaded package at its original compiled base, not the IDs of a later capture run. -Package paths remain relative and may not contain empty, dot, dot-dot, control, surrogate, absolute, or backslash segments. `/` serves `dist/index.html`, and directory-style requests first look for their nested `index.html`. A missing extensionless browser route falls back to the application entry point. A dotted route receives the same fallback only when the saved template manifest declares it; missing asset paths return 404. The prototype's normalized start page is used after grant exchange. +Hub serves only one matching successful Build with `dist/index.html` in a connected repository and active branch. Missing or ambiguous ownership returns 404; duplicate ownership also produces a warning. Hub does not pick another Build or impose a new uniqueness constraint. Builds with null provider IDs and local Builds have no canonical path contract and are unsupported for private hosted preview. Their stored data remains untouched. -Content types come from the checked package path, with unknown extensions served as `application/octet-stream`. HTML is private and revalidated. Immutable assets use a private one-year cache. Desktop and narrow screenshots are served from their package paths through the same Build authorization. +Old base-`/` packages are not portable to these paths. Change the build configuration and push a **new commit** to create a new Build. A workflow rerun does not replace an immutable successful Build for the same prototype and commit. Existing packages, storage keys, Build numbers and UUIDs, review threads, and ShareLink relations remain untouched. The package does not declare its base, so Hub cannot detect an app compiled for the wrong one. -Preview reads share a 100 MiB source-byte allowance per API process across Build origins, private previews, template previews, and public links. Hub reserves each file's recorded size before reading storage and keeps that reservation until the read settles and the HTTP response finishes or disconnects. A request returns 503 without reading the file when the allowance is full. Small and empty files reserve at least 64 KiB each. Temporary template-manifest reads release their reservation before reading the selected HTML file. +## Buffered preview reads + +Artifact reads share a 100 MiB source-byte allowance per API process across private previews, template previews, and existing public preview origins. Hub reserves each file's recorded size before reading storage and keeps that reservation until the read settles and the HTTP response finishes or disconnects. A request returns 503 without reading the file when the allowance is full. Small and empty files reserve at least 64 KiB each. Temporary template-manifest reads release their reservation before reading the selected HTML file. This allowance bounds concurrent buffered preview files, not total process memory. Storage downloads can hold chunks and their combined buffer at once, and HTML bridge injection needs additional strings and encoded bytes. Imports and other runtime work need separate headroom within the deployment's memory allocation. -HTML responses inject the generated hosted preview bridge. The bridge installs the shared Controls engine and bindings, which load that Build's `/controls.replica.json`, and reports review element or area selections to the authenticated parent page. Review records store the anchor and Build identity separately; the bridge does not write artifacts or receive Hub session cookies. The generated bridge is checked by `npm run controls:assets:check`. +## Access and compatibility + +Every private document, asset, screenshot, and bridge request requires a live Hub session and repository visibility for that exact Build. Hub checks authority again after reading stored bytes. Session expiry, repository removal, branch retirement, or access revocation denies subsequent requests. Numeric path IDs are locators, not capabilities; anonymous users and share cookies cannot authorize this mount. + +Resources use private revalidation rather than a fresh immutable browser cache, so the browser cannot skip the next authorization check. Screenshots and bridge responses are private and not stored. Already returned bytes cannot be recalled. + +The prototype response keeps Build selection on `/repositories/:repositoryId/prototypes/:prototypeId?build=N`. Its preview and screenshot URLs use the owning Build's canonical path. Existing Build access URLs resolve the selected successful Build and redirect to that path, joining its logical start route, query, and fragment. Template access URLs similarly preserve their exact default-branch Build and declared screenshot paths. Template previews remain browse-only and require the existing template access rules. + +Private wildcard grants, cookies, authorization endpoints, and the `preview_origin` query parameter are removed. Old direct private wildcard URLs no longer authorize a preview. The retained Build and template access endpoints redirect supported GitHub Builds to their canonical path instead. + +`HUB_PREVIEW_ORIGIN`, wildcard host resolution, encryption, and separate-domain validation remain only because existing [public shares](share-links.md) actively use them. Keep that configuration, DNS, and TLS while those shares are in use. Public share endpoints, grants, expiry, revocation, and cookies remain; they do not authorize or redirect to the private canonical mount. Without a wildcard origin, sharing remains unavailable. A separate sharing-service design is deferred, not implemented here. + +## File and bridge behavior + +The `/previews/` mount precedes the Hub SPA fallback, including when preview serving is disabled. Preview misses never return the Hub page. The canonical root without its final slash redirects with 308 and preserves its query. + +Hub rejects malformed provider IDs, traversal, encoded separators, backslashes, controls, and unsafe package paths before storage access. `/` serves `dist/index.html`; a directory first tries its nested `index.html`. Missing extensionless HTML navigations may use the root SPA document. Dotted routes receive that fallback only when the saved template manifest declares them. Missing scripts and other assets return 404. Content types come from the stored path and responses disable MIME sniffing. + +Hub injects only its prefixed `__replica/bridge/v1.js` script into HTML. `__replica/` is reserved for that bridge and authorized screenshots. Controls load the retained Build's own `controls.replica.json`. Review and canvas messages still validate their schema, origin, and source frame. Review anchors store logical paths relative to the Build root, compare consistently across owning-run mounts, and retain query and fragment encoding. Navigation adds the active Build prefix again. Templates and public shares do not enable review. + +## Trusted-publisher boundary + +**Private prototype JavaScript is trusted code on the Hub origin.** A user who views a Build lets that code act with their Hub permissions, including administrator permissions when applicable. It can call Hub APIs with ambient cookies, access Hub-origin browser storage and other prototypes' storage, and read or navigate the parent page. A compromised publisher dependency inherits this access. + +This hosting model trusts connected-repository publishers. Paths, CSP, `HttpOnly`, and the iframe sandbox do not restore origin isolation. Keep secrets out of browser storage. Source-frame checks prevent accidental frame cross-talk; they are not a security boundary against same-origin prototype code. -## Browser boundary +Private responses retain CSP with `frame-ancestors 'self'`, no referrers, no MIME sniffing, and disabled camera, microphone, and geolocation. Service-worker script requests are rejected and Hub sends no `Service-Worker-Allowed` header. The existing iframe sandbox retains `allow-same-origin` because opaque origins would break session-authorized app resources and storage. -Each Build has a separate origin. Responses deny MIME sniffing and referrers, restrict framing to the configured Hub origin, keep resources same-origin, disable camera, microphone, and geolocation, and apply a same-origin content security policy. The iframe remains sandboxed by the Hub frontend. Preview routes return 404 on the Hub host, an unknown Build host, an invalid or expired grant, a mismatched Build cookie, and unsafe paths. +## Rollout and rollback -The first version does not add Canvas pairing, standalone Build pages, hosted repository discovery, hosted Build execution, or GitHub App setup. +Deploy the new Hub image through the installation's normal release process, upgrade the screenshot action, and rebuild affected prototypes with the canonical base. No database migration or wildcard configuration is needed for private GitHub previews. Keep configured wildcard infrastructure only for existing public sharing; retiring it is a separate decision. -Local mode also supports [Build-pinned public share links](share-links.md). They reuse this file-serving path and Build-specific origin, but exchange a purpose-bound public grant for a separate purpose-bound `replica_share_preview` cookie. Grants and cookies cannot be exchanged. Public requests recheck the saved link and deployment setting before and after artifact reads. They never accept a Hub session as public authorization or expose repository and review data. +The installer does not modify existing prototype compiler or workflow settings. Non-GitHub path mounts, public-sharing migration, package base metadata, and arbitrary post-build relocation are not included. Rollback changes the Hub image, not stored Builds or artifacts. A previously working wildcard installation also needs its retained configuration, DNS, and TLS; an installation without them returns to its former no-preview behavior. diff --git a/hub/docs/github-actions-builds.md b/hub/docs/github-actions-builds.md index 7a065dfde..a349ddfce 100644 --- a/hub/docs/github-actions-builds.md +++ b/hub/docs/github-actions-builds.md @@ -31,7 +31,7 @@ Removing a workflow stops artifact imports from it. Its next import pass marks a An omitted file, `builds`, or `builds.workflows` keeps the legacy default. An explicit list replaces that default; include `.github/workflows/replica.yml` explicitly to select it too. Use one to ten unique paths directly under `.github/workflows/`, ending in `.yml` or `.yaml`. Filenames must start with an ASCII letter or digit and contain only letters, digits, dots, underscores, or hyphens; each complete path is limited to 255 characters. Configuration must be a regular JSON file of at most 16 KiB. Invalid configuration stops imports and discovery with an error naming the configuration file; provider failures do not select a fallback workflow. -GitHub identifies reusable workflow runs by the top-level caller, not the called workflow. Select `publish-proto.yml`, not Mini-Foundry's reusable `publish-proto-core.yml`. Selection alone does not add publishing jobs or make Azure output suitable for Hub: the selected caller must produce the existing Replica artifacts with a Hub-compatible root base path (`VITE_BASE=/`). This configuration does not modify downstream workflows or Azure publishing. +GitHub identifies reusable workflow runs by the top-level caller, not the called workflow. Select `publish-proto.yml`, not Mini-Foundry's reusable `publish-proto-core.yml`. Selection alone does not add publishing jobs or make Azure output suitable for Hub: the selected caller must produce the existing Replica artifacts for the [private preview base](build-previews.md#build-and-workflow-contract). Use `/previews/github/${{ github.repository_id }}/${{ github.run_id }}/` as the build-time base and router basename, or relative output with hash routing as in Starter. This configuration does not modify downstream workflows or Azure publishing. When several selected workflows publish the same branch and commit, they share one Build. Existing run and attempt ordering still governs unfinished Builds. The first successful dist import remains immutable, and later screenshots attach only when their digest matches that dist. Select workflows that intentionally produce the same Hub output rather than competing variants. @@ -83,6 +83,15 @@ Keep publish last in its job: later steps delay the completed-job event used for The optional [build action](../../actions/build/action.yml) is still available. It runs `npm ci` and `npm run build` as a non-root user in a Node container. With `screenshots: separate`, it uploads the same dist package as the publish action and can replace the build steps and publish action above. Existing single-job workflows remain compatible: `screenshots` defaults to `inline`, which uploads one package containing the dist and screenshots, so Hub imports it only after screenshots finish. +For a fixed-base app, upgrade the action references to a reviewed revision containing `base-path` support before configuring capture. Set the app's compiler base using its supported configuration, such as `VITE_BASE`, and pass the same original base to the screenshot step: + +```yaml +with: + base-path: /previews/github/${{ github.repository_id }}/${{ github.run_id }}/ +``` + +The same input applies to inline capture in `actions/build`; it does not configure the compiler in that action's build container. Capture mounts the downloaded `dist` at that path and joins the root and logical template routes beneath it, preserving query and fragment. The default `/` remains available for root-base or relative-output apps. The earlier pinned example above works for Starter's relative output; it must be upgraded before adding this new input. + To use the build and publish actions as separate steps, set `build-only: 'true'` on the build action, then call the publish action. Build-only mode leaves the static output in the workspace without packaging, uploads, browser installation, or screenshot capture. Without this option, both actions upload `replica-build-v1`, and GitHub rejects the duplicate artifact name. If Hub is offline during an update, the workflow can still upload both artifacts to GitHub. GitHub does not automatically retry failed webhook deliveries. Once Hub returns, polling or requested redelivery can import the retained packages. Hub still needs GitHub API and artifact-download access. Recovery is bounded by the three-day artifact retention and polling window; expired packages cannot be recovered automatically. Re-running the workflow is safe because successful Builds and artifacts are never replaced. diff --git a/hub/docs/share-links.md b/hub/docs/share-links.md index d385a6acd..a9dc966d2 100644 --- a/hub/docs/share-links.md +++ b/hub/docs/share-links.md @@ -43,9 +43,11 @@ Expired, revoked, disabled, or unavailable hosted links return not found. Local ## Public preview boundary +Public shares still require `HUB_PREVIEW_ORIGIN` and its wildcard DNS/TLS configuration. Private [path-based previews](build-previews.md) do not replace this flow or make it available without that configuration. Moving public sharing to a separate service is outside the private-preview change. A fixed-base package is not automatically portable to a wildcard root or another pathname; share such a Build only when its app supports that address. + `GET /api/shared/:shareId` requires no Hub session. An active response contains only the saved label, prototype display name, Build number, expiration, Controls identity, and a preview authorization URL. It never includes repository identifiers, navigation, comments, screenshots, users, or Hub-session data. -The authorization URL redirects to the existing Build-specific preview origin. A two-minute encrypted public grant is bound to the share link and Build. The preview origin exchanges it for a separate `replica_share_preview` cookie, limited to eight hours or the link deadline, whichever comes first. The authenticated `replica_preview` cookie is not accepted as public authorization, and the public cookie does not authorize signed-in Hub routes. +The authorization URL redirects to the existing Build-specific preview origin. A two-minute encrypted public grant is bound to the share link and Build. The preview origin exchanges it for a `replica_share_preview` cookie, limited to eight hours or the link deadline, whichever comes first. Hub sessions do not authorize that public preview, and the public cookie does not authorize signed-in Hub routes or private preview paths. Public previews reuse the same artifact lookup, path validation, content types, SPA fallback, security headers, HTML bridge injection, and Controls runtime as signed-in previews. The serving path rechecks the share link and deployment setting for every request and after artifact storage returns, so revocation, expiration, disablement, Build removal, and artifact unavailability stop later responses without a second file-serving implementation. diff --git a/hub/docs/testing-and-operations.md b/hub/docs/testing-and-operations.md index d63fcee29..f23a5dd2c 100644 --- a/hub/docs/testing-and-operations.md +++ b/hub/docs/testing-and-operations.md @@ -85,7 +85,7 @@ npm run build:runtime npm run test:local ``` -The test starts the built client and Express on one loopback port with an isolated PostgreSQL worker database. It signs in as the fixed local administrator, registers a draft, and verifies its gallery listing and audit record. It hides **Welcome** and revisits the direct page, opens a named template from the latest successful default-branch Build, and copies a prompt including the current preview route. It opens **Canvas connections** and exercises public sharing in a second signed-out browser context. Reloading after revocation must no longer open the preview. No `.env` or external account is needed. The test removes its database, private storage, and browser session. +The test starts the built client and Express on one loopback port with an isolated PostgreSQL worker database. It signs in as the fixed local administrator, registers a draft, and verifies its gallery listing and audit record. It hides **Welcome** and revisits the direct page, then checks the explicit unavailable-preview state for local Builds and templates, which have no supported private path contract. It opens **Canvas connections** and exercises the existing public-sharing flow in a second signed-out browser context. Reloading after revocation must no longer open the public preview. No `.env` or external account is needed. The test removes its database, private storage, and browser session. The test seeds a small SQL fixture and saved preview bytes, not a Git history. Use the [local Build workflow](development.md#build-local-prototype-repositories) to check Git discovery, Build execution, screenshot capture, and packaging separately. Use the [mock frontend](frontend.md#start-with-mock-data) to explore slow or failing responses, not as evidence that the real API persists changes. diff --git a/hub/server/assets/hosted-preview-bridge.ts b/hub/server/assets/hosted-preview-bridge.ts index 7917a1a81..103c59230 100644 --- a/hub/server/assets/hosted-preview-bridge.ts +++ b/hub/server/assets/hosted-preview-bridge.ts @@ -1,2 +1,2 @@ // prettier-ignore -export const hostedPreviewBridgeSource = "var ReplicaHostedPreviewBridge=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;lt[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=((e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)))(s((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});var t=r();t.code=`require(\"ajv/dist/runtime/equal\").default`,e.default=t}));e.validateShape=ee;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern \"^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern \"^[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==\"default\"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern \"^#[0-9a-fA-F]{6}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return I.errors=a,o===0}e.number=L;function L(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return L.errors=a,l===0}e.slider=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.choice=te;function te(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return te.errors=a,o===0}e.checkboxGroup=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==\"default\"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.text=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return re.errors=a,l===0}e.color=ie;function ie(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern \"^#[0-9a-fA-F]{6}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ie.errors=a,o===0}e.button=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return z.errors=a,o===0}}))(),1);function u(e){if(e&&typeof e==`object`){for(let t of Object.values(e))u(t);Object.freeze(e)}return e}function d(e){return Array.isArray(e)?`[${e.map(d).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${d(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function f(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>f(e,t));if(e.any)return e.any.some(e=>f(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:p,validateDeclaration:m}=l.default,h={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function g(e){let t=[...m.errors].filter(e=>!/^\\/controls\\/\\d+(?:\\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(h,e?.type)?h[e.type]:void 0,i=r&&l.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: \"${e.params.additionalProperty}\"`:e.message,keyword:e.keyword,params:e.params}))}var _=class extends Error{constructor(e){super(`Invalid controls.replica.json:\\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(`\n`)}`),this.name=`ControlsValidationError`,this.issues=e}};function v(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function y(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(y):[]}function b(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new _([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...y(s.when),...y(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function x(e){let t=new Set;function n(e,r=0){if(r>24)throw new _([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new _([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new _([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new _([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new _([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function S(e){x(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return w(e),C(e),e;if(!p(e))throw new _(p.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: \"${e.params.additionalProperty}\"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{w(e),C(e)}catch(e){throw e instanceof _?new _(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new _([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function C(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new _(t)}function w(e){if(x(e),!m(e))throw new _(g(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=v(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=v(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new _(t);return b(e),e}var T=Symbol.for(`replica.controls.injected.runtime`),E=new WeakMap;function D(){let e=globalThis[T];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>O(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});E.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[T]=n}return globalThis[T]}function O(e){w(e);let t=u(structuredClone(e)),n=d(t),r=D(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(d(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope \"${t.scope}\"; reload after schema changes`);return i}let a=E.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=b(t),l=new Set,p=new Map,m=new Set,h={},g=0,_=!1,y=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function C(e){let n={};for(let t of c){let r=o.get(t);n[t]=f(r.when,e)&&f(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return u({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,f(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function T(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=u({...C(T()),revision:g});function O(e){let t=C(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(d(t)!==d(n)&&(x=u({...t,revision:++g}),y=!0,!_)){_=!0;try{for(;y;){y=!1;for(let e of[...l])e();a.notify()}}finally{_=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control \"${e}\"`);if(!x.visible[e])throw Error(`Control \"${e}\" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return l.add(e),()=>l.delete(e)},update(e,t){let n=v(k(e),t);if(n)throw Error(`Control \"${e}\": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control \"${n}\"`);let i=v(e,r);if(i)throw Error(`Control \"${n}\": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control \"${e}\"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(T());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control \"${e}\" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for \"${e}\"`);if(m.has(e))throw Error(`Action \"${e}\" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function k(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role=\"button\"], [role=\"link\"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function A(e,t){return JSON.stringify(e)===JSON.stringify(t)}function j(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function M(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function N(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API \"${e}\" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API \"${e}\" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function ee(e){let t=e.binding;if(t.type===`api`){let e=N(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method \"${n}\" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=M(t.selector),r=k(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\\(/.test(t)){let e=t.match(/\\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function te(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function ne(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():te(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,\"replicaControlsBinding\",{value:!0}),window.dispatchEvent(a)}function re(e){S(e);let t=(e.sets??[e]).map(e=>({controller:O(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=D().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!k(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return ee(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(j()).origin!==new URL(i).origin:j()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function _(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=v(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function y(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=j(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await ne(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await _(e,t,o,s?j():a);if(!A(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await _(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${L(e).message}`)}throw!l&&A(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function x(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await y(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!A(await R(()=>I(n,r)),n.default))await y(e,t,n.default);else{let n=await _(e,t,r,j());t.rejection&&!A(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=j();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>x(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function E(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of b(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!A(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await y(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&A(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(`\n`).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=v(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:D(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>E(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?v(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return E(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await E(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(`\n`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function ie(){let e=await fetch(`/controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(e.status===404||e.status===410)return;if(!e.ok)throw Error(`controls.replica.json returned HTTP ${e.status}.`);let t=``,n=e.body?.getReader();if(n){let e=new TextDecoder,r=0;for(;;){let{done:i,value:a}=await n.read();if(i)break;if(r+=a.byteLength,r>256e3)throw await n.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);t+=e.decode(a,{stream:!0})}t+=e.decode()}else t=await e.text();if(new TextEncoder().encode(t).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(e.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\\s*<(?:!doctype html|html)/i.test(t)))return re(JSON.parse(t))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var ae=`replica:controls`;function oe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function se(e){return w(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var ce=/^rc\\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function le(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!ce.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function ue(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=ce.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{le(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function de(e,t){let n=new URL(e,window.location.href),r=ue(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(le(r.scopes)))n.searchParams.set(e,t);return n.toString()}function fe(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=le({...ue(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(de(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=ue(e);if(t.notice)throw Error(t.notice);s=le(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function pe(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var me={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope \"${e}\" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function he(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?me.controlsActionUnavailable:``)}}function ge(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>he(e,t)))}}function _e(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=fe(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,pe(se(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await ie(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(se);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:ae,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(oe(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:ge(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!oe(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!z(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var B=`data-replica-canvas-bridge`,ve=new TextEncoder,ye=null,V=null,H=null,U=null,be=`light-dark(#0969da, #58a6ff)`,W=null,xe=``,Se=``,G=new Map;function Ce(){let e=q();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{Se=`replicaControlsBinding`in e&&e.replicaControlsBinding?Ce():``});function K(e){return e.replace(/\\s+/g,` `).trim()}function we(e,t){let n=``,r=0;for(let i of e){let e=ve.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function q(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname,search:e?`?${e}`:``,hash:window.location.hash}}function Te(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Ee(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function De(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return we(K(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function Oe(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\\\${e}`)}function ke(e){if(e.id){let t=`#${Oe(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}=\"${Oe(n)}\"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function Ae(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&De(e)!==t.accessibleName?!1:!t.selectedText||K(e.textContent||``).includes(t.selectedText)}function je(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&Ae(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&Ae(r,e)){if(n)return null;n=r}return n}function Me(){let e=document.createElement(`div`);return e.setAttribute(B,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,be),document.documentElement.append(e),e}function J(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function Ne(e,t=null){H?.remove(),H=e,U=t,H.style.pointerEvents=`none`}function Y(e,t){window.parent.postMessage(t,e)}function X(){V?.(),V=null}function Z(e,t,n){X(),Y(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Pe(e,t,n){let r=e.getBoundingClientRect(),i=ke(e);if(!r.width||!r.height||!i)return null;let a=we(K(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:q(),selector:i,accessibleName:De(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:Ee(r),viewport:Te(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Fe(e,t){X();let n=null,r=Me(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${B}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,J(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Pe(n,i.clientX,i.clientY);a?(r.style.position=$(n)?`fixed`:`absolute`,J(r,n.getBoundingClientRect()),Ne(r,n),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Z(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),V=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,H!==r&&r.remove()}}function Ie(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(B)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=ke(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:De(e),tagName:e.tagName.toLowerCase(),role:we(e.getAttribute(`role`)||``,64),textExcerpt:we(K(e.textContent||``),500),rect:Ee(n)}]})}function Le(e){return{schemaVersion:1,kind:`area`,route:q(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:Ee(e),viewport:Te(),elements:Ie(e)}}function Re(e,t,n=!1){X();let r=document.createElement(`div`);r.setAttribute(B,``),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let i=Me();i.style.display=`none`,document.body.append(r);let a=null,o=null,s=null,c=null;function l(e,t){r.style.pointerEvents=`none`;let n=document.elementFromPoint(e,t);return r.style.pointerEvents=``,n===document.body||n===document.documentElement?null:n}function u(n,r,a){i.style.position=a&&$(a)?`fixed`:`absolute`,J(i,r),Ne(i,a),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:n})}function d(e,t){if(!a)return;let n=Math.min(a.x,e),r=Math.min(a.y,t),o=Math.abs(e-a.x),s=Math.abs(t-a.y);i.style.display=`block`,J(i,new DOMRect(n,r,o,s))}function f(e){e.button!==0||a||(e.preventDefault(),a={x:e.clientX,y:e.clientY},s=e.pointerId,o=n?l(e.clientX,e.clientY):null,r.setPointerCapture(e.pointerId),d(e.clientX,e.clientY))}function p(e){if(a)e.pointerId===s&&(e.preventDefault(),d(e.clientX,e.clientY));else{if(!n)return;let t=l(e.clientX,e.clientY);i.style.display=t?`block`:`none`,t&&J(i,t.getBoundingClientRect())}}function m(r){if(!a||r.pointerId!==s)return;r.preventDefault();let i=Math.max(0,Math.min(window.innerWidth,r.clientX)),c=Math.max(0,Math.min(window.innerHeight,r.clientY)),l=new DOMRect(Math.min(a.x,i),Math.min(a.y,c),Math.abs(i-a.x),Math.abs(c-a.y));if(n&&Math.hypot(l.width,l.height)<8){let n=o?Pe(o,a.x,a.y):null;if(!n||!o){Z(e,t,`element-unavailable`);return}u(n,o.getBoundingClientRect(),o)}else(n?l.width<8||l.height<8:Math.hypot(l.width,l.height)<8)?Z(e,t,`area-too-small`):u(Le(l),l)}function h(r){if(!n||r.detail!==0||!(r.target instanceof Element)||r.target.hasAttribute(B))return;r.preventDefault(),r.stopImmediatePropagation();let i=r.target,a=i.getBoundingClientRect(),o=Pe(i,a.left+a.width/2,a.top+a.height/2);o?u(o,a,i):Z(e,t,`element-unavailable`)}function g(n){X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t,reason:n?`interrupted`:`escape`})}function _(r){if(n&&r.shiftKey&&r.key===`Enter`)r.preventDefault(),c={x:window.innerWidth/2,y:window.innerHeight/2},a=null,i.style.display=`block`,J(i,new DOMRect(c.x,c.y,4,4));else if(c&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(r.key)){if(r.preventDefault(),r.key===`Enter`||r.key===` `){if(!a)a={...c};else{let n=new DOMRect(Math.min(a.x,c.x),Math.min(a.y,c.y),Math.abs(a.x-c.x),Math.abs(a.y-c.y));if(n.width<8||n.height<8){Z(e,t,`area-too-small`);return}u(Le(n),n)}}else c={x:Math.max(0,Math.min(window.innerWidth,c.x+(r.key===`ArrowRight`?10:r.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(window.innerHeight,c.y+(r.key===`ArrowDown`?10:r.key===`ArrowUp`?-10:0)))},a?d(c.x,c.y):J(i,new DOMRect(c.x,c.y,4,4))}else r.key===`Escape`&&(r.preventDefault(),g())}r.addEventListener(`pointerdown`,f),r.addEventListener(`pointermove`,p),r.addEventListener(`pointerup`,m),r.addEventListener(`pointercancel`,g),r.addEventListener(`lostpointercapture`,g),n&&document.addEventListener(`click`,h,!0),document.addEventListener(`keydown`,_,!0),V=()=>{r.removeEventListener(`pointerdown`,f),r.removeEventListener(`pointermove`,p),r.removeEventListener(`pointerup`,m),r.removeEventListener(`pointercancel`,g),r.removeEventListener(`lostpointercapture`,g),n&&document.removeEventListener(`click`,h,!0),document.removeEventListener(`keydown`,_,!0),r.remove(),H!==i&&i.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function ze(e){let t=q();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=je({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:$(n)}}function Be(e=!1){if(!W||!ye)return;let t=q(),n=JSON.stringify(t);e&&=n===xe,xe=n;let r=[];for(let t of W.anchors){let n=G.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=ze(t.anchor);if(!e){G.delete(t.id);continue}G.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}Y(ye,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:W.nonce,route:t,...Se===Ce()?{replaceRoute:!0}:{},results:r})}function Ve(e){let t=e.data;if(document.querySelector(`script[src=\"/__replica/bridge/v1.js\"]`)||e.source!==window.parent||e.origin!==ye||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){Y(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,improvementSelection:!0,nonce:t.nonce,route:q(),...Se===Ce()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;be=t.accent;for(let e of document.querySelectorAll(`[${B}]`))e.style.setProperty(`--replica-selection-accent`,be);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=q(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(k(n,!0)||(De(n)||K(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Fe(e.origin,t.nonce):t.mode===`area`?Re(e.origin,t.nonce):t.mode===`improvement`&&Re(e.origin,t.nonce,!0);return}if(t.type===`replica:canvas:cancel-selection`){X(),Y(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce,reason:`command`});return}if(t.type===`replica:canvas:clear-selection`){H?.remove(),H=null,U=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors))return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});W={nonce:t.nonce,anchors:n},G.clear(),Be()}var He=Symbol.for(`replica.canvas.bridge.v1`),Ue=window;function We(e){let t=Ue[He];if(t===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof t==`function`&&t(),be=`light-dark(#0969da, #58a6ff)`,ye=e,W=null,xe=``,G.clear();let n=_e(e),r=null;function i(){r!==null&&window.cancelAnimationFrame(r),r=null,H&&U&&(H.style.position=$(U)?`fixed`:`absolute`,J(H,U.getBoundingClientRect())),Be()}function a(){r===null&&W&&(r=window.requestAnimationFrame(i))}function o(e){H&&U&&(e.target!==document&&e.target!==window||$(U))&&J(H,U.getBoundingClientRect()),r===null?Be(e.target===document||e.target===window):i()}function s(){Be()}function c(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||V||!W||t.target instanceof Element&&t.target.closest(`[role=\"dialog\"], dialog, [role=\"menu\"]`))return;let n=W;window.setTimeout(()=>{t.defaultPrevented||V||W!==n||Y(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,Ve),window.addEventListener(`scroll`,o,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),window.addEventListener(`keydown`,c);let l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${B}], [data-replica-controls-bridge]`)))&&a()});l.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let u=typeof ResizeObserver==`function`?new ResizeObserver(a):null;u?.observe(document.documentElement),Ue[He]=()=>{window.removeEventListener(`message`,Ve),window.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,s),window.removeEventListener(`keydown`,c),l.disconnect(),u?.disconnect(),r!==null&&window.cancelAnimationFrame(r),W=null,xe=``,G.clear(),n(),X(),H?.remove(),H=null,U=null}}function Ge(e,t=`canvas`){if(t===`canvas`){if(!/^http:\\/\\/127\\.0\\.0\\.1:\\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`)}else{let t=URL.parse(e);if(!t||t.origin!==e||t.pathname!==`/`||t.search||t.hash||![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid Replica Hub parent.`)}We(e)}function Ke(e){Ge(e,`hosted`)}return e.installHostedBridge=Ke,e})({});" +export const hostedPreviewBridgeSource = "var ReplicaHostedPreviewBridge=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;lt[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=((e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)))(s((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});var t=r();t.code=`require(\"ajv/dist/runtime/equal\").default`,e.default=t}));e.validateShape=ee;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern \"^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern \"^[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==\"default\"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern \"^#[0-9a-fA-F]{6}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return F.errors=a,o===0}e.number=I;function I(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return I.errors=a,l===0}e.slider=L;function L(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return L.errors=a,l===0}e.choice=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return R.errors=a,o===0}e.checkboxGroup=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==\"default\"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.text=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return re.errors=a,l===0}e.color=ie;function ie(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern \"^#[0-9a-fA-F]{6}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ie.errors=a,o===0}e.button=ae;function ae(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ae.errors=a,o===0}}))(),1);function u(e){if(e&&typeof e==`object`){for(let t of Object.values(e))u(t);Object.freeze(e)}return e}function d(e){return Array.isArray(e)?`[${e.map(d).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${d(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function f(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>f(e,t));if(e.any)return e.any.some(e=>f(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:p,validateDeclaration:m}=l.default,h={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function g(e){let t=[...m.errors].filter(e=>!/^\\/controls\\/\\d+(?:\\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(h,e?.type)?h[e.type]:void 0,i=r&&l.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: \"${e.params.additionalProperty}\"`:e.message,keyword:e.keyword,params:e.params}))}var _=class extends Error{constructor(e){super(`Invalid controls.replica.json:\\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(`\n`)}`),this.name=`ControlsValidationError`,this.issues=e}};function v(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function y(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(y):[]}function b(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new _([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...y(s.when),...y(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function x(e){let t=new Set;function n(e,r=0){if(r>24)throw new _([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new _([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new _([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new _([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new _([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function S(e){x(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return w(e),C(e),e;if(!p(e))throw new _(p.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: \"${e.params.additionalProperty}\"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{w(e),C(e)}catch(e){throw e instanceof _?new _(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new _([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function C(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new _(t)}function w(e){if(x(e),!m(e))throw new _(g(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=v(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=v(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new _(t);return b(e),e}var T=Symbol.for(`replica.controls.injected.runtime`),E=new WeakMap;function D(){let e=globalThis[T];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>O(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});E.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[T]=n}return globalThis[T]}function O(e){w(e);let t=u(structuredClone(e)),n=d(t),r=D(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(d(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope \"${t.scope}\"; reload after schema changes`);return i}let a=E.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=b(t),l=new Set,p=new Map,m=new Set,h={},g=0,_=!1,y=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function C(e){let n={};for(let t of c){let r=o.get(t);n[t]=f(r.when,e)&&f(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return u({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,f(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function T(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=u({...C(T()),revision:g});function O(e){let t=C(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(d(t)!==d(n)&&(x=u({...t,revision:++g}),y=!0,!_)){_=!0;try{for(;y;){y=!1;for(let e of[...l])e();a.notify()}}finally{_=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control \"${e}\"`);if(!x.visible[e])throw Error(`Control \"${e}\" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return l.add(e),()=>l.delete(e)},update(e,t){let n=v(k(e),t);if(n)throw Error(`Control \"${e}\": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control \"${n}\"`);let i=v(e,r);if(i)throw Error(`Control \"${n}\": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control \"${e}\"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(T());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control \"${e}\" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for \"${e}\"`);if(m.has(e))throw Error(`Action \"${e}\" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function k(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role=\"button\"], [role=\"link\"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function A(e){return/^\\/previews\\/github\\/[1-9]\\d*\\/[1-9]\\d*\\//.exec(e)?.[0]??`/`}function j(e,t){return JSON.stringify(e)===JSON.stringify(t)}function M(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function N(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function ee(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API \"${e}\" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API \"${e}\" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function te(e){let t=e.binding;if(t.type===`api`){let e=ee(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method \"${n}\" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=N(t.selector),r=k(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\\(/.test(t)){let e=t.match(/\\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function ne(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function re(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():ne(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,\"replicaControlsBinding\",{value:!0}),window.dispatchEvent(a)}function ie(e){S(e);let t=(e.sets??[e]).map(e=>({controller:O(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=D().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!k(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return te(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(M()).origin!==new URL(i).origin:M()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function _(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=v(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function y(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=M(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await re(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await _(e,t,o,s?M():a);if(!j(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await _(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${L(e).message}`)}throw!l&&j(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function x(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await y(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!j(await R(()=>I(n,r)),n.default))await y(e,t,n.default);else{let n=await _(e,t,r,M());t.rejection&&!j(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=M();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>x(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function E(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of b(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!j(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await y(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&j(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(`\n`).slice(0,1e3))}let A=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=v(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:D(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>E(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?v(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return E(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await E(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(`\n`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(A);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function ae(e=A(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\\s*<(?:!doctype html|html)/i.test(n)))return ie(JSON.parse(n))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var oe=`replica:controls`;function se(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function ce(e){return w(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var le=/^rc\\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function ue(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!le.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function de(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=le.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{ue(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function fe(e,t){let n=new URL(e,window.location.href),r=de(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(ue(r.scopes)))n.searchParams.set(e,t);return n.toString()}function pe(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=ue({...de(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(fe(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=de(e);if(t.notice)throw Error(t.notice);s=ue(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function me(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var he={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope \"${e}\" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ge(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?he.controlsActionUnavailable:``)}}function _e(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>ge(e,t)))}}function ve(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=pe(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,me(ce(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await ae(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(ce);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:oe,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(se(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:_e(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!se(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!z(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var B=`data-replica-canvas-bridge`,ye=new TextEncoder,be=null,V=null,H=null,U=null,xe=`light-dark(#0969da, #58a6ff)`,W=null,Se=``,Ce=``,G=new Map;function we(){let e=q();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{Ce=`replicaControlsBinding`in e&&e.replicaControlsBinding?we():``});function K(e){return e.replace(/\\s+/g,` `).trim()}function Te(e,t){let n=``,r=0;for(let i of e){let e=ye.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function q(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname.slice(A(window.location.pathname).length-1),search:e?`?${e}`:``,hash:window.location.hash}}function Ee(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function De(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function Oe(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return Te(K(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function ke(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\\\${e}`)}function Ae(e){if(e.id){let t=`#${ke(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}=\"${ke(n)}\"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function je(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&Oe(e)!==t.accessibleName?!1:!t.selectedText||K(e.textContent||``).includes(t.selectedText)}function Me(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&je(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&je(r,e)){if(n)return null;n=r}return n}function Ne(){let e=document.createElement(`div`);return e.setAttribute(B,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,xe),document.documentElement.append(e),e}function J(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function Pe(e,t=null){H?.remove(),H=e,U=t,H.style.pointerEvents=`none`}function Y(e,t){window.parent.postMessage(t,e)}function X(){V?.(),V=null}function Z(e,t,n){X(),Y(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Fe(e,t,n){let r=e.getBoundingClientRect(),i=Ae(e);if(!r.width||!r.height||!i)return null;let a=Te(K(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:q(),selector:i,accessibleName:Oe(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:De(r),viewport:Ee(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Ie(e,t){X();let n=null,r=Ne(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${B}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,J(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Fe(n,i.clientX,i.clientY);a?(r.style.position=$(n)?`fixed`:`absolute`,J(r,n.getBoundingClientRect()),Pe(r,n),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Z(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),V=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,H!==r&&r.remove()}}function Le(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(B)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=Ae(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:Oe(e),tagName:e.tagName.toLowerCase(),role:Te(e.getAttribute(`role`)||``,64),textExcerpt:Te(K(e.textContent||``),500),rect:De(n)}]})}function Re(e){return{schemaVersion:1,kind:`area`,route:q(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:De(e),viewport:Ee(),elements:Le(e)}}function ze(e,t,n=!1){X();let r=document.createElement(`div`);r.setAttribute(B,``),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let i=Ne();i.style.display=`none`,document.body.append(r);let a=null,o=null,s=null,c=null;function l(e,t){r.style.pointerEvents=`none`;let n=document.elementFromPoint(e,t);return r.style.pointerEvents=``,n===document.body||n===document.documentElement?null:n}function u(n,r,a){i.style.position=a&&$(a)?`fixed`:`absolute`,J(i,r),Pe(i,a),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:n})}function d(e,t){if(!a)return;let n=Math.min(a.x,e),r=Math.min(a.y,t),o=Math.abs(e-a.x),s=Math.abs(t-a.y);i.style.display=`block`,J(i,new DOMRect(n,r,o,s))}function f(e){e.button!==0||a||(e.preventDefault(),a={x:e.clientX,y:e.clientY},s=e.pointerId,o=n?l(e.clientX,e.clientY):null,r.setPointerCapture(e.pointerId),d(e.clientX,e.clientY))}function p(e){if(a)e.pointerId===s&&(e.preventDefault(),d(e.clientX,e.clientY));else{if(!n)return;let t=l(e.clientX,e.clientY);i.style.display=t?`block`:`none`,t&&J(i,t.getBoundingClientRect())}}function m(r){if(!a||r.pointerId!==s)return;r.preventDefault();let i=Math.max(0,Math.min(window.innerWidth,r.clientX)),c=Math.max(0,Math.min(window.innerHeight,r.clientY)),l=new DOMRect(Math.min(a.x,i),Math.min(a.y,c),Math.abs(i-a.x),Math.abs(c-a.y));if(n&&Math.hypot(l.width,l.height)<8){let n=o?Fe(o,a.x,a.y):null;if(!n||!o){Z(e,t,`element-unavailable`);return}u(n,o.getBoundingClientRect(),o)}else(n?l.width<8||l.height<8:Math.hypot(l.width,l.height)<8)?Z(e,t,`area-too-small`):u(Re(l),l)}function h(r){if(!n||r.detail!==0||!(r.target instanceof Element)||r.target.hasAttribute(B))return;r.preventDefault(),r.stopImmediatePropagation();let i=r.target,a=i.getBoundingClientRect(),o=Fe(i,a.left+a.width/2,a.top+a.height/2);o?u(o,a,i):Z(e,t,`element-unavailable`)}function g(n){X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t,reason:n?`interrupted`:`escape`})}function _(r){if(n&&r.shiftKey&&r.key===`Enter`)r.preventDefault(),c={x:window.innerWidth/2,y:window.innerHeight/2},a=null,i.style.display=`block`,J(i,new DOMRect(c.x,c.y,4,4));else if(c&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(r.key)){if(r.preventDefault(),r.key===`Enter`||r.key===` `){if(!a)a={...c};else{let n=new DOMRect(Math.min(a.x,c.x),Math.min(a.y,c.y),Math.abs(a.x-c.x),Math.abs(a.y-c.y));if(n.width<8||n.height<8){Z(e,t,`area-too-small`);return}u(Re(n),n)}}else c={x:Math.max(0,Math.min(window.innerWidth,c.x+(r.key===`ArrowRight`?10:r.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(window.innerHeight,c.y+(r.key===`ArrowDown`?10:r.key===`ArrowUp`?-10:0)))},a?d(c.x,c.y):J(i,new DOMRect(c.x,c.y,4,4))}else r.key===`Escape`&&(r.preventDefault(),g())}r.addEventListener(`pointerdown`,f),r.addEventListener(`pointermove`,p),r.addEventListener(`pointerup`,m),r.addEventListener(`pointercancel`,g),r.addEventListener(`lostpointercapture`,g),n&&document.addEventListener(`click`,h,!0),document.addEventListener(`keydown`,_,!0),V=()=>{r.removeEventListener(`pointerdown`,f),r.removeEventListener(`pointermove`,p),r.removeEventListener(`pointerup`,m),r.removeEventListener(`pointercancel`,g),r.removeEventListener(`lostpointercapture`,g),n&&document.removeEventListener(`click`,h,!0),document.removeEventListener(`keydown`,_,!0),r.remove(),H!==i&&i.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function Be(e){let t=q();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=Me({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:$(n)}}function Ve(e=!1){if(!W||!be)return;let t=q(),n=JSON.stringify(t);e&&=n===Se,Se=n;let r=[];for(let t of W.anchors){let n=G.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=Be(t.anchor);if(!e){G.delete(t.id);continue}G.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}Y(be,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:W.nonce,route:t,...Ce===we()?{replaceRoute:!0}:{},results:r})}function He(e){let t=e.data;if(document.querySelector(`script[src=\"${A(window.location.pathname)}__replica/bridge/v1.js\"]`)||e.source!==window.parent||e.origin!==be||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){Y(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,improvementSelection:!0,nonce:t.nonce,route:q(),...Ce===we()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;xe=t.accent;for(let e of document.querySelectorAll(`[${B}]`))e.style.setProperty(`--replica-selection-accent`,xe);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=q(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(k(n,!0)||(Oe(n)||K(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Ie(e.origin,t.nonce):t.mode===`area`?ze(e.origin,t.nonce):t.mode===`improvement`&&ze(e.origin,t.nonce,!0);return}if(t.type===`replica:canvas:cancel-selection`){X(),Y(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce,reason:`command`});return}if(t.type===`replica:canvas:clear-selection`){H?.remove(),H=null,U=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors))return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});W={nonce:t.nonce,anchors:n},G.clear(),Ve()}var Ue=Symbol.for(`replica.canvas.bridge.v1`),We=window;function Ge(e){let t=We[Ue];if(t===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof t==`function`&&t(),xe=`light-dark(#0969da, #58a6ff)`,be=e,W=null,Se=``,G.clear();let n=ve(e),r=null;function i(){r!==null&&window.cancelAnimationFrame(r),r=null,H&&U&&(H.style.position=$(U)?`fixed`:`absolute`,J(H,U.getBoundingClientRect())),Ve()}function a(){r===null&&W&&(r=window.requestAnimationFrame(i))}function o(e){H&&U&&(e.target!==document&&e.target!==window||$(U))&&J(H,U.getBoundingClientRect()),r===null?Ve(e.target===document||e.target===window):i()}function s(){Ve()}function c(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||V||!W||t.target instanceof Element&&t.target.closest(`[role=\"dialog\"], dialog, [role=\"menu\"]`))return;let n=W;window.setTimeout(()=>{t.defaultPrevented||V||W!==n||Y(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,He),window.addEventListener(`scroll`,o,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),window.addEventListener(`keydown`,c);let l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${B}], [data-replica-controls-bridge]`)))&&a()});l.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let u=typeof ResizeObserver==`function`?new ResizeObserver(a):null;u?.observe(document.documentElement),We[Ue]=()=>{window.removeEventListener(`message`,He),window.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,s),window.removeEventListener(`keydown`,c),l.disconnect(),u?.disconnect(),r!==null&&window.cancelAnimationFrame(r),W=null,Se=``,G.clear(),n(),X(),H?.remove(),H=null,U=null}}function Ke(e,t=`canvas`){if(t===`canvas`){if(!/^http:\\/\\/127\\.0\\.0\\.1:\\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`)}else{let t=URL.parse(e);if(!t||t.origin!==e||t.pathname!==`/`||t.search||t.hash||![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid Replica Hub parent.`)}Ge(e)}function qe(e){Ke(e,`hosted`)}return e.installHostedBridge=qe,e})({});" diff --git a/hub/server/assets/hosted-review-bridge.ts b/hub/server/assets/hosted-review-bridge.ts index 03302a454..ce26d2839 100644 --- a/hub/server/assets/hosted-review-bridge.ts +++ b/hub/server/assets/hosted-review-bridge.ts @@ -1,2 +1,2 @@ // prettier-ignore -export const hostedReviewBridgeSource = ";(function installReplicaPreviewBridge() {\n \"use strict\"\n\n // Preview hosts serve this script directly, so it cannot import Vite modules.\n const HUB_ORIGIN = \"__REPLICA_HUB_ORIGIN__\"\n const REVIEW_ENABLED = \"__REPLICA_REVIEW_ENABLED__\" !== \"false\"\n const PROTOCOL_VERSION = 1\n const ANCHOR_SCHEMA_VERSION = 1\n const REQUEST_ID_MAXIMUM_BYTES = 128\n const ANCHORS_PER_MESSAGE = 200\n const ANCHOR_MAXIMUM_BYTES = 16_384\n const PATHNAME_MAXIMUM_BYTES = 2_048\n const SEARCH_MAXIMUM_BYTES = 2_048\n const HASH_MAXIMUM_BYTES = 1_024\n const SELECTOR_MAXIMUM_BYTES = 4_096\n const ACCESSIBLE_NAME_MAXIMUM_BYTES = 1_000\n const TAG_NAME_MAXIMUM_BYTES = 64\n const SELECTED_TEXT_MAXIMUM_BYTES = 2_000\n const AREA_ROLE_MAXIMUM_BYTES = 64\n const AREA_TEXT_EXCERPT_MAXIMUM_BYTES = 500\n const AREA_PATH_MAXIMUM_POINTS = 160\n const AREA_ELEMENTS_MAXIMUM = 8\n const AREA_MINIMUM_DIAGONAL = 8\n const AREA_SAMPLE_GRID = 6\n const AREA_GEOMETRY_TOLERANCE = 0.15\n const GEOMETRY_ABSOLUTE_MAXIMUM = 1_000_000\n const VIEWPORT_DIMENSION_MAXIMUM = 100_000\n const HIGHLIGHT_FADE_MILLISECONDS = 200\n const BRIDGE_NODE_ATTRIBUTE = \"data-replica-bridge\"\n const textEncoder = new TextEncoder()\n const nativeReplaceState = History.prototype.replaceState\n\n let selectionMode = null\n let selectionRequestId = null\n let drawingPointerId = null\n let shapeOptimizing = false\n let areaStroke = []\n let selectionPending = false\n let pendingAreaAnchor = null\n let highlightedElement = null\n let highlightElement = null\n let areaHighlightElement = null\n let areaHighlightPath = null\n let originalCursor = \"\"\n let originalTouchAction = \"\"\n let focusTimer = null\n let geometryFrame = null\n let pendingFragmentRoute = null\n let fragmentRestoreToken = null\n const anchors = new Map()\n const geometry = new Map()\n\n function isViewportAnchoredElement(element) {\n for (let current = element; current; current = current.parentElement) {\n const position = window.getComputedStyle(current).position\n if (position === \"fixed\" || position === \"sticky\") return true\n }\n return false\n }\n\n function isObject(value) {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n }\n\n function hasExactKeys(value, expected) {\n const actual = Object.keys(value)\n return actual.length === expected.length && expected.every((key) => actual.includes(key))\n }\n\n function byteLength(value) {\n return textEncoder.encode(value).length\n }\n\n function isBoundedString(value, maximumBytes, options = {}) {\n if (typeof value !== \"string\" || byteLength(value) > maximumBytes) return false\n if (options.required && value.trim() === \"\") return false\n if (options.prefix && value !== \"\" && !value.startsWith(options.prefix)) return false\n return true\n }\n\n function isFiniteNumber(value, minimum, maximum) {\n return (\n typeof value === \"number\" && Number.isFinite(value) && value >= minimum && value <= maximum\n )\n }\n\n function isRoute(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\"pathname\", \"search\", \"hash\"]) &&\n isBoundedString(value.pathname, PATHNAME_MAXIMUM_BYTES, {\n required: true,\n prefix: \"/\",\n }) &&\n isBoundedString(value.search, SEARCH_MAXIMUM_BYTES, { prefix: \"?\" }) &&\n isBoundedString(value.hash, HASH_MAXIMUM_BYTES, { prefix: \"#\" })\n )\n }\n\n function isRect(value, allowNegativePosition) {\n const minimumPosition = allowNegativePosition ? -GEOMETRY_ABSOLUTE_MAXIMUM : 0\n return (\n isObject(value) &&\n hasExactKeys(value, [\"x\", \"y\", \"width\", \"height\"]) &&\n isFiniteNumber(value.x, minimumPosition, GEOMETRY_ABSOLUTE_MAXIMUM) &&\n isFiniteNumber(value.y, minimumPosition, GEOMETRY_ABSOLUTE_MAXIMUM) &&\n isFiniteNumber(value.width, 0, GEOMETRY_ABSOLUTE_MAXIMUM) &&\n isFiniteNumber(value.height, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n )\n }\n\n function isViewport(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\"width\", \"height\", \"scrollX\", \"scrollY\"]) &&\n isFiniteNumber(value.width, 1, VIEWPORT_DIMENSION_MAXIMUM) &&\n isFiniteNumber(value.height, 1, VIEWPORT_DIMENSION_MAXIMUM) &&\n isFiniteNumber(value.scrollX, 0, GEOMETRY_ABSOLUTE_MAXIMUM) &&\n isFiniteNumber(value.scrollY, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n )\n }\n\n function isNormalizedPoint(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\"x\", \"y\"]) &&\n isFiniteNumber(value.x, 0, 1) &&\n isFiniteNumber(value.y, 0, 1)\n )\n }\n\n function hasValidSerializedSize(value) {\n try {\n return byteLength(JSON.stringify(value)) <= ANCHOR_MAXIMUM_BYTES\n } catch {\n return false\n }\n }\n\n function isElementAnchor(value) {\n if (\n !isObject(value) ||\n !hasExactKeys(value, [\n \"schemaVersion\",\n \"kind\",\n \"route\",\n \"selector\",\n \"accessibleName\",\n \"tagName\",\n \"selectedText\",\n \"rect\",\n \"viewport\",\n \"elementOffset\",\n ])\n ) {\n return false\n }\n\n return (\n value.schemaVersion === ANCHOR_SCHEMA_VERSION &&\n value.kind === \"element\" &&\n isRoute(value.route) &&\n isBoundedString(value.selector, SELECTOR_MAXIMUM_BYTES, { required: true }) &&\n isBoundedString(value.accessibleName, ACCESSIBLE_NAME_MAXIMUM_BYTES) &&\n isBoundedString(value.tagName, TAG_NAME_MAXIMUM_BYTES, { required: true }) &&\n /^[a-z][a-z0-9-]*$/.test(value.tagName) &&\n isBoundedString(value.selectedText, SELECTED_TEXT_MAXIMUM_BYTES) &&\n isRect(value.rect, false) &&\n isViewport(value.viewport) &&\n isNormalizedPoint(value.elementOffset) &&\n hasValidSerializedSize(value)\n )\n }\n\n function isAreaElement(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\n \"selector\",\n \"accessibleName\",\n \"tagName\",\n \"role\",\n \"textExcerpt\",\n \"rect\",\n ]) &&\n isBoundedString(value.selector, SELECTOR_MAXIMUM_BYTES, { required: true }) &&\n isBoundedString(value.accessibleName, ACCESSIBLE_NAME_MAXIMUM_BYTES) &&\n isBoundedString(value.tagName, TAG_NAME_MAXIMUM_BYTES, { required: true }) &&\n /^[a-z][a-z0-9-]*$/.test(value.tagName) &&\n isBoundedString(value.role, AREA_ROLE_MAXIMUM_BYTES) &&\n isBoundedString(value.textExcerpt, AREA_TEXT_EXCERPT_MAXIMUM_BYTES) &&\n isRect(value.rect, false)\n )\n }\n\n function isAreaAnchor(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\n \"schemaVersion\",\n \"kind\",\n \"route\",\n \"path\",\n \"rect\",\n \"viewport\",\n \"elements\",\n ]) &&\n value.schemaVersion === ANCHOR_SCHEMA_VERSION &&\n value.kind === \"area\" &&\n isRoute(value.route) &&\n Array.isArray(value.path) &&\n value.path.length >= 2 &&\n value.path.length <= AREA_PATH_MAXIMUM_POINTS &&\n value.path.every(isNormalizedPoint) &&\n isRect(value.rect, false) &&\n Math.hypot(value.rect.width, value.rect.height) >= AREA_MINIMUM_DIAGONAL &&\n isViewport(value.viewport) &&\n Array.isArray(value.elements) &&\n value.elements.length <= AREA_ELEMENTS_MAXIMUM &&\n value.elements.every(isAreaElement) &&\n hasValidSerializedSize(value)\n )\n }\n\n function isAnchor(value) {\n return isElementAnchor(value) || isAreaAnchor(value)\n }\n\n function isCommand(message) {\n if (\n !isObject(message) ||\n !hasExactKeys(message, [\"protocolVersion\", \"requestId\", \"type\", \"payload\"]) ||\n message.protocolVersion !== PROTOCOL_VERSION ||\n !isBoundedString(message.requestId, REQUEST_ID_MAXIMUM_BYTES, { required: true }) ||\n typeof message.type !== \"string\" ||\n !isObject(message.payload)\n ) {\n return false\n }\n\n if (\n message.type === \"replica:bridge:request-ready\" ||\n message.type === \"replica:bridge:select-element\" ||\n message.type === \"replica:bridge:select-area\" ||\n message.type === \"replica:bridge:cancel-selection\" ||\n message.type === \"replica:bridge:clear-selection\"\n ) {\n return hasExactKeys(message.payload, [])\n }\n\n if (message.type === \"replica:bridge:focus-anchor\") {\n return (\n hasExactKeys(message.payload, [\"commentId\"]) &&\n Number.isSafeInteger(message.payload.commentId) &&\n message.payload.commentId > 0\n )\n }\n\n if (message.type === \"replica:bridge:set-theme\") {\n return (\n hasExactKeys(message.payload, [\"theme\"]) &&\n (message.payload.theme === \"light\" || message.payload.theme === \"dark\")\n )\n }\n\n if (message.type === \"replica:bridge:restore-fragment\") {\n return (\n hasExactKeys(message.payload, [\"route\"]) &&\n isRoute(message.payload.route) &&\n message.payload.route.hash.length > 1 &&\n !message.payload.route.hash.startsWith(\"#/\") &&\n !message.payload.route.hash.startsWith(\"#!\") &&\n new URL(message.payload.route.hash, location.href).hash === message.payload.route.hash\n )\n }\n\n if (message.type === \"replica:bridge:resolve-anchors\") {\n if (\n !hasExactKeys(message.payload, [\"replace\", \"anchors\"]) ||\n typeof message.payload.replace !== \"boolean\" ||\n !Array.isArray(message.payload.anchors) ||\n message.payload.anchors.length > ANCHORS_PER_MESSAGE\n ) {\n return false\n }\n\n return message.payload.anchors.every(\n (entry) =>\n isObject(entry) &&\n hasExactKeys(entry, [\"commentId\", \"originBuild\", \"anchor\"]) &&\n Number.isSafeInteger(entry.commentId) &&\n entry.commentId > 0 &&\n typeof entry.originBuild === \"boolean\" &&\n isAnchor(entry.anchor),\n )\n }\n\n return false\n }\n\n function createRequestId() {\n return crypto.randomUUID()\n }\n\n function currentRoute() {\n return {\n pathname: truncate(location.pathname, PATHNAME_MAXIMUM_BYTES),\n search: truncate(controlFreeSearch(), SEARCH_MAXIMUM_BYTES),\n hash: truncate(location.hash, HASH_MAXIMUM_BYTES),\n }\n }\n\n function controlFreeSearch() {\n const search = location.search\n .slice(1)\n .split(\"&\")\n .filter((part) => {\n const key = new URLSearchParams(part).keys().next().value\n return key !== \"rc\" && !key?.startsWith(\"rc.\")\n })\n .join(\"&\")\n return search ? `?${search}` : \"\"\n }\n\n function post(type, requestId, payload) {\n window.parent.postMessage(\n { protocolVersion: PROTOCOL_VERSION, requestId, type, payload },\n HUB_ORIGIN,\n )\n }\n\n function normalizeText(value) {\n return value.replace(/\\s+/g, \" \").trim()\n }\n\n function truncate(value, maximumBytes) {\n let result = \"\"\n for (const character of value) {\n if (byteLength(result + character) > maximumBytes) break\n result += character\n }\n return result\n }\n\n function accessibleName(element) {\n const labelledBy = element.getAttribute(\"aria-labelledby\")\n const labelledText = labelledBy\n ? labelledBy\n .split(/\\s+/)\n .map((id) => document.getElementById(id)?.textContent || \"\")\n .join(\" \")\n : \"\"\n const labels =\n \"labels\" in element && element.labels\n ? Array.from(element.labels)\n .map((label) => label.textContent || \"\")\n .join(\" \")\n : \"\"\n const value =\n element.getAttribute(\"aria-label\") ||\n labelledText ||\n labels ||\n element.getAttribute(\"alt\") ||\n element.getAttribute(\"title\") ||\n \"\"\n return truncate(normalizeText(value), ACCESSIBLE_NAME_MAXIMUM_BYTES)\n }\n\n function selectedText(element) {\n const selection = window.getSelection()\n const anchorNode = selection?.anchorNode\n const focusNode = selection?.focusNode\n if (\n !selection ||\n selection.isCollapsed ||\n !anchorNode ||\n !focusNode ||\n !element.contains(anchorNode) ||\n !element.contains(focusNode)\n )\n return \"\"\n return truncate(normalizeText(selection.toString()), SELECTED_TEXT_MAXIMUM_BYTES)\n }\n\n function textExcerpt(element) {\n return truncate(normalizeText(element.textContent || \"\"), AREA_TEXT_EXCERPT_MAXIMUM_BYTES)\n }\n\n function clamp(value, minimum, maximum) {\n return Math.max(minimum, Math.min(value, maximum))\n }\n\n function capturedViewport() {\n return {\n width: clamp(window.innerWidth, 1, VIEWPORT_DIMENSION_MAXIMUM),\n height: clamp(window.innerHeight, 1, VIEWPORT_DIMENSION_MAXIMUM),\n scrollX: clamp(window.scrollX, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n scrollY: clamp(window.scrollY, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n }\n }\n\n function documentRectangle(element) {\n const rect = element.getBoundingClientRect()\n const x = clamp(rect.left + window.scrollX, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n const y = clamp(rect.top + window.scrollY, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n return {\n x,\n y,\n width: clamp(rect.width, 0, GEOMETRY_ABSOLUTE_MAXIMUM - x),\n height: clamp(rect.height, 0, GEOMETRY_ABSOLUTE_MAXIMUM - y),\n }\n }\n\n function escapedIdentifier(value) {\n if (window.CSS && typeof window.CSS.escape === \"function\") return window.CSS.escape(value)\n return value.replace(/[^a-zA-Z0-9_-]/g, (character) => `\\\\${character}`)\n }\n\n function escapedAttribute(value) {\n return value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')\n }\n\n function isUniqueSelector(selector, element) {\n try {\n const matches = document.querySelectorAll(selector)\n return matches.length === 1 && matches[0] === element\n } catch {\n return false\n }\n }\n\n function selectorFor(element) {\n if (element.id) {\n const selector = `#${escapedIdentifier(element.id)}`\n if (isUniqueSelector(selector, element)) return selector\n }\n\n for (const attribute of [\"data-testid\", \"data-test-id\", \"data-component\"]) {\n const value = element.getAttribute(attribute)\n if (!value || byteLength(value) > 512) continue\n const selector = `${element.tagName.toLowerCase()}[${attribute}=\"${escapedAttribute(value)}\"]`\n if (isUniqueSelector(selector, element)) return selector\n }\n\n const parts = []\n let current = element\n while (current instanceof Element) {\n const tagName = current.tagName.toLowerCase()\n const siblings = current.parentElement\n ? Array.from(current.parentElement.children).filter(\n (sibling) => sibling.tagName === current.tagName,\n )\n : []\n const position = siblings.indexOf(current)\n parts.unshift(\n siblings.length > 1 && position >= 0 ? `${tagName}:nth-of-type(${position + 1})` : tagName,\n )\n const selector = parts.join(\" > \")\n if (byteLength(selector) > SELECTOR_MAXIMUM_BYTES) return null\n if (isUniqueSelector(selector, element)) return selector\n current = current.parentElement\n }\n return null\n }\n\n function capturedAnchor(element, event) {\n const selector = selectorFor(element)\n if (!selector) return null\n\n const rect = element.getBoundingClientRect()\n const width = Math.max(0, Math.min(rect.width, GEOMETRY_ABSOLUTE_MAXIMUM))\n const height = Math.max(0, Math.min(rect.height, GEOMETRY_ABSOLUTE_MAXIMUM))\n const offsetX = width > 0 ? (event.clientX - rect.left) / width : 0.5\n const offsetY = height > 0 ? (event.clientY - rect.top) / height : 0.5\n return {\n schemaVersion: ANCHOR_SCHEMA_VERSION,\n kind: \"element\",\n route: currentRoute(),\n selector,\n accessibleName: accessibleName(element),\n tagName: element.tagName.toLowerCase(),\n selectedText: selectedText(element),\n rect: {\n x: Math.max(0, Math.min(rect.left + window.scrollX, GEOMETRY_ABSOLUTE_MAXIMUM)),\n y: Math.max(0, Math.min(rect.top + window.scrollY, GEOMETRY_ABSOLUTE_MAXIMUM)),\n width,\n height,\n },\n viewport: capturedViewport(),\n elementOffset: {\n x: Math.max(0, Math.min(offsetX, 1)),\n y: Math.max(0, Math.min(offsetY, 1)),\n },\n }\n }\n\n function pointDistance(first, second) {\n return Math.hypot(second.x - first.x, second.y - first.y)\n }\n\n function pathBounds(points) {\n const xs = points.map((point) => point.x)\n const ys = points.map((point) => point.y)\n const left = Math.min(...xs)\n const right = Math.max(...xs)\n const top = Math.min(...ys)\n const bottom = Math.max(...ys)\n return {\n left,\n right,\n top,\n bottom,\n width: right - left,\n height: bottom - top,\n diagonal: Math.hypot(right - left, bottom - top),\n }\n }\n\n function pointToSegmentDistance(point, start, end) {\n const dx = end.x - start.x\n const dy = end.y - start.y\n const lengthSquared = dx * dx + dy * dy\n if (lengthSquared === 0) return pointDistance(point, start)\n\n const projection = clamp(\n ((point.x - start.x) * dx + (point.y - start.y) * dy) / lengthSquared,\n 0,\n 1,\n )\n return Math.hypot(point.x - (start.x + projection * dx), point.y - (start.y + projection * dy))\n }\n\n function pathScore(points, candidate, normalizer) {\n const squaredErrors = points.map((point) => {\n let nearest = Number.POSITIVE_INFINITY\n for (let index = 1; index < candidate.length; index += 1) {\n nearest = Math.min(\n nearest,\n pointToSegmentDistance(point, candidate[index - 1], candidate[index]),\n )\n }\n return nearest * nearest\n })\n return (\n Math.sqrt(squaredErrors.reduce((sum, error) => sum + error, 0) / squaredErrors.length) /\n normalizer\n )\n }\n\n function rectanglePath(bounds, square) {\n const centerX = (bounds.left + bounds.right) / 2\n const centerY = (bounds.top + bounds.bottom) / 2\n const halfWidth = square ? (bounds.width + bounds.height) / 4 : bounds.width / 2\n const halfHeight = square ? halfWidth : bounds.height / 2\n const left = centerX - halfWidth\n const right = centerX + halfWidth\n const top = centerY - halfHeight\n const bottom = centerY + halfHeight\n return [\n { x: left, y: top },\n { x: right, y: top },\n { x: right, y: bottom },\n { x: left, y: bottom },\n { x: left, y: top },\n ]\n }\n\n function ellipsePath(bounds, circle) {\n const centerX = (bounds.left + bounds.right) / 2\n const centerY = (bounds.top + bounds.bottom) / 2\n const radiusX = circle ? (bounds.width + bounds.height) / 4 : bounds.width / 2\n const radiusY = circle ? radiusX : bounds.height / 2\n return Array.from({ length: 49 }, (_, index) => {\n const angle = (index / 48) * Math.PI * 2\n return {\n x: centerX + Math.cos(angle) * radiusX,\n y: centerY + Math.sin(angle) * radiusY,\n }\n })\n }\n\n function optimizedStroke(points) {\n if (points.length < 2) return points\n\n const bounds = pathBounds(points)\n if (bounds.diagonal < 16) return points\n\n const first = points[0]\n const last = points[points.length - 1]\n const closureRatio = pointDistance(first, last) / bounds.diagonal\n if (closureRatio > 0.25 || points.length < 8) {\n const line = [first, last]\n return pathScore(points, line, bounds.diagonal) <= 0.08 ? line : points\n }\n\n const candidates = [\n rectanglePath(bounds, false),\n rectanglePath(bounds, true),\n ellipsePath(bounds, false),\n ellipsePath(bounds, true),\n ].map((path) => ({ path, score: pathScore(points, path, bounds.diagonal) }))\n const best = candidates.reduce((current, candidate) =>\n candidate.score < current.score ? candidate : current,\n )\n return best.score <= 0.1 ? best.path : points\n }\n\n function downsamplePath(points, maximum) {\n if (points.length <= maximum) return points\n\n return Array.from({ length: maximum }, (_, index) => {\n const sourceIndex = Math.round((index / (maximum - 1)) * (points.length - 1))\n return points[sourceIndex]\n })\n }\n\n function areaElementContext(element) {\n const selector = selectorFor(element)\n if (!selector) return null\n\n return {\n selector,\n accessibleName: accessibleName(element),\n tagName: element.tagName.toLowerCase(),\n role: truncate(element.getAttribute(\"role\") || \"\", AREA_ROLE_MAXIMUM_BYTES),\n textExcerpt: textExcerpt(element),\n rect: documentRectangle(element),\n }\n }\n\n function captureAreaElements(bounds) {\n const found = new Map()\n for (\n let column = 0;\n column < AREA_SAMPLE_GRID && found.size < AREA_ELEMENTS_MAXIMUM;\n column += 1\n ) {\n for (let row = 0; row < AREA_SAMPLE_GRID && found.size < AREA_ELEMENTS_MAXIMUM; row += 1) {\n const x = bounds.left + (bounds.width * (column + 0.5)) / AREA_SAMPLE_GRID\n const y = bounds.top + (bounds.height * (row + 0.5)) / AREA_SAMPLE_GRID\n const element = document\n .elementsFromPoint(x, y)\n .find(\n (candidate) =>\n candidate !== document.documentElement &&\n candidate !== document.body &&\n !candidate.closest(`[${BRIDGE_NODE_ATTRIBUTE}]`),\n )\n if (!element) continue\n\n const context = areaElementContext(element)\n if (context && !found.has(context.selector))\n found.set(context.selector, { context, element })\n }\n }\n\n const entries = Array.from(found.values())\n return entries\n .filter(\n (entry) =>\n !entries.some(\n (candidate) => candidate !== entry && entry.element.contains(candidate.element),\n ),\n )\n .slice(0, AREA_ELEMENTS_MAXIMUM)\n .map((entry) => entry.context)\n }\n\n function normalizedAreaPath(points, bounds) {\n return points.map((point) => ({\n x: bounds.width > 0 ? clamp((point.x - bounds.left) / bounds.width, 0, 1) : 0.5,\n y: bounds.height > 0 ? clamp((point.y - bounds.top) / bounds.height, 0, 1) : 0.5,\n }))\n }\n\n function capturedAreaAnchor(clientPoints, optimize) {\n let points = optimize ? optimizedStroke(clientPoints) : clientPoints\n points = downsamplePath(points, AREA_PATH_MAXIMUM_POINTS)\n const bounds = pathBounds(points)\n if (bounds.diagonal < AREA_MINIMUM_DIAGONAL) return { reason: \"area-too-small\" }\n\n const left = clamp(bounds.left + window.scrollX, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n const top = clamp(bounds.top + window.scrollY, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n const right = clamp(bounds.right + window.scrollX, left, GEOMETRY_ABSOLUTE_MAXIMUM)\n const bottom = clamp(bounds.bottom + window.scrollY, top, GEOMETRY_ABSOLUTE_MAXIMUM)\n const anchor = {\n schemaVersion: ANCHOR_SCHEMA_VERSION,\n kind: \"area\",\n route: currentRoute(),\n path: normalizedAreaPath(points, bounds),\n rect: { x: left, y: top, width: right - left, height: bottom - top },\n viewport: capturedViewport(),\n elements: captureAreaElements(bounds),\n }\n\n while (!isAreaAnchor(anchor) && anchor.elements.length > 0) anchor.elements.pop()\n while (!isAreaAnchor(anchor) && anchor.path.length > 2) {\n anchor.path = downsamplePath(anchor.path, Math.max(2, Math.floor(anchor.path.length / 2)))\n }\n return isAreaAnchor(anchor) ? { anchor } : { reason: \"area-unavailable\" }\n }\n\n function routeMatches(route) {\n const current = currentRoute()\n return (\n route.pathname === current.pathname &&\n route.search === current.search &&\n route.hash === current.hash\n )\n }\n\n function querySelectorElement(selector) {\n try {\n return document.querySelector(selector)\n } catch {\n return null\n }\n }\n\n function savedContextText(context) {\n return \"selectedText\" in context ? context.selectedText : context.textExcerpt\n }\n\n function elementMatchesContext(element, context) {\n if (element.tagName.toLowerCase() !== context.tagName) return false\n if (context.accessibleName && accessibleName(element) !== context.accessibleName) return false\n if (\"role\" in context && context.role && element.getAttribute(\"role\") !== context.role)\n return false\n\n const savedText = savedContextText(context)\n return !savedText || normalizeText(element.textContent || \"\").includes(savedText)\n }\n\n function uniqueContextElement(context, excludedElement) {\n const savedText = savedContextText(context)\n if (!context.accessibleName && !savedText) return null\n\n let match = null\n for (const element of document.getElementsByTagName(context.tagName)) {\n if (\n element === excludedElement ||\n element.closest(`[${BRIDGE_NODE_ATTRIBUTE}]`) ||\n !elementMatchesContext(element, context)\n ) {\n continue\n }\n if (match) return null\n\n match = element\n }\n return match\n }\n\n function resolvedElementContext(context) {\n const selected = querySelectorElement(context.selector)\n if (selected && elementMatchesContext(selected, context)) {\n return { status: \"resolved\", element: selected }\n }\n\n const moved = uniqueContextElement(context, selected)\n if (moved) return { status: \"moved\", element: moved }\n return { status: selected ? \"changed\" : \"missing\" }\n }\n\n function viewportRectangle(element) {\n const rect = element.getBoundingClientRect()\n return {\n x: clamp(rect.left, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n y: clamp(rect.top, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n width: clamp(rect.width, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n height: clamp(rect.height, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n }\n }\n\n function resolvedElementAnchor(commentId, anchor, originBuild) {\n const target = resolvedElementContext(anchor)\n if (!target.element) return { result: { commentId, status: target.status } }\n\n const boundedRect = viewportRectangle(target.element)\n if (!isRect(boundedRect, true)) {\n return { result: { commentId, status: \"missing\" } }\n }\n\n const documentRect = documentRectangle(target.element)\n const status =\n target.status === \"moved\" || (!originBuild && rectanglesDiffer(anchor.rect, documentRect))\n ? \"moved\"\n : \"resolved\"\n return {\n result: {\n commentId,\n status,\n rect: boundedRect,\n point: {\n x: clamp(\n boundedRect.x + boundedRect.width * anchor.elementOffset.x,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n y: clamp(\n boundedRect.y + boundedRect.height * anchor.elementOffset.y,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n },\n },\n element: target.element,\n viewportAnchored: isViewportAnchoredElement(target.element),\n }\n }\n\n function rectangleUnion(rectangles) {\n const left = Math.min(...rectangles.map((rect) => rect.x))\n const top = Math.min(...rectangles.map((rect) => rect.y))\n const right = Math.max(...rectangles.map((rect) => rect.x + rect.width))\n const bottom = Math.max(...rectangles.map((rect) => rect.y + rect.height))\n return { x: left, y: top, width: right - left, height: bottom - top }\n }\n\n function normalizedRectangle(rect, union) {\n return {\n x: union.width > 0 ? (rect.x - union.x) / union.width : 0,\n y: union.height > 0 ? (rect.y - union.y) / union.height : 0,\n width: union.width > 0 ? rect.width / union.width : 1,\n height: union.height > 0 ? rect.height / union.height : 1,\n }\n }\n\n function areaGeometryMatches(savedRectangles, currentRectangles) {\n if (savedRectangles.length <= 1) return true\n\n const savedUnion = rectangleUnion(savedRectangles)\n const currentUnion = rectangleUnion(currentRectangles)\n return savedRectangles.every((savedRect, index) => {\n const currentRect = currentRectangles[index]\n const saved = normalizedRectangle(savedRect, savedUnion)\n const current = normalizedRectangle(currentRect, currentUnion)\n return [\"x\", \"y\", \"width\", \"height\"].every(\n (key) => Math.abs(saved[key] - current[key]) <= AREA_GEOMETRY_TOLERANCE,\n )\n })\n }\n\n function transformCoordinate(value, savedStart, savedSize, currentStart, currentSize) {\n if (savedSize === 0) return value + currentStart - savedStart\n return currentStart + ((value - savedStart) / savedSize) * currentSize\n }\n\n function transformedAreaRectangle(rect, savedUnion, currentUnion) {\n const left = transformCoordinate(\n rect.x,\n savedUnion.x,\n savedUnion.width,\n currentUnion.x,\n currentUnion.width,\n )\n const right = transformCoordinate(\n rect.x + rect.width,\n savedUnion.x,\n savedUnion.width,\n currentUnion.x,\n currentUnion.width,\n )\n const top = transformCoordinate(\n rect.y,\n savedUnion.y,\n savedUnion.height,\n currentUnion.y,\n currentUnion.height,\n )\n const bottom = transformCoordinate(\n rect.y + rect.height,\n savedUnion.y,\n savedUnion.height,\n currentUnion.y,\n currentUnion.height,\n )\n return {\n x: clamp(Math.min(left, right), 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n y: clamp(Math.min(top, bottom), 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n width: clamp(Math.abs(right - left), 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n height: clamp(Math.abs(bottom - top), 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n }\n }\n\n function rectanglesDiffer(first, second) {\n return [\"x\", \"y\", \"width\", \"height\"].some((key) => Math.abs(first[key] - second[key]) > 4)\n }\n\n function areaPinPoint(anchor, rect) {\n const target = { x: 1, y: 0 }\n const normalized = anchor.path.reduce(\n (nearest, candidate) => {\n const distance = (candidate.x - target.x) ** 2 + (candidate.y - target.y) ** 2\n return distance < nearest.distance ? { point: candidate, distance } : nearest\n },\n { point: target, distance: Number.POSITIVE_INFINITY },\n ).point\n return {\n x: clamp(\n rect.x + normalized.x * rect.width,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n y: clamp(\n rect.y + normalized.y * rect.height,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n }\n }\n\n function areaResult(commentId, anchor, status, documentRect) {\n const rect = {\n x: clamp(\n documentRect.x - window.scrollX,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n y: clamp(\n documentRect.y - window.scrollY,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n width: clamp(documentRect.width, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n height: clamp(documentRect.height, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n }\n return { commentId, status, rect, point: areaPinPoint(anchor, rect) }\n }\n\n function resolvedAreaAnchor(commentId, anchor, originBuild) {\n if (originBuild) {\n return {\n result: areaResult(commentId, anchor, \"resolved\", anchor.rect),\n documentRect: anchor.rect,\n }\n }\n if (anchor.elements.length === 0) return { result: { commentId, status: \"missing\" } }\n\n const targets = anchor.elements.map(resolvedElementContext)\n if (targets.some((target) => target.status === \"changed\")) {\n return { result: { commentId, status: \"changed\" } }\n }\n\n const available = targets.filter((target) => target.element)\n if (available.length === 0) return { result: { commentId, status: \"missing\" } }\n if (available.length !== targets.length) return { result: { commentId, status: \"changed\" } }\n if (new Set(targets.map((target) => target.element)).size !== targets.length) {\n return { result: { commentId, status: \"changed\" } }\n }\n\n const savedRectangles = anchor.elements.map((element) => element.rect)\n const currentRectangles = targets.map((target) => documentRectangle(target.element))\n if (!areaGeometryMatches(savedRectangles, currentRectangles)) {\n return { result: { commentId, status: \"changed\" } }\n }\n\n const savedUnion = rectangleUnion(savedRectangles)\n const currentUnion = rectangleUnion(currentRectangles)\n const documentRect = transformedAreaRectangle(anchor.rect, savedUnion, currentUnion)\n const status =\n targets.some((target) => target.status === \"moved\") ||\n rectanglesDiffer(anchor.rect, documentRect)\n ? \"moved\"\n : \"resolved\"\n return {\n result: areaResult(commentId, anchor, status, documentRect),\n documentRect,\n viewportAnchored: targets.some((target) => isViewportAnchoredElement(target.element)),\n }\n }\n\n function resolvedAnchor(commentId, reference) {\n const anchor = reference.anchor\n if (!routeMatches(anchor.route)) {\n return { result: { commentId, status: \"route-mismatch\" } }\n }\n return anchor.kind === \"area\"\n ? resolvedAreaAnchor(commentId, anchor, reference.originBuild)\n : resolvedElementAnchor(commentId, anchor, reference.originBuild)\n }\n\n function resolveGeometry(commentId, reference) {\n const resolved = resolvedAnchor(commentId, reference)\n geometry.set(commentId, {\n ...resolved,\n scrollX: window.scrollX,\n scrollY: window.scrollY,\n })\n return resolved.result\n }\n\n function resolveEntries(entries, requestId) {\n const results = entries.map(([commentId, reference]) => resolveGeometry(commentId, reference))\n post(\"replica:bridge:anchors-resolved\", requestId, { results })\n return results\n }\n\n function sendAllGeometry() {\n geometryFrame = null\n if (highlightedElement) showHighlight(highlightedElement, true)\n refreshPendingArea()\n const entries = Array.from(anchors.entries())\n for (let index = 0; index < entries.length; index += ANCHORS_PER_MESSAGE) {\n resolveEntries(entries.slice(index, index + ANCHORS_PER_MESSAGE), createRequestId())\n }\n }\n\n function scheduleGeometry() {\n if (geometryFrame !== null || (anchors.size === 0 && !pendingAreaAnchor)) return\n geometryFrame = window.requestAnimationFrame(sendAllGeometry)\n }\n\n function handleScroll(event) {\n // Keep ordinary targets in document coordinates; nested scroll and sticky targets need layout.\n if (event.target !== document && event.target !== window) {\n scheduleGeometry()\n return\n }\n if (highlightedElement && isViewportAnchoredElement(highlightedElement)) {\n showHighlight(highlightedElement, true)\n }\n refreshPendingArea()\n if (geometryFrame !== null) {\n window.cancelAnimationFrame(geometryFrame)\n sendAllGeometry()\n return\n }\n const results = Array.from(anchors, ([commentId, reference]) => {\n const cached = geometry.get(commentId)\n if (!cached || cached.viewportAnchored) {\n return resolveGeometry(commentId, reference)\n }\n const result = cached.result\n if (!result.point) return result\n const dx = cached.scrollX - window.scrollX\n const dy = cached.scrollY - window.scrollY\n return {\n ...result,\n point: {\n x: clamp(result.point.x + dx, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n y: clamp(result.point.y + dy, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n },\n rect: {\n ...result.rect,\n x: clamp(result.rect.x + dx, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n y: clamp(result.rect.y + dy, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n },\n }\n })\n for (let index = 0; index < results.length; index += ANCHORS_PER_MESSAGE) {\n post(\"replica:bridge:anchors-resolved\", createRequestId(), {\n results: results.slice(index, index + ANCHORS_PER_MESSAGE),\n })\n }\n }\n\n function ensureHighlight() {\n if (highlightElement) return highlightElement\n highlightElement = document.createElement(\"div\")\n highlightElement.setAttribute(BRIDGE_NODE_ATTRIBUTE, \"highlight\")\n const reduceMotion =\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n Object.assign(highlightElement.style, {\n background: \"rgba(9, 105, 218, 0.12)\",\n border: \"2px solid rgb(9, 105, 218)\",\n borderRadius: \"4px\",\n boxSizing: \"border-box\",\n opacity: \"0\",\n pointerEvents: \"none\",\n position: \"fixed\",\n transition: reduceMotion ? \"none\" : `opacity ${HIGHLIGHT_FADE_MILLISECONDS}ms ease-out`,\n zIndex: \"2147483647\",\n })\n document.documentElement.append(highlightElement)\n return highlightElement\n }\n\n function clearFocusTimer() {\n if (focusTimer === null) return\n\n window.clearTimeout(focusTimer)\n focusTimer = null\n }\n\n function showHighlight(element, preserveTimer = false) {\n if (!preserveTimer) clearFocusTimer()\n const rect = element.getBoundingClientRect()\n const highlight = ensureHighlight()\n const viewportAnchored = isViewportAnchoredElement(element)\n Object.assign(highlight.style, {\n height: `${Math.max(0, rect.height)}px`,\n position: viewportAnchored ? \"fixed\" : \"absolute\",\n left: `${rect.left + (viewportAnchored ? 0 : window.scrollX)}px`,\n opacity: \"1\",\n top: `${rect.top + (viewportAnchored ? 0 : window.scrollY)}px`,\n width: `${Math.max(0, rect.width)}px`,\n })\n highlightedElement = element\n }\n\n function hideHighlight() {\n if (highlightElement) highlightElement.style.opacity = \"0\"\n highlightedElement = null\n }\n\n function ensureAreaHighlight() {\n if (areaHighlightElement && areaHighlightPath) return areaHighlightElement\n\n areaHighlightElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\")\n areaHighlightElement.setAttribute(BRIDGE_NODE_ATTRIBUTE, \"area-highlight\")\n areaHighlightElement.setAttribute(\"aria-hidden\", \"true\")\n Object.assign(areaHighlightElement.style, {\n height: \"100%\",\n inset: \"0\",\n overflow: \"visible\",\n pointerEvents: \"none\",\n position: \"fixed\",\n width: \"100%\",\n zIndex: \"2147483647\",\n })\n areaHighlightPath = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polyline\")\n areaHighlightPath.setAttribute(\"fill\", \"none\")\n areaHighlightPath.setAttribute(\"stroke\", \"rgb(9, 105, 218)\")\n areaHighlightPath.setAttribute(\"stroke-linecap\", \"round\")\n areaHighlightPath.setAttribute(\"stroke-linejoin\", \"round\")\n areaHighlightPath.setAttribute(\"stroke-width\", \"2\")\n areaHighlightElement.append(areaHighlightPath)\n document.documentElement.append(areaHighlightElement)\n return areaHighlightElement\n }\n\n function showAreaHighlight(points) {\n ensureAreaHighlight()\n areaHighlightElement.style.position = \"absolute\"\n areaHighlightPath.setAttribute(\n \"points\",\n points.map((point) => `${point.x + window.scrollX},${point.y + window.scrollY}`).join(\" \"),\n )\n areaHighlightElement.style.opacity = points.length > 1 ? \"1\" : \"0\"\n }\n\n function clearAreaHighlight() {\n pendingAreaAnchor = null\n if (areaHighlightPath) areaHighlightPath.setAttribute(\"points\", \"\")\n if (areaHighlightElement) areaHighlightElement.style.opacity = \"0\"\n }\n\n function refreshPendingArea() {\n if (!pendingAreaAnchor) return\n\n const rect = {\n x: pendingAreaAnchor.rect.x - window.scrollX,\n y: pendingAreaAnchor.rect.y - window.scrollY,\n width: pendingAreaAnchor.rect.width,\n height: pendingAreaAnchor.rect.height,\n }\n showAreaHighlight(\n pendingAreaAnchor.path.map((point) => ({\n x: rect.x + point.x * rect.width,\n y: rect.y + point.y * rect.height,\n })),\n )\n }\n\n function stopSelection(clearPendingArea) {\n const wasSelecting = selectionMode !== null\n selectionMode = null\n selectionRequestId = null\n drawingPointerId = null\n shapeOptimizing = false\n areaStroke = []\n if (wasSelecting) {\n document.documentElement.style.cursor = originalCursor\n document.documentElement.style.touchAction = originalTouchAction\n }\n document.removeEventListener(\"pointermove\", handleElementPointerMove, true)\n document.removeEventListener(\"pointerdown\", handleElementPointerDown, true)\n document.removeEventListener(\"pointerdown\", handleAreaPointerDown, true)\n document.removeEventListener(\"pointermove\", handleAreaPointerMove, true)\n document.removeEventListener(\"pointerup\", handleAreaPointerUp, true)\n document.removeEventListener(\"pointercancel\", handleAreaPointerCancel, true)\n document.removeEventListener(\"keydown\", handleSelectionKeyDown, true)\n hideHighlight()\n if (clearPendingArea) {\n selectionPending = false\n clearAreaHighlight()\n }\n }\n\n function prepareSelection(requestId, mode) {\n stopSelection(true)\n clearFocusTimer()\n hideHighlight()\n selectionMode = mode\n selectionRequestId = requestId\n originalCursor = document.documentElement.style.cursor\n originalTouchAction = document.documentElement.style.touchAction\n document.documentElement.style.cursor = \"crosshair\"\n document.addEventListener(\"keydown\", handleSelectionKeyDown, true)\n }\n\n function startElementSelection(requestId) {\n prepareSelection(requestId, \"element\")\n document.addEventListener(\"pointermove\", handleElementPointerMove, true)\n document.addEventListener(\"pointerdown\", handleElementPointerDown, true)\n }\n\n function startAreaSelection(requestId) {\n prepareSelection(requestId, \"area\")\n document.documentElement.style.touchAction = \"none\"\n document.addEventListener(\"pointerdown\", handleAreaPointerDown, true)\n document.addEventListener(\"pointermove\", handleAreaPointerMove, true)\n document.addEventListener(\"pointerup\", handleAreaPointerUp, true)\n document.addEventListener(\"pointercancel\", handleAreaPointerCancel, true)\n }\n\n function eventElement(event) {\n return event.target instanceof Element && !event.target.closest(`[${BRIDGE_NODE_ATTRIBUTE}]`)\n ? event.target\n : null\n }\n\n function handleElementPointerMove(event) {\n const element = eventElement(event)\n if (element && element !== highlightedElement) showHighlight(element)\n }\n\n function handleElementPointerDown(event) {\n if (selectionMode !== \"element\" || !selectionRequestId) return\n event.preventDefault()\n event.stopImmediatePropagation()\n const requestId = selectionRequestId\n const element = eventElement(event)\n const anchor = element ? capturedAnchor(element, event) : null\n stopSelection(true)\n if (anchor && isElementAnchor(anchor)) {\n selectionPending = true\n post(\"replica:bridge:element-selected\", requestId, { anchor })\n } else {\n post(\"replica:bridge:selection-failed\", requestId, { reason: \"element-unavailable\" })\n }\n }\n\n function handleAreaPointerDown(event) {\n if (\n selectionMode !== \"area\" ||\n !selectionRequestId ||\n drawingPointerId !== null ||\n event.button !== 0\n ) {\n return\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n drawingPointerId = event.pointerId\n shapeOptimizing = event.shiftKey\n areaStroke = [{ x: event.clientX, y: event.clientY }]\n showAreaHighlight(areaStroke)\n }\n\n function handleAreaPointerMove(event) {\n if (\n selectionMode !== \"area\" ||\n drawingPointerId === null ||\n event.pointerId !== drawingPointerId\n ) {\n return\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n const point = { x: event.clientX, y: event.clientY }\n const previous = areaStroke[areaStroke.length - 1]\n if (!previous || pointDistance(previous, point) >= 1) areaStroke.push(point)\n shapeOptimizing = event.shiftKey\n showAreaHighlight(shapeOptimizing ? optimizedStroke(areaStroke) : areaStroke)\n }\n\n function handleAreaPointerUp(event) {\n if (\n selectionMode !== \"area\" ||\n !selectionRequestId ||\n drawingPointerId === null ||\n event.pointerId !== drawingPointerId\n ) {\n return\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n const finalPoint = { x: event.clientX, y: event.clientY }\n const previous = areaStroke[areaStroke.length - 1]\n if (!previous || pointDistance(previous, finalPoint) >= 1) areaStroke.push(finalPoint)\n\n const requestId = selectionRequestId\n const captured = capturedAreaAnchor(areaStroke, shapeOptimizing || event.shiftKey)\n if (captured.anchor) {\n selectionPending = true\n pendingAreaAnchor = captured.anchor\n stopSelection(false)\n refreshPendingArea()\n post(\"replica:bridge:area-selected\", requestId, { anchor: captured.anchor })\n return\n }\n\n stopSelection(true)\n post(\"replica:bridge:selection-failed\", requestId, { reason: captured.reason })\n }\n\n function handleAreaPointerCancel(event) {\n if (\n selectionMode !== \"area\" ||\n !selectionRequestId ||\n drawingPointerId === null ||\n event.pointerId !== drawingPointerId\n ) {\n return\n }\n\n const requestId = selectionRequestId\n stopSelection(true)\n post(\"replica:bridge:selection-cancelled\", requestId, {})\n }\n\n function handleSelectionKeyDown(event) {\n if (!selectionMode || event.key !== \"Escape\" || !selectionRequestId) return\n\n event.preventDefault()\n event.stopImmediatePropagation()\n const requestId = selectionRequestId\n stopSelection(true)\n post(\"replica:bridge:selection-cancelled\", requestId, {})\n }\n\n function isEditableTarget(target) {\n if (!(target instanceof Element)) return false\n\n const editable = target.closest(\"[contenteditable]\")\n return (\n target.matches(\"input, textarea, select\") ||\n (editable && editable.getAttribute(\"contenteditable\") !== \"false\")\n )\n }\n\n function handleConversationEscape(event) {\n if (\n event.key === \"Escape\" &&\n !selectionMode &&\n !selectionPending &&\n !pendingAreaAnchor &&\n !event.defaultPrevented &&\n !event.isComposing &&\n !(\n event.target instanceof Element &&\n event.target.closest('[role=\"dialog\"], dialog, [role=\"menu\"]')\n )\n ) {\n window.setTimeout(() => {\n if (event.defaultPrevented || selectionMode || selectionPending || pendingAreaAnchor) return\n\n post(\"replica:bridge:conversation-dismiss-requested\", createRequestId(), {})\n }, 0)\n }\n }\n\n function handleShortcutKeyDown(event) {\n const key = event.key.toLowerCase()\n const messageType =\n key === \"c\" && event.shiftKey\n ? \"replica:bridge:sidebar-toggle-requested\"\n : key === \"c\"\n ? \"replica:bridge:element-selection-requested\"\n : key === \"h\" && !event.shiftKey\n ? \"replica:bridge:area-selection-requested\"\n : null\n if (\n selectionMode ||\n selectionPending ||\n pendingAreaAnchor ||\n event.defaultPrevented ||\n event.repeat ||\n event.metaKey ||\n event.ctrlKey ||\n event.altKey ||\n !messageType ||\n isEditableTarget(event.target)\n ) {\n return\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n post(messageType, createRequestId(), {})\n }\n\n function focusAnchor(commentId, requestId) {\n clearFocusTimer()\n hideHighlight()\n const reference = anchors.get(commentId)\n if (!reference) {\n post(\"replica:bridge:anchor-focused\", requestId, {\n result: { commentId, status: \"missing\" },\n })\n return\n }\n\n let resolution = resolvedAnchor(commentId, reference)\n let result = resolution.result\n if ((result.status === \"resolved\" || result.status === \"moved\") && resolution.element) {\n resolution.element.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"auto\" })\n showHighlight(resolution.element)\n focusTimer = window.setTimeout(() => {\n focusTimer = null\n hideHighlight()\n }, 1_500)\n } else if (\n (result.status === \"resolved\" || result.status === \"moved\") &&\n resolution.documentRect &&\n typeof window.scrollTo === \"function\"\n ) {\n window.scrollTo({\n left: Math.max(\n 0,\n resolution.documentRect.x + resolution.documentRect.width / 2 - window.innerWidth / 2,\n ),\n top: Math.max(\n 0,\n resolution.documentRect.y + resolution.documentRect.height / 2 - window.innerHeight / 2,\n ),\n behavior: \"auto\",\n })\n }\n if (result.status === \"resolved\" || result.status === \"moved\") {\n resolution = resolvedAnchor(commentId, reference)\n result = resolution.result\n }\n post(\"replica:bridge:anchor-focused\", requestId, { result })\n scheduleGeometry()\n }\n\n function afterRender(callback) {\n // Let application frames queued during startup render before resolving the fragment.\n window.requestAnimationFrame(() => window.requestAnimationFrame(callback))\n }\n\n function fragmentTarget(hash) {\n let name = hash.slice(1)\n try {\n name = decodeURIComponent(name)\n } catch {\n // Malformed percent escapes can still be literal DOM IDs.\n }\n return (\n document.getElementById(name) ||\n Array.from(document.getElementsByName(name)).find((element) => element.tagName === \"A\")\n )\n }\n\n function clearPendingFragmentOnNavigation() {\n if (\n pendingFragmentRoute &&\n (pendingFragmentRoute.pathname !== location.pathname ||\n pendingFragmentRoute.search !== controlFreeSearch() ||\n pendingFragmentRoute.hash !== location.hash)\n ) {\n pendingFragmentRoute = null\n }\n }\n\n function restorePendingFragment() {\n clearPendingFragmentOnNavigation()\n if (!pendingFragmentRoute) return\n\n const target = fragmentTarget(pendingFragmentRoute.hash)\n if (!target) return\n\n pendingFragmentRoute = null\n target.scrollIntoView({ block: \"start\", inline: \"nearest\", behavior: \"instant\" })\n scheduleGeometry()\n }\n\n function restoreFragment(route, requestId) {\n const token = {}\n fragmentRestoreToken = token\n pendingFragmentRoute = null\n const matchesDocument = () =>\n route.pathname === location.pathname && route.search === controlFreeSearch()\n if (!matchesDocument()) return\n\n const acknowledge = () => {\n if (fragmentRestoreToken !== token) return\n\n routeChanged()\n post(\"replica:bridge:ready\", requestId, { route: currentRoute() })\n }\n afterRender(() => {\n if (fragmentRestoreToken !== token || !matchesDocument()) return\n\n const target = fragmentTarget(route.hash)\n if (target) {\n const url = new URL(location.href)\n url.hash = route.hash\n // Bypass router wrappers without sending the hashchange/popstate they interpret as routes.\n nativeReplaceState.call(history, history.state, \"\", url.href)\n target.scrollIntoView({ block: \"start\", inline: \"nearest\", behavior: \"instant\" })\n acknowledge()\n return\n }\n\n pendingFragmentRoute = route\n if (location.hash === route.hash) {\n acknowledge()\n return\n }\n // A bare fragment may be an application route. Let its normal navigation handlers run.\n window.addEventListener(\"hashchange\", () => afterRender(acknowledge), {\n capture: true,\n once: true,\n })\n location.hash = route.hash\n })\n }\n\n function handleMessage(event) {\n if (event.origin !== HUB_ORIGIN || event.source !== window.parent || !isCommand(event.data))\n return\n\n const message = event.data\n if (message.type === \"replica:bridge:request-ready\") {\n post(\"replica:bridge:ready\", message.requestId, { route: currentRoute() })\n return\n }\n if (message.type === \"replica:bridge:set-theme\") {\n const theme = message.payload.theme\n document.documentElement.style.colorScheme = theme\n document.documentElement.dataset.replicaTheme = theme\n window.dispatchEvent(new CustomEvent(\"replica:theme-change\", { detail: { theme } }))\n return\n }\n if (message.type === \"replica:bridge:restore-fragment\") {\n restoreFragment(message.payload.route, message.requestId)\n return\n }\n if (!REVIEW_ENABLED) return\n\n if (message.type === \"replica:bridge:select-element\") {\n startElementSelection(message.requestId)\n return\n }\n if (message.type === \"replica:bridge:select-area\") {\n startAreaSelection(message.requestId)\n return\n }\n if (message.type === \"replica:bridge:cancel-selection\") {\n stopSelection(true)\n post(\"replica:bridge:selection-cancelled\", message.requestId, {})\n return\n }\n if (message.type === \"replica:bridge:clear-selection\") {\n stopSelection(true)\n return\n }\n if (message.type === \"replica:bridge:focus-anchor\") {\n focusAnchor(message.payload.commentId, message.requestId)\n return\n }\n if (message.payload.replace) {\n anchors.clear()\n geometry.clear()\n }\n for (const entry of message.payload.anchors) {\n anchors.set(entry.commentId, {\n anchor: entry.anchor,\n originBuild: entry.originBuild,\n })\n }\n resolveEntries(\n message.payload.anchors.map((entry) => [\n entry.commentId,\n { anchor: entry.anchor, originBuild: entry.originBuild },\n ]),\n message.requestId,\n )\n }\n\n function routeChanged() {\n clearPendingFragmentOnNavigation()\n post(\"replica:bridge:route-changed\", createRequestId(), { route: currentRoute() })\n scheduleGeometry()\n }\n\n function patchHistory(methodName) {\n const original = history[methodName]\n history[methodName] = function patchedHistoryMethod(...argumentsList) {\n const result = original.apply(this, argumentsList)\n routeChanged()\n return result\n }\n }\n\n window.addEventListener(\"message\", handleMessage)\n if (REVIEW_ENABLED) {\n window.addEventListener(\"keydown\", handleShortcutKeyDown, true)\n window.addEventListener(\"keydown\", handleConversationEscape)\n }\n window.addEventListener(\"popstate\", routeChanged)\n window.addEventListener(\"hashchange\", routeChanged)\n window.addEventListener(\"resize\", scheduleGeometry)\n window.addEventListener(\"scroll\", handleScroll, { capture: true, passive: true })\n patchHistory(\"pushState\")\n patchHistory(\"replaceState\")\n\n if (typeof ResizeObserver === \"function\") {\n const resizeObserver = new ResizeObserver(scheduleGeometry)\n resizeObserver.observe(document.documentElement)\n }\n if (typeof MutationObserver === \"function\") {\n const mutationObserver = new MutationObserver((mutations) => {\n const hasPrototypeChange = mutations.some((mutation) => {\n const target = mutation.target\n return !(target instanceof Element && target.closest(`[${BRIDGE_NODE_ATTRIBUTE}]`))\n })\n if (hasPrototypeChange) {\n restorePendingFragment()\n scheduleGeometry()\n }\n })\n mutationObserver.observe(document.documentElement, {\n attributes: true,\n characterData: true,\n childList: true,\n subtree: true,\n })\n }\n})()\n" +export const hostedReviewBridgeSource = ";(function installReplicaPreviewBridge() {\n \"use strict\"\n\n // Preview hosts serve this script directly, so it cannot import Vite modules.\n const HUB_ORIGIN = \"__REPLICA_HUB_ORIGIN__\"\n const REVIEW_ENABLED = \"__REPLICA_REVIEW_ENABLED__\" !== \"false\"\n const PROTOCOL_VERSION = 1\n const ANCHOR_SCHEMA_VERSION = 1\n const REQUEST_ID_MAXIMUM_BYTES = 128\n const ANCHORS_PER_MESSAGE = 200\n const ANCHOR_MAXIMUM_BYTES = 16_384\n const PATHNAME_MAXIMUM_BYTES = 2_048\n const SEARCH_MAXIMUM_BYTES = 2_048\n const HASH_MAXIMUM_BYTES = 1_024\n const SELECTOR_MAXIMUM_BYTES = 4_096\n const ACCESSIBLE_NAME_MAXIMUM_BYTES = 1_000\n const TAG_NAME_MAXIMUM_BYTES = 64\n const SELECTED_TEXT_MAXIMUM_BYTES = 2_000\n const AREA_ROLE_MAXIMUM_BYTES = 64\n const AREA_TEXT_EXCERPT_MAXIMUM_BYTES = 500\n const AREA_PATH_MAXIMUM_POINTS = 160\n const AREA_ELEMENTS_MAXIMUM = 8\n const AREA_MINIMUM_DIAGONAL = 8\n const AREA_SAMPLE_GRID = 6\n const AREA_GEOMETRY_TOLERANCE = 0.15\n const GEOMETRY_ABSOLUTE_MAXIMUM = 1_000_000\n const VIEWPORT_DIMENSION_MAXIMUM = 100_000\n const HIGHLIGHT_FADE_MILLISECONDS = 200\n const BRIDGE_NODE_ATTRIBUTE = \"data-replica-bridge\"\n const textEncoder = new TextEncoder()\n const nativeReplaceState = History.prototype.replaceState\n const previewBase =\n /^\\/previews\\/github\\/[1-9]\\d*\\/[1-9]\\d*\\//.exec(location.pathname)?.[0] ?? \"/\"\n\n function logicalPathname() {\n return location.pathname.startsWith(previewBase)\n ? location.pathname.slice(previewBase.length - 1)\n : location.pathname\n }\n\n let selectionMode = null\n let selectionRequestId = null\n let drawingPointerId = null\n let shapeOptimizing = false\n let areaStroke = []\n let selectionPending = false\n let pendingAreaAnchor = null\n let highlightedElement = null\n let highlightElement = null\n let areaHighlightElement = null\n let areaHighlightPath = null\n let originalCursor = \"\"\n let originalTouchAction = \"\"\n let focusTimer = null\n let geometryFrame = null\n let pendingFragmentRoute = null\n let fragmentRestoreToken = null\n const anchors = new Map()\n const geometry = new Map()\n\n function isViewportAnchoredElement(element) {\n for (let current = element; current; current = current.parentElement) {\n const position = window.getComputedStyle(current).position\n if (position === \"fixed\" || position === \"sticky\") return true\n }\n return false\n }\n\n function isObject(value) {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n }\n\n function hasExactKeys(value, expected) {\n const actual = Object.keys(value)\n return actual.length === expected.length && expected.every((key) => actual.includes(key))\n }\n\n function byteLength(value) {\n return textEncoder.encode(value).length\n }\n\n function isBoundedString(value, maximumBytes, options = {}) {\n if (typeof value !== \"string\" || byteLength(value) > maximumBytes) return false\n if (options.required && value.trim() === \"\") return false\n if (options.prefix && value !== \"\" && !value.startsWith(options.prefix)) return false\n return true\n }\n\n function isFiniteNumber(value, minimum, maximum) {\n return (\n typeof value === \"number\" && Number.isFinite(value) && value >= minimum && value <= maximum\n )\n }\n\n function isRoute(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\"pathname\", \"search\", \"hash\"]) &&\n isBoundedString(value.pathname, PATHNAME_MAXIMUM_BYTES, {\n required: true,\n prefix: \"/\",\n }) &&\n isBoundedString(value.search, SEARCH_MAXIMUM_BYTES, { prefix: \"?\" }) &&\n isBoundedString(value.hash, HASH_MAXIMUM_BYTES, { prefix: \"#\" })\n )\n }\n\n function isRect(value, allowNegativePosition) {\n const minimumPosition = allowNegativePosition ? -GEOMETRY_ABSOLUTE_MAXIMUM : 0\n return (\n isObject(value) &&\n hasExactKeys(value, [\"x\", \"y\", \"width\", \"height\"]) &&\n isFiniteNumber(value.x, minimumPosition, GEOMETRY_ABSOLUTE_MAXIMUM) &&\n isFiniteNumber(value.y, minimumPosition, GEOMETRY_ABSOLUTE_MAXIMUM) &&\n isFiniteNumber(value.width, 0, GEOMETRY_ABSOLUTE_MAXIMUM) &&\n isFiniteNumber(value.height, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n )\n }\n\n function isViewport(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\"width\", \"height\", \"scrollX\", \"scrollY\"]) &&\n isFiniteNumber(value.width, 1, VIEWPORT_DIMENSION_MAXIMUM) &&\n isFiniteNumber(value.height, 1, VIEWPORT_DIMENSION_MAXIMUM) &&\n isFiniteNumber(value.scrollX, 0, GEOMETRY_ABSOLUTE_MAXIMUM) &&\n isFiniteNumber(value.scrollY, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n )\n }\n\n function isNormalizedPoint(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\"x\", \"y\"]) &&\n isFiniteNumber(value.x, 0, 1) &&\n isFiniteNumber(value.y, 0, 1)\n )\n }\n\n function hasValidSerializedSize(value) {\n try {\n return byteLength(JSON.stringify(value)) <= ANCHOR_MAXIMUM_BYTES\n } catch {\n return false\n }\n }\n\n function isElementAnchor(value) {\n if (\n !isObject(value) ||\n !hasExactKeys(value, [\n \"schemaVersion\",\n \"kind\",\n \"route\",\n \"selector\",\n \"accessibleName\",\n \"tagName\",\n \"selectedText\",\n \"rect\",\n \"viewport\",\n \"elementOffset\",\n ])\n ) {\n return false\n }\n\n return (\n value.schemaVersion === ANCHOR_SCHEMA_VERSION &&\n value.kind === \"element\" &&\n isRoute(value.route) &&\n isBoundedString(value.selector, SELECTOR_MAXIMUM_BYTES, { required: true }) &&\n isBoundedString(value.accessibleName, ACCESSIBLE_NAME_MAXIMUM_BYTES) &&\n isBoundedString(value.tagName, TAG_NAME_MAXIMUM_BYTES, { required: true }) &&\n /^[a-z][a-z0-9-]*$/.test(value.tagName) &&\n isBoundedString(value.selectedText, SELECTED_TEXT_MAXIMUM_BYTES) &&\n isRect(value.rect, false) &&\n isViewport(value.viewport) &&\n isNormalizedPoint(value.elementOffset) &&\n hasValidSerializedSize(value)\n )\n }\n\n function isAreaElement(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\n \"selector\",\n \"accessibleName\",\n \"tagName\",\n \"role\",\n \"textExcerpt\",\n \"rect\",\n ]) &&\n isBoundedString(value.selector, SELECTOR_MAXIMUM_BYTES, { required: true }) &&\n isBoundedString(value.accessibleName, ACCESSIBLE_NAME_MAXIMUM_BYTES) &&\n isBoundedString(value.tagName, TAG_NAME_MAXIMUM_BYTES, { required: true }) &&\n /^[a-z][a-z0-9-]*$/.test(value.tagName) &&\n isBoundedString(value.role, AREA_ROLE_MAXIMUM_BYTES) &&\n isBoundedString(value.textExcerpt, AREA_TEXT_EXCERPT_MAXIMUM_BYTES) &&\n isRect(value.rect, false)\n )\n }\n\n function isAreaAnchor(value) {\n return (\n isObject(value) &&\n hasExactKeys(value, [\n \"schemaVersion\",\n \"kind\",\n \"route\",\n \"path\",\n \"rect\",\n \"viewport\",\n \"elements\",\n ]) &&\n value.schemaVersion === ANCHOR_SCHEMA_VERSION &&\n value.kind === \"area\" &&\n isRoute(value.route) &&\n Array.isArray(value.path) &&\n value.path.length >= 2 &&\n value.path.length <= AREA_PATH_MAXIMUM_POINTS &&\n value.path.every(isNormalizedPoint) &&\n isRect(value.rect, false) &&\n Math.hypot(value.rect.width, value.rect.height) >= AREA_MINIMUM_DIAGONAL &&\n isViewport(value.viewport) &&\n Array.isArray(value.elements) &&\n value.elements.length <= AREA_ELEMENTS_MAXIMUM &&\n value.elements.every(isAreaElement) &&\n hasValidSerializedSize(value)\n )\n }\n\n function isAnchor(value) {\n return isElementAnchor(value) || isAreaAnchor(value)\n }\n\n function isCommand(message) {\n if (\n !isObject(message) ||\n !hasExactKeys(message, [\"protocolVersion\", \"requestId\", \"type\", \"payload\"]) ||\n message.protocolVersion !== PROTOCOL_VERSION ||\n !isBoundedString(message.requestId, REQUEST_ID_MAXIMUM_BYTES, { required: true }) ||\n typeof message.type !== \"string\" ||\n !isObject(message.payload)\n ) {\n return false\n }\n\n if (\n message.type === \"replica:bridge:request-ready\" ||\n message.type === \"replica:bridge:select-element\" ||\n message.type === \"replica:bridge:select-area\" ||\n message.type === \"replica:bridge:cancel-selection\" ||\n message.type === \"replica:bridge:clear-selection\"\n ) {\n return hasExactKeys(message.payload, [])\n }\n\n if (message.type === \"replica:bridge:focus-anchor\") {\n return (\n hasExactKeys(message.payload, [\"commentId\"]) &&\n Number.isSafeInteger(message.payload.commentId) &&\n message.payload.commentId > 0\n )\n }\n\n if (message.type === \"replica:bridge:set-theme\") {\n return (\n hasExactKeys(message.payload, [\"theme\"]) &&\n (message.payload.theme === \"light\" || message.payload.theme === \"dark\")\n )\n }\n\n if (message.type === \"replica:bridge:restore-fragment\") {\n return (\n hasExactKeys(message.payload, [\"route\"]) &&\n isRoute(message.payload.route) &&\n message.payload.route.hash.length > 1 &&\n !message.payload.route.hash.startsWith(\"#/\") &&\n !message.payload.route.hash.startsWith(\"#!\") &&\n new URL(message.payload.route.hash, location.href).hash === message.payload.route.hash\n )\n }\n\n if (message.type === \"replica:bridge:resolve-anchors\") {\n if (\n !hasExactKeys(message.payload, [\"replace\", \"anchors\"]) ||\n typeof message.payload.replace !== \"boolean\" ||\n !Array.isArray(message.payload.anchors) ||\n message.payload.anchors.length > ANCHORS_PER_MESSAGE\n ) {\n return false\n }\n\n return message.payload.anchors.every(\n (entry) =>\n isObject(entry) &&\n hasExactKeys(entry, [\"commentId\", \"originBuild\", \"anchor\"]) &&\n Number.isSafeInteger(entry.commentId) &&\n entry.commentId > 0 &&\n typeof entry.originBuild === \"boolean\" &&\n isAnchor(entry.anchor),\n )\n }\n\n return false\n }\n\n function createRequestId() {\n return crypto.randomUUID()\n }\n\n function currentRoute() {\n return {\n pathname: truncate(logicalPathname(), PATHNAME_MAXIMUM_BYTES),\n search: truncate(controlFreeSearch(), SEARCH_MAXIMUM_BYTES),\n hash: truncate(location.hash, HASH_MAXIMUM_BYTES),\n }\n }\n\n function controlFreeSearch() {\n const search = location.search\n .slice(1)\n .split(\"&\")\n .filter((part) => {\n const key = new URLSearchParams(part).keys().next().value\n return key !== \"rc\" && !key?.startsWith(\"rc.\")\n })\n .join(\"&\")\n return search ? `?${search}` : \"\"\n }\n\n function post(type, requestId, payload) {\n window.parent.postMessage(\n { protocolVersion: PROTOCOL_VERSION, requestId, type, payload },\n HUB_ORIGIN,\n )\n }\n\n function normalizeText(value) {\n return value.replace(/\\s+/g, \" \").trim()\n }\n\n function truncate(value, maximumBytes) {\n let result = \"\"\n for (const character of value) {\n if (byteLength(result + character) > maximumBytes) break\n result += character\n }\n return result\n }\n\n function accessibleName(element) {\n const labelledBy = element.getAttribute(\"aria-labelledby\")\n const labelledText = labelledBy\n ? labelledBy\n .split(/\\s+/)\n .map((id) => document.getElementById(id)?.textContent || \"\")\n .join(\" \")\n : \"\"\n const labels =\n \"labels\" in element && element.labels\n ? Array.from(element.labels)\n .map((label) => label.textContent || \"\")\n .join(\" \")\n : \"\"\n const value =\n element.getAttribute(\"aria-label\") ||\n labelledText ||\n labels ||\n element.getAttribute(\"alt\") ||\n element.getAttribute(\"title\") ||\n \"\"\n return truncate(normalizeText(value), ACCESSIBLE_NAME_MAXIMUM_BYTES)\n }\n\n function selectedText(element) {\n const selection = window.getSelection()\n const anchorNode = selection?.anchorNode\n const focusNode = selection?.focusNode\n if (\n !selection ||\n selection.isCollapsed ||\n !anchorNode ||\n !focusNode ||\n !element.contains(anchorNode) ||\n !element.contains(focusNode)\n )\n return \"\"\n return truncate(normalizeText(selection.toString()), SELECTED_TEXT_MAXIMUM_BYTES)\n }\n\n function textExcerpt(element) {\n return truncate(normalizeText(element.textContent || \"\"), AREA_TEXT_EXCERPT_MAXIMUM_BYTES)\n }\n\n function clamp(value, minimum, maximum) {\n return Math.max(minimum, Math.min(value, maximum))\n }\n\n function capturedViewport() {\n return {\n width: clamp(window.innerWidth, 1, VIEWPORT_DIMENSION_MAXIMUM),\n height: clamp(window.innerHeight, 1, VIEWPORT_DIMENSION_MAXIMUM),\n scrollX: clamp(window.scrollX, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n scrollY: clamp(window.scrollY, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n }\n }\n\n function documentRectangle(element) {\n const rect = element.getBoundingClientRect()\n const x = clamp(rect.left + window.scrollX, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n const y = clamp(rect.top + window.scrollY, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n return {\n x,\n y,\n width: clamp(rect.width, 0, GEOMETRY_ABSOLUTE_MAXIMUM - x),\n height: clamp(rect.height, 0, GEOMETRY_ABSOLUTE_MAXIMUM - y),\n }\n }\n\n function escapedIdentifier(value) {\n if (window.CSS && typeof window.CSS.escape === \"function\") return window.CSS.escape(value)\n return value.replace(/[^a-zA-Z0-9_-]/g, (character) => `\\\\${character}`)\n }\n\n function escapedAttribute(value) {\n return value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')\n }\n\n function isUniqueSelector(selector, element) {\n try {\n const matches = document.querySelectorAll(selector)\n return matches.length === 1 && matches[0] === element\n } catch {\n return false\n }\n }\n\n function selectorFor(element) {\n if (element.id) {\n const selector = `#${escapedIdentifier(element.id)}`\n if (isUniqueSelector(selector, element)) return selector\n }\n\n for (const attribute of [\"data-testid\", \"data-test-id\", \"data-component\"]) {\n const value = element.getAttribute(attribute)\n if (!value || byteLength(value) > 512) continue\n const selector = `${element.tagName.toLowerCase()}[${attribute}=\"${escapedAttribute(value)}\"]`\n if (isUniqueSelector(selector, element)) return selector\n }\n\n const parts = []\n let current = element\n while (current instanceof Element) {\n const tagName = current.tagName.toLowerCase()\n const siblings = current.parentElement\n ? Array.from(current.parentElement.children).filter(\n (sibling) => sibling.tagName === current.tagName,\n )\n : []\n const position = siblings.indexOf(current)\n parts.unshift(\n siblings.length > 1 && position >= 0 ? `${tagName}:nth-of-type(${position + 1})` : tagName,\n )\n const selector = parts.join(\" > \")\n if (byteLength(selector) > SELECTOR_MAXIMUM_BYTES) return null\n if (isUniqueSelector(selector, element)) return selector\n current = current.parentElement\n }\n return null\n }\n\n function capturedAnchor(element, event) {\n const selector = selectorFor(element)\n if (!selector) return null\n\n const rect = element.getBoundingClientRect()\n const width = Math.max(0, Math.min(rect.width, GEOMETRY_ABSOLUTE_MAXIMUM))\n const height = Math.max(0, Math.min(rect.height, GEOMETRY_ABSOLUTE_MAXIMUM))\n const offsetX = width > 0 ? (event.clientX - rect.left) / width : 0.5\n const offsetY = height > 0 ? (event.clientY - rect.top) / height : 0.5\n return {\n schemaVersion: ANCHOR_SCHEMA_VERSION,\n kind: \"element\",\n route: currentRoute(),\n selector,\n accessibleName: accessibleName(element),\n tagName: element.tagName.toLowerCase(),\n selectedText: selectedText(element),\n rect: {\n x: Math.max(0, Math.min(rect.left + window.scrollX, GEOMETRY_ABSOLUTE_MAXIMUM)),\n y: Math.max(0, Math.min(rect.top + window.scrollY, GEOMETRY_ABSOLUTE_MAXIMUM)),\n width,\n height,\n },\n viewport: capturedViewport(),\n elementOffset: {\n x: Math.max(0, Math.min(offsetX, 1)),\n y: Math.max(0, Math.min(offsetY, 1)),\n },\n }\n }\n\n function pointDistance(first, second) {\n return Math.hypot(second.x - first.x, second.y - first.y)\n }\n\n function pathBounds(points) {\n const xs = points.map((point) => point.x)\n const ys = points.map((point) => point.y)\n const left = Math.min(...xs)\n const right = Math.max(...xs)\n const top = Math.min(...ys)\n const bottom = Math.max(...ys)\n return {\n left,\n right,\n top,\n bottom,\n width: right - left,\n height: bottom - top,\n diagonal: Math.hypot(right - left, bottom - top),\n }\n }\n\n function pointToSegmentDistance(point, start, end) {\n const dx = end.x - start.x\n const dy = end.y - start.y\n const lengthSquared = dx * dx + dy * dy\n if (lengthSquared === 0) return pointDistance(point, start)\n\n const projection = clamp(\n ((point.x - start.x) * dx + (point.y - start.y) * dy) / lengthSquared,\n 0,\n 1,\n )\n return Math.hypot(point.x - (start.x + projection * dx), point.y - (start.y + projection * dy))\n }\n\n function pathScore(points, candidate, normalizer) {\n const squaredErrors = points.map((point) => {\n let nearest = Number.POSITIVE_INFINITY\n for (let index = 1; index < candidate.length; index += 1) {\n nearest = Math.min(\n nearest,\n pointToSegmentDistance(point, candidate[index - 1], candidate[index]),\n )\n }\n return nearest * nearest\n })\n return (\n Math.sqrt(squaredErrors.reduce((sum, error) => sum + error, 0) / squaredErrors.length) /\n normalizer\n )\n }\n\n function rectanglePath(bounds, square) {\n const centerX = (bounds.left + bounds.right) / 2\n const centerY = (bounds.top + bounds.bottom) / 2\n const halfWidth = square ? (bounds.width + bounds.height) / 4 : bounds.width / 2\n const halfHeight = square ? halfWidth : bounds.height / 2\n const left = centerX - halfWidth\n const right = centerX + halfWidth\n const top = centerY - halfHeight\n const bottom = centerY + halfHeight\n return [\n { x: left, y: top },\n { x: right, y: top },\n { x: right, y: bottom },\n { x: left, y: bottom },\n { x: left, y: top },\n ]\n }\n\n function ellipsePath(bounds, circle) {\n const centerX = (bounds.left + bounds.right) / 2\n const centerY = (bounds.top + bounds.bottom) / 2\n const radiusX = circle ? (bounds.width + bounds.height) / 4 : bounds.width / 2\n const radiusY = circle ? radiusX : bounds.height / 2\n return Array.from({ length: 49 }, (_, index) => {\n const angle = (index / 48) * Math.PI * 2\n return {\n x: centerX + Math.cos(angle) * radiusX,\n y: centerY + Math.sin(angle) * radiusY,\n }\n })\n }\n\n function optimizedStroke(points) {\n if (points.length < 2) return points\n\n const bounds = pathBounds(points)\n if (bounds.diagonal < 16) return points\n\n const first = points[0]\n const last = points[points.length - 1]\n const closureRatio = pointDistance(first, last) / bounds.diagonal\n if (closureRatio > 0.25 || points.length < 8) {\n const line = [first, last]\n return pathScore(points, line, bounds.diagonal) <= 0.08 ? line : points\n }\n\n const candidates = [\n rectanglePath(bounds, false),\n rectanglePath(bounds, true),\n ellipsePath(bounds, false),\n ellipsePath(bounds, true),\n ].map((path) => ({ path, score: pathScore(points, path, bounds.diagonal) }))\n const best = candidates.reduce((current, candidate) =>\n candidate.score < current.score ? candidate : current,\n )\n return best.score <= 0.1 ? best.path : points\n }\n\n function downsamplePath(points, maximum) {\n if (points.length <= maximum) return points\n\n return Array.from({ length: maximum }, (_, index) => {\n const sourceIndex = Math.round((index / (maximum - 1)) * (points.length - 1))\n return points[sourceIndex]\n })\n }\n\n function areaElementContext(element) {\n const selector = selectorFor(element)\n if (!selector) return null\n\n return {\n selector,\n accessibleName: accessibleName(element),\n tagName: element.tagName.toLowerCase(),\n role: truncate(element.getAttribute(\"role\") || \"\", AREA_ROLE_MAXIMUM_BYTES),\n textExcerpt: textExcerpt(element),\n rect: documentRectangle(element),\n }\n }\n\n function captureAreaElements(bounds) {\n const found = new Map()\n for (\n let column = 0;\n column < AREA_SAMPLE_GRID && found.size < AREA_ELEMENTS_MAXIMUM;\n column += 1\n ) {\n for (let row = 0; row < AREA_SAMPLE_GRID && found.size < AREA_ELEMENTS_MAXIMUM; row += 1) {\n const x = bounds.left + (bounds.width * (column + 0.5)) / AREA_SAMPLE_GRID\n const y = bounds.top + (bounds.height * (row + 0.5)) / AREA_SAMPLE_GRID\n const element = document\n .elementsFromPoint(x, y)\n .find(\n (candidate) =>\n candidate !== document.documentElement &&\n candidate !== document.body &&\n !candidate.closest(`[${BRIDGE_NODE_ATTRIBUTE}]`),\n )\n if (!element) continue\n\n const context = areaElementContext(element)\n if (context && !found.has(context.selector))\n found.set(context.selector, { context, element })\n }\n }\n\n const entries = Array.from(found.values())\n return entries\n .filter(\n (entry) =>\n !entries.some(\n (candidate) => candidate !== entry && entry.element.contains(candidate.element),\n ),\n )\n .slice(0, AREA_ELEMENTS_MAXIMUM)\n .map((entry) => entry.context)\n }\n\n function normalizedAreaPath(points, bounds) {\n return points.map((point) => ({\n x: bounds.width > 0 ? clamp((point.x - bounds.left) / bounds.width, 0, 1) : 0.5,\n y: bounds.height > 0 ? clamp((point.y - bounds.top) / bounds.height, 0, 1) : 0.5,\n }))\n }\n\n function capturedAreaAnchor(clientPoints, optimize) {\n let points = optimize ? optimizedStroke(clientPoints) : clientPoints\n points = downsamplePath(points, AREA_PATH_MAXIMUM_POINTS)\n const bounds = pathBounds(points)\n if (bounds.diagonal < AREA_MINIMUM_DIAGONAL) return { reason: \"area-too-small\" }\n\n const left = clamp(bounds.left + window.scrollX, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n const top = clamp(bounds.top + window.scrollY, 0, GEOMETRY_ABSOLUTE_MAXIMUM)\n const right = clamp(bounds.right + window.scrollX, left, GEOMETRY_ABSOLUTE_MAXIMUM)\n const bottom = clamp(bounds.bottom + window.scrollY, top, GEOMETRY_ABSOLUTE_MAXIMUM)\n const anchor = {\n schemaVersion: ANCHOR_SCHEMA_VERSION,\n kind: \"area\",\n route: currentRoute(),\n path: normalizedAreaPath(points, bounds),\n rect: { x: left, y: top, width: right - left, height: bottom - top },\n viewport: capturedViewport(),\n elements: captureAreaElements(bounds),\n }\n\n while (!isAreaAnchor(anchor) && anchor.elements.length > 0) anchor.elements.pop()\n while (!isAreaAnchor(anchor) && anchor.path.length > 2) {\n anchor.path = downsamplePath(anchor.path, Math.max(2, Math.floor(anchor.path.length / 2)))\n }\n return isAreaAnchor(anchor) ? { anchor } : { reason: \"area-unavailable\" }\n }\n\n function routeMatches(route) {\n const current = currentRoute()\n return (\n route.pathname === current.pathname &&\n route.search === current.search &&\n route.hash === current.hash\n )\n }\n\n function querySelectorElement(selector) {\n try {\n return document.querySelector(selector)\n } catch {\n return null\n }\n }\n\n function savedContextText(context) {\n return \"selectedText\" in context ? context.selectedText : context.textExcerpt\n }\n\n function elementMatchesContext(element, context) {\n if (element.tagName.toLowerCase() !== context.tagName) return false\n if (context.accessibleName && accessibleName(element) !== context.accessibleName) return false\n if (\"role\" in context && context.role && element.getAttribute(\"role\") !== context.role)\n return false\n\n const savedText = savedContextText(context)\n return !savedText || normalizeText(element.textContent || \"\").includes(savedText)\n }\n\n function uniqueContextElement(context, excludedElement) {\n const savedText = savedContextText(context)\n if (!context.accessibleName && !savedText) return null\n\n let match = null\n for (const element of document.getElementsByTagName(context.tagName)) {\n if (\n element === excludedElement ||\n element.closest(`[${BRIDGE_NODE_ATTRIBUTE}]`) ||\n !elementMatchesContext(element, context)\n ) {\n continue\n }\n if (match) return null\n\n match = element\n }\n return match\n }\n\n function resolvedElementContext(context) {\n const selected = querySelectorElement(context.selector)\n if (selected && elementMatchesContext(selected, context)) {\n return { status: \"resolved\", element: selected }\n }\n\n const moved = uniqueContextElement(context, selected)\n if (moved) return { status: \"moved\", element: moved }\n return { status: selected ? \"changed\" : \"missing\" }\n }\n\n function viewportRectangle(element) {\n const rect = element.getBoundingClientRect()\n return {\n x: clamp(rect.left, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n y: clamp(rect.top, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n width: clamp(rect.width, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n height: clamp(rect.height, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n }\n }\n\n function resolvedElementAnchor(commentId, anchor, originBuild) {\n const target = resolvedElementContext(anchor)\n if (!target.element) return { result: { commentId, status: target.status } }\n\n const boundedRect = viewportRectangle(target.element)\n if (!isRect(boundedRect, true)) {\n return { result: { commentId, status: \"missing\" } }\n }\n\n const documentRect = documentRectangle(target.element)\n const status =\n target.status === \"moved\" || (!originBuild && rectanglesDiffer(anchor.rect, documentRect))\n ? \"moved\"\n : \"resolved\"\n return {\n result: {\n commentId,\n status,\n rect: boundedRect,\n point: {\n x: clamp(\n boundedRect.x + boundedRect.width * anchor.elementOffset.x,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n y: clamp(\n boundedRect.y + boundedRect.height * anchor.elementOffset.y,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n },\n },\n element: target.element,\n viewportAnchored: isViewportAnchoredElement(target.element),\n }\n }\n\n function rectangleUnion(rectangles) {\n const left = Math.min(...rectangles.map((rect) => rect.x))\n const top = Math.min(...rectangles.map((rect) => rect.y))\n const right = Math.max(...rectangles.map((rect) => rect.x + rect.width))\n const bottom = Math.max(...rectangles.map((rect) => rect.y + rect.height))\n return { x: left, y: top, width: right - left, height: bottom - top }\n }\n\n function normalizedRectangle(rect, union) {\n return {\n x: union.width > 0 ? (rect.x - union.x) / union.width : 0,\n y: union.height > 0 ? (rect.y - union.y) / union.height : 0,\n width: union.width > 0 ? rect.width / union.width : 1,\n height: union.height > 0 ? rect.height / union.height : 1,\n }\n }\n\n function areaGeometryMatches(savedRectangles, currentRectangles) {\n if (savedRectangles.length <= 1) return true\n\n const savedUnion = rectangleUnion(savedRectangles)\n const currentUnion = rectangleUnion(currentRectangles)\n return savedRectangles.every((savedRect, index) => {\n const currentRect = currentRectangles[index]\n const saved = normalizedRectangle(savedRect, savedUnion)\n const current = normalizedRectangle(currentRect, currentUnion)\n return [\"x\", \"y\", \"width\", \"height\"].every(\n (key) => Math.abs(saved[key] - current[key]) <= AREA_GEOMETRY_TOLERANCE,\n )\n })\n }\n\n function transformCoordinate(value, savedStart, savedSize, currentStart, currentSize) {\n if (savedSize === 0) return value + currentStart - savedStart\n return currentStart + ((value - savedStart) / savedSize) * currentSize\n }\n\n function transformedAreaRectangle(rect, savedUnion, currentUnion) {\n const left = transformCoordinate(\n rect.x,\n savedUnion.x,\n savedUnion.width,\n currentUnion.x,\n currentUnion.width,\n )\n const right = transformCoordinate(\n rect.x + rect.width,\n savedUnion.x,\n savedUnion.width,\n currentUnion.x,\n currentUnion.width,\n )\n const top = transformCoordinate(\n rect.y,\n savedUnion.y,\n savedUnion.height,\n currentUnion.y,\n currentUnion.height,\n )\n const bottom = transformCoordinate(\n rect.y + rect.height,\n savedUnion.y,\n savedUnion.height,\n currentUnion.y,\n currentUnion.height,\n )\n return {\n x: clamp(Math.min(left, right), 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n y: clamp(Math.min(top, bottom), 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n width: clamp(Math.abs(right - left), 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n height: clamp(Math.abs(bottom - top), 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n }\n }\n\n function rectanglesDiffer(first, second) {\n return [\"x\", \"y\", \"width\", \"height\"].some((key) => Math.abs(first[key] - second[key]) > 4)\n }\n\n function areaPinPoint(anchor, rect) {\n const target = { x: 1, y: 0 }\n const normalized = anchor.path.reduce(\n (nearest, candidate) => {\n const distance = (candidate.x - target.x) ** 2 + (candidate.y - target.y) ** 2\n return distance < nearest.distance ? { point: candidate, distance } : nearest\n },\n { point: target, distance: Number.POSITIVE_INFINITY },\n ).point\n return {\n x: clamp(\n rect.x + normalized.x * rect.width,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n y: clamp(\n rect.y + normalized.y * rect.height,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n }\n }\n\n function areaResult(commentId, anchor, status, documentRect) {\n const rect = {\n x: clamp(\n documentRect.x - window.scrollX,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n y: clamp(\n documentRect.y - window.scrollY,\n -GEOMETRY_ABSOLUTE_MAXIMUM,\n GEOMETRY_ABSOLUTE_MAXIMUM,\n ),\n width: clamp(documentRect.width, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n height: clamp(documentRect.height, 0, GEOMETRY_ABSOLUTE_MAXIMUM),\n }\n return { commentId, status, rect, point: areaPinPoint(anchor, rect) }\n }\n\n function resolvedAreaAnchor(commentId, anchor, originBuild) {\n if (originBuild) {\n return {\n result: areaResult(commentId, anchor, \"resolved\", anchor.rect),\n documentRect: anchor.rect,\n }\n }\n if (anchor.elements.length === 0) return { result: { commentId, status: \"missing\" } }\n\n const targets = anchor.elements.map(resolvedElementContext)\n if (targets.some((target) => target.status === \"changed\")) {\n return { result: { commentId, status: \"changed\" } }\n }\n\n const available = targets.filter((target) => target.element)\n if (available.length === 0) return { result: { commentId, status: \"missing\" } }\n if (available.length !== targets.length) return { result: { commentId, status: \"changed\" } }\n if (new Set(targets.map((target) => target.element)).size !== targets.length) {\n return { result: { commentId, status: \"changed\" } }\n }\n\n const savedRectangles = anchor.elements.map((element) => element.rect)\n const currentRectangles = targets.map((target) => documentRectangle(target.element))\n if (!areaGeometryMatches(savedRectangles, currentRectangles)) {\n return { result: { commentId, status: \"changed\" } }\n }\n\n const savedUnion = rectangleUnion(savedRectangles)\n const currentUnion = rectangleUnion(currentRectangles)\n const documentRect = transformedAreaRectangle(anchor.rect, savedUnion, currentUnion)\n const status =\n targets.some((target) => target.status === \"moved\") ||\n rectanglesDiffer(anchor.rect, documentRect)\n ? \"moved\"\n : \"resolved\"\n return {\n result: areaResult(commentId, anchor, status, documentRect),\n documentRect,\n viewportAnchored: targets.some((target) => isViewportAnchoredElement(target.element)),\n }\n }\n\n function resolvedAnchor(commentId, reference) {\n const anchor = reference.anchor\n if (!routeMatches(anchor.route)) {\n return { result: { commentId, status: \"route-mismatch\" } }\n }\n return anchor.kind === \"area\"\n ? resolvedAreaAnchor(commentId, anchor, reference.originBuild)\n : resolvedElementAnchor(commentId, anchor, reference.originBuild)\n }\n\n function resolveGeometry(commentId, reference) {\n const resolved = resolvedAnchor(commentId, reference)\n geometry.set(commentId, {\n ...resolved,\n scrollX: window.scrollX,\n scrollY: window.scrollY,\n })\n return resolved.result\n }\n\n function resolveEntries(entries, requestId) {\n const results = entries.map(([commentId, reference]) => resolveGeometry(commentId, reference))\n post(\"replica:bridge:anchors-resolved\", requestId, { results })\n return results\n }\n\n function sendAllGeometry() {\n geometryFrame = null\n if (highlightedElement) showHighlight(highlightedElement, true)\n refreshPendingArea()\n const entries = Array.from(anchors.entries())\n for (let index = 0; index < entries.length; index += ANCHORS_PER_MESSAGE) {\n resolveEntries(entries.slice(index, index + ANCHORS_PER_MESSAGE), createRequestId())\n }\n }\n\n function scheduleGeometry() {\n if (geometryFrame !== null || (anchors.size === 0 && !pendingAreaAnchor)) return\n geometryFrame = window.requestAnimationFrame(sendAllGeometry)\n }\n\n function handleScroll(event) {\n // Keep ordinary targets in document coordinates; nested scroll and sticky targets need layout.\n if (event.target !== document && event.target !== window) {\n scheduleGeometry()\n return\n }\n if (highlightedElement && isViewportAnchoredElement(highlightedElement)) {\n showHighlight(highlightedElement, true)\n }\n refreshPendingArea()\n if (geometryFrame !== null) {\n window.cancelAnimationFrame(geometryFrame)\n sendAllGeometry()\n return\n }\n const results = Array.from(anchors, ([commentId, reference]) => {\n const cached = geometry.get(commentId)\n if (!cached || cached.viewportAnchored) {\n return resolveGeometry(commentId, reference)\n }\n const result = cached.result\n if (!result.point) return result\n const dx = cached.scrollX - window.scrollX\n const dy = cached.scrollY - window.scrollY\n return {\n ...result,\n point: {\n x: clamp(result.point.x + dx, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n y: clamp(result.point.y + dy, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n },\n rect: {\n ...result.rect,\n x: clamp(result.rect.x + dx, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n y: clamp(result.rect.y + dy, -GEOMETRY_ABSOLUTE_MAXIMUM, GEOMETRY_ABSOLUTE_MAXIMUM),\n },\n }\n })\n for (let index = 0; index < results.length; index += ANCHORS_PER_MESSAGE) {\n post(\"replica:bridge:anchors-resolved\", createRequestId(), {\n results: results.slice(index, index + ANCHORS_PER_MESSAGE),\n })\n }\n }\n\n function ensureHighlight() {\n if (highlightElement) return highlightElement\n highlightElement = document.createElement(\"div\")\n highlightElement.setAttribute(BRIDGE_NODE_ATTRIBUTE, \"highlight\")\n const reduceMotion =\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n Object.assign(highlightElement.style, {\n background: \"rgba(9, 105, 218, 0.12)\",\n border: \"2px solid rgb(9, 105, 218)\",\n borderRadius: \"4px\",\n boxSizing: \"border-box\",\n opacity: \"0\",\n pointerEvents: \"none\",\n position: \"fixed\",\n transition: reduceMotion ? \"none\" : `opacity ${HIGHLIGHT_FADE_MILLISECONDS}ms ease-out`,\n zIndex: \"2147483647\",\n })\n document.documentElement.append(highlightElement)\n return highlightElement\n }\n\n function clearFocusTimer() {\n if (focusTimer === null) return\n\n window.clearTimeout(focusTimer)\n focusTimer = null\n }\n\n function showHighlight(element, preserveTimer = false) {\n if (!preserveTimer) clearFocusTimer()\n const rect = element.getBoundingClientRect()\n const highlight = ensureHighlight()\n const viewportAnchored = isViewportAnchoredElement(element)\n Object.assign(highlight.style, {\n height: `${Math.max(0, rect.height)}px`,\n position: viewportAnchored ? \"fixed\" : \"absolute\",\n left: `${rect.left + (viewportAnchored ? 0 : window.scrollX)}px`,\n opacity: \"1\",\n top: `${rect.top + (viewportAnchored ? 0 : window.scrollY)}px`,\n width: `${Math.max(0, rect.width)}px`,\n })\n highlightedElement = element\n }\n\n function hideHighlight() {\n if (highlightElement) highlightElement.style.opacity = \"0\"\n highlightedElement = null\n }\n\n function ensureAreaHighlight() {\n if (areaHighlightElement && areaHighlightPath) return areaHighlightElement\n\n areaHighlightElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\")\n areaHighlightElement.setAttribute(BRIDGE_NODE_ATTRIBUTE, \"area-highlight\")\n areaHighlightElement.setAttribute(\"aria-hidden\", \"true\")\n Object.assign(areaHighlightElement.style, {\n height: \"100%\",\n inset: \"0\",\n overflow: \"visible\",\n pointerEvents: \"none\",\n position: \"fixed\",\n width: \"100%\",\n zIndex: \"2147483647\",\n })\n areaHighlightPath = document.createElementNS(\"http://www.w3.org/2000/svg\", \"polyline\")\n areaHighlightPath.setAttribute(\"fill\", \"none\")\n areaHighlightPath.setAttribute(\"stroke\", \"rgb(9, 105, 218)\")\n areaHighlightPath.setAttribute(\"stroke-linecap\", \"round\")\n areaHighlightPath.setAttribute(\"stroke-linejoin\", \"round\")\n areaHighlightPath.setAttribute(\"stroke-width\", \"2\")\n areaHighlightElement.append(areaHighlightPath)\n document.documentElement.append(areaHighlightElement)\n return areaHighlightElement\n }\n\n function showAreaHighlight(points) {\n ensureAreaHighlight()\n areaHighlightElement.style.position = \"absolute\"\n areaHighlightPath.setAttribute(\n \"points\",\n points.map((point) => `${point.x + window.scrollX},${point.y + window.scrollY}`).join(\" \"),\n )\n areaHighlightElement.style.opacity = points.length > 1 ? \"1\" : \"0\"\n }\n\n function clearAreaHighlight() {\n pendingAreaAnchor = null\n if (areaHighlightPath) areaHighlightPath.setAttribute(\"points\", \"\")\n if (areaHighlightElement) areaHighlightElement.style.opacity = \"0\"\n }\n\n function refreshPendingArea() {\n if (!pendingAreaAnchor) return\n\n const rect = {\n x: pendingAreaAnchor.rect.x - window.scrollX,\n y: pendingAreaAnchor.rect.y - window.scrollY,\n width: pendingAreaAnchor.rect.width,\n height: pendingAreaAnchor.rect.height,\n }\n showAreaHighlight(\n pendingAreaAnchor.path.map((point) => ({\n x: rect.x + point.x * rect.width,\n y: rect.y + point.y * rect.height,\n })),\n )\n }\n\n function stopSelection(clearPendingArea) {\n const wasSelecting = selectionMode !== null\n selectionMode = null\n selectionRequestId = null\n drawingPointerId = null\n shapeOptimizing = false\n areaStroke = []\n if (wasSelecting) {\n document.documentElement.style.cursor = originalCursor\n document.documentElement.style.touchAction = originalTouchAction\n }\n document.removeEventListener(\"pointermove\", handleElementPointerMove, true)\n document.removeEventListener(\"pointerdown\", handleElementPointerDown, true)\n document.removeEventListener(\"pointerdown\", handleAreaPointerDown, true)\n document.removeEventListener(\"pointermove\", handleAreaPointerMove, true)\n document.removeEventListener(\"pointerup\", handleAreaPointerUp, true)\n document.removeEventListener(\"pointercancel\", handleAreaPointerCancel, true)\n document.removeEventListener(\"keydown\", handleSelectionKeyDown, true)\n hideHighlight()\n if (clearPendingArea) {\n selectionPending = false\n clearAreaHighlight()\n }\n }\n\n function prepareSelection(requestId, mode) {\n stopSelection(true)\n clearFocusTimer()\n hideHighlight()\n selectionMode = mode\n selectionRequestId = requestId\n originalCursor = document.documentElement.style.cursor\n originalTouchAction = document.documentElement.style.touchAction\n document.documentElement.style.cursor = \"crosshair\"\n document.addEventListener(\"keydown\", handleSelectionKeyDown, true)\n }\n\n function startElementSelection(requestId) {\n prepareSelection(requestId, \"element\")\n document.addEventListener(\"pointermove\", handleElementPointerMove, true)\n document.addEventListener(\"pointerdown\", handleElementPointerDown, true)\n }\n\n function startAreaSelection(requestId) {\n prepareSelection(requestId, \"area\")\n document.documentElement.style.touchAction = \"none\"\n document.addEventListener(\"pointerdown\", handleAreaPointerDown, true)\n document.addEventListener(\"pointermove\", handleAreaPointerMove, true)\n document.addEventListener(\"pointerup\", handleAreaPointerUp, true)\n document.addEventListener(\"pointercancel\", handleAreaPointerCancel, true)\n }\n\n function eventElement(event) {\n return event.target instanceof Element && !event.target.closest(`[${BRIDGE_NODE_ATTRIBUTE}]`)\n ? event.target\n : null\n }\n\n function handleElementPointerMove(event) {\n const element = eventElement(event)\n if (element && element !== highlightedElement) showHighlight(element)\n }\n\n function handleElementPointerDown(event) {\n if (selectionMode !== \"element\" || !selectionRequestId) return\n event.preventDefault()\n event.stopImmediatePropagation()\n const requestId = selectionRequestId\n const element = eventElement(event)\n const anchor = element ? capturedAnchor(element, event) : null\n stopSelection(true)\n if (anchor && isElementAnchor(anchor)) {\n selectionPending = true\n post(\"replica:bridge:element-selected\", requestId, { anchor })\n } else {\n post(\"replica:bridge:selection-failed\", requestId, { reason: \"element-unavailable\" })\n }\n }\n\n function handleAreaPointerDown(event) {\n if (\n selectionMode !== \"area\" ||\n !selectionRequestId ||\n drawingPointerId !== null ||\n event.button !== 0\n ) {\n return\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n drawingPointerId = event.pointerId\n shapeOptimizing = event.shiftKey\n areaStroke = [{ x: event.clientX, y: event.clientY }]\n showAreaHighlight(areaStroke)\n }\n\n function handleAreaPointerMove(event) {\n if (\n selectionMode !== \"area\" ||\n drawingPointerId === null ||\n event.pointerId !== drawingPointerId\n ) {\n return\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n const point = { x: event.clientX, y: event.clientY }\n const previous = areaStroke[areaStroke.length - 1]\n if (!previous || pointDistance(previous, point) >= 1) areaStroke.push(point)\n shapeOptimizing = event.shiftKey\n showAreaHighlight(shapeOptimizing ? optimizedStroke(areaStroke) : areaStroke)\n }\n\n function handleAreaPointerUp(event) {\n if (\n selectionMode !== \"area\" ||\n !selectionRequestId ||\n drawingPointerId === null ||\n event.pointerId !== drawingPointerId\n ) {\n return\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n const finalPoint = { x: event.clientX, y: event.clientY }\n const previous = areaStroke[areaStroke.length - 1]\n if (!previous || pointDistance(previous, finalPoint) >= 1) areaStroke.push(finalPoint)\n\n const requestId = selectionRequestId\n const captured = capturedAreaAnchor(areaStroke, shapeOptimizing || event.shiftKey)\n if (captured.anchor) {\n selectionPending = true\n pendingAreaAnchor = captured.anchor\n stopSelection(false)\n refreshPendingArea()\n post(\"replica:bridge:area-selected\", requestId, { anchor: captured.anchor })\n return\n }\n\n stopSelection(true)\n post(\"replica:bridge:selection-failed\", requestId, { reason: captured.reason })\n }\n\n function handleAreaPointerCancel(event) {\n if (\n selectionMode !== \"area\" ||\n !selectionRequestId ||\n drawingPointerId === null ||\n event.pointerId !== drawingPointerId\n ) {\n return\n }\n\n const requestId = selectionRequestId\n stopSelection(true)\n post(\"replica:bridge:selection-cancelled\", requestId, {})\n }\n\n function handleSelectionKeyDown(event) {\n if (!selectionMode || event.key !== \"Escape\" || !selectionRequestId) return\n\n event.preventDefault()\n event.stopImmediatePropagation()\n const requestId = selectionRequestId\n stopSelection(true)\n post(\"replica:bridge:selection-cancelled\", requestId, {})\n }\n\n function isEditableTarget(target) {\n if (!(target instanceof Element)) return false\n\n const editable = target.closest(\"[contenteditable]\")\n return (\n target.matches(\"input, textarea, select\") ||\n (editable && editable.getAttribute(\"contenteditable\") !== \"false\")\n )\n }\n\n function handleConversationEscape(event) {\n if (\n event.key === \"Escape\" &&\n !selectionMode &&\n !selectionPending &&\n !pendingAreaAnchor &&\n !event.defaultPrevented &&\n !event.isComposing &&\n !(\n event.target instanceof Element &&\n event.target.closest('[role=\"dialog\"], dialog, [role=\"menu\"]')\n )\n ) {\n window.setTimeout(() => {\n if (event.defaultPrevented || selectionMode || selectionPending || pendingAreaAnchor) return\n\n post(\"replica:bridge:conversation-dismiss-requested\", createRequestId(), {})\n }, 0)\n }\n }\n\n function handleShortcutKeyDown(event) {\n const key = event.key.toLowerCase()\n const messageType =\n key === \"c\" && event.shiftKey\n ? \"replica:bridge:sidebar-toggle-requested\"\n : key === \"c\"\n ? \"replica:bridge:element-selection-requested\"\n : key === \"h\" && !event.shiftKey\n ? \"replica:bridge:area-selection-requested\"\n : null\n if (\n selectionMode ||\n selectionPending ||\n pendingAreaAnchor ||\n event.defaultPrevented ||\n event.repeat ||\n event.metaKey ||\n event.ctrlKey ||\n event.altKey ||\n !messageType ||\n isEditableTarget(event.target)\n ) {\n return\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n post(messageType, createRequestId(), {})\n }\n\n function focusAnchor(commentId, requestId) {\n clearFocusTimer()\n hideHighlight()\n const reference = anchors.get(commentId)\n if (!reference) {\n post(\"replica:bridge:anchor-focused\", requestId, {\n result: { commentId, status: \"missing\" },\n })\n return\n }\n\n let resolution = resolvedAnchor(commentId, reference)\n let result = resolution.result\n if ((result.status === \"resolved\" || result.status === \"moved\") && resolution.element) {\n resolution.element.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"auto\" })\n showHighlight(resolution.element)\n focusTimer = window.setTimeout(() => {\n focusTimer = null\n hideHighlight()\n }, 1_500)\n } else if (\n (result.status === \"resolved\" || result.status === \"moved\") &&\n resolution.documentRect &&\n typeof window.scrollTo === \"function\"\n ) {\n window.scrollTo({\n left: Math.max(\n 0,\n resolution.documentRect.x + resolution.documentRect.width / 2 - window.innerWidth / 2,\n ),\n top: Math.max(\n 0,\n resolution.documentRect.y + resolution.documentRect.height / 2 - window.innerHeight / 2,\n ),\n behavior: \"auto\",\n })\n }\n if (result.status === \"resolved\" || result.status === \"moved\") {\n resolution = resolvedAnchor(commentId, reference)\n result = resolution.result\n }\n post(\"replica:bridge:anchor-focused\", requestId, { result })\n scheduleGeometry()\n }\n\n function afterRender(callback) {\n // Let application frames queued during startup render before resolving the fragment.\n window.requestAnimationFrame(() => window.requestAnimationFrame(callback))\n }\n\n function fragmentTarget(hash) {\n let name = hash.slice(1)\n try {\n name = decodeURIComponent(name)\n } catch {\n // Malformed percent escapes can still be literal DOM IDs.\n }\n return (\n document.getElementById(name) ||\n Array.from(document.getElementsByName(name)).find((element) => element.tagName === \"A\")\n )\n }\n\n function clearPendingFragmentOnNavigation() {\n if (\n pendingFragmentRoute &&\n (pendingFragmentRoute.pathname !== logicalPathname() ||\n pendingFragmentRoute.search !== controlFreeSearch() ||\n pendingFragmentRoute.hash !== location.hash)\n ) {\n pendingFragmentRoute = null\n }\n }\n\n function restorePendingFragment() {\n clearPendingFragmentOnNavigation()\n if (!pendingFragmentRoute) return\n\n const target = fragmentTarget(pendingFragmentRoute.hash)\n if (!target) return\n\n pendingFragmentRoute = null\n target.scrollIntoView({ block: \"start\", inline: \"nearest\", behavior: \"instant\" })\n scheduleGeometry()\n }\n\n function restoreFragment(route, requestId) {\n const token = {}\n fragmentRestoreToken = token\n pendingFragmentRoute = null\n const matchesDocument = () =>\n route.pathname === logicalPathname() && route.search === controlFreeSearch()\n if (!matchesDocument()) return\n\n const acknowledge = () => {\n if (fragmentRestoreToken !== token) return\n\n routeChanged()\n post(\"replica:bridge:ready\", requestId, { route: currentRoute() })\n }\n afterRender(() => {\n if (fragmentRestoreToken !== token || !matchesDocument()) return\n\n const target = fragmentTarget(route.hash)\n if (target) {\n const url = new URL(location.href)\n url.hash = route.hash\n // Bypass router wrappers without sending the hashchange/popstate they interpret as routes.\n nativeReplaceState.call(history, history.state, \"\", url.href)\n target.scrollIntoView({ block: \"start\", inline: \"nearest\", behavior: \"instant\" })\n acknowledge()\n return\n }\n\n pendingFragmentRoute = route\n if (location.hash === route.hash) {\n acknowledge()\n return\n }\n // A bare fragment may be an application route. Let its normal navigation handlers run.\n window.addEventListener(\"hashchange\", () => afterRender(acknowledge), {\n capture: true,\n once: true,\n })\n location.hash = route.hash\n })\n }\n\n function handleMessage(event) {\n if (event.origin !== HUB_ORIGIN || event.source !== window.parent || !isCommand(event.data))\n return\n\n const message = event.data\n if (message.type === \"replica:bridge:request-ready\") {\n post(\"replica:bridge:ready\", message.requestId, { route: currentRoute() })\n return\n }\n if (message.type === \"replica:bridge:set-theme\") {\n const theme = message.payload.theme\n document.documentElement.style.colorScheme = theme\n document.documentElement.dataset.replicaTheme = theme\n window.dispatchEvent(new CustomEvent(\"replica:theme-change\", { detail: { theme } }))\n return\n }\n if (message.type === \"replica:bridge:restore-fragment\") {\n restoreFragment(message.payload.route, message.requestId)\n return\n }\n if (!REVIEW_ENABLED) return\n\n if (message.type === \"replica:bridge:select-element\") {\n startElementSelection(message.requestId)\n return\n }\n if (message.type === \"replica:bridge:select-area\") {\n startAreaSelection(message.requestId)\n return\n }\n if (message.type === \"replica:bridge:cancel-selection\") {\n stopSelection(true)\n post(\"replica:bridge:selection-cancelled\", message.requestId, {})\n return\n }\n if (message.type === \"replica:bridge:clear-selection\") {\n stopSelection(true)\n return\n }\n if (message.type === \"replica:bridge:focus-anchor\") {\n focusAnchor(message.payload.commentId, message.requestId)\n return\n }\n if (message.payload.replace) {\n anchors.clear()\n geometry.clear()\n }\n for (const entry of message.payload.anchors) {\n anchors.set(entry.commentId, {\n anchor: entry.anchor,\n originBuild: entry.originBuild,\n })\n }\n resolveEntries(\n message.payload.anchors.map((entry) => [\n entry.commentId,\n { anchor: entry.anchor, originBuild: entry.originBuild },\n ]),\n message.requestId,\n )\n }\n\n function routeChanged() {\n clearPendingFragmentOnNavigation()\n post(\"replica:bridge:route-changed\", createRequestId(), { route: currentRoute() })\n scheduleGeometry()\n }\n\n function patchHistory(methodName) {\n const original = history[methodName]\n history[methodName] = function patchedHistoryMethod(...argumentsList) {\n const result = original.apply(this, argumentsList)\n routeChanged()\n return result\n }\n }\n\n window.addEventListener(\"message\", handleMessage)\n if (REVIEW_ENABLED) {\n window.addEventListener(\"keydown\", handleShortcutKeyDown, true)\n window.addEventListener(\"keydown\", handleConversationEscape)\n }\n window.addEventListener(\"popstate\", routeChanged)\n window.addEventListener(\"hashchange\", routeChanged)\n window.addEventListener(\"resize\", scheduleGeometry)\n window.addEventListener(\"scroll\", handleScroll, { capture: true, passive: true })\n patchHistory(\"pushState\")\n patchHistory(\"replaceState\")\n\n if (typeof ResizeObserver === \"function\") {\n const resizeObserver = new ResizeObserver(scheduleGeometry)\n resizeObserver.observe(document.documentElement)\n }\n if (typeof MutationObserver === \"function\") {\n const mutationObserver = new MutationObserver((mutations) => {\n const hasPrototypeChange = mutations.some((mutation) => {\n const target = mutation.target\n return !(target instanceof Element && target.closest(`[${BRIDGE_NODE_ATTRIBUTE}]`))\n })\n if (hasPrototypeChange) {\n restorePendingFragment()\n scheduleGeometry()\n }\n })\n mutationObserver.observe(document.documentElement, {\n attributes: true,\n characterData: true,\n childList: true,\n subtree: true,\n })\n }\n})()\n" diff --git a/hub/server/create-app/index.test.ts b/hub/server/create-app/index.test.ts index aca5c6a43..247a828eb 100644 --- a/hub/server/create-app/index.test.ts +++ b/hub/server/create-app/index.test.ts @@ -39,7 +39,7 @@ describe("createApp()", () => { const base = `http://127.0.0.1:${port}` await fetch(`${base}/api/shared/secret-share-id?grant=secret-public-grant`) - await fetch(`${base}/__replica/authorize?grant=secret-preview-grant`) + await fetch(`${base}/__replica/share/authorize?grant=secret-preview-grant`) expect(records).toHaveLength(2) for (const record of records) { @@ -247,7 +247,6 @@ describe("createApp()", () => { delete: vi.fn(), }, bridgeSource: "", - findTargetById: vi.fn(), findArtifact: vi.fn(), readAvailableShareLink: readAvailableLink, } diff --git a/hub/server/create-app/index.ts b/hub/server/create-app/index.ts index 4b56f2621..5f00f2dfe 100644 --- a/hub/server/create-app/index.ts +++ b/hub/server/create-app/index.ts @@ -44,9 +44,9 @@ export function createApp({ "/api/notifications", "/api/repositories", "/api/shared", - "/__replica/authorize", "/__replica/share/authorize", "/api/settings", + "/previews", ], authenticationSecurity(), ) diff --git a/hub/server/domains/build-preview/create-preview-grant/index.ts b/hub/server/domains/build-preview/create-preview-grant/index.ts deleted file mode 100644 index 463062084..000000000 --- a/hub/server/domains/build-preview/create-preview-grant/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { encryptAuthenticationValue } from "../../authentication/encrypt-authentication-value/index.ts" - -export function createPreviewGrant( - input: { - buildId: string - expiresAt: Date - sessionDigest: string - } & ( - { target: "preview" | "desktop" | "narrow" } | { target: "template"; screenshotPath?: string } - ), - key: Buffer, -): string { - return encryptAuthenticationValue( - JSON.stringify({ - v: 1, - b: input.buildId, - t: input.target, - p: input.target === "template" ? input.screenshotPath : undefined, - e: input.expiresAt.getTime(), - s: input.sessionDigest, - }), - key, - ) -} diff --git a/hub/server/domains/build-preview/create-preview-session/index.ts b/hub/server/domains/build-preview/create-preview-session/index.ts deleted file mode 100644 index 4a34a7a98..000000000 --- a/hub/server/domains/build-preview/create-preview-session/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { encryptAuthenticationValue } from "../../authentication/encrypt-authentication-value/index.ts" - -export function createPreviewSession( - buildId: string, - sessionDigest: string, - expiresAt: Date, - key: Buffer, - template = false, -): string { - return encryptAuthenticationValue( - JSON.stringify({ - v: 1, - b: buildId, - s: sessionDigest, - e: expiresAt.getTime(), - t: template || undefined, - }), - key, - ) -} diff --git a/hub/server/domains/build-preview/inject-preview-bridge/index.ts b/hub/server/domains/build-preview/inject-preview-bridge/index.ts index 83e858c73..1b0fede62 100644 --- a/hub/server/domains/build-preview/inject-preview-bridge/index.ts +++ b/hub/server/domains/build-preview/inject-preview-bridge/index.ts @@ -1,8 +1,8 @@ const closingHead = /<\/head\s*>/i -export function injectPreviewBridge(html: Uint8Array): Uint8Array { +export function injectPreviewBridge(html: Uint8Array, mountPath = "/"): Uint8Array { const source = new TextDecoder().decode(html) - const script = '' + const script = `` const output = closingHead.test(source) ? source.replace(closingHead, `${script}`) : `${source}${script}` diff --git a/hub/server/domains/build-preview/read-build-preview-file/index.ts b/hub/server/domains/build-preview/read-build-preview-file/index.ts index f2e42f2f4..7514cb36f 100644 --- a/hub/server/domains/build-preview/read-build-preview-file/index.ts +++ b/hub/server/domains/build-preview/read-build-preview-file/index.ts @@ -102,7 +102,7 @@ export async function readBuildPreviewFile( const html = contentType.startsWith("text/html") return { status: "ok", - bytes: html ? injectPreviewBridge(stored.bytes) : stored.bytes, + bytes: html ? injectPreviewBridge(stored.bytes, input.mountPath) : stored.bytes, contentType, html, } diff --git a/hub/server/domains/build-preview/read-build-preview-file/types.ts b/hub/server/domains/build-preview/read-build-preview-file/types.ts index 4d8eace85..127de6b48 100644 --- a/hub/server/domains/build-preview/read-build-preview-file/types.ts +++ b/hub/server/domains/build-preview/read-build-preview-file/types.ts @@ -5,6 +5,7 @@ export interface ReadBuildPreviewFileInput { buildId: string distOnly?: boolean requestPath: string + mountPath?: string } export interface ReadBuildPreviewFileDependencies { diff --git a/hub/server/domains/build-preview/read-preview-grant/index.test.ts b/hub/server/domains/build-preview/read-preview-grant/index.test.ts deleted file mode 100644 index 34fa2460e..000000000 --- a/hub/server/domains/build-preview/read-preview-grant/index.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { randomBytes, randomUUID } from "node:crypto" -import { describe, expect, it } from "vitest" - -import { createPreviewGrant } from "../create-preview-grant" -import { readPreviewGrant } from "." - -describe("readPreviewGrant()", () => { - it("accepts a short-lived grant with its Build and target", () => { - const key = randomBytes(32) - const buildId = randomUUID() - const now = new Date("2026-11-16T22:00:00.000Z") - const expiresAt = new Date(now.getTime() + 30_000) - - expect( - readPreviewGrant( - createPreviewGrant( - { - buildId, - target: "desktop", - expiresAt, - sessionDigest: "a".repeat(64), - }, - key, - ), - key, - now, - ), - ).toEqual({ - buildId, - target: "desktop", - expiresAt, - sessionDigest: "a".repeat(64), - }) - }) - - it("rejects expired grants and grants whose lifetime exceeds one minute", () => { - const key = randomBytes(32) - const buildId = randomUUID() - const now = new Date("2026-11-16T22:00:00.000Z") - - for (const expiresAt of [new Date(now.getTime()), new Date(now.getTime() + 60_001)]) { - const grant = createPreviewGrant( - { - buildId, - target: "preview", - expiresAt, - sessionDigest: "a".repeat(64), - }, - key, - ) - expect(readPreviewGrant(grant, key, now)).toBeNull() - } - }) -}) diff --git a/hub/server/domains/build-preview/read-preview-grant/index.ts b/hub/server/domains/build-preview/read-preview-grant/index.ts deleted file mode 100644 index 91bdefd91..000000000 --- a/hub/server/domains/build-preview/read-preview-grant/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { z } from "zod" - -import { decryptAuthenticationValue } from "../../authentication/decrypt-authentication-value/index.ts" -import { isTemplateScreenshotPath } from "../template-screenshot-path/index.ts" - -const grantSchema = z - .object({ - v: z.literal(1), - b: z.uuid(), - t: z.enum(["preview", "desktop", "narrow", "template"]), - p: z.string().refine(isTemplateScreenshotPath).optional(), - e: z.number().int().positive(), - s: z.string().regex(/^[a-f0-9]{64}$/), - }) - .strict() - .refine(({ p, t }) => p === undefined || t === "template") - -export function readPreviewGrant(value: string, key: Buffer, now = new Date()) { - try { - const grant = grantSchema.parse(JSON.parse(decryptAuthenticationValue(value, key))) - if (grant.e <= now.getTime() || grant.e > now.getTime() + 60_000) return null - return { - buildId: grant.b, - target: grant.t, - ...(grant.p ? { screenshotPath: grant.p } : {}), - expiresAt: new Date(grant.e), - sessionDigest: grant.s, - } - } catch { - return null - } -} diff --git a/hub/server/domains/build-preview/read-preview-session/index.test.ts b/hub/server/domains/build-preview/read-preview-session/index.test.ts deleted file mode 100644 index 6b74c687d..000000000 --- a/hub/server/domains/build-preview/read-preview-session/index.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { randomBytes, randomUUID } from "node:crypto" -import { describe, expect, it } from "vitest" - -import { createPreviewSession } from "../create-preview-session" -import { readPreviewSession } from "." - -describe("readPreviewSession()", () => { - it("accepts an unexpired session only on its Build origin", () => { - const key = randomBytes(32) - const buildId = randomUUID() - const now = new Date("2026-11-16T22:00:00.000Z") - const session = createPreviewSession( - buildId, - "a".repeat(64), - new Date(now.getTime() + 1_000), - key, - ) - - expect(readPreviewSession(session, buildId, key, now)).toMatchObject({ b: buildId }) - expect(readPreviewSession(session, randomUUID(), key, now)).toBeNull() - }) - - it("rejects a session at and after its expiry", () => { - const key = randomBytes(32) - const buildId = randomUUID() - const expiresAt = new Date("2026-11-16T22:00:00.000Z") - const session = createPreviewSession(buildId, "a".repeat(64), expiresAt, key) - - expect(readPreviewSession(session, buildId, key, expiresAt)).toBeNull() - }) -}) diff --git a/hub/server/domains/build-preview/read-preview-session/index.ts b/hub/server/domains/build-preview/read-preview-session/index.ts deleted file mode 100644 index 3cdfe5fbb..000000000 --- a/hub/server/domains/build-preview/read-preview-session/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { z } from "zod" - -import { decryptAuthenticationValue } from "../../authentication/decrypt-authentication-value/index.ts" - -const sessionSchema = z - .object({ - v: z.literal(1), - b: z.uuid(), - s: z.string().regex(/^[a-f0-9]{64}$/), - e: z.number().int().positive(), - t: z.literal(true).optional(), - }) - .strict() - -export function readPreviewSession(value: string, buildId: string, key: Buffer, now = new Date()) { - try { - const session = sessionSchema.parse(JSON.parse(decryptAuthenticationValue(value, key))) - return session.b === buildId && session.e > now.getTime() ? session : null - } catch { - return null - } -} diff --git a/hub/server/domains/local-builds/synchronize-local-builds/index.db.test.ts b/hub/server/domains/local-builds/synchronize-local-builds/index.db.test.ts index 7184f19f4..2cc6aef47 100644 --- a/hub/server/domains/local-builds/synchronize-local-builds/index.db.test.ts +++ b/hub/server/domains/local-builds/synchronize-local-builds/index.db.test.ts @@ -256,6 +256,7 @@ describe("synchronizeLocalBuilds()", () => { buildId: build.id, startPage: "/", artifactPath: expected.path, + mountPath: null, }) if (!target) throw new Error(`Missing ${expected.target} preview target.`) diff --git a/hub/server/index.test.ts b/hub/server/index.test.ts index d69b3b7d8..a0b0e42c5 100644 --- a/hub/server/index.test.ts +++ b/hub/server/index.test.ts @@ -2,6 +2,7 @@ import { generateKeyPairSync } from "node:crypto" import { beforeEach, describe, expect, it, vi } from "vitest" import { Prisma } from "./generated/prisma/client.ts" +import { createConfiguredArtifactStorage } from "./domains/artifacts/create-configured-artifact-storage" import { logger } from "./integrations/pino" import { runApi } from "./run-api" import { startServerProcesses } from "./start-server-processes" @@ -68,6 +69,7 @@ describe("server runtime", () => { vi.doUnmock("./routes/api/product/create-product-route-dependencies/index.ts") vi.doUnmock("./routes/api/settings/github/create-github-setup-route-dependencies/index.ts") vi.doUnmock("./routes/api/github/webhooks/create-github-webhook-route-dependencies/index.ts") + vi.doUnmock("./routes/build-preview/create-build-preview-route-dependencies/index.ts") vi.mocked(parseRuntimeConfig).mockReturnValue(apiConfiguration) vi.mocked(runApi).mockResolvedValue(undefined) vi.spyOn(process, "exit").mockImplementation((code) => { @@ -381,7 +383,7 @@ describe("server runtime", () => { ) }) - it("loads route-owned authentication composition when auth is configured", async () => { + it("composes authenticated private previews without a wildcard preview origin", async () => { const createAuthenticationRouteDependencies = vi.fn() const createCopilotConnectionRouteDependencies = vi.fn() const createLearningsRouteDependencies = vi.fn() @@ -401,6 +403,19 @@ describe("server runtime", () => { } configureSharedSettings() configureGitHubApp() + vi.stubEnv("HUB_PREVIEW_ORIGIN", undefined) + const storage = { + isReady: vi.fn().mockResolvedValue(true), + read: vi.fn(), + write: vi.fn(), + delete: vi.fn(), + } + vi.mocked(createConfiguredArtifactStorage).mockResolvedValue(storage) + const preview = { applicationOrigin: "https://hub.example.test", storage } + const createBuildPreviewRouteDependencies = vi.fn().mockReturnValue(preview) + vi.doMock("./routes/build-preview/create-build-preview-route-dependencies/index.ts", () => ({ + createBuildPreviewRouteDependencies, + })) const copilotConnection = { applicationOrigin: "https://hub.example.test", } @@ -410,6 +425,7 @@ describe("server runtime", () => { vi.mocked(parseRuntimeConfig).mockReturnValue({ ...apiConfiguration, databaseUrl: "postgresql://hub.example.test/replica", + hasArtifactStorage: true, }) createAuthenticationRouteDependencies.mockResolvedValue(authentication) createCopilotConnectionRouteDependencies.mockResolvedValue(copilotConnection) @@ -446,6 +462,10 @@ describe("server runtime", () => { expect(createAuthenticationRouteDependencies).toHaveBeenCalledWith(process.env) expect(createProductRouteDependencies).toHaveBeenCalledOnce() + expect(createProductRouteDependencies).toHaveBeenCalledWith( + expect.objectContaining({ applicationOrigin: "https://hub.example.test" }), + ) + expect(createBuildPreviewRouteDependencies).toHaveBeenCalledWith(process.env, storage) expect(createCopilotConnectionRouteDependencies).toHaveBeenCalledWith( process.env, logger, @@ -465,6 +485,7 @@ describe("server runtime", () => { githubSetup, learnings, product, + preview, }), ) }) diff --git a/hub/server/index.ts b/hub/server/index.ts index b801a4143..c04815bc9 100644 --- a/hub/server/index.ts +++ b/hub/server/index.ts @@ -132,14 +132,10 @@ try { try { if (authenticationConfiguration.providerConfigured) { authentication = await createAuthenticationRouteDependencies(authenticationEnvironment) - const previewConfigured = storage && authenticationEnvironment.HUB_PREVIEW_ORIGIN - if (previewConfigured) { + if (storage) { const { createBuildPreviewRouteDependencies } = await import("./routes/build-preview/create-build-preview-route-dependencies/index.ts") preview = createBuildPreviewRouteDependencies(authenticationEnvironment, storage) - preview.restoreSession = authentication.currentSession.restore.bind( - authentication.currentSession, - ) } const { createCopilotConnectionRouteDependencies } = await import("./routes/api/copilot-connection/create-copilot-connection-route-dependencies/index.ts") @@ -217,7 +213,7 @@ try { localAnalyticsAdministration, ), localAnalyticsAdministration, - applicationOrigin: previewConfigured + applicationOrigin: storage ? authenticationEnvironment.HUB_APPLICATION_ORIGIN : undefined, scopeGitHubMembers: authenticationConfiguration.githubConfigured, @@ -226,16 +222,13 @@ try { ? createReviewDirectory(repositoryCredentials) : undefined, onReviewCommentDeleted: (input) => learningDependencies.redactComment(input), - previewBaseOrigin: previewConfigured - ? authenticationEnvironment.HUB_PREVIEW_ORIGIN - : undefined, withReviewCommentDeleteLock: (operation) => learningDependencies.serializeReviewCommentDeletion(operation), }) } else { await disableAuthenticationProviders() } - if (preview || !authenticationConfiguration.localConfigured) { + if (preview?.previewBaseOrigin || !authenticationConfiguration.localConfigured) { const { createPublicSharingRouteDependencies } = await import("./routes/api/public-sharing/create-public-sharing-route-dependencies/index.ts") publicSharing = await createPublicSharingRouteDependencies( @@ -244,7 +237,7 @@ try { ? undefined : { hostedReady: Boolean( - preview && + preview?.previewBaseOrigin && authentication?.github && typeof product?.getVerifiedRepositoryPermission === "function", ), diff --git a/hub/server/integrations/express/create-preview-cookie/index.ts b/hub/server/integrations/express/create-preview-cookie/index.ts deleted file mode 100644 index c4d202cd5..000000000 --- a/hub/server/integrations/express/create-preview-cookie/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export function createPreviewCookie(input: { - value: string - expiresAt: Date - secure: boolean -}): string { - return [ - `replica_preview=${encodeURIComponent(input.value)}`, - "Path=/", - "HttpOnly", - "SameSite=None", - input.secure ? "Secure" : null, - `Expires=${input.expiresAt.toUTCString()}`, - ] - .filter(Boolean) - .join("; ") -} diff --git a/hub/server/repositories/build-artifacts/find-build-preview-target/index.ts b/hub/server/repositories/build-artifacts/find-build-preview-target/index.ts index 1970ff717..4ccc2a301 100644 --- a/hub/server/repositories/build-artifacts/find-build-preview-target/index.ts +++ b/hub/server/repositories/build-artifacts/find-build-preview-target/index.ts @@ -1,48 +1,44 @@ import type { PrismaClient } from "../../../generated/prisma/client.ts" +import { createBuildPreviewPath } from "../../../utils/create-build-preview-path/index.ts" const targetPaths = { preview: "dist/index.html", desktop: "screenshots/desktop.png", narrow: "screenshots/narrow.png", - template: "dist/index.html", } as const export type BuildPreviewTarget = keyof typeof targetPaths export async function findBuildPreviewTarget( database: PrismaClient, - input: - | { - repositoryId: string - prototypeId: string - buildNumber: number - target: BuildPreviewTarget - } - | { buildId: string; target: BuildPreviewTarget }, + input: { + repositoryId: string + prototypeId: string + buildNumber: number + target: BuildPreviewTarget + }, ) { const artifact = await database.buildArtifact.findFirst({ where: { path: targetPaths[input.target], build: { state: "successful", - ...("buildId" in input - ? { id: input.buildId } - : { - number: input.buildNumber, - prototypeId: input.prototypeId, - prototype: { - repositoryId: input.repositoryId, - replica: false, - branchName: { not: "replica/install-workflow" }, - repository: { removedAt: null }, - }, - }), + number: input.buildNumber, + prototypeId: input.prototypeId, + prototype: { + repositoryId: input.repositoryId, + replica: false, + branchDeletedAt: null, + branchName: { not: "replica/install-workflow" }, + repository: { removedAt: null }, + }, }, }, select: { buildId: true, build: { select: { + githubWorkflowRunId: true, prototype: { select: { startPage: true, @@ -50,7 +46,14 @@ export async function findBuildPreviewTarget( branchDeletedAt: true, repositoryId: true, replica: true, - repository: { select: { defaultBranch: true, removedAt: true, localPath: true } }, + repository: { + select: { + defaultBranch: true, + removedAt: true, + localPath: true, + githubRepositoryId: true, + }, + }, }, }, }, @@ -59,31 +62,15 @@ export async function findBuildPreviewTarget( }) const prototype = artifact?.build.prototype if (!artifact || !prototype || prototype.repository.removedAt) return null - if (input.target === "template") { - if ( - !("buildId" in input) || - prototype.branchDeletedAt || - prototype.branchName !== prototype.repository.defaultBranch - ) - return null - } else if ( - prototype.replica || - prototype.branchName === prototype.repository.defaultBranch || - prototype.branchName === "replica/install-workflow" - ) - return null + if (prototype.branchName === prototype.repository.defaultBranch) return null return { buildId: artifact.buildId, - startPage: input.target === "template" ? "/" : prototype.startPage || "/", + startPage: prototype.startPage || "/", artifactPath: targetPaths[input.target], - ...(input.target === "template" - ? { - templateRepository: { - id: prototype.repositoryId, - local: Boolean(prototype.repository.localPath), - }, - } - : {}), + mountPath: createBuildPreviewPath( + prototype.repository.githubRepositoryId, + artifact.build.githubWorkflowRunId, + ), } } diff --git a/hub/server/repositories/build-artifacts/find-default-template-build/index.ts b/hub/server/repositories/build-artifacts/find-default-template-build/index.ts index 7b9d3cab2..31f9259a8 100644 --- a/hub/server/repositories/build-artifacts/find-default-template-build/index.ts +++ b/hub/server/repositories/build-artifacts/find-default-template-build/index.ts @@ -1,5 +1,6 @@ import { Prisma } from "../../../generated/prisma/client.ts" import type { PrismaClient } from "../../../generated/prisma/client.ts" +import { createBuildPreviewPath } from "../../../utils/create-build-preview-path/index.ts" import { type RepositoryScope, visibleRepositoryWhere, @@ -15,7 +16,13 @@ export function findDefaultTemplateBuild( async (transaction) => { const repository = await transaction.repository.findFirst({ where: { id: repositoryId, ...visibleRepositoryWhere(scope) }, - select: { id: true, nameWithOwner: true, defaultBranch: true, localPath: true }, + select: { + id: true, + nameWithOwner: true, + defaultBranch: true, + localPath: true, + githubRepositoryId: true, + }, }) if (!repository) return null @@ -38,6 +45,7 @@ export function findDefaultTemplateBuild( id: true, number: true, prototypeId: true, + githubWorkflowRunId: true, artifacts: { where: { OR: [ @@ -51,7 +59,19 @@ export function findDefaultTemplateBuild( }, }) : null - return { repository, build } + const { githubRepositoryId, ...publicRepository } = repository + return { + repository: publicRepository, + build: build + ? { + id: build.id, + number: build.number, + prototypeId: build.prototypeId, + artifacts: build.artifacts, + mountPath: createBuildPreviewPath(githubRepositoryId, build.githubWorkflowRunId), + } + : null, + } }, { isolationLevel: Prisma.TransactionIsolationLevel.RepeatableRead }, ) diff --git a/hub/server/repositories/build-artifacts/find-path-preview-targets/index.db.test.ts b/hub/server/repositories/build-artifacts/find-path-preview-targets/index.db.test.ts new file mode 100644 index 000000000..62cc958db --- /dev/null +++ b/hub/server/repositories/build-artifacts/find-path-preview-targets/index.db.test.ts @@ -0,0 +1,158 @@ +import { randomUUID } from "node:crypto" +import { describe, expect, it } from "vitest" + +import type { BuildState } from "../../../generated/prisma/client" +import { prisma } from "../../../integrations/prisma" +import { findPathPreviewTargets } from "." + +async function createRepository() { + return prisma.repository.create({ + data: { + githubRepositoryId: 9007199254740993n, + nameWithOwner: `octo/${randomUUID()}`, + defaultBranch: "main", + }, + }) +} + +async function createBuild( + repositoryId: string, + input: { + branchName?: string + state?: BuildState + artifactPath?: string | null + runId?: bigint + } = {}, +) { + const prototype = await prisma.prototype.create({ + data: { repositoryId, branchName: input.branchName ?? `proto/${randomUUID()}` }, + }) + const artifactPath = input.artifactPath === undefined ? "dist/index.html" : input.artifactPath + return prisma.build.create({ + data: { + prototypeId: prototype.id, + number: 1, + state: input.state ?? "successful", + commitSha: "a".repeat(40), + githubWorkflowRunId: input.runId ?? 9007199254740995n, + githubWorkflowRunAttempt: 1, + artifacts: artifactPath + ? { + create: { + kind: "dist", + path: artifactPath, + storageKey: randomUUID(), + byteLength: 10, + }, + } + : undefined, + }, + }) +} + +describe("findPathPreviewTargets()", () => { + it("finds the exact immutable owning run without rounding GitHub identifiers or following a selecting run", async () => { + const repository = await createRepository() + const build = await createBuild(repository.id) + await prisma.prototype.update({ + where: { id: build.prototypeId }, + data: { currentBuildId: build.id, currentBuildRunId: 9007199254740997n }, + }) + await prisma.gitHubBuildRunCompletion.create({ + data: { + buildId: build.id, + githubWorkflowRunId: 9007199254740997n, + runAttempt: 1, + completedAt: new Date(), + }, + }) + + await expect( + findPathPreviewTargets(prisma, { + githubRepositoryId: "9007199254740993", + githubWorkflowRunId: "9007199254740995", + }), + ).resolves.toEqual([ + { buildId: build.id, repository: { id: repository.id, local: false }, template: false }, + ]) + for (const input of [ + { githubRepositoryId: "9007199254740992", githubWorkflowRunId: "9007199254740995" }, + { githubRepositoryId: "9007199254740993", githubWorkflowRunId: "9007199254740994" }, + { githubRepositoryId: "9007199254740993", githubWorkflowRunId: "9007199254740997" }, + ]) { + await expect(findPathPreviewTargets(prisma, input)).resolves.toEqual([]) + } + }) + + it("requires a successful Build with its entry artifact in a connected repository", async () => { + const repository = await createRepository() + const unavailable = [ + await createBuild(repository.id, { state: "running", runId: 101n }), + await createBuild(repository.id, { state: "failed", runId: 102n }), + await createBuild(repository.id, { artifactPath: null, runId: 103n }), + await createBuild(repository.id, { artifactPath: "dist/assets/app.js", runId: 104n }), + ] + + for (const build of unavailable) { + await expect( + findPathPreviewTargets(prisma, { + githubRepositoryId: "9007199254740993", + githubWorkflowRunId: String(build.githubWorkflowRunId), + }), + ).resolves.toEqual([]) + } + + const removed = await createBuild(repository.id, { runId: 105n }) + await prisma.repository.update({ + where: { id: repository.id }, + data: { removedAt: new Date() }, + }) + await expect( + findPathPreviewTargets(prisma, { + githubRepositoryId: "9007199254740993", + githubWorkflowRunId: String(removed.githubWorkflowRunId), + }), + ).resolves.toEqual([]) + }) + + it("returns enough candidates to reject ambiguous runs instead of choosing one Build", async () => { + const repository = await createRepository() + const builds = [ + await createBuild(repository.id), + await createBuild(repository.id), + await createBuild(repository.id), + ] + + const targets = await findPathPreviewTargets(prisma, { + githubRepositoryId: "9007199254740993", + githubWorkflowRunId: "9007199254740995", + }) + + expect(targets).toHaveLength(2) + expect(new Set(targets.map((target) => target.buildId)).size).toBe(2) + for (const target of targets) { + expect(builds.map((build) => build.id)).toContain(target.buildId) + } + }) + + it("marks default-branch artifacts as templates and excludes workflow installation branches", async () => { + const repository = await createRepository() + const template = await createBuild(repository.id, { branchName: "main", runId: 201n }) + await createBuild(repository.id, { branchName: "replica/install-workflow", runId: 202n }) + + await expect( + findPathPreviewTargets(prisma, { + githubRepositoryId: "9007199254740993", + githubWorkflowRunId: "201", + }), + ).resolves.toEqual([ + { buildId: template.id, repository: { id: repository.id, local: false }, template: true }, + ]) + await expect( + findPathPreviewTargets(prisma, { + githubRepositoryId: "9007199254740993", + githubWorkflowRunId: "202", + }), + ).resolves.toEqual([]) + }) +}) diff --git a/hub/server/repositories/build-artifacts/find-path-preview-targets/index.ts b/hub/server/repositories/build-artifacts/find-path-preview-targets/index.ts new file mode 100644 index 000000000..dd00a3b48 --- /dev/null +++ b/hub/server/repositories/build-artifacts/find-path-preview-targets/index.ts @@ -0,0 +1,44 @@ +import type { PrismaClient } from "../../../generated/prisma/client.ts" + +export async function findPathPreviewTargets( + database: PrismaClient, + input: { githubRepositoryId: string; githubWorkflowRunId: string }, +) { + const builds = await database.build.findMany({ + where: { + state: "successful", + githubWorkflowRunId: BigInt(input.githubWorkflowRunId), + artifacts: { some: { kind: "dist", path: "dist/index.html" } }, + prototype: { + branchDeletedAt: null, + branchName: { not: "replica/install-workflow" }, + repository: { + githubRepositoryId: BigInt(input.githubRepositoryId), + removedAt: null, + localPath: null, + }, + }, + }, + take: 2, + select: { + id: true, + prototype: { + select: { + replica: true, + branchName: true, + repository: { select: { id: true, defaultBranch: true } }, + }, + }, + }, + }) + if ( + builds.length === 1 && + builds[0]!.prototype.replica && + builds[0]!.prototype.branchName !== builds[0]!.prototype.repository.defaultBranch + ) + return [] + return builds.map(({ id, prototype }) => { + const template = prototype.branchName === prototype.repository.defaultBranch + return { buildId: id, repository: { id: prototype.repository.id, local: false }, template } + }) +} diff --git a/hub/server/repositories/prototype-index/find-prototype-detail/index.db.test.ts b/hub/server/repositories/prototype-index/find-prototype-detail/index.db.test.ts index cc5eff611..68410906d 100644 --- a/hub/server/repositories/prototype-index/find-prototype-detail/index.db.test.ts +++ b/hub/server/repositories/prototype-index/find-prototype-detail/index.db.test.ts @@ -74,12 +74,17 @@ describe("findPrototypeDetail()", () => { ).toBe("owner") }) - it("maps successful Build artifacts to access URLs and the selected Controls identity", async () => { + it("maps successful Build artifacts to canonical URLs and the selected Controls identity", async () => { const repositoryId = randomUUID() const prototypeId = randomUUID() const buildId = randomUUID() await prisma.repository.create({ - data: { id: repositoryId, nameWithOwner: "team/design", defaultBranch: "main" }, + data: { + id: repositoryId, + githubRepositoryId: 2001n, + nameWithOwner: "team/design", + defaultBranch: "main", + }, }) await prisma.prototype.create({ data: { @@ -95,6 +100,7 @@ describe("findPrototypeDetail()", () => { prototypeId, number: 42, state: "successful", + githubWorkflowRunId: 3002n, artifacts: { create: [ { @@ -133,15 +139,17 @@ describe("findPrototypeDetail()", () => { 42, undefined, null, - (_buildId, repository, prototype, build, target) => - `/api/repositories/${repository}/prototypes/${prototype}/builds/${build}/access?target=${target}`, + (mountPath, target, startPage = "/") => + mountPath + ? `${mountPath}${target === "preview" ? startPage.slice(1) : `__replica/screenshots/${target}.png`}` + : null, ) expect(detail?.selectedBuild).toMatchObject({ number: 42, - previewUrl: `/api/repositories/${repositoryId}/prototypes/${prototypeId}/builds/42/access?target=preview`, - desktopScreenshotUrl: `/api/repositories/${repositoryId}/prototypes/${prototypeId}/builds/42/access?target=desktop`, - narrowScreenshotUrl: `/api/repositories/${repositoryId}/prototypes/${prototypeId}/builds/42/access?target=narrow`, + previewUrl: "/previews/github/2001/3002/checkout", + desktopScreenshotUrl: "/previews/github/2001/3002/__replica/screenshots/desktop.png", + narrowScreenshotUrl: "/previews/github/2001/3002/__replica/screenshots/narrow.png", }) expect(detail?.controlsIdentity).toBe("controls-binding") }) diff --git a/hub/server/repositories/prototype-index/find-prototype-detail/index.ts b/hub/server/repositories/prototype-index/find-prototype-detail/index.ts index 9e3fb4019..5022b51d0 100644 --- a/hub/server/repositories/prototype-index/find-prototype-detail/index.ts +++ b/hub/server/repositories/prototype-index/find-prototype-detail/index.ts @@ -1,5 +1,6 @@ import { Prisma, type Build } from "../../../generated/prisma/client.ts" import { trimPrototypeMetadata } from "../../../utils/trim-prototype-metadata/index.ts" +import { createBuildPreviewPath } from "../../../utils/create-build-preview-path/index.ts" import { type RepositoryScope, visibleRepositoryWhere } from "../visible-repository-where/index.ts" const hiddenBranches = ["replica/install-workflow"] @@ -18,18 +19,16 @@ export async function findPrototypeDetail( buildPage?: { page: number; pageSize: number }, scope: RepositoryScope = null, buildArtifactUrl?: ( - buildId: string, - repositoryId: string, - prototypeId: string, - buildNumber: number, + mountPath: string | null, target: "preview" | "desktop" | "narrow", - ) => string, + startPage?: string, + ) => string | null, ) { const detail = await database.$transaction( async (transaction) => { const repository = await transaction.repository.findFirst({ where: { id: repositoryId, ...visibleRepositoryWhere(scope) }, - select: { id: true, nameWithOwner: true, defaultBranch: true }, + select: { id: true, nameWithOwner: true, defaultBranch: true, githubRepositoryId: true }, }) if (!repository) return null @@ -93,6 +92,7 @@ export async function findPrototypeDetail( authorAvatarUrl: true, createdAt: true, workflowCreatedAt: true, + githubWorkflowRunId: true, startedAt: true, finishedAt: true, failureSummary: true, @@ -163,30 +163,22 @@ export async function findPrototypeDetail( previewUrl: build.artifacts.some(({ path }) => path === "dist/index.html") && buildArtifactUrl ? buildArtifactUrl( - build.id, - prototype.repositoryId, - prototype.id, - build.number, + createBuildPreviewPath(repository.githubRepositoryId, build.githubWorkflowRunId), "preview", + prototype.startPage || "/", ) : null, desktopScreenshotUrl: build.artifacts.some(({ path }) => path === "screenshots/desktop.png") && buildArtifactUrl ? buildArtifactUrl( - build.id, - prototype.repositoryId, - prototype.id, - build.number, + createBuildPreviewPath(repository.githubRepositoryId, build.githubWorkflowRunId), "desktop", ) : null, narrowScreenshotUrl: build.artifacts.some(({ path }) => path === "screenshots/narrow.png") && buildArtifactUrl ? buildArtifactUrl( - build.id, - prototype.repositoryId, - prototype.id, - build.number, + createBuildPreviewPath(repository.githubRepositoryId, build.githubWorkflowRunId), "narrow", ) : null, @@ -209,7 +201,11 @@ export async function findPrototypeDetail( } : null return { - repository, + repository: { + id: repository.id, + nameWithOwner: repository.nameWithOwner, + defaultBranch: repository.defaultBranch, + }, prototype: { id: prototype.id, repositoryId: prototype.repositoryId, diff --git a/hub/server/routes/api/product/create-product-route-dependencies/index.ts b/hub/server/routes/api/product/create-product-route-dependencies/index.ts index 398a39ff7..7133b1241 100644 --- a/hub/server/routes/api/product/create-product-route-dependencies/index.ts +++ b/hub/server/routes/api/product/create-product-route-dependencies/index.ts @@ -5,7 +5,6 @@ import { recordAnalyticsEvent } from "../../../../domains/analytics/record-event import type { AnalyticsSettings } from "../../../../domains/analytics/types.ts" import { restoreHubSession } from "../../../../domains/admission/restore-hub-session/index.ts" import { runSessionRestoreTransaction } from "../../../../domains/admission/run-session-restore-transaction/index.ts" -import { createBuildPreviewOrigin } from "../../../../domains/build-preview/create-build-preview-origin/index.ts" import { editPrototypeMetadata } from "../../../../domains/prototypes/edit-prototype-metadata/index.ts" import { PrototypeMetadataError } from "../../../../domains/prototypes/errors.ts" import { readPrototypeWithIntroduction } from "../../../../domains/prototypes/read-prototype-with-introduction/index.ts" @@ -55,6 +54,7 @@ import { } from "../../../../repositories/users/welcome-preference/index.ts" import { canWriteRepository } from "../../../../utils/can-write-repository/index.ts" import { localDeveloperIdentity } from "../../../../utils/local-developer-identity/index.ts" +import { normalizeStartPage } from "../../../../utils/normalize-start-page/index.ts" import type { AnalyticsViewer } from "../../repositories/analytics/types.ts" import { readWithPersistedRepositoryScope } from "../read-with-persisted-repository-scope/index.ts" import { resolvePersistedRepositoryScope } from "../resolve-persisted-repository-scope/index.ts" @@ -80,7 +80,6 @@ interface CreateProductRouteDependenciesOptions { commentId: number actorLogin: string }) => Promise - previewBaseOrigin?: string getRepositoryPermission?: WorkspaceProductRouteDependencies["getRepositoryPermission"] withReviewCommentDeleteLock?: (operation: () => Promise) => Promise } @@ -95,7 +94,6 @@ export function createProductRouteDependencies({ githubReviewDirectory, authorizeReviewMutation, onReviewCommentDeleted, - previewBaseOrigin, getRepositoryPermission: permissionOverride, withReviewCommentDeleteLock, }: CreateProductRouteDependenciesOptions = {}): WorkspaceProductRouteDependencies { @@ -264,27 +262,16 @@ export function createProductRouteDependencies({ } return true }) - const buildArtifactUrl = - applicationOrigin && previewBaseOrigin - ? ( - buildId: string, - repositoryId: string, - prototypeId: string, - buildNumber: number, - target: "preview" | "desktop" | "narrow", - ) => { - const url = new URL( - `/api/repositories/${repositoryId}/prototypes/${prototypeId}/builds/${buildNumber}/access`, - applicationOrigin, - ) - url.searchParams.set("target", target) - url.searchParams.set( - "preview_origin", - createBuildPreviewOrigin(buildId, previewBaseOrigin), - ) - return url.toString() - } - : undefined + const buildArtifactUrl = applicationOrigin + ? (mountPath: string | null, target: "preview" | "desktop" | "narrow", startPage = "/") => { + if (!mountPath) return null + const route = + target === "preview" + ? (normalizeStartPage(startPage) ?? "/") + : `/__replica/screenshots/${target}.png` + return new URL(`${mountPath}${route.slice(1)}`, applicationOrigin).toString() + } + : undefined const mentions = createReviewMentionDirectory(prisma, githubReviewDirectory) return { getRepositoryPermission, diff --git a/hub/server/routes/api/public-sharing/hosted-sharing.db.test.ts b/hub/server/routes/api/public-sharing/hosted-sharing.db.test.ts index f80e6c1f5..def9f27d3 100644 --- a/hub/server/routes/api/public-sharing/hosted-sharing.db.test.ts +++ b/hub/server/routes/api/public-sharing/hosted-sharing.db.test.ts @@ -126,7 +126,6 @@ async function startHub( const product = { ...createProductRouteDependencies({ applicationOrigin: preview.applicationOrigin, - previewBaseOrigin: preview.previewBaseOrigin, }), getVerifiedRepositoryPermission: getRepositoryPermission, } diff --git a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts index 68b75df5d..4fd8f4eca 100644 --- a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts +++ b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts @@ -5,8 +5,6 @@ import type { AddressInfo } from "node:net" import express from "express" import { describe, expect, it, vi, type Mock } from "vitest" -import { hashAuthenticationValue } from "../../../../../../../domains/authentication/hash-authentication-value" -import { readPreviewGrant } from "../../../../../../../domains/build-preview/read-preview-grant" import type { CurrentSessionDependencies } from "../../../../../auth/types" import type { ProductRouteDependencies } from "../../../../../product/types" import type { BuildPreviewRouteDependencies } from "../../../../../../build-preview/types" @@ -30,6 +28,7 @@ async function withAccessRoute( membershipId: randomUUID(), userId: randomUUID(), provider: "github", + sessionProvider: "github", login: "mona", name: "Mona", role: "MEMBER" as const, @@ -46,11 +45,11 @@ async function withAccessRoute( buildId: randomUUID(), startPage: "/checkout", artifactPath: "dist/index.html", + mountPath: "/previews/github/2001/3002/", }), } const preview: BuildPreviewRouteDependencies = { applicationOrigin: "https://hub.example.com", - previewBaseOrigin: "https://preview.example.com", encryptionKey: randomBytes(32), storage: { isReady: vi.fn(), @@ -59,8 +58,8 @@ async function withAccessRoute( delete: vi.fn(), }, bridgeSource: "", - findTargetById: vi.fn(), findArtifact: vi.fn(), + findPathTargets: vi.fn(), } const app = express() app.get( @@ -94,8 +93,8 @@ describe("get()", () => { }) }) - it("redirects authorized members to a short-lived Build-origin grant", async () => { - await withAccessRoute(async (url, product, preview) => { + it("redirects a UUID Build access URL to its fixed prefix while preserving the requested route", async () => { + await withAccessRoute(async (url, product) => { const request = new URL(url) request.searchParams.set("target", "preview") request.searchParams.set("route", "/checkout?step=shipping#address") @@ -106,14 +105,10 @@ describe("get()", () => { expect(response.status).toBe(302) const destination = new URL(response.headers.get("location")!) - expect(destination.origin).toMatch(/^https:\/\/[\da-f-]+\.preview\.example\.com$/) - expect(destination.pathname).toBe("/__replica/authorize") - const grant = readPreviewGrant(destination.searchParams.get("grant")!, preview.encryptionKey) - expect(grant).toMatchObject({ - target: "preview", - sessionDigest: hashAuthenticationValue("member-session"), - }) - expect(destination.searchParams.get("route")).toBe("/checkout?step=shipping#address") + expect(destination.toString()).toBe( + "https://hub.example.com/previews/github/2001/3002/checkout?step=shipping#address", + ) + expect(response.headers.get("set-cookie")).toBeNull() expect(response.headers.get("cache-control")).toBe("no-store") expect(response.headers.get("referrer-policy")).toBe("no-referrer") const [repositoryId, prototypeId] = new URL(url).pathname.slice(1).split("/") @@ -133,6 +128,53 @@ describe("get()", () => { headers: { cookie: "hub_session=member-session" }, redirect: "manual", }) + expect(response.status).toBe(404) + expect(response.headers.get("location")).toBeNull() + }) + }) + + it.each(["desktop", "narrow"])("redirects %s access to the same fixed prefix", async (target) => { + await withAccessRoute(async (url) => { + const response = await fetch(`${url}?target=${target}`, { + headers: { cookie: "hub_session=member-session" }, + redirect: "manual", + }) + + expect(response.status).toBe(302) + expect(response.headers.get("location")).toBe( + `https://hub.example.com/previews/github/2001/3002/__replica/screenshots/${target}.png`, + ) + }) + }) + + it("does not use a public-share wildcard when the Build has no canonical GitHub identifiers", async () => { + await withAccessRoute(async (url, product, preview) => { + preview.previewBaseOrigin = "https://share.example.net" + product.findBuildPreviewTarget.mockResolvedValue({ + buildId: randomUUID(), + startPage: "/", + artifactPath: "dist/index.html", + mountPath: null, + }) + const response = await fetch(`${url}?target=preview`, { + headers: { cookie: "hub_session=member-session" }, + redirect: "manual", + }) + + expect(response.status).toBe(404) + expect(response.headers.get("location")).toBeNull() + expect(response.headers.get("set-cookie")).toBeNull() + }) + }) + + it("does not redirect a fixed-prefix Build after repository access is revoked", async () => { + await withAccessRoute(async (url, product) => { + vi.mocked(product.isRepositoryVisible).mockResolvedValue(false) + + const response = await fetch(`${url}?target=preview`, { + headers: { cookie: "hub_session=member-session" }, + redirect: "manual", + }) expect(response.status).toBe(404) expect(response.headers.get("location")).toBeNull() @@ -165,21 +207,6 @@ describe("get()", () => { }, restore) }) - it("rejects a tampered Build origin hint", async () => { - await withAccessRoute(async (url) => { - const request = new URL(url) - request.searchParams.set("target", "preview") - request.searchParams.set("preview_origin", "https://untrusted.example.com") - const response = await fetch(request, { - headers: { cookie: "hub_session=member-session" }, - redirect: "manual", - }) - - expect(response.status).toBe(400) - expect(response.headers.get("location")).toBeNull() - }) - }) - it("rejects an unsafe deep-link route", async () => { await withAccessRoute(async (url) => { const request = new URL(url) @@ -195,8 +222,8 @@ describe("get()", () => { }) }) - it("carries long valid routes outside the bounded encrypted grant", async () => { - await withAccessRoute(async (url, _product, preview) => { + it("preserves long valid routes in the canonical redirect", async () => { + await withAccessRoute(async (url) => { const route = `/${"a".repeat(1500)}` const request = new URL(url) request.searchParams.set("target", "preview") @@ -208,10 +235,7 @@ describe("get()", () => { expect(response.status).toBe(302) const destination = new URL(response.headers.get("location")!) - expect(destination.searchParams.get("route")).toBe(route) - expect( - readPreviewGrant(destination.searchParams.get("grant")!, preview.encryptionKey), - ).toMatchObject({ target: "preview" }) + expect(destination.pathname).toBe(`/previews/github/2001/3002${route}`) }) }) }) diff --git a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts index c752c0f17..fd3f803d0 100644 --- a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts +++ b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts @@ -1,9 +1,6 @@ import type { RequestHandler } from "express" import { z } from "zod" -import { createBuildPreviewOrigin } from "../../../../../../../domains/build-preview/create-build-preview-origin/index.ts" -import { createPreviewGrant } from "../../../../../../../domains/build-preview/create-preview-grant/index.ts" -import { hashAuthenticationValue } from "../../../../../../../domains/authentication/hash-authentication-value/index.ts" import { hubSessionCookieName } from "../../../../../../../integrations/express/hub-session-cookie-name/index.ts" import { readCookie } from "../../../../../../../integrations/express/read-cookie/index.ts" import type { CurrentSessionDependencies } from "../../../../../auth/types.ts" @@ -16,7 +13,6 @@ import type { BuildPreviewRouteDependencies } from "../../../../../../build-prev const querySchema = z .object({ target: z.enum(["preview", "desktop", "narrow"]), - preview_origin: z.url().optional(), route: z.string().max(4096).optional(), }) .strict() @@ -68,33 +64,29 @@ export function get( response.status(404).json({ error: "Build preview not found." }) return } - const previewOrigin = createBuildPreviewOrigin(target.buildId, preview.previewBaseOrigin) - if (query.data.preview_origin && query.data.preview_origin !== previewOrigin) { - response.status(400).json({ error: "The Build preview origin is invalid." }) - return - } const requestedRoute = query.data.route ? normalizeStartPage(query.data.route) : undefined if (query.data.route && !requestedRoute) { response.status(400).json({ error: "The Build preview route is invalid." }) return } - const grant = createPreviewGrant( - { - buildId: target.buildId, - target: query.data.target, - expiresAt: new Date(Date.now() + 30_000), - sessionDigest: hashAuthenticationValue(cookie), - }, - preview.encryptionKey, - ) - const destination = new URL("/__replica/authorize", previewOrigin) - destination.searchParams.set("grant", grant) - if (query.data.target === "preview" && requestedRoute) { - destination.searchParams.set("route", requestedRoute) + if (!target.mountPath) { + response.status(404).json({ error: "This Build has no supported hosted preview address." }) + return } + if (!(await product.isRepositoryVisible(current, repositoryId.data))) { + response.status(404).json({ error: "Build preview not found." }) + return + } + const path = + query.data.target === "preview" + ? (requestedRoute ?? normalizeStartPage(target.startPage) ?? "/") + : `/__replica/screenshots/${query.data.target}.png` response.setHeader("Cache-Control", "no-store") response.setHeader("Referrer-Policy", "no-referrer") - response.redirect(302, destination.toString()) + response.redirect( + 302, + new URL(`${target.mountPath}${path.slice(1)}`, preview.applicationOrigin).toString(), + ) } catch (error) { next(error) } diff --git a/hub/server/routes/api/repositories/templates/index.db.test.ts b/hub/server/routes/api/repositories/templates/index.db.test.ts index fc33b25cb..6a5e27543 100644 --- a/hub/server/routes/api/repositories/templates/index.db.test.ts +++ b/hub/server/routes/api/repositories/templates/index.db.test.ts @@ -9,7 +9,7 @@ import { createApp } from "../../../../create-app" import { hubSessionCookieName } from "../../../../integrations/express/hub-session-cookie-name" import { prisma } from "../../../../integrations/prisma" import { findBuildArtifact } from "../../../../repositories/build-artifacts/find-build-artifact" -import { findBuildPreviewTarget } from "../../../../repositories/build-artifacts/find-build-preview-target" +import { findPathPreviewTargets } from "../../../../repositories/build-artifacts/find-path-preview-targets" import { createProductRouteDependencies } from "../../product/create-product-route-dependencies" import type { WorkspaceProductRouteDependencies } from "../../product/types" @@ -68,10 +68,10 @@ async function withRepository( }), preview: { applicationOrigin: origin, - previewBaseOrigin: "http://preview.localhost:3001", encryptionKey: randomBytes(32), bridgeSource: "", - findTargetById: (buildId, target) => findBuildPreviewTarget(prisma, { buildId, target }), + findPathTargets: (githubRepositoryId, githubWorkflowRunId) => + findPathPreviewTargets(prisma, { githubRepositoryId, githubWorkflowRunId }), findArtifact: (buildId, path) => findBuildArtifact(prisma, buildId, path), storage: { isReady: () => Promise.resolve(true), @@ -164,6 +164,7 @@ it("keeps the catalog, screenshot, and routed preview on one successful default- prototypeId, number: 2, state: "successful", + githubWorkflowRunId: 3002n, workflowCreatedAt: new Date("2026-01-03"), artifacts: { create: [ @@ -222,20 +223,18 @@ it("keeps the catalog, screenshot, and routed preview on one successful default- const accessPath = preview.pathname.slice(`/api/repositories/${repositoryId}`.length) const granted = await read(accessPath + preview.search) expect(granted.status).toBe(302) - const authorize = new URL(granted.headers.get("location")!) - expect(authorize.origin).toBe(`http://${selected.id}.preview.localhost:3001`) - const exchanged = await readPreview(authorize) - expect(exchanged.status).toBe(303) - expect(exchanged.headers.location).toBe(route) - const cookie = exchanged.headers["set-cookie"]?.[0]?.split(";", 1)[0] - expect(cookie).toBeDefined() - const frame = await readPreview(new URL(route, authorize), cookie) + const destination = new URL(granted.headers.get("location")!) + expect(destination.toString()).toBe(`http://localhost:5173/previews/github/456/3002${route}`) + expect(granted.headers.get("set-cookie")).toBeNull() + const cookie = `${hubSessionCookieName}=template-test` + const frame = await readPreview(destination, cookie) + expect(frame.status).toBe(200) expect(frame.bytes.toString()).toContain("Saved Settings") const previewScreenshot = new URL( - "/__replica/screenshots/templates/settings/desktop.png", - authorize, + "/previews/github/456/3002/__replica/screenshots/templates/settings/desktop.png", + destination, ) - expect((await readPreview(previewScreenshot)).status).toBe(404) + expect((await readPreview(previewScreenshot)).status).toBe(401) const captured = await readPreview(previewScreenshot, cookie) expect(captured.headers["content-type"]).toBe("image/png") expect(captured.bytes).toEqual(png) diff --git a/hub/server/routes/api/repositories/templates/index.test.ts b/hub/server/routes/api/repositories/templates/index.test.ts index 8e28fe5d2..fd235683b 100644 --- a/hub/server/routes/api/repositories/templates/index.test.ts +++ b/hub/server/routes/api/repositories/templates/index.test.ts @@ -1,4 +1,4 @@ -import { randomUUID } from "node:crypto" +import { randomBytes, randomUUID } from "node:crypto" import { once } from "node:events" import { createServer } from "node:http" import type { AddressInfo } from "node:net" @@ -8,19 +8,28 @@ import { describe, expect, it, vi } from "vitest" import type { CurrentSessionDependencies } from "../../auth/types" import { GitHubProviderRequestError } from "../../../../integrations/github/errors" import type { WorkspaceProductRouteDependencies } from "../../product/types" +import type { BuildPreviewRouteDependencies } from "../../../build-preview/types" import { templateRoutes } from "." type Viewer = NonNullable>> async function withTemplates( - options: { provider: string; administrator?: boolean; permission?: "read" | "write" }, + options: { + provider: string + administrator?: boolean + permission?: "read" | "write" + mountPath?: string | null + publicShareOrigin?: string + }, run: (fixture: { + buildId: string read: (path: string, cookie?: string) => Promise visibility: ReturnType> restore: ReturnType> }) => Promise, ) { const repositoryId = randomUUID() + const buildId = randomUUID() const viewer: Viewer = { userId: randomUUID(), membershipId: randomUUID(), @@ -47,7 +56,16 @@ async function withTemplates( defaultBranch: "main", localPath: null, }, - build: null, + build: + options.mountPath !== undefined + ? { + id: buildId, + prototypeId: randomUUID(), + number: 1, + mountPath: options.mountPath, + artifacts: [{ path: "dist/index.html", storageKey: "entry", byteLength: 1 }], + } + : null, }), }, listRepositories: vi.fn(), @@ -58,22 +76,37 @@ async function withTemplates( editPrototypeMetadata: vi.fn(), findBuildPreviewTarget: vi.fn(), } - const routes = templateRoutes({ restore }, product, undefined) + const preview: BuildPreviewRouteDependencies | undefined = + options.mountPath !== undefined + ? { + applicationOrigin: "https://hub.example.com", + previewBaseOrigin: options.publicShareOrigin, + encryptionKey: randomBytes(32), + bridgeSource: "", + storage: { isReady: vi.fn(), read: vi.fn(), write: vi.fn(), delete: vi.fn() }, + findArtifact: vi.fn(), + findPathTargets: vi.fn(), + } + : undefined + const routes = templateRoutes({ restore }, product, preview) const app = express() app.get("/repositories/:repositoryId/templates", routes.catalog) app.get("/repositories/:repositoryId/templates/:templateId", routes.detail) app.get("/repositories/:repositoryId/create/permission", routes.permission) + app.get("/repositories/:repositoryId/template-builds/:buildId/access", routes.access) const server = createServer(app) server.listen(0, "127.0.0.1") await once(server, "listening") try { const { port } = server.address() as AddressInfo await run({ + buildId, visibility, restore, read: (path, cookie = "hub_session=member-session") => fetch(`http://127.0.0.1:${port}/repositories/${repositoryId}${path}`, { headers: { cookie }, + redirect: "manual", }), }) } finally { @@ -84,6 +117,44 @@ async function withTemplates( } describe("templateRoutes()", () => { + it("offers and opens a mounted template without a wildcard preview origin", async () => { + await withTemplates( + { provider: "github", mountPath: "/previews/github/2001/3002/" }, + async ({ read, buildId }) => { + const route = "/checkout?step=shipping#address" + const detail = await read(`/templates/default?return_path=${encodeURIComponent(route)}`) + expect(detail.status).toBe(200) + const result = (await detail.json()) as { template: { previewUrl: string } } + const access = new URL(result.template.previewUrl) + expect(access.pathname).toContain(`/template-builds/${buildId}/access`) + + const response = await read(`/template-builds/${buildId}/access${access.search}`) + + expect(response.status).toBe(302) + expect(response.headers.get("location")).toBe( + `https://hub.example.com/previews/github/2001/3002${route}`, + ) + expect(response.headers.get("set-cookie")).toBeNull() + }, + ) + }) + + it("does not offer or open an identifier-less template through a public-share wildcard", async () => { + await withTemplates( + { provider: "github", mountPath: null, publicShareOrigin: "https://share.example.net" }, + async ({ read, buildId }) => { + const detail = await read("/templates/default") + expect(detail.status).toBe(200) + expect(await detail.json()).toMatchObject({ template: { previewUrl: null } }) + + const response = await read(`/template-builds/${buildId}/access?target=preview&route=%2F`) + + expect(response.status).toBe(404) + expect(response.headers.get("location")).toBeNull() + }, + ) + }) + it.each([ { access: "GitHub read-only", provider: "github", permission: "read" as const }, { access: "Entra member", provider: "entra" }, diff --git a/hub/server/routes/api/repositories/templates/index.ts b/hub/server/routes/api/repositories/templates/index.ts index af349d0b3..e70c67dd9 100644 --- a/hub/server/routes/api/repositories/templates/index.ts +++ b/hub/server/routes/api/repositories/templates/index.ts @@ -2,8 +2,6 @@ import type { Request, RequestHandler } from "express" import { z } from "zod" import { hashAuthenticationValue } from "../../../../domains/authentication/hash-authentication-value/index.ts" -import { createBuildPreviewOrigin } from "../../../../domains/build-preview/create-build-preview-origin/index.ts" -import { createPreviewGrant } from "../../../../domains/build-preview/create-preview-grant/index.ts" import { readTemplateManifest, TemplateManifestUnavailable, @@ -37,7 +35,6 @@ const accessQuery = z.discriminatedUnion("target", [ z.strictObject({ target: z.literal("preview"), route: z.string().max(2048), - preview_origin: z.url(), }), z.strictObject({ target: z.literal("desktop"), @@ -67,7 +64,8 @@ function presentTemplate( preview: BuildPreviewRouteDependencies | undefined, initialRoute: string, ) { - const previewable = preview && build?.artifacts.some(({ path }) => path === "dist/index.html") + const previewable = + preview && build?.mountPath && build?.artifacts.some(({ path }) => path === "dist/index.html") function screenshot(theme: "light" | "dark") { return previewable && build?.artifacts.some(({ path }) => path === templateScreenshotPath(entry.id, theme)) @@ -86,7 +84,6 @@ function presentTemplate( ? accessUrl(preview, repositoryId, build.id, { target: "preview", route: initialRoute, - preview_origin: createBuildPreviewOrigin(build.id, preview.previewBaseOrigin), }) : null, screenshotUrl: screenshot("light"), @@ -218,40 +215,32 @@ export function templateRoutes( if (!preview || !buildId.success || !query.success) return null const snapshot = await load(viewer, repositoryId, buildId.data) if (!snapshot?.build?.artifacts.some(({ path }) => path === "dist/index.html")) return null - const origin = createBuildPreviewOrigin(buildId.data, preview.previewBaseOrigin) + const mountPath = snapshot.build.mountPath + if (!mountPath) return null + const origin = preview.applicationOrigin if (!(await product.isRepositoryVisible(viewer, repositoryId))) return null if (query.data.target === "preview") { const route = templateReturnPath(query.data.route) - return route && query.data.preview_origin === origin - ? { buildId: buildId.data, origin, route } - : null + return route ? { buildId: buildId.data, origin, mountPath, route } : null } const { template, theme } = query.data if (!snapshot.templates.some(({ id }) => id === template)) return null const screenshotPath = templateScreenshotPath(template, theme) return snapshot.build.artifacts.some(({ path }) => path === screenshotPath) - ? { buildId: buildId.data, origin, screenshotPath } + ? { buildId: buildId.data, origin, mountPath, screenshotPath } : null }, - (response, result, cookie) => { + (response, result) => { if (!preview) return - const destination = new URL("/__replica/authorize", result.origin) - destination.searchParams.set( - "grant", - createPreviewGrant( - { - buildId: result.buildId, - target: "template", - screenshotPath: result.screenshotPath, - expiresAt: new Date(Date.now() + 30_000), - sessionDigest: hashAuthenticationValue(cookie), - }, - preview.encryptionKey, - ), - ) - if (result.route) destination.searchParams.set("route", result.route) + response.setHeader("Cache-Control", "private, no-store") + const route = result.screenshotPath + ? `/__replica/${result.screenshotPath}` + : result.route || "/" response.setHeader("Referrer-Policy", "no-referrer") - response.redirect(302, destination.toString()) + response.redirect( + 302, + new URL(`${result.mountPath}${route.slice(1)}`, result.origin).toString(), + ) }, ), } diff --git a/hub/server/routes/build-preview/authorize/get/index.test.ts b/hub/server/routes/build-preview/authorize/get/index.test.ts deleted file mode 100644 index c699a6214..000000000 --- a/hub/server/routes/build-preview/authorize/get/index.test.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { randomBytes, randomUUID } from "node:crypto" -import { once } from "node:events" -import { createServer, request as httpRequest, type IncomingHttpHeaders } from "node:http" -import type { AddressInfo } from "node:net" -import express from "express" -import { describe, expect, it, vi, type Mock } from "vitest" - -import { createPreviewGrant } from "../../../../domains/build-preview/create-preview-grant" -import type { BuildPreviewRouteDependencies } from "../../types" -import { get } from "." - -async function request(origin: string, path: string, host: string) { - return new Promise<{ - status: number - headers: IncomingHttpHeaders - }>((resolve, reject) => { - const url = new URL(origin) - const outgoing = httpRequest( - { hostname: url.hostname, port: url.port, path, headers: { host } }, - (response) => { - response.resume() - response.on("end", () => - resolve({ status: response.statusCode ?? 0, headers: response.headers }), - ) - }, - ) - outgoing.on("error", reject) - outgoing.end() - }) -} - -async function withAuthorizeRoute( - operation: ( - origin: string, - dependencies: BuildPreviewRouteDependencies, - key: Buffer, - findTargetById: Mock, - ) => Promise, -) { - const key = randomBytes(32) - const app = express() - const server = createServer(app) - server.listen(0, "127.0.0.1") - await once(server, "listening") - const { port } = server.address() as AddressInfo - const findTargetById = vi.fn() - const dependencies: BuildPreviewRouteDependencies = { - applicationOrigin: "https://hub.example.com", - previewBaseOrigin: `http://preview.localhost:${port}`, - encryptionKey: key, - storage: { - isReady: vi.fn(), - read: vi.fn(), - write: vi.fn(), - delete: vi.fn(), - }, - bridgeSource: "", - findTargetById: findTargetById.mockResolvedValue({ - buildId: randomUUID(), - startPage: "/checkout?step=shipping#address", - artifactPath: "dist/index.html", - }), - findArtifact: vi.fn(), - } - app.get("/__replica/authorize", get(dependencies)) - try { - await operation(`http://127.0.0.1:${port}`, dependencies, key, findTargetById) - } finally { - await new Promise((resolve, reject) => { - server.close((error) => (error ? reject(error) : resolve())) - }) - } -} - -describe("get()", () => { - it("exchanges a matching grant for an isolated preview session and start-page redirect", async () => { - await withAuthorizeRoute(async (origin, _dependencies, key, findTargetById) => { - const buildId = randomUUID() - findTargetById.mockResolvedValue({ - buildId, - startPage: "/checkout?step=shipping#address", - artifactPath: "dist/index.html", - }) - const grant = createPreviewGrant( - { - buildId, - target: "preview", - expiresAt: new Date(Date.now() + 30_000), - sessionDigest: "a".repeat(64), - }, - key, - ) - - const response = await request( - origin, - `/__replica/authorize?grant=${encodeURIComponent(grant)}`, - `${buildId}.preview.localhost:${new URL(origin).port}`, - ) - - expect(response.status).toBe(303) - expect(response.headers.location).toBe("/checkout?step=shipping#address") - expect(response.headers["set-cookie"]?.[0]).toMatch( - /^replica_preview=.+; Path=\/; HttpOnly; SameSite=None; Secure; Expires=/, - ) - expect(response.headers["cache-control"]).toBe("no-store") - expect(findTargetById).toHaveBeenCalledWith(buildId, "preview") - }) - }) - - it("does not exchange a grant on another Build origin", async () => { - await withAuthorizeRoute(async (origin, _dependencies, key, findTargetById) => { - const grant = createPreviewGrant( - { - buildId: randomUUID(), - target: "desktop", - expiresAt: new Date(Date.now() + 30_000), - sessionDigest: "a".repeat(64), - }, - key, - ) - - const response = await request( - origin, - `/__replica/authorize?grant=${encodeURIComponent(grant)}`, - `${randomUUID()}.preview.localhost:${new URL(origin).port}`, - ) - - expect(response.status).toBe(404) - expect(response.headers["set-cookie"]).toBeUndefined() - expect(findTargetById).not.toHaveBeenCalled() - }) - }) - - it("validates and redirects to a deep route carried outside the grant", async () => { - await withAuthorizeRoute(async (origin, _dependencies, key, findTargetById) => { - const buildId = randomUUID() - findTargetById.mockResolvedValue({ - buildId, - startPage: "/", - artifactPath: "dist/index.html", - }) - const grant = createPreviewGrant( - { - buildId, - target: "preview", - expiresAt: new Date(Date.now() + 30_000), - sessionDigest: "a".repeat(64), - }, - key, - ) - const host = `${buildId}.preview.localhost:${new URL(origin).port}` - - const valid = await request( - origin, - `/__replica/authorize?grant=${encodeURIComponent(grant)}&route=${encodeURIComponent("/checkout?step=shipping#address")}`, - host, - ) - expect(valid.status).toBe(303) - expect(valid.headers.location).toBe("/checkout?step=shipping#address") - - const unsafe = await request( - origin, - `/__replica/authorize?grant=${encodeURIComponent(grant)}&route=${encodeURIComponent("https://untrusted.example.com")}`, - host, - ) - expect(unsafe.status).toBe(404) - expect(unsafe.headers["set-cookie"]).toBeUndefined() - }) - }) -}) diff --git a/hub/server/routes/build-preview/authorize/get/index.ts b/hub/server/routes/build-preview/authorize/get/index.ts deleted file mode 100644 index a58f737b4..000000000 --- a/hub/server/routes/build-preview/authorize/get/index.ts +++ /dev/null @@ -1,66 +0,0 @@ -import type { RequestHandler } from "express" - -import { createPreviewSession } from "../../../../domains/build-preview/create-preview-session/index.ts" -import { readPreviewBuildId } from "../../../../domains/build-preview/read-preview-build-id/index.ts" -import { readPreviewGrant } from "../../../../domains/build-preview/read-preview-grant/index.ts" -import { normalizeStartPage } from "../../../../utils/normalize-start-page/index.ts" -import { z } from "zod" -import { createPreviewCookie } from "../../../../integrations/express/create-preview-cookie/index.ts" -import type { BuildPreviewRouteDependencies } from "../../types.ts" - -export function get(dependencies: BuildPreviewRouteDependencies): RequestHandler { - return async (request, response, next) => { - try { - const buildId = readPreviewBuildId(request.get("host"), dependencies.previewBaseOrigin) - const grantValue = typeof request.query.grant === "string" ? request.query.grant : "" - const requestedRoute = z.string().max(4096).safeParse(request.query.route) - const grant = readPreviewGrant(grantValue, dependencies.encryptionKey) - const normalizedRoute = requestedRoute.success - ? normalizeStartPage(requestedRoute.data) - : null - if (!buildId || !grant || grant.buildId !== buildId) { - response.status(404).end() - return - } - if (request.query.route !== undefined && !normalizedRoute) { - response.status(404).end() - return - } - const target = await dependencies.findTargetById(buildId, grant.target) - if ( - !target || - (grant.screenshotPath && !(await dependencies.findArtifact(buildId, grant.screenshotPath))) - ) { - response.status(404).end() - return - } - const expiresAt = new Date(Date.now() + 15 * 60_000) - response.setHeader( - "Set-Cookie", - createPreviewCookie({ - value: createPreviewSession( - buildId, - grant.sessionDigest, - expiresAt, - dependencies.encryptionKey, - grant.target === "template", - ), - expiresAt, - secure: - new URL(dependencies.previewBaseOrigin).protocol === "https:" || - new URL(dependencies.previewBaseOrigin).hostname.endsWith(".localhost"), - }), - ) - response.setHeader("Cache-Control", "no-store") - response.setHeader("Referrer-Policy", "no-referrer") - const destination = grant.screenshotPath - ? `/__replica/${grant.screenshotPath}` - : grant.target === "preview" || grant.target === "template" - ? (normalizedRoute ?? normalizeStartPage(target.startPage) ?? "/") - : `/__replica/screenshots/${grant.target}.png` - response.redirect(303, destination) - } catch (error) { - next(error) - } - } -} diff --git a/hub/server/routes/build-preview/create-build-preview-route-dependencies/index.test.ts b/hub/server/routes/build-preview/create-build-preview-route-dependencies/index.test.ts index 9d2c0810d..efabf77b0 100644 --- a/hub/server/routes/build-preview/create-build-preview-route-dependencies/index.test.ts +++ b/hub/server/routes/build-preview/create-build-preview-route-dependencies/index.test.ts @@ -10,6 +10,19 @@ const storage = {} as ArtifactStorage const encryptionKey = randomBytes(32).toString("base64") describe("createBuildPreviewRouteDependencies()", () => { + it("enables canonical private serving with storage and no wildcard origin", () => { + const preview = createBuildPreviewRouteDependencies( + { + HUB_APPLICATION_ORIGIN: "https://hub.example.com", + HUB_AUTHENTICATION_ENCRYPTION_KEY: encryptionKey, + }, + storage, + ) + expect(preview.previewBaseOrigin).toBeUndefined() + expect(typeof preview.findPathTargets).toBe("function") + expect(preview.storage).toBe(storage) + }) + it("requires previews to use a separate registrable domain outside local development", () => { expect(() => createBuildPreviewRouteDependencies( diff --git a/hub/server/routes/build-preview/create-build-preview-route-dependencies/index.ts b/hub/server/routes/build-preview/create-build-preview-route-dependencies/index.ts index 165b7be7f..edb3e7ec8 100644 --- a/hub/server/routes/build-preview/create-build-preview-route-dependencies/index.ts +++ b/hub/server/routes/build-preview/create-build-preview-route-dependencies/index.ts @@ -6,12 +6,12 @@ import { hostedPreviewBridgeSource } from "../../../assets/hosted-preview-bridge import { hostedReviewBridgeSource } from "../../../assets/hosted-review-bridge.ts" import { prisma } from "../../../integrations/prisma/index.ts" import { findBuildArtifact } from "../../../repositories/build-artifacts/find-build-artifact/index.ts" -import { findBuildPreviewTarget } from "../../../repositories/build-artifacts/find-build-preview-target/index.ts" +import { findPathPreviewTargets } from "../../../repositories/build-artifacts/find-path-preview-targets/index.ts" import type { BuildPreviewRouteDependencies } from "../types.ts" const environmentSchema = z.object({ HUB_APPLICATION_ORIGIN: z.url(), - HUB_PREVIEW_ORIGIN: z.url(), + HUB_PREVIEW_ORIGIN: z.url().optional(), HUB_AUTHENTICATION_ENCRYPTION_KEY: z.string().min(1), }) @@ -21,10 +21,12 @@ export function createBuildPreviewRouteDependencies( ): BuildPreviewRouteDependencies { const parsed = environmentSchema.parse(environment) const applicationOrigin = new URL(parsed.HUB_APPLICATION_ORIGIN) - const previewBaseOrigin = new URL(parsed.HUB_PREVIEW_ORIGIN) + const previewBaseOrigin = parsed.HUB_PREVIEW_ORIGIN + ? new URL(parsed.HUB_PREVIEW_ORIGIN) + : undefined for (const [name, origin] of [ ["HUB_APPLICATION_ORIGIN", applicationOrigin], - ["HUB_PREVIEW_ORIGIN", previewBaseOrigin], + ...(previewBaseOrigin ? ([["HUB_PREVIEW_ORIGIN", previewBaseOrigin]] as const) : []), ] as const) { if ( origin.origin !== parsed[name] || @@ -36,15 +38,16 @@ export function createBuildPreviewRouteDependencies( throw new Error(`${name} must be an exact HTTP origin without a trailing slash.`) } } - if (previewBaseOrigin.hostname === applicationOrigin.hostname) { + if (previewBaseOrigin?.hostname === applicationOrigin.hostname) { throw new Error("HUB_PREVIEW_ORIGIN must use a separate wildcard hostname.") } const localPreview = - previewBaseOrigin.hostname.endsWith(".localhost") && + previewBaseOrigin?.hostname.endsWith(".localhost") && (applicationOrigin.hostname === "localhost" || applicationOrigin.hostname === "127.0.0.1" || applicationOrigin.hostname === "[::1]") if ( + previewBaseOrigin && !localPreview && (!getDomain(applicationOrigin.hostname) || getDomain(applicationOrigin.hostname) === getDomain(previewBaseOrigin.hostname)) @@ -54,6 +57,7 @@ export function createBuildPreviewRouteDependencies( ) } if ( + previewBaseOrigin && previewBaseOrigin.protocol !== "https:" && !previewBaseOrigin.hostname.endsWith(".localhost") ) { @@ -65,12 +69,13 @@ export function createBuildPreviewRouteDependencies( } return { applicationOrigin: applicationOrigin.origin, - previewBaseOrigin: previewBaseOrigin.origin, + previewBaseOrigin: previewBaseOrigin?.origin, encryptionKey, storage, bridgeSource: hostedPreviewBridgeSource, reviewBridgeSource: hostedReviewBridgeSource, - findTargetById: (buildId, target) => findBuildPreviewTarget(prisma, { buildId, target }), findArtifact: (buildId, path) => findBuildArtifact(prisma, buildId, path), + findPathTargets: (githubRepositoryId, githubWorkflowRunId) => + findPathPreviewTargets(prisma, { githubRepositoryId, githubWorkflowRunId }), } } diff --git a/hub/server/routes/build-preview/path/get/index.db.test.ts b/hub/server/routes/build-preview/path/get/index.db.test.ts new file mode 100644 index 000000000..6fefac57a --- /dev/null +++ b/hub/server/routes/build-preview/path/get/index.db.test.ts @@ -0,0 +1,226 @@ +import { createHash, generateKeyPairSync, randomBytes, randomUUID } from "node:crypto" +import { once } from "node:events" +import { createServer } from "node:http" +import type { AddressInfo } from "node:net" +import { describe, expect, it, onTestFinished, vi } from "vitest" + +import { createApp } from "../../../../create-app" +import type { ArtifactStorage } from "../../../../domains/artifacts/create-artifact-storage/types" +import { createLogger } from "../../../../integrations/pino/create-logger" +import { prisma } from "../../../../integrations/prisma" +import { createAuthenticationRouteDependencies } from "../../../api/auth/create-authentication-route-dependencies" +import { createProductRouteDependencies } from "../../../api/product/create-product-route-dependencies" +import { createBuildPreviewRouteDependencies } from "../../create-build-preview-route-dependencies" + +describe("private preview composition", () => { + it("serves real product URLs without a wildcard setting and checks live sessions and grants for every resource", async () => { + vi.stubEnv("HUB_PREVIEW_ORIGIN", undefined) + const server = createServer() + onTestFinished( + () => + new Promise((resolve, reject) => { + server.close((error) => (error ? reject(error) : resolve())) + }), + ) + server.listen(0, "127.0.0.1") + await once(server, "listening") + const { port } = server.address() as AddressInfo + const origin = `http://127.0.0.1:${port}` + const { privateKey } = generateKeyPairSync("rsa", { modulusLength: 2048 }) + const environment = { + GITHUB_CLIENT_ID: "test-client", + GITHUB_CLIENT_SECRET: "test-secret", + GITHUB_PROVIDER_REVISION: "1", + GITHUB_APP_ID: "123", + GITHUB_APP_INSTALLATION_ID: "456", + GITHUB_APP_PRIVATE_KEY_BASE64: Buffer.from( + privateKey.export({ format: "pem", type: "pkcs8" }).toString(), + ).toString("base64"), + GITHUB_WEBHOOK_SECRET: "test-webhook-secret-at-least-20-characters", + HUB_APPLICATION_ORIGIN: origin, + HUB_AUTHENTICATION_ENCRYPTION_KEY: randomBytes(32).toString("base64"), + HUB_BOOTSTRAP_SECRET: "test-bootstrap-secret-at-least-32-characters", + } + const authentication = await createAuthenticationRouteDependencies(environment) + const provider = await prisma.authenticationProvider.findUniqueOrThrow({ + where: { key: "github" }, + }) + const user = await prisma.user.create({ + data: { profile: { create: { provider: "github", login: "preview-reader" } } }, + }) + const identity = await prisma.externalIdentity.create({ + data: { + userId: user.id, + provider: "github", + issuer: "https://github.com", + subject: user.id, + }, + }) + const membership = await prisma.membership.create({ + data: { + userId: user.id, + assignments: { + create: { + externalIdentityId: identity.id, + providerRevisionId: provider.selectedRevisionId, + providerAssignmentSubject: identity.subject, + source: "AUTHENTICATION_PROVIDER", + role: "MEMBER", + }, + }, + }, + }) + const token = randomUUID() + const session = await prisma.hubSession.create({ + data: { + membershipId: membership.id, + externalIdentityId: identity.id, + providerRevisionId: provider.selectedRevisionId, + digest: createHash("sha256").update(token).digest("hex"), + revocationRevision: 0, + expiresAt: new Date("2099-01-01T00:00:00Z"), + }, + }) + const repository = await prisma.repository.create({ + data: { githubRepositoryId: 2001n, nameWithOwner: "team/previews", defaultBranch: "main" }, + }) + const retained = await prisma.repository.create({ + data: { githubRepositoryId: 2002n, nameWithOwner: "team/retained", defaultBranch: "main" }, + }) + await prisma.repositoryAccessGrant.createMany({ + data: [repository, retained].map(({ id }) => ({ + membershipId: membership.id, + repositoryId: id, + observedAt: new Date(), + })), + }) + const prototype = await prisma.prototype.create({ + data: { + repositoryId: repository.id, + branchName: "proto/checkout", + startPage: "/checkout?stage=shipping#address", + }, + }) + const png = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10) + const packageFiles = new Map([ + [ + "dist/index.html", + new TextEncoder().encode("Saved checkout"), + ], + ["dist/assets/app.css", new TextEncoder().encode("body { display: block }")], + ["screenshots/desktop.png", png], + ["screenshots/narrow.png", png], + ]) + const bytesByKey = new Map() + const build = await prisma.build.create({ + data: { + prototypeId: prototype.id, + number: 1, + state: "successful", + commitSha: "a".repeat(40), + githubWorkflowRunId: 3002n, + artifacts: { + create: Array.from(packageFiles, ([path, bytes]) => { + const storageKey = randomUUID() + bytesByKey.set(storageKey, bytes) + return { + path, + kind: path.startsWith("screenshots/") ? "screenshot" : "dist", + storageKey, + byteLength: bytes.byteLength, + } + }), + }, + }, + }) + await prisma.prototype.update({ + where: { id: prototype.id }, + data: { currentBuildId: build.id }, + }) + const read = vi.fn((key) => { + const bytes = bytesByKey.get(key) + return Promise.resolve(bytes ? { status: "ok", bytes } : { status: "not-found" }) + }) + const storage: ArtifactStorage = { + isReady: vi.fn().mockResolvedValue(true), + read, + write: vi.fn(), + delete: vi.fn(), + } + const preview = createBuildPreviewRouteDependencies(environment, storage) + const product = createProductRouteDependencies({ + applicationOrigin: origin, + scopeGitHubMembers: true, + }) + server.on( + "request", + createApp({ + authentication, + product, + preview, + logger: createLogger({ level: "silent" }), + }), + ) + const headers = { cookie: `hub_session=${token}`, accept: "text/html" } + const detail = await fetch( + `${origin}/api/repositories/${repository.id}/prototypes/${prototype.id}`, + { headers }, + ) + expect(detail.status).toBe(200) + const dto = (await detail.json()) as { + selectedBuild: { + previewUrl: string + desktopScreenshotUrl: string + narrowScreenshotUrl: string + } + } + const mount = `${origin}/previews/github/2001/3002/` + expect(dto.selectedBuild).toMatchObject({ + previewUrl: `${mount}checkout?stage=shipping#address`, + desktopScreenshotUrl: `${mount}__replica/screenshots/desktop.png`, + narrowScreenshotUrl: `${mount}__replica/screenshots/narrow.png`, + }) + const document = await fetch(dto.selectedBuild.previewUrl, { headers }) + expect(document.status).toBe(200) + expect(await document.text()).toContain("Saved checkout") + for (const url of [ + dto.selectedBuild.desktopScreenshotUrl, + dto.selectedBuild.narrowScreenshotUrl, + ]) { + const screenshot = await fetch(url, { headers }) + expect(screenshot.status).toBe(200) + expect(screenshot.headers.get("content-type")).toBe("image/png") + expect(new Uint8Array(await screenshot.arrayBuffer())).toEqual(png) + } + const resources = [ + dto.selectedBuild.previewUrl, + dto.selectedBuild.desktopScreenshotUrl, + dto.selectedBuild.narrowScreenshotUrl, + `${mount}assets/app.css`, + `${mount}__replica/bridge/v1.js`, + ] + for (const url of resources.slice(3)) { + expect((await fetch(url, { headers })).status).toBe(200) + } + + read.mockClear() + await prisma.repositoryAccessGrant.deleteMany({ + where: { repositoryId: repository.id, membershipId: membership.id }, + }) + for (const url of resources) { + expect((await fetch(url, { headers })).status, url).toBe(404) + } + await prisma.repositoryAccessGrant.create({ + data: { + repositoryId: repository.id, + membershipId: membership.id, + observedAt: new Date(), + }, + }) + expect(await authentication.signOut.end(session.digest)).toBe(true) + for (const url of resources) { + expect((await fetch(url, { headers })).status, url).toBe(401) + } + expect(read).not.toHaveBeenCalled() + }) +}) diff --git a/hub/server/routes/build-preview/path/get/index.test.ts b/hub/server/routes/build-preview/path/get/index.test.ts new file mode 100644 index 000000000..7463a0b2a --- /dev/null +++ b/hub/server/routes/build-preview/path/get/index.test.ts @@ -0,0 +1,358 @@ +import { randomBytes, randomUUID } from "node:crypto" +import { once } from "node:events" +import { mkdir, rm, writeFile } from "node:fs/promises" +import { createServer, request as httpRequest, type IncomingHttpHeaders } from "node:http" +import type { AddressInfo } from "node:net" +import { join, resolve } from "node:path" +import { describe, expect, it, onTestFinished, vi } from "vitest" + +import { createApp } from "../../../../create-app" +import type { ArtifactStorage } from "../../../../domains/artifacts/create-artifact-storage/types" +import { createSharePreviewSession } from "../../../../domains/public-sharing/create-share-preview-session" +import { createLogger } from "../../../../integrations/pino/create-logger" +import type { AuthenticationRouteDependencies } from "../../../api/auth/types" +import type { ProductRouteDependencies } from "../../../api/product/types" +import type { BuildPreviewRouteDependencies } from "../../types" + +interface RouteResponse { + status: number + headers: IncomingHttpHeaders + body: Buffer +} + +async function request( + origin: string, + path: string, + headers: Record = { cookie: "hub_session=member-session" }, +): Promise { + return new Promise((resolve, reject) => { + const url = new URL(origin) + const outgoing = httpRequest( + { hostname: url.hostname, port: url.port, path, headers }, + (response) => { + const chunks: Buffer[] = [] + response.on("data", (chunk: Buffer) => chunks.push(chunk)) + response.on("end", () => + resolve({ + status: response.statusCode ?? 0, + headers: response.headers, + body: Buffer.concat(chunks), + }), + ) + }, + ) + outgoing.on("error", reject) + outgoing.end() + }) +} + +async function createFixture() { + const directory = resolve(`server/routes/build-preview/path/get/.preview-test-${randomUUID()}`) + const clientDirectory = join(directory, "client") + await mkdir(clientDirectory, { recursive: true }) + onTestFinished(() => rm(directory, { recursive: true, force: true })) + await writeFile(join(clientDirectory, "index.html"), "Hub shell marker") + const artifacts = new Map() + const savedBytes = new Map() + const storage: ArtifactStorage = { + isReady: vi.fn(), + read(key) { + const bytes = savedBytes.get(key) + return Promise.resolve(bytes ? { status: "ok", bytes } : { status: "not-found" }) + }, + write: vi.fn(), + delete: vi.fn(), + } + function save(path: string, content: string | Uint8Array) { + const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content + const storageKey = randomUUID() + savedBytes.set(storageKey, bytes) + artifacts.set(path, { storageKey, byteLength: bytes.byteLength }) + } + const buildId = randomUUID() + const repositoryId = randomUUID() + const mountPath = "/previews/github/2001/3002" + const viewer = { + membershipId: randomUUID(), + userId: randomUUID(), + provider: "github", + sessionProvider: "github", + login: "mona", + name: "Mona", + role: "MEMBER" as const, + } + const restore = vi + .fn() + .mockResolvedValue(viewer) + const isRepositoryVisible = vi + .fn() + .mockResolvedValue(true) + const product: ProductRouteDependencies = { + isRepositoryVisible, + listRepositories: vi.fn(), + findRepositoryIndex: vi.fn(), + findRepositoryAuthors: vi.fn(), + findPrototypeDetail: vi.fn(), + readPrototypeWithIntroduction: vi.fn(), + editPrototypeMetadata: vi.fn(), + findBuildPreviewTarget: vi.fn(), + } + const target = { buildId, repository: { id: repositoryId, local: false }, template: false } + const findPathTargets = vi + .fn>() + .mockResolvedValue([target]) + const findArtifact = vi + .fn() + .mockImplementation((id, path) => + Promise.resolve(id === buildId ? (artifacts.get(path) ?? null) : null), + ) + const readAvailableShareLink = vi.fn().mockResolvedValue({ + expiresAt: new Date(Date.now() + 60_000), + startPage: "/", + }) + const preview: BuildPreviewRouteDependencies = { + applicationOrigin: "https://hub.example.com", + encryptionKey: randomBytes(32), + storage, + bridgeSource: "globalThis.ReplicaHostedPreviewBridge={installHostedBridge(){}}", + findPathTargets, + findArtifact, + readAvailableShareLink, + } + const server = createServer() + onTestFinished( + () => + new Promise((resolve, reject) => { + server.close((error) => (error ? reject(error) : resolve())) + }), + ) + server.listen(0, "127.0.0.1") + await once(server, "listening") + const { port } = server.address() as AddressInfo + const origin = `http://127.0.0.1:${port}` + preview.applicationOrigin = origin + server.on( + "request", + createApp({ + clientDirectory, + logger: createLogger({ level: "silent" }), + authentication: { + currentSession: { restore }, + signOut: { applicationOrigin: preview.applicationOrigin, secureCookie: true, end: vi.fn() }, + }, + preview, + product, + }), + ) + return { + origin, + mountPath, + preview, + viewer, + target, + restore, + isRepositoryVisible, + findPathTargets, + findArtifact, + readAvailableShareLink, + storage, + save, + } +} + +describe("get()", () => { + it("serves mounted files, nested indexes and HTML routes without falling back for missing assets", async () => { + const fixture = await createFixture() + const { origin, mountPath, save, findPathTargets, isRepositoryVisible, viewer, target } = + fixture + save("dist/index.html", "Private prototype") + save("dist/docs/index.html", "Nested page") + save("dist/assets/app.css", "body { display: block }") + + for (const [path, contentType, content] of [ + ["/", "text/html", "Private prototype"], + ["/docs/", "text/html", "Nested page"], + ["/checkout/cart?step=shipping", "text/html", "Private prototype"], + ["/assets/app.css", "text/css", "body { display: block }"], + ] as const) { + const response = await request(origin, `${mountPath}${path}`, { + cookie: "hub_session=member-session", + accept: "text/html", + }) + + expect(response.status, path).toBe(200) + expect(response.headers["content-type"]).toContain(contentType) + expect(response.body.toString()).toContain(content) + expect(response.headers["cache-control"]).toMatch(/\b(?:no-cache|no-store)\b/) + expect(response.headers["cache-control"]).not.toContain("immutable") + expect(response.headers["content-security-policy"]).toContain("frame-ancestors 'self'") + if (contentType === "text/html") { + expect(response.body.toString()).toContain( + ``, + ) + } + } + expect(findPathTargets).toHaveBeenCalledWith("2001", "3002") + expect(isRepositoryVisible).toHaveBeenCalledWith( + expect.objectContaining({ membershipId: viewer.membershipId }), + target.repository.id, + ) + + for (const [path, accept] of [ + ["/assets/missing.js", "text/html"], + ["/missing-route", "application/json"], + ] as const) { + const missing = await request(origin, `${mountPath}${path}`, { + cookie: "hub_session=member-session", + accept, + }) + expect(missing.status, path).toBe(404) + expect(missing.body.toString()).not.toContain("Hub shell marker") + expect(missing.body.toString()).not.toContain("Private prototype") + } + }) + + it("adds the canonical trailing slash without losing the query", async () => { + const { origin, mountPath } = await createFixture() + + const response = await request(origin, `${mountPath}?step=shipping&return=%2Fcart`) + + expect(response.status).toBe(308) + expect(response.headers.location).toBe(`${mountPath}/?step=shipping&return=%2Fcart`) + }) + + it("rejects malformed identifiers and unsafe raw paths before reading storage or the Hub shell", async () => { + const { origin, mountPath, storage, findArtifact } = await createFixture() + const read = vi.spyOn(storage, "read") + + for (const path of [ + "/previews/github/0/3002/", + "/previews/github/02001/3002/", + "/previews/github/%32%30%30%31/3002/", + "/previews/github/2001/0/", + "/previews/github/2001/03002/", + "/previews/github/2001/3e3/", + "/previews/github/2001/%33%30%30%32/", + `${mountPath}/../private`, + `${mountPath}/%2e%2e/private`, + `${mountPath}/%252e%252e/private`, + `${mountPath}/assets%2fprivate`, + `${mountPath}/assets%5cprivate`, + `${mountPath}/assets\\private`, + `${mountPath}/bad%00path`, + `${mountPath}/bad%1fpath`, + `${mountPath}/bad%`, + ]) { + const response = await request(origin, path, { + cookie: "hub_session=member-session", + accept: "text/html", + }) + + expect(response.status, path).toBe(404) + expect(response.body.toString(), path).not.toContain("Hub shell marker") + } + expect(findArtifact).not.toHaveBeenCalled() + expect(read).not.toHaveBeenCalled() + }) + + it("does not accept public-share or wildcard-preview cookies as a Hub session", async () => { + const { origin, mountPath, preview, target, save, storage, readAvailableShareLink } = + await createFixture() + save("dist/index.html", "Private prototype") + const read = vi.spyOn(storage, "read") + const share = createSharePreviewSession( + { + buildId: target.buildId, + shareLinkId: randomUUID(), + expiresAt: new Date(Date.now() + 60_000), + }, + preview.encryptionKey, + ) + for (const cookie of [ + "", + `replica_share_preview=${encodeURIComponent(share)}`, + "replica_preview=obsolete-private-cookie", + ]) { + const response = await request(origin, `${mountPath}/`, { cookie, accept: "text/html" }) + + expect(response.status).toBe(401) + expect(response.body.toString()).not.toContain("Hub shell marker") + expect(response.body.toString()).not.toContain("Private prototype") + } + expect(read).not.toHaveBeenCalled() + expect(readAvailableShareLink).not.toHaveBeenCalled() + }) + + it.each(["session expiry", "repository revocation"])( + "rechecks %s on a subsequent asset request", + async (change) => { + const { origin, mountPath, save, restore, isRepositoryVisible } = await createFixture() + save("dist/assets/app.css", "private-asset") + const first = await request(origin, `${mountPath}/assets/app.css`) + expect(first.status).toBe(200) + expect(first.body.toString()).toBe("private-asset") + expect(first.headers["cache-control"]).toMatch(/\b(?:no-cache|no-store)\b/) + + if (change === "session expiry") restore.mockResolvedValue(null) + else isRepositoryVisible.mockResolvedValue(false) + const denied = await request(origin, `${mountPath}/assets/app.css`) + + expect(denied.status).toBe(change === "session expiry" ? 401 : 404) + expect(denied.body.toString()).not.toContain("private-asset") + }, + ) + + it.each(["session expiry", "repository revocation"])( + "discards artifact bytes when %s occurs during storage read", + async (change) => { + const { origin, mountPath, save, storage, restore, isRepositoryVisible } = + await createFixture() + save("dist/assets/app.css", "private-artifact-bytes") + const read = storage.read.bind(storage) + const reading = vi.spyOn(storage, "read").mockImplementation(async (key) => { + const result = await read(key) + if (change === "session expiry") restore.mockResolvedValue(null) + else isRepositoryVisible.mockResolvedValue(false) + return result + }) + + const response = await request(origin, `${mountPath}/assets/app.css`) + + expect(reading).toHaveBeenCalledOnce() + expect(response.status).toBe(404) + expect(response.body.toString()).not.toContain("private-artifact-bytes") + }, + ) + + it("fails closed for missing or ambiguous owning-run targets instead of serving Hub navigation", async () => { + const { origin, mountPath, findPathTargets, target, storage } = await createFixture() + const read = vi.spyOn(storage, "read") + + for (const targets of [[], [target, { ...target, buildId: randomUUID() }]]) { + findPathTargets.mockResolvedValue(targets) + + const response = await request(origin, `${mountPath}/checkout`, { + cookie: "hub_session=member-session", + accept: "text/html", + }) + + expect(response.status).toBe(404) + expect(response.body.toString()).not.toContain("Hub shell marker") + } + expect(read).not.toHaveBeenCalled() + }) + + it("refuses Service Worker script requests even when their artifact exists", async () => { + const { origin, mountPath, save, storage } = await createFixture() + save("dist/service-worker.js", "self.addEventListener('fetch', () => {})") + const read = vi.spyOn(storage, "read") + + const response = await request(origin, `${mountPath}/service-worker.js`, { + cookie: "hub_session=member-session", + "service-worker": "script", + }) + + expect(response.status).toBe(404) + expect(read).not.toHaveBeenCalled() + }) +}) diff --git a/hub/server/routes/build-preview/path/get/index.ts b/hub/server/routes/build-preview/path/get/index.ts new file mode 100644 index 000000000..0bdad7d27 --- /dev/null +++ b/hub/server/routes/build-preview/path/get/index.ts @@ -0,0 +1,144 @@ +import type { RequestHandler } from "express" + +import { readBuildPreviewFile } from "../../../../domains/build-preview/read-build-preview-file/index.ts" +import { readTemplateScreenshotPath } from "../../../../domains/build-preview/template-screenshot-path/index.ts" +import { hubSessionCookieName } from "../../../../integrations/express/hub-session-cookie-name/index.ts" +import { readCookie } from "../../../../integrations/express/read-cookie/index.ts" +import type { CurrentSessionDependencies } from "../../../api/auth/types.ts" +import { readProductSession } from "../../../api/product/read-product-session/index.ts" +import { canBrowseTemplates } from "../../../api/product/template-repository-access/index.ts" +import type { ProductRouteDependencies } from "../../../api/product/types.ts" +import type { BuildPreviewRouteDependencies } from "../../types.ts" + +export function get( + preview: BuildPreviewRouteDependencies, + session: CurrentSessionDependencies, + product: ProductRouteDependencies, +): RequestHandler { + return async (request, response, next) => { + response.setHeader("Cache-Control", "private, no-store") + response.setHeader("X-Content-Type-Options", "nosniff") + response.setHeader("Referrer-Policy", "no-referrer") + try { + const rawPath = request.originalUrl.split("?")[0] ?? "" + const match = /^\/previews\/github\/([1-9]\d{0,18})\/([1-9]\d{0,18})(\/.*)?$/.exec(rawPath) + const path = match?.[3] ?? "/" + let decoded: string + try { + decoded = decodeURIComponent(path) + } catch { + response.status(404).end() + return + } + if ( + !match || + BigInt(match[1]!) > 9223372036854775807n || + BigInt(match[2]!) > 9223372036854775807n || + /%2f|%5c/i.test(path) || + /[\\%\p{Cc}\p{Cs}]/u.test(decoded) || + decoded.split("/").some((part) => part === "." || part === "..") || + request.get("service-worker")?.toLowerCase() === "script" || + request.get("host") !== new URL(preview.applicationOrigin).host + ) { + response.status(404).end() + return + } + const cookie = readCookie(request, hubSessionCookieName) + const viewer = await readProductSession(cookie, session) + if (!viewer) { + response.status(401).end() + return + } + const { userId, membershipId } = viewer + const targets = await preview.findPathTargets?.(match[1]!, match[2]!) + if (!targets || targets.length !== 1) { + if (targets && targets.length > 1) + request.log.warn("More than one Build owns the requested private preview path.") + response.status(404).end() + return + } + const target = targets[0]! + async function authorized() { + const current = await readProductSession(cookie, session) + if ( + !current || + current.userId !== userId || + current.membershipId !== membershipId || + (target.template && !canBrowseTemplates(current, target.repository.local)) || + !(await product.isRepositoryVisible(current, target.repository.id)) + ) + return false + const live = await preview.findPathTargets?.(match![1]!, match![2]!) + return live?.length === 1 && live[0]?.buildId === target.buildId + } + if (!(await authorized())) { + response.status(404).end() + return + } + const mountPath = `/previews/github/${match[1]}/${match[2]}/` + if (!match[3]) { + response.redirect(308, `${mountPath}${request.originalUrl.slice(rawPath.length)}`) + return + } + response.setHeader( + "Content-Security-Policy", + "default-src 'self' data: blob:; script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'self'; base-uri 'self'; form-action 'self'", + ) + response.setHeader("Cross-Origin-Resource-Policy", "same-origin") + response.setHeader("Permissions-Policy", "camera=(), microphone=(), geolocation=()") + if (path === "/__replica/bridge/v1.js") { + const review = (preview.reviewBridgeSource ?? "") + .replaceAll('"__REPLICA_HUB_ORIGIN__"', JSON.stringify(preview.applicationOrigin)) + .replaceAll('"__REPLICA_REVIEW_ENABLED__"', JSON.stringify(String(!target.template))) + response + .type("text/javascript") + .send( + `${review}\n${preview.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge(${JSON.stringify(preview.applicationOrigin)});`, + ) + return + } + const screenshot = + readTemplateScreenshotPath(path) ?? + (path === "/__replica/screenshots/narrow.png" ? "screenshots/narrow.png" : null) + if ( + (path.startsWith("/__replica/") && !screenshot) || + (screenshot && + screenshot !== "screenshots/desktop.png" && + screenshot !== "screenshots/narrow.png" && + !target.template) + ) { + response.status(404).end() + return + } + const file = await readBuildPreviewFile( + { + acceptsHtml: Boolean( + request.accepts("html") && + request + .get("accept") + ?.split(",") + .some((type) => type.split(";")[0]?.trim() === "text/html"), + ), + buildId: target.buildId, + requestPath: path, + mountPath, + }, + preview, + ) + if (!(await authorized())) { + response.status(404).end() + return + } + if (file.status !== "ok") { + response.status(file.status === "not-found" ? 404 : 503).end() + return + } + response.setHeader("Cache-Control", screenshot ? "private, no-store" : "private, no-cache") + response.setHeader("Content-Type", file.contentType) + response.setHeader("Content-Length", file.bytes.byteLength) + response.end(file.bytes) + } catch (error) { + next(error) + } + } +} diff --git a/hub/server/routes/build-preview/serve/get/index.test.ts b/hub/server/routes/build-preview/serve/get/index.test.ts index d21d59b72..12f0c416a 100644 --- a/hub/server/routes/build-preview/serve/get/index.test.ts +++ b/hub/server/routes/build-preview/serve/get/index.test.ts @@ -2,12 +2,7 @@ import { createHash, randomBytes, randomUUID } from "node:crypto" import { once } from "node:events" import { createReadStream } from "node:fs" import { mkdir, mkdtemp, open, readFile, rm, writeFile } from "node:fs/promises" -import { - createServer, - request as httpRequest, - type IncomingHttpHeaders, - type ServerResponse, -} from "node:http" +import { createServer, request as httpRequest, type IncomingHttpHeaders } from "node:http" import type { AddressInfo } from "node:net" import path from "node:path" import { Readable } from "node:stream" @@ -15,7 +10,6 @@ import express, { type ErrorRequestHandler } from "express" import { describe, expect, it, onTestFinished, vi, type Mock } from "vitest" import { extractDistPackage } from "../../../../domains/build-artifacts/extract-dist-package" -import { createPreviewSession } from "../../../../domains/build-preview/create-preview-session" import { createSharePreviewSession } from "../../../../domains/public-sharing/create-share-preview-session" import { createZipArchive } from "../../../../test/create-zip-archive" import type { BuildPreviewRouteDependencies } from "../../types" @@ -27,14 +21,6 @@ interface RouteResponse { body: Buffer } -function deferred() { - let resolve!: (value: T) => void - const promise = new Promise((settle) => { - resolve = settle - }) - return { promise, resolve } -} - async function request( origin: string, path: string, @@ -77,18 +63,15 @@ async function withServeRoute( operation: (input: { origin: string buildId: string - cookie: string + key: Buffer dependencies: BuildPreviewRouteDependencies findArtifact: Mock read: Mock readAvailableShareLink: Mock< NonNullable > - restoreSession: Mock> shareCookie: string - templateCookie: string }) => Promise, - observeResponse?: (response: ServerResponse, requestPath: string) => void, ) { const key = randomBytes(32) const buildId = randomUUID() @@ -106,9 +89,6 @@ async function withServeRoute( expiresAt: new Date(Date.now() + 60 * 60_000), startPage: "/", }) - const restoreSession = vi - .fn>() - .mockResolvedValue({ userId: randomUUID() }) const dependencies: BuildPreviewRouteDependencies = { applicationOrigin: "https://hub.example.com", previewBaseOrigin: `http://preview.localhost:${port}`, @@ -122,24 +102,10 @@ async function withServeRoute( bridgeSource: "globalThis.ReplicaHostedPreviewBridge={installHostedBridge(origin){}}", reviewBridgeSource: 'globalThis.reviewBridge={origin:"__REPLICA_HUB_ORIGIN__",enabled:"__REPLICA_REVIEW_ENABLED__" !== "false"};', - findTargetById: vi.fn().mockResolvedValue({ - buildId, - startPage: "/", - artifactPath: "dist/index.html", - templateRepository: { id: randomUUID(), local: true }, - }), findArtifact, readAvailableShareLink, - restoreSession, } - app.use((request, response, next) => { - observeResponse?.(response, request.path) - next() - }) - app.get( - "/{*path}", - get(dependencies, () => Promise.resolve(true)), - ) + app.get("/{*path}", get(dependencies)) function handleError( error: unknown, _request: Parameters[1], @@ -153,12 +119,6 @@ async function withServeRoute( response.status(500).end() } app.use(handleError) - const session = createPreviewSession( - buildId, - "a".repeat(64), - new Date(Date.now() + 15 * 60_000), - key, - ) const shareSession = createSharePreviewSession( { buildId, @@ -167,25 +127,16 @@ async function withServeRoute( }, key, ) - const templateSession = createPreviewSession( - buildId, - "b".repeat(64), - new Date(Date.now() + 15 * 60_000), - key, - true, - ) try { await operation({ origin: `http://127.0.0.1:${port}`, buildId, - cookie: `replica_preview=${encodeURIComponent(session)}`, + key, dependencies, findArtifact, read, readAvailableShareLink, - restoreSession, shareCookie: `replica_share_preview=${encodeURIComponent(shareSession)}`, - templateCookie: `replica_preview=${encodeURIComponent(templateSession)}`, }) } finally { await new Promise((resolve, reject) => { @@ -202,12 +153,12 @@ function requestHeaders(buildId: string, origin: string, cookie: string) { } describe("get()", () => { - it("keeps a preview session isolated to its Build origin", async () => { - await withServeRoute(async ({ origin, cookie, findArtifact }) => { + it("keeps a public share session isolated to its Build origin", async () => { + await withServeRoute(async ({ origin, shareCookie, findArtifact }) => { const response = await request( origin, "/index.html", - requestHeaders(randomUUID(), origin, cookie), + requestHeaders(randomUUID(), origin, shareCookie), ) expect(response.status).toBe(404) @@ -216,11 +167,11 @@ describe("get()", () => { }) it("rejects traversal before looking up an artifact", async () => { - await withServeRoute(async ({ origin, buildId, cookie, findArtifact, read }) => { + await withServeRoute(async ({ origin, buildId, shareCookie, findArtifact, read }) => { const response = await request( origin, "/../private.txt", - requestHeaders(buildId, origin, cookie), + requestHeaders(buildId, origin, shareCookie), ) expect(response.status).toBe(404) @@ -230,7 +181,7 @@ describe("get()", () => { }) it("falls back to the SPA start document and injects the hosted bridge", async () => { - await withServeRoute(async ({ origin, buildId, cookie, findArtifact, read }) => { + await withServeRoute(async ({ origin, buildId, shareCookie, findArtifact, read }) => { const source = new TextEncoder().encode( "Checkout", ) @@ -244,7 +195,7 @@ describe("get()", () => { }) const response = await request(origin, "/checkout/cart", { - ...requestHeaders(buildId, origin, cookie), + ...requestHeaders(buildId, origin, shareCookie), accept: "text/html", }) @@ -255,7 +206,7 @@ describe("get()", () => { '', ) expect(response.headers["content-type"]).toBe("text/html; charset=utf-8") - expect(response.headers["cache-control"]).toBe("private, no-cache") + expect(response.headers["cache-control"]).toBe("private, no-store") expect(response.headers["content-length"]).toBe(String(response.body.byteLength)) expect(response.headers["content-security-policy"]).toContain( "frame-ancestors https://hub.example.com", @@ -269,8 +220,8 @@ describe("get()", () => { }) }) - it("serves immutable assets and both named screenshots with path-derived content types", async () => { - await withServeRoute(async ({ origin, buildId, cookie, findArtifact, read }) => { + it("serves public assets and local screenshots without reusable caching", async () => { + await withServeRoute(async ({ origin, buildId, shareCookie, findArtifact, read }) => { findArtifact.mockImplementation((_buildId, path) => Promise.resolve({ storageKey: path, @@ -281,7 +232,7 @@ describe("get()", () => { status: "ok", bytes: Uint8Array.of(7, 8), }) - const headers = requestHeaders(buildId, origin, cookie) + const headers = requestHeaders(buildId, origin, shareCookie) const asset = await request(origin, "/assets/app.css", headers) const desktop = await request(origin, "/__replica/screenshots/desktop.png", headers) @@ -295,12 +246,12 @@ describe("get()", () => { expect(narrow.headers["content-type"]).toBe("image/png") for (const response of [asset, desktop, narrow]) { expect(response.status).toBe(200) - expect(response.headers["cache-control"]).toBe("private, max-age=31536000, immutable") + expect(response.headers["cache-control"]).toBe("private, no-store") expect(response.body).toEqual(Buffer.from([7, 8])) } expect(asset.headers["cross-origin-resource-policy"]).toBe("same-origin") - expect(desktop.headers["cross-origin-resource-policy"]).toBe("cross-origin") - expect(narrow.headers["cross-origin-resource-policy"]).toBe("cross-origin") + expect(desktop.headers["cross-origin-resource-policy"]).toBe("same-origin") + expect(narrow.headers["cross-origin-resource-policy"]).toBe("same-origin") }) }) @@ -396,7 +347,7 @@ describe("get()", () => { status: "already-exists", }) - await withServeRoute(async ({ origin, buildId, cookie, dependencies, findArtifact }) => { + await withServeRoute(async ({ origin, buildId, shareCookie, dependencies, findArtifact }) => { dependencies.storage = storage findArtifact.mockImplementation((_buildId, artifactPath) => Promise.resolve( @@ -411,7 +362,7 @@ describe("get()", () => { const response = await request( origin, "/assets/data.bin", - requestHeaders(buildId, origin, cookie), + requestHeaders(buildId, origin, shareCookie), (chunk) => { receivedBytes += chunk.byteLength digest.update(chunk) @@ -421,245 +372,34 @@ describe("get()", () => { expect(response.status).toBe(200) expect(response.headers["content-length"]).toBe(String(maximumBytes)) expect(response.headers["content-type"]).toBe("application/octet-stream") - expect(response.headers["cache-control"]).toBe("private, max-age=31536000, immutable") + expect(response.headers["cache-control"]).toBe("private, no-store") expect(receivedBytes).toBe(maximumBytes) expect(digest.digest("hex")).toBe(expectedDigest) }) }, 15_000) - it("shares the source-byte limit across private, public, and template requests on different Build servers", async () => { - await withServeRoute(async (privateRoute) => { - await withServeRoute(async (publicRoute) => { - const readStarted = deferred() - const stored = - deferred>>() - privateRoute.findArtifact.mockResolvedValue({ - storageKey: "private-asset", - byteLength: 100 * 1024 * 1024, - }) - privateRoute.read.mockImplementation(() => { - readStarted.resolve() - return stored.promise - }) - publicRoute.findArtifact.mockImplementation((_buildId, artifactPath) => - Promise.resolve( - artifactPath === "dist/asset.bin" || artifactPath === "templates.json" - ? { storageKey: "public-asset", byteLength: 1 } - : null, - ), - ) - publicRoute.read.mockResolvedValue({ status: "ok", bytes: Uint8Array.of(7) }) - const first = request( - privateRoute.origin, - "/asset.bin", - requestHeaders(privateRoute.buildId, privateRoute.origin, privateRoute.cookie), + it("disables review behavior in the public preview bridge", async () => { + await withServeRoute( + async ({ origin, buildId, shareCookie, dependencies, findArtifact, read }) => { + const response = await request( + origin, + "/__replica/bridge/v1.js", + requestHeaders(buildId, origin, shareCookie), ) - try { - await readStarted.promise - const blocked = await request( - publicRoute.origin, - "/asset.bin", - requestHeaders(publicRoute.buildId, publicRoute.origin, publicRoute.shareCookie), - ) - const blockedTemplate = await request(publicRoute.origin, "/release/v2.0", { - ...requestHeaders(publicRoute.buildId, publicRoute.origin, publicRoute.templateCookie), - accept: "text/html", - }) - - expect(blocked.status).toBe(503) - expect(blockedTemplate.status).toBe(503) - expect(publicRoute.read).not.toHaveBeenCalled() - } finally { - stored.resolve({ status: "ok", bytes: Uint8Array.of(1) }) - expect((await first).status).toBe(200) - } - - const recovered = await request( - publicRoute.origin, - "/asset.bin", - requestHeaders(publicRoute.buildId, publicRoute.origin, publicRoute.shareCookie), + expect(response.status).toBe(200) + expect(response.headers["content-type"]).toMatch(/^text\/javascript/) + expect(response.headers["cache-control"]).toBe("private, no-store") + expect(response.body.toString()).toBe( + `globalThis.reviewBridge={origin:"https://hub.example.com",enabled:"false" !== "false"};\n${dependencies.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge("https://hub.example.com");`, ) - expect(recovered.status).toBe(200) - expect(publicRoute.read).toHaveBeenCalledOnce() - }) - }) - }) - - it.each(["finish", "close"] as const)( - "holds source bytes after reading until the response emits %s", - async (completion) => { - const responsePending = deferred<{ - response: ServerResponse - finish: () => void - }>() - await withServeRoute( - async ({ origin, buildId, cookie, findArtifact, read }) => { - findArtifact.mockResolvedValue({ - storageKey: "asset-key", - byteLength: 100 * 1024 * 1024, - }) - read.mockResolvedValue({ status: "ok", bytes: Uint8Array.of(7) }) - const headers = requestHeaders(buildId, origin, cookie) - const first = request(origin, "/slow.bin", headers).catch((error: unknown) => error) - const pending = await responsePending.promise - - try { - const blocked = await request(origin, "/asset.bin", headers) - - expect(blocked.status).toBe(503) - expect(read).toHaveBeenCalledOnce() - } finally { - const completed = once(pending.response, completion) - if (completion === "finish") pending.finish() - else pending.response.destroy() - await completed - await first - } - - expect((await request(origin, "/asset.bin", headers)).status).toBe(200) - expect(read).toHaveBeenCalledTimes(2) - }, - (response, requestPath) => { - if (requestPath !== "/slow.bin") return - const end = response.end.bind(response) - vi.spyOn(response, "end").mockImplementation(() => { - responsePending.resolve({ response, finish: () => end(Uint8Array.of(7)) }) - return response - }) - }, - ) - }, - ) - - it.each(["storage read", "authorization recheck"] as const)( - "keeps a disconnected request reserved until its pending %s settles", - async (pendingOperation) => { - const pendingStarted = deferred() - const proceed = deferred() - const disconnected = deferred() - await withServeRoute( - async ({ origin, buildId, cookie, findArtifact, read, restoreSession }) => { - findArtifact.mockResolvedValue({ - storageKey: "asset-key", - byteLength: 100 * 1024 * 1024, - }) - read.mockResolvedValue({ status: "ok", bytes: Uint8Array.of(7) }) - if (pendingOperation === "storage read") { - read.mockImplementationOnce(async () => { - pendingStarted.resolve() - await proceed.promise - return { status: "ok", bytes: Uint8Array.of(7) } - }) - } - if (pendingOperation === "authorization recheck") { - restoreSession - .mockResolvedValueOnce({ userId: randomUUID() }) - .mockImplementationOnce(async () => { - pendingStarted.resolve() - await proceed.promise - return { userId: randomUUID() } - }) - } - const headers = requestHeaders(buildId, origin, cookie) - const abort = new AbortController() - const first = request(origin, "/pending.bin", headers, undefined, abort.signal).catch( - (error: unknown) => error, - ) - - try { - await pendingStarted.promise - abort.abort() - await disconnected.promise - const blocked = await request(origin, "/asset.bin", headers) - - expect(blocked.status).toBe(503) - expect(read).toHaveBeenCalledOnce() - } finally { - proceed.resolve() - abort.abort() - await first - } - - expect((await request(origin, "/asset.bin", headers)).status).toBe(200) - expect(read).toHaveBeenCalledTimes(2) - }, - (response, requestPath) => { - if (requestPath === "/pending.bin") { - response.once("close", () => disconnected.resolve()) - } - }, - ) - }, - ) - - it("releases the template manifest reservation before reading the SPA entry point", async () => { - await withServeRoute(async ({ origin, buildId, cookie, findArtifact, read }) => { - const manifest = new TextEncoder().encode( - JSON.stringify({ templates: [{ path: "/release/v2.0" }] }), - ) - const html = new TextEncoder().encode("Release notes") - findArtifact.mockImplementation((_buildId, artifactPath) => - Promise.resolve( - artifactPath === "templates.json" - ? { storageKey: "manifest-key", byteLength: 100 * 1024 * 1024 } - : artifactPath === "dist/index.html" - ? { storageKey: "index-key", byteLength: html.byteLength } - : null, - ), - ) - read.mockImplementation((key) => - Promise.resolve({ status: "ok", bytes: key === "manifest-key" ? manifest : html }), - ) - - const response = await request(origin, "/release/v2.0", { - ...requestHeaders(buildId, origin, cookie), - accept: "text/html", - }) - - expect(response.status).toBe(200) - expect(response.body.toString()).toContain("Release notes") - expect(read).toHaveBeenNthCalledWith(1, "manifest-key") - expect(read).toHaveBeenNthCalledWith(2, "index-key") - }) - }) - - it("serves the generated hosted bridge only to an authorized preview session", async () => { - await withServeRoute(async ({ origin, buildId, cookie, dependencies, findArtifact, read }) => { - const response = await request( - origin, - "/__replica/bridge/v1.js", - requestHeaders(buildId, origin, cookie), - ) - - expect(response.status).toBe(200) - expect(response.headers["content-type"]).toMatch(/^text\/javascript/) - expect(response.headers["cache-control"]).toBe("private, max-age=300") - expect(response.body.toString()).toBe( - `globalThis.reviewBridge={origin:"https://hub.example.com",enabled:"true" !== "false"};\n${dependencies.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge("https://hub.example.com");`, - ) - expect(findArtifact).not.toHaveBeenCalled() - expect(read).not.toHaveBeenCalled() - }) - }) - - it("disables review behavior in the public preview bridge", async () => { - await withServeRoute(async ({ origin, buildId, shareCookie, dependencies }) => { - const response = await request( - origin, - "/__replica/bridge/v1.js", - requestHeaders(buildId, origin, shareCookie), - ) - - expect(response.status).toBe(200) - expect(response.headers["cache-control"]).toBe("private, no-store") - expect(response.body.toString()).toBe( - `globalThis.reviewBridge={origin:"https://hub.example.com",enabled:"false" !== "false"};\n${dependencies.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge("https://hub.example.com");`, - ) - }) + expect(findArtifact).not.toHaveBeenCalled() + expect(read).not.toHaveBeenCalled() + }, + ) }) - it("keeps a valid public share separate from an invalid authenticated preview cookie", async () => { + it("ignores an obsolete private cookie beside a valid public share", async () => { await withServeRoute( async ({ origin, buildId, shareCookie, findArtifact, read, readAvailableShareLink }) => { findArtifact.mockResolvedValue({ @@ -683,37 +423,29 @@ describe("get()", () => { ) }) - it("falls back to a public session when a valid private cookie lost live authority", async () => { + it("rejects expired public sessions and private cookies without a public share", async () => { await withServeRoute( - async ({ - origin, - buildId, - cookie, - shareCookie, - restoreSession, - findArtifact, - read, - readAvailableShareLink, - }) => { - restoreSession.mockResolvedValue(null) - findArtifact.mockResolvedValue({ - storageKey: "asset-key", - byteLength: 2, - }) - read.mockResolvedValue({ - status: "ok", - bytes: Uint8Array.of(7, 8), - }) - - const response = await request( - origin, - "/asset.bin", - requestHeaders(buildId, origin, `${cookie}; ${shareCookie}`), + async ({ origin, buildId, key, findArtifact, read, readAvailableShareLink }) => { + const expired = createSharePreviewSession( + { buildId, shareLinkId: randomUUID(), expiresAt: new Date(Date.now() - 1_000) }, + key, ) - expect(response.status).toBe(200) - expect(response.headers["cache-control"]).toBe("private, no-store") - expect(readAvailableShareLink).toHaveBeenCalledTimes(2) + for (const cookie of [ + "", + "hub_session=member-session; replica_preview=obsolete-private-cookie", + `replica_share_preview=${encodeURIComponent(expired)}`, + ]) { + const response = await request( + origin, + "/asset.bin", + requestHeaders(buildId, origin, cookie), + ) + expect(response.status).toBe(404) + } + expect(findArtifact).not.toHaveBeenCalled() + expect(read).not.toHaveBeenCalled() + expect(readAvailableShareLink).not.toHaveBeenCalled() }, ) }) @@ -751,9 +483,9 @@ describe("get()", () => { ) }) - it("rechecks private session and repository authority after reading artifact bytes", async () => { + it("stops serving files and bridge scripts after a public link is revoked", async () => { await withServeRoute( - async ({ origin, buildId, cookie, restoreSession, findArtifact, read }) => { + async ({ origin, buildId, shareCookie, readAvailableShareLink, findArtifact, read }) => { findArtifact.mockResolvedValue({ storageKey: "asset-key", byteLength: 2, @@ -762,15 +494,11 @@ describe("get()", () => { status: "ok", bytes: Uint8Array.of(7, 8), }) - restoreSession.mockResolvedValueOnce({ userId: randomUUID() }).mockResolvedValueOnce(null) - - const response = await request( - origin, - "/asset.bin", - requestHeaders(buildId, origin, cookie), - ) - - expect(response.status).toBe(404) + const headers = requestHeaders(buildId, origin, shareCookie) + expect((await request(origin, "/asset.bin", headers)).status).toBe(200) + readAvailableShareLink.mockResolvedValue(null) + expect((await request(origin, "/asset.bin", headers)).status).toBe(404) + expect((await request(origin, "/__replica/bridge/v1.js", headers)).status).toBe(404) expect(read).toHaveBeenCalledOnce() }, ) @@ -779,7 +507,7 @@ describe("get()", () => { it.each(["not-found", "unavailable", "error"] as const)( "releases the source-byte reservation after storage returns %s", async (failure) => { - await withServeRoute(async ({ origin, buildId, cookie, findArtifact, read }) => { + await withServeRoute(async ({ origin, buildId, shareCookie, findArtifact, read }) => { findArtifact.mockResolvedValue({ storageKey: "asset-key", byteLength: 100 * 1024 * 1024, @@ -787,7 +515,7 @@ describe("get()", () => { read.mockResolvedValue({ status: "ok", bytes: Uint8Array.of(7) }) if (failure === "error") read.mockRejectedValueOnce(new Error("Storage read failed")) else read.mockResolvedValueOnce({ status: failure }) - const headers = requestHeaders(buildId, origin, cookie) + const headers = requestHeaders(buildId, origin, shareCookie) const failed = await request(origin, "/asset.bin", headers) const recovered = await request(origin, "/asset.bin", headers) diff --git a/hub/server/routes/build-preview/serve/get/index.ts b/hub/server/routes/build-preview/serve/get/index.ts index 41555e185..bfa89a872 100644 --- a/hub/server/routes/build-preview/serve/get/index.ts +++ b/hub/server/routes/build-preview/serve/get/index.ts @@ -2,18 +2,13 @@ import type { RequestHandler } from "express" import { readBuildPreviewFile } from "../../../../domains/build-preview/read-build-preview-file/index.ts" import { readPreviewBuildId } from "../../../../domains/build-preview/read-preview-build-id/index.ts" -import { readPreviewSession } from "../../../../domains/build-preview/read-preview-session/index.ts" import { readTemplateScreenshotPath } from "../../../../domains/build-preview/template-screenshot-path/index.ts" import { reserveBuildPreviewBytes } from "../../../../domains/build-preview/reserve-build-preview-bytes/index.ts" import { readSharePreviewSession } from "../../../../domains/public-sharing/read-share-preview-session/index.ts" import { readCookie } from "../../../../integrations/express/read-cookie/index.ts" import type { BuildPreviewRouteDependencies } from "../../types.ts" -function setSecurityHeaders( - response: Parameters[1], - applicationOrigin: string, - sharedScreenshot: boolean, -) { +function setSecurityHeaders(response: Parameters[1], applicationOrigin: string) { response.setHeader( "Content-Security-Policy", [ @@ -28,36 +23,13 @@ function setSecurityHeaders( "form-action 'self'", ].join("; "), ) - response.setHeader( - "Cross-Origin-Resource-Policy", - sharedScreenshot ? "cross-origin" : "same-origin", - ) + response.setHeader("Cross-Origin-Resource-Policy", "same-origin") response.setHeader("Permissions-Policy", "camera=(), microphone=(), geolocation=()") response.setHeader("Referrer-Policy", "no-referrer") response.setHeader("X-Content-Type-Options", "nosniff") } -export function get( - dependencies: BuildPreviewRouteDependencies, - canReadTemplate?: ( - sessionDigest: string, - repository: { id: string; local: boolean }, - ) => Promise, -): RequestHandler { - async function authorizePrivate( - session: NonNullable>, - buildId: string, - ) { - if (!session.t && !(await dependencies.restoreSession?.(session.s))) return false - const target = await dependencies.findTargetById(buildId, session.t ? "template" : "preview") - return session.t - ? Boolean( - target?.templateRepository && - (await canReadTemplate?.(session.s, target.templateRepository)), - ) - : Boolean(target) - } - +export function get(dependencies: BuildPreviewRouteDependencies): RequestHandler { return async (request, response, next) => { const reservations = new Set<() => void>() let handlingRequest = true @@ -75,57 +47,39 @@ export function get( response.once("finish", onResponseEnd) response.once("close", onResponseEnd) try { + if (!dependencies.previewBaseOrigin) { + next() + return + } const buildId = readPreviewBuildId(request.get("host"), dependencies.previewBaseOrigin) if (!buildId) { next() return } - const sessionValue = readCookie(request, "replica_preview") - const authenticated = - sessionValue && readPreviewSession(sessionValue, buildId, dependencies.encryptionKey) const shareValue = readCookie(request, "replica_share_preview") const shareSession = shareValue && readSharePreviewSession(shareValue, buildId, dependencies.encryptionKey) - const privateAuthorized = authenticated && (await authorizePrivate(authenticated, buildId)) const publicLink = - !privateAuthorized && shareSession && dependencies.readAvailableShareLink + shareSession && dependencies.readAvailableShareLink ? await dependencies.readAvailableShareLink(shareSession.s, buildId) : null - if (!privateAuthorized && !publicLink) { + if (!publicLink) { response.status(404).end() return } const templateScreenshot = readTemplateScreenshotPath(request.path) - if ( - templateScreenshot && - templateScreenshot !== "screenshots/desktop.png" && - !(privateAuthorized && authenticated && authenticated.t) - ) { + if (templateScreenshot && templateScreenshot !== "screenshots/desktop.png") { response.status(404).end() return } - const screenshot = - templateScreenshot || - request.path === "/__replica/screenshots/desktop.png" || - request.path === "/__replica/screenshots/narrow.png" - setSecurityHeaders( - response, - dependencies.applicationOrigin, - Boolean(privateAuthorized && screenshot), - ) + setSecurityHeaders(response, dependencies.applicationOrigin) if (request.path === "/__replica/bridge/v1.js") { const reviewSource = (dependencies.reviewBridgeSource ?? "") - .replace('"__REPLICA_HUB_ORIGIN__"', JSON.stringify(dependencies.applicationOrigin)) - .replace( - '"__REPLICA_REVIEW_ENABLED__"', - JSON.stringify(String(Boolean(privateAuthorized && authenticated && !authenticated.t))), - ) + .replaceAll('"__REPLICA_HUB_ORIGIN__"', JSON.stringify(dependencies.applicationOrigin)) + .replaceAll('"__REPLICA_REVIEW_ENABLED__"', JSON.stringify("false")) const source = `${reviewSource}\n${dependencies.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge(${JSON.stringify(dependencies.applicationOrigin)});` - response.setHeader( - "Cache-Control", - publicLink ? "private, no-store" : "private, max-age=300", - ) + response.setHeader("Cache-Control", "private, no-store") response.type("text/javascript").send(source) return } @@ -134,7 +88,7 @@ export function get( { acceptsHtml: Boolean(request.accepts("html")), buildId, - distOnly: publicLink?.hosted, + distOnly: publicLink.hosted, requestPath: request.path, }, { @@ -159,7 +113,6 @@ export function get( return } if ( - !privateAuthorized && shareSession && (!dependencies.readAvailableShareLink || !(await dependencies.readAvailableShareLink(shareSession.s, buildId))) @@ -167,21 +120,7 @@ export function get( response.status(404).end() return } - if ( - privateAuthorized && - (!authenticated || !(await authorizePrivate(authenticated, buildId))) - ) { - response.status(404).end() - return - } - response.setHeader( - "Cache-Control", - publicLink || (templateScreenshot && authenticated && authenticated.t) - ? "private, no-store" - : file.html - ? "private, no-cache" - : "private, max-age=31536000, immutable", - ) + response.setHeader("Cache-Control", "private, no-store") response.setHeader("Content-Type", file.contentType) response.setHeader("Content-Length", file.bytes.byteLength) response.end(file.bytes) diff --git a/hub/server/routes/build-preview/share-authorize/get/index.test.ts b/hub/server/routes/build-preview/share-authorize/get/index.test.ts index 3377779b4..85aac58e3 100644 --- a/hub/server/routes/build-preview/share-authorize/get/index.test.ts +++ b/hub/server/routes/build-preview/share-authorize/get/index.test.ts @@ -71,7 +71,6 @@ async function withRoute( delete: vi.fn(), }, bridgeSource: "", - findTargetById: vi.fn(), findArtifact: vi.fn(), } const sharing: PublicSharingRouteDependencies = { diff --git a/hub/server/routes/build-preview/share-authorize/get/index.ts b/hub/server/routes/build-preview/share-authorize/get/index.ts index d42ebadea..9d78e9a55 100644 --- a/hub/server/routes/build-preview/share-authorize/get/index.ts +++ b/hub/server/routes/build-preview/share-authorize/get/index.ts @@ -14,6 +14,10 @@ export function get( ): RequestHandler { return async (request, response, next) => { try { + if (!preview.previewBaseOrigin) { + response.status(404).end() + return + } const buildId = readPreviewBuildId(request.get("host"), preview.previewBaseOrigin) const value = typeof request.query.grant === "string" ? request.query.grant : "" const grant = readSharePreviewGrant(value, preview.encryptionKey) diff --git a/hub/server/routes/build-preview/types.ts b/hub/server/routes/build-preview/types.ts index dda9967e4..fd89148d9 100644 --- a/hub/server/routes/build-preview/types.ts +++ b/hub/server/routes/build-preview/types.ts @@ -1,22 +1,12 @@ import type { ArtifactStorage } from "../../domains/artifacts/create-artifact-storage/types.ts" -import type { BuildPreviewTarget } from "../../repositories/build-artifacts/find-build-preview-target/index.ts" export interface BuildPreviewRouteDependencies { applicationOrigin: string - previewBaseOrigin: string + previewBaseOrigin?: string encryptionKey: Buffer storage: ArtifactStorage bridgeSource: string reviewBridgeSource?: string - findTargetById( - buildId: string, - target: BuildPreviewTarget, - ): Promise<{ - buildId: string - startPage: string - artifactPath: string - templateRepository?: { id: string; local: boolean } - } | null> findArtifact( buildId: string, path: string, @@ -25,5 +15,8 @@ export interface BuildPreviewRouteDependencies { shareLinkId: string, buildId: string, ): Promise<{ expiresAt: Date; startPage: string; hosted?: true } | null> - restoreSession?(sessionDigest: string): Promise + findPathTargets?( + repositoryId: string, + workflowRunId: string, + ): Promise<{ buildId: string; repository: { id: string; local: boolean }; template: boolean }[]> } diff --git a/hub/server/routes/index.ts b/hub/server/routes/index.ts index 84d63ce7a..7ed56ac19 100644 --- a/hub/server/routes/index.ts +++ b/hub/server/routes/index.ts @@ -16,7 +16,6 @@ import { get as handleApiReadyGet } from "./api/ready/get/index.ts" import { get as handleWorkspaceGet } from "./api/workspace/get/index.ts" import { patch as handleWelcomePatch } from "./api/workspace/welcome/patch/index.ts" import { templateRoutes } from "./api/repositories/templates/index.ts" -import { canBrowseTemplates } from "./api/product/template-repository-access/index.ts" import { get as handleRepositoryAuthorsGet } from "./api/repositories/authors/get/index.ts" import { get as handleRepositoryGet } from "./api/repositories/show/get/index.ts" import { mountRepositoryAnalytics } from "./api/repositories/analytics/index.ts" @@ -35,8 +34,8 @@ import { createCollaborationHandlers } from "./api/review-comments/collaboration import { createInboxHandlers } from "./api/notifications/index.ts" import { get as handleBuildPreviewAccessGet } from "./api/repositories/prototypes/builds/access/get/index.ts" import { get as handlePrototypeManagementGet } from "./api/repositories/prototype-management/get/index.ts" -import { get as handleBuildPreviewAuthorizeGet } from "./build-preview/authorize/get/index.ts" import { get as handleBuildPreviewServeGet } from "./build-preview/serve/get/index.ts" +import { get as handlePathPreviewGet } from "./build-preview/path/get/index.ts" import { get as handleSharePreviewAuthorizeGet } from "./build-preview/share-authorize/get/index.ts" import { get as handleSharingSettingsGet } from "./api/public-sharing/settings/get/index.ts" import { patch as handleSharingSettingsPatch } from "./api/public-sharing/settings/patch/index.ts" @@ -96,22 +95,18 @@ export function routes(app: Express, dependencies: RouteDependencies = {}): void publicSharing, } = dependencies if (preview) { - app.get("/__replica/authorize", handleBuildPreviewAuthorizeGet(preview)) + if (preview.findPathTargets && authentication && product) + app.use("/previews", handlePathPreviewGet(preview, authentication.currentSession, product)) + } + app.use("/previews", (_request, response) => { + response.setHeader("Cache-Control", "private, no-store") + response.status(404).end() + }) + if (preview?.previewBaseOrigin) { if (publicSharing) { app.get("/__replica/share/authorize", handleSharePreviewAuthorizeGet(preview, publicSharing)) } - app.get( - "/{*path}", - handleBuildPreviewServeGet(preview, async (digest, repository) => { - const current = await authentication?.currentSession.restore(digest) - return Boolean( - current && - product && - canBrowseTemplates(current, repository.local) && - (await product.isRepositoryVisible(current, repository.id)), - ) - }), - ) + app.get("/{*path}", handleBuildPreviewServeGet(preview)) } app.get("/api/health", handleApiHealthGet) app.get("/api/ready", (request, response) => diff --git a/hub/server/utils/create-build-preview-path/index.ts b/hub/server/utils/create-build-preview-path/index.ts new file mode 100644 index 000000000..543340ab6 --- /dev/null +++ b/hub/server/utils/create-build-preview-path/index.ts @@ -0,0 +1,13 @@ +export function createBuildPreviewPath( + repositoryId: bigint | string | null, + workflowRunId: bigint | string | null, +): string | null { + if ( + repositoryId === null || + workflowRunId === null || + !/^[1-9]\d*$/.test(String(repositoryId)) || + !/^[1-9]\d*$/.test(String(workflowRunId)) + ) + return null + return `/previews/github/${repositoryId}/${workflowRunId}/` +} diff --git a/hub/test/local-smoke/browser.js b/hub/test/local-smoke/browser.js index 114e543de..47cd23758 100644 --- a/hub/test/local-smoke/browser.js +++ b/hub/test/local-smoke/browser.js @@ -95,26 +95,9 @@ Object(async (page) => { const templates = admin.getByRole("region", { name: "Templates", exact: true }) await templates.getByRole("link", { name: "Open template: Field notes", exact: true }).click() await admin - .locator("iframe") - .contentFrame() - .getByRole("heading", { name: "Field notes template", exact: true }) + .getByRole("heading", { name: "Template preview unavailable", exact: true }) .waitFor() - await adminContext.grantPermissions(["clipboard-read", "clipboard-write"], { - origin: root.origin, - }) - await admin.getByRole("button", { name: "Branch from here", exact: true }).click() - const brief = "Add a trail map to the field notes." - await admin - .getByPlaceholder("What changes would you like to make?", { exact: true }) - .fill(brief) - await admin - .getByRole("button", { name: "Copy prompt", exact: true }) - .and(admin.locator("button:enabled")) - .click() - await admin.waitForFunction(async (submittedBrief) => { - const prompt = await navigator.clipboard.readText() - return prompt.includes(submittedBrief) && prompt.includes("/field-notes") - }, brief) + await admin.locator("iframe").waitFor({ state: "detached" }) await admin.goto(galleryUrl, { waitUntil: "domcontentloaded" }) await admin.getByRole("link", { name: "Canvas connections", exact: true }).click() @@ -147,13 +130,9 @@ Object(async (page) => { .click() await welcome.click() - const privatePreview = admin.getByTitle("Welcome, Build 1 preview", { exact: true }) - await privatePreview.waitFor() await dismissIntroduction("Welcome") - await privatePreview - .contentFrame() - .getByRole("heading", { name: "Welcome prototype", exact: true }) - .waitFor() + await admin.getByRole("heading", { name: "Build 1 has no preview", exact: true }).waitFor() + await admin.locator("iframe").waitFor({ state: "detached" }) const welcomeUrl = admin.url() await admin.goto(new URL("/settings/sharing", root).href, { waitUntil: "domcontentloaded" }) diff --git a/hub/vite.config.ts b/hub/vite.config.ts index 6fc92a105..ff45d4b7d 100644 --- a/hub/vite.config.ts +++ b/hub/vite.config.ts @@ -25,12 +25,18 @@ export default defineConfig(({ mode }) => ({ server: { port: 5173, strictPort: true, - proxy: { "/api": { target: "http://127.0.0.1:3001", ws: true } }, + proxy: { + "/api": { target: "http://127.0.0.1:3001", ws: true }, + "/previews": { target: "http://127.0.0.1:3001" }, + }, }, preview: { port: 5173, strictPort: true, - proxy: { "/api": { target: "http://127.0.0.1:3001", ws: true } }, + proxy: { + "/api": { target: "http://127.0.0.1:3001", ws: true }, + "/previews": { target: "http://127.0.0.1:3001" }, + }, }, resolve: { alias: { ...viteAliases, [controlsValidatorModule]: controlsValidatorPath } }, optimizeDeps: { include: [controlsValidatorModule] }, diff --git a/starter/README.md b/starter/README.md index 43d43a8df..85314936e 100644 --- a/starter/README.md +++ b/starter/README.md @@ -4,6 +4,8 @@ A minimal starting point for a new prototype. Download and review `scripts/insta The app has hash-based routing, a start page, a linked sub-page, and a scaffolded activity example. Replace the example pages with your prototype. +Vite emits relative resource URLs (`base: "./"`) so GitHub Builds can run under Hub's private `/previews/github///` mount. Existing copied repositories must adopt that setting and push a new commit to rebuild; successful immutable Builds are not rewritten. Apps using pathname routing instead need their supported build-time base and router basename set to that exact prefix. Configure the screenshot action's `base-path` to match the package's original base. + Plain/fresh `/setup-skills` also dispatches one tooling agent after intake to check user-named token, component and other packages, offer missing dependencies and attempt approved installs before context writers begin. It reuses the current diff --git a/starter/vite.config.ts b/starter/vite.config.ts index e81d659a5..3f355136f 100644 --- a/starter/vite.config.ts +++ b/starter/vite.config.ts @@ -8,6 +8,7 @@ import { viteAliases } from "./vite-aliases.ts" const root = path.dirname(fileURLToPath(import.meta.url)) export default defineConfig({ + base: "./", root, plugins: [react()], resolve: { alias: viteAliases }, From fb1577a44debbc67b0e3f1c2a62ed62a70cea576 Mon Sep 17 00:00:00 2001 From: Will Eastler <32074613+weastler@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:10:26 -0800 Subject: [PATCH 2/4] fix(hub): close mounted preview boundary gaps Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- hub/docs/build-previews.md | 4 +- hub/docs/development.md | 6 +- hub/docs/frontend.md | 2 +- .../build-preview/path/get/index.test.ts | 136 +++++++++++++++++- .../routes/build-preview/path/get/index.ts | 19 ++- 5 files changed, 157 insertions(+), 10 deletions(-) diff --git a/hub/docs/build-previews.md b/hub/docs/build-previews.md index bcb4d5a8f..1e1fece65 100644 --- a/hub/docs/build-previews.md +++ b/hub/docs/build-previews.md @@ -30,7 +30,7 @@ This allowance bounds concurrent buffered preview files, not total process memor ## Access and compatibility -Every private document, asset, screenshot, and bridge request requires a live Hub session and repository visibility for that exact Build. Hub checks authority again after reading stored bytes. Session expiry, repository removal, branch retirement, or access revocation denies subsequent requests. Numeric path IDs are locators, not capabilities; anonymous users and share cookies cannot authorize this mount. +Every private document, asset, screenshot, and bridge request requires a live Hub session and repository visibility for that exact Build. Hub checks authority again after reading stored bytes. Session expiry, repository removal, branch retirement, access revocation, or a change in template classification denies the request. Numeric path IDs are locators, not capabilities; anonymous users and share cookies cannot authorize this mount. Resources use private revalidation rather than a fresh immutable browser cache, so the browser cannot skip the next authorization check. Screenshots and bridge responses are private and not stored. Already returned bytes cannot be recalled. @@ -42,7 +42,7 @@ Private wildcard grants, cookies, authorization endpoints, and the `preview_orig ## File and bridge behavior -The `/previews/` mount precedes the Hub SPA fallback, including when preview serving is disabled. Preview misses never return the Hub page. The canonical root without its final slash redirects with 308 and preserves its query. +The `/previews/` mount accepts only GET and HEAD and precedes the Hub SPA fallback, including when preview serving is disabled. Preview misses never return the Hub page. The canonical root without its final slash redirects with 308 and preserves its query. Hub rejects malformed provider IDs, traversal, encoded separators, backslashes, controls, and unsafe package paths before storage access. `/` serves `dist/index.html`; a directory first tries its nested `index.html`. Missing extensionless HTML navigations may use the root SPA document. Dotted routes receive that fallback only when the saved template manifest declares them. Missing scripts and other assets return 404. Content types come from the stored path and responses disable MIME sniffing. diff --git a/hub/docs/development.md b/hub/docs/development.md index 609cb2ef1..47c1429df 100644 --- a/hub/docs/development.md +++ b/hub/docs/development.md @@ -53,7 +53,9 @@ In a second terminal, also from `hub/`, start Vite: npm run dev ``` -Open . React Router's Vite development server forwards `/api` requests to Express at . `GET /api/health` and `GET /api/ready` return JSON. The [authentication and Hub session guide](authentication.md) describes configured sign-in and enrollment. A signed-in member opens the first available repository, or an empty workspace when none exist. The real index supports search, user filtering, pagination, and latest Build status. Members can browse Build history, select a successful Build with `?build=N`, open its isolated preview, edit visible prototype metadata, use persisted review conversations, and manage [Build-pinned local share links](share-links.md). +Open . React Router's Vite development server forwards `/api` and `/previews` requests to Express at . `GET /api/health` and `GET /api/ready` return JSON. The [authentication and Hub session guide](authentication.md) describes configured sign-in and enrollment. A signed-in member opens the first available repository, or an empty workspace when none exist. The real index supports search, user filtering, pagination, and latest Build status. Members can browse Build history, select a successful Build with `?build=N`, edit visible prototype metadata, and use persisted review conversations. + +Private hosted previews require a supported GitHub Build and use the Hub origin, not an isolated origin. Local Builds and local templates have no supported private preview mount. See [Build previews](build-previews.md) for the compiler base, access rules, and publisher trust boundary. Existing [local share links](share-links.md) retain their separate public-serving configuration. With `npm run dev:api`, the home page shows **Sign in as local developer**. Selecting it signs you in as one fixed local developer who is a Hub administrator. No password or outside account is involved. The command explicitly enables `HUB_LOCAL_MODE` and local sign-in and defaults `NODE_ENV` to `development`. The API refuses local mode unless the runtime role is API-only and `DATABASE_URL` points at a local development database. It also requires `HOST` to be `127.0.0.1`, `::1`, or `localhost` and `HUB_APPLICATION_ORIGIN` to be a loopback origin. It refuses GitHub or Entra sign-in and repository connection settings, but an explicitly configured Copilot GitHub App can still be used. Unset origin, encryption key, and bootstrap secret values get local defaults. See [Local developer sign-in](authentication.md#local-developer-sign-in) for how this mode reuses the normal sign-in checks. @@ -129,7 +131,7 @@ From a discovered repository's gallery, choose **Edit prototype listings** to ad The runner uses an isolated detached Git worktree for the exact commit, so working-tree changes and untracked files do not enter the Build. Successful packages store validated `dist` files, screenshots, and the optional template manifest as immutable artifact bytes. Hub records failed state and a bounded error summary when validation, the prototype build, screenshots, packaging, storage, or persistence fails. -Successful local Builds are immediately available to the authenticated [preview layer](build-previews.md) through their saved `BuildArtifact` records. The preview and screenshot URLs use the same artifact paths and storage keys written by synchronization; no import or second artifact representation is required. The injected preview bridge supplies element and area anchors to the parent Hub page. The fixed local identity can list and change persisted conversations for those configured repositories while each thread remains pinned to the successful Build where it began. After a local administrator enables deployment sharing, the same saved preview can receive an opaque public link through the [local sharing contract](share-links.md). +Successful local Builds retain their checked `BuildArtifact` records and immutable bytes, but private preview and screenshot URLs are unavailable without a supported [mount contract](build-previews.md). Existing persisted conversations remain pinned to their original Builds. After a local administrator enables deployment sharing, eligible saved artifacts can still receive an opaque public link through the separate [local sharing contract](share-links.md). Reviews and share links do not modify or duplicate Build artifacts. Public links do not expose review or repository data. The local identity can use review reactions, Canvas pairing, and analytics settings without GitHub. Use separate authorized GitHub identities to exercise hosted permissions and mention and Inbox behavior across accounts. diff --git a/hub/docs/frontend.md b/hub/docs/frontend.md index 2e99bd08d..70e95e94c 100644 --- a/hub/docs/frontend.md +++ b/hub/docs/frontend.md @@ -30,7 +30,7 @@ In real mode, signed-in members open the first repository or an empty workspace. Live [review and Inbox](review-collaboration.md) use saved PostgreSQL records and repository access checks. [Public preview links](share-links.md) are Build-pinned, signed-out routes with no private Hub navigation. [Analytics](analytics.md) and repository audit require repository-level administration. Hub-wide sign-in, enrollment, administration, audit, and session revocation keep their separate authorization. -The Build pickers and History list all Build states in both modes. Successful Builds open the prototype view with `?build=N`; History shows when each Build was added in the viewer's local timezone. Real previews use saved artifacts from local Builds or [GitHub Actions imports](github-actions-builds.md). Share-link management offers successful Builds with a saved preview. +The Build pickers and History list all Build states in both modes. Successful Builds open the prototype view with `?build=N`; History shows when each Build was added in the viewer's local timezone. Private previews use saved [GitHub Actions imports](github-actions-builds.md) through the [canonical preview contract](build-previews.md). Local Builds and local templates have no supported private mount. Existing share-link management remains separate and offers successful Builds, with artifact eligibility checked by the sharing API. Product screens retain product-facing copy from the retained pages and their original fixtures. They do not describe mock data, simulations, or synthetic accounts. The bottom-right test toolbar is the only orange development surface and the only place for mock-only warnings, request diagnostics, and explanations of local actions. It can be collapsed on any viewport. Normal product validation, access-denied, and failure feedback remain in the product UI. diff --git a/hub/server/routes/build-preview/path/get/index.test.ts b/hub/server/routes/build-preview/path/get/index.test.ts index 7463a0b2a..eecdc0e11 100644 --- a/hub/server/routes/build-preview/path/get/index.test.ts +++ b/hub/server/routes/build-preview/path/get/index.test.ts @@ -24,11 +24,12 @@ async function request( origin: string, path: string, headers: Record = { cookie: "hub_session=member-session" }, + method = "GET", ): Promise { return new Promise((resolve, reject) => { const url = new URL(origin) const outgoing = httpRequest( - { hostname: url.hostname, port: url.port, path, headers }, + { hostname: url.hostname, port: url.port, path, headers, method }, (response) => { const chunks: Buffer[] = [] response.on("data", (chunk: Buffer) => chunks.push(chunk)) @@ -161,6 +162,43 @@ async function createFixture() { } describe("get()", () => { + it("rejects unsupported methods before checking sessions, targets or storage", async () => { + const { origin, mountPath, save, restore, findPathTargets, findArtifact, storage } = + await createFixture() + save("dist/assets/app.css", "private-asset") + const read = vi.spyOn(storage, "read") + + for (const method of ["POST", "PUT", "PATCH", "DELETE", "OPTIONS"]) { + const response = await request( + origin, + `${mountPath}/assets/app.css`, + { cookie: "hub_session=member-session" }, + method, + ) + + expect.soft(response.status, method).toBe(404) + } + expect(restore).not.toHaveBeenCalled() + expect(findPathTargets).not.toHaveBeenCalled() + expect(findArtifact).not.toHaveBeenCalled() + expect(read).not.toHaveBeenCalled() + }) + + it("keeps GET and HEAD available while omitting the HEAD body", async () => { + const { origin, mountPath, save } = await createFixture() + save("dist/assets/app.css", "private-asset") + const headers = { cookie: "hub_session=member-session" } + + const get = await request(origin, `${mountPath}/assets/app.css`, headers, "GET") + const head = await request(origin, `${mountPath}/assets/app.css`, headers, "HEAD") + + expect(get.status).toBe(200) + expect(get.body.toString()).toBe("private-asset") + expect(head.status).toBe(200) + expect(head.body).toHaveLength(0) + expect(head.headers["content-length"]).toBe(get.headers["content-length"]) + }) + it("serves mounted files, nested indexes and HTML routes without falling back for missing assets", async () => { const fixture = await createFixture() const { origin, mountPath, save, findPathTargets, isRepositoryVisible, viewer, target } = @@ -302,6 +340,102 @@ describe("get()", () => { }, ) + it("denies the bridge when the same Build becomes a template during authorization", async () => { + const { origin, mountPath, preview, target, findPathTargets, findArtifact, storage } = + await createFixture() + preview.reviewBridgeSource = 'globalThis.reviewEnabled = "__REPLICA_REVIEW_ENABLED__";' + findPathTargets + .mockResolvedValueOnce([target]) + .mockResolvedValue([{ ...target, template: true }]) + const read = vi.spyOn(storage, "read") + + const response = await request(origin, `${mountPath}/__replica/bridge/v1.js`) + + expect(response.status).toBe(404) + expect(response.body.toString()).not.toContain('globalThis.reviewEnabled = "true"') + expect(findArtifact).not.toHaveBeenCalled() + expect(read).not.toHaveBeenCalled() + }) + + it("discards a named template screenshot when the same Build loses template eligibility during its read", async () => { + const { origin, mountPath, target, save, storage, findPathTargets } = await createFixture() + findPathTargets.mockResolvedValue([{ ...target, template: true }]) + save("screenshots/templates/welcome/desktop.png", Uint8Array.of(7, 8)) + const read = storage.read.bind(storage) + const reading = vi.spyOn(storage, "read").mockImplementation(async (key) => { + const result = await read(key) + findPathTargets.mockResolvedValue([target]) + return result + }) + + const response = await request( + origin, + `${mountPath}/__replica/screenshots/templates/welcome/desktop.png`, + ) + + expect(reading).toHaveBeenCalledOnce() + expect(response.status).toBe(404) + expect(response.body).toHaveLength(0) + }) + + it.each(["identity", "locality"])( + "denies a template bridge when repository %s changes without changing the Build", + async (change) => { + const { origin, mountPath, target, findPathTargets, isRepositoryVisible } = + await createFixture() + const initial = { ...target, template: true } + const changed = { + ...initial, + repository: + change === "identity" + ? { ...target.repository, id: randomUUID() } + : { ...target.repository, local: true }, + } + isRepositoryVisible.mockImplementation((_viewer, id) => + Promise.resolve(id === target.repository.id), + ) + findPathTargets.mockResolvedValueOnce([initial]).mockResolvedValue([changed]) + + const response = await request(origin, `${mountPath}/__replica/bridge/v1.js`) + + expect(response.status).toBe(404) + expect(response.body).toHaveLength(0) + }, + ) + + it("serves the hosted bridge for an encoded reserved path instead of a stored shadow", async () => { + const { origin, mountPath, save, findArtifact, storage } = await createFixture() + save("dist/__replica/bridge/v1.js", "globalThis.shadowedBridge = true") + const read = vi.spyOn(storage, "read") + + const canonical = await request(origin, `${mountPath}/__replica/bridge/v1.js`) + const encoded = await request(origin, `${mountPath}/%5f_replica/bridge/v1.js`) + + expect(canonical.status).toBe(200) + expect(encoded.status).toBe(200) + expect(encoded.body).toEqual(canonical.body) + expect(findArtifact).not.toHaveBeenCalled() + expect(read).not.toHaveBeenCalled() + }) + + it.each(["/%5f_replica/unknown", "/__replica"])( + "rejects reserved path %s before an artifact lookup or SPA fallback", + async (path) => { + const { origin, mountPath, save, findArtifact, storage } = await createFixture() + save("dist/index.html", "Private SPA") + const read = vi.spyOn(storage, "read") + + const response = await request(origin, `${mountPath}${path}`, { + cookie: "hub_session=member-session", + accept: "text/html", + }) + + expect(response.status).toBe(404) + expect(findArtifact).not.toHaveBeenCalled() + expect(read).not.toHaveBeenCalled() + }, + ) + it.each(["session expiry", "repository revocation"])( "discards artifact bytes when %s occurs during storage read", async (change) => { diff --git a/hub/server/routes/build-preview/path/get/index.ts b/hub/server/routes/build-preview/path/get/index.ts index 0bdad7d27..e39576997 100644 --- a/hub/server/routes/build-preview/path/get/index.ts +++ b/hub/server/routes/build-preview/path/get/index.ts @@ -20,6 +20,10 @@ export function get( response.setHeader("X-Content-Type-Options", "nosniff") response.setHeader("Referrer-Policy", "no-referrer") try { + if (request.method !== "GET" && request.method !== "HEAD") { + response.status(404).end() + return + } const rawPath = request.originalUrl.split("?")[0] ?? "" const match = /^\/previews\/github\/([1-9]\d{0,18})\/([1-9]\d{0,18})(\/.*)?$/.exec(rawPath) const path = match?.[3] ?? "/" @@ -69,7 +73,14 @@ export function get( ) return false const live = await preview.findPathTargets?.(match![1]!, match![2]!) - return live?.length === 1 && live[0]?.buildId === target.buildId + const currentTarget = live?.length === 1 ? live[0] : undefined + return Boolean( + currentTarget && + currentTarget.buildId === target.buildId && + currentTarget.template === target.template && + currentTarget.repository.id === target.repository.id && + currentTarget.repository.local === target.repository.local, + ) } if (!(await authorized())) { response.status(404).end() @@ -86,7 +97,7 @@ export function get( ) response.setHeader("Cross-Origin-Resource-Policy", "same-origin") response.setHeader("Permissions-Policy", "camera=(), microphone=(), geolocation=()") - if (path === "/__replica/bridge/v1.js") { + if (decoded === "/__replica/bridge/v1.js") { const review = (preview.reviewBridgeSource ?? "") .replaceAll('"__REPLICA_HUB_ORIGIN__"', JSON.stringify(preview.applicationOrigin)) .replaceAll('"__REPLICA_REVIEW_ENABLED__"', JSON.stringify(String(!target.template))) @@ -99,9 +110,9 @@ export function get( } const screenshot = readTemplateScreenshotPath(path) ?? - (path === "/__replica/screenshots/narrow.png" ? "screenshots/narrow.png" : null) + (decoded === "/__replica/screenshots/narrow.png" ? "screenshots/narrow.png" : null) if ( - (path.startsWith("/__replica/") && !screenshot) || + ((decoded === "/__replica" || decoded.startsWith("/__replica/")) && !screenshot) || (screenshot && screenshot !== "screenshots/desktop.png" && screenshot !== "screenshots/narrow.png" && From ab9cc77e4b8ea8cabbfe37612efa694df76ec8ff Mon Sep 17 00:00:00 2001 From: Will Eastler <32074613+weastler@users.noreply.github.com> Date: Fri, 20 Nov 2026 19:36:12 -0800 Subject: [PATCH 3/4] fix(hub): retain preview ownership and revalidate assets Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../scripts/create-static-server/index.mjs | 4 +- .../create-static-server/index.test.mjs | 93 +++- hub/docs/build-previews.md | 10 +- hub/docs/github-actions-builds.md | 7 +- hub/schema/build.prisma | 1 + .../migration.sql | 2 + .../read-build-preview-file/index.ts | 23 +- .../read-build-preview-file/types.ts | 3 + .../index.db.test.ts | 30 ++ .../find-path-preview-targets/index.ts | 35 +- .../find-prototype-detail/index.db.test.ts | 28 ++ .../find-prototype-detail/index.ts | 13 +- .../find-repository-index/index.ts | 36 +- .../routes/api/product-index/index.db.test.ts | 13 +- .../builds/access/get/index.test.ts | 38 ++ .../prototypes/builds/access/get/index.ts | 6 +- .../index.ts | 45 ++ .../build-preview/path/get/index.db.test.ts | 46 +- .../build-preview/path/get/index.test.ts | 415 +++++++++++++++++- .../routes/build-preview/path/get/index.ts | 26 +- .../build-preview/serve/get/index.test.ts | 12 +- .../routes/build-preview/serve/get/index.ts | 34 +- hub/server/routes/index.ts | 14 +- .../index.db.test.ts | 152 +++++++ 24 files changed, 960 insertions(+), 126 deletions(-) create mode 100644 hub/schema/migrations/20261220120000_build_preview_run_lookup/migration.sql create mode 100644 hub/server/routes/build-preview/create-preview-response-reservation/index.ts create mode 100644 hub/test/database/build-preview-run-lookup-migration/index.db.test.ts diff --git a/actions/build/scripts/create-static-server/index.mjs b/actions/build/scripts/create-static-server/index.mjs index 0aba204e3..66e1e914e 100644 --- a/actions/build/scripts/create-static-server/index.mjs +++ b/actions/build/scripts/create-static-server/index.mjs @@ -19,7 +19,7 @@ export function createStaticServer(dist, templatePaths = [], basePath = "/") { const decoded = decodeURIComponent(rawPath) if ( /%2f|%5c/i.test(rawPath) || - /[\\%\p{Cc}]/u.test(decoded) || + /[\\\p{Cc}]/u.test(decoded) || decoded.split("/").some((part) => part === "." || part === "..") ) { response.writeHead(400).end() @@ -53,7 +53,7 @@ export function createStaticServer(dist, templatePaths = [], basePath = "/") { let details try { details = await lstat(filePath) - if (details.isDirectory()) { + if (details.isDirectory() && requestPath.endsWith("/")) { const index = path.join(filePath, "index.html") const indexDetails = await lstat(index).catch((error) => { if (!["ENOENT", "ENOTDIR"].includes(error.code)) throw error diff --git a/actions/build/scripts/create-static-server/index.test.mjs b/actions/build/scripts/create-static-server/index.test.mjs index 40ca3b814..08ee675e1 100644 --- a/actions/build/scripts/create-static-server/index.test.mjs +++ b/actions/build/scripts/create-static-server/index.test.mjs @@ -1,18 +1,25 @@ import assert from "node:assert/strict" -import { mkdir, writeFile } from "node:fs/promises" +import { randomUUID } from "node:crypto" +import { mkdir, rm, writeFile } from "node:fs/promises" +import { request } from "node:http" import path from "node:path" import { describe, it } from "node:test" -import { temporaryDirectory } from "../../test/temporary-directory/index.mjs" - import { closeServer } from "../close-server/index.mjs" import { listenOnLoopback } from "../listen-on-loopback/index.mjs" import { createStaticServer } from "./index.mjs" +async function createDirectory(context) { + const directory = path.resolve(`.static-server-test-${randomUUID()}`) + await mkdir(directory) + context.after(() => rm(directory, { recursive: true, force: true })) + return directory +} + describe("createStaticServer()", () => { - it("serves only the compiled base with nested documents and logical template routes", async () => { - const dist = await temporaryDirectory() + it("serves only the compiled base with nested documents and logical template routes", async (context) => { + const dist = await createDirectory(context) const base = "/previews/github/123/456/" await mkdir(path.join(dist, "docs")) await writeFile( @@ -47,8 +54,8 @@ describe("createStaticServer()", () => { } }) - it("serves client-side browser routes but never replaces missing assets with HTML", async () => { - const dist = await temporaryDirectory() + it("serves client-side browser routes but never replaces missing assets with HTML", async (context) => { + const dist = await createDirectory(context) await writeFile(path.join(dist, "index.html"), "

App

") const server = createStaticServer(dist) const port = await listenOnLoopback(server) @@ -69,8 +76,8 @@ describe("createStaticServer()", () => { } }) - it("falls back for declared dotted and directory routes without hiding missing assets", async () => { - const dist = await temporaryDirectory() + it("falls back for declared dotted and directory routes without hiding missing assets", async (context) => { + const dist = await createDirectory(context) const html = "

App

" await writeFile(path.join(dist, "index.html"), html) await mkdir(path.join(dist, "assets")) @@ -116,4 +123,72 @@ describe("createStaticServer()", () => { await closeServer(server) } }) + + for (const base of ["/", "/previews/github/123/456/"]) { + it(`decodes percent filenames once under ${base}`, async (context) => { + const dist = await createDirectory(context) + await mkdir(path.join(dist, "assets")) + await writeFile(path.join(dist, "assets/100%complete.bin"), "literal percent bytes") + await writeFile(path.join(dist, "assets/%2f.bin"), "literal encoded separator bytes") + const server = createStaticServer(dist, [], base) + const port = await listenOnLoopback(server) + try { + for (const [file, expected] of [ + ["100%25complete.bin", "literal percent bytes"], + ["%252f.bin", "literal encoded separator bytes"], + ]) { + const response = await fetch(`http://127.0.0.1:${port}${base}assets/${file}`) + assert.equal(response.status, 200) + assert.equal(await response.text(), expected) + } + for (const unsafe of [ + "assets%2fprivate.bin", + "assets%5cprivate.bin", + "%2e%2e/private.bin", + ]) { + const status = await new Promise((resolve, reject) => { + const outgoing = request( + { hostname: "127.0.0.1", port, path: `${base}${unsafe}` }, + (response) => { + response.resume() + response.on("end", () => resolve(response.statusCode)) + }, + ) + outgoing.on("error", reject) + outgoing.end() + }) + assert.equal(status, 400, unsafe) + } + } finally { + await closeServer(server) + } + }) + } + + it("uses a nested index only for a trailing slash, not its declared logical route", async (context) => { + const dist = await createDirectory(context) + const base = "/previews/github/123/456/" + const rootHtml = "

Root SPA

" + const nestedHtml = '

Nested document

' + await mkdir(path.join(dist, "docs")) + await writeFile(path.join(dist, "index.html"), rootHtml) + await writeFile(path.join(dist, "docs/index.html"), nestedHtml) + await writeFile(path.join(dist, "docs/app.js"), "nested asset") + const server = createStaticServer(dist, ["/docs"], base) + const port = await listenOnLoopback(server) + const origin = `http://127.0.0.1:${port}` + try { + const logical = await fetch(`${origin}${base}docs`, { headers: { Accept: "text/html" } }) + assert.equal(logical.status, 200) + assert.equal(await logical.text(), rootHtml) + const nestedUrl = `${origin}${base}docs/` + const nested = await fetch(nestedUrl, { headers: { Accept: "text/html" } }) + assert.equal(nested.status, 200) + assert.equal(await nested.text(), nestedHtml) + const asset = await fetch(new URL("./app.js", nestedUrl)) + assert.equal(await asset.text(), "nested asset") + } finally { + await closeServer(server) + } + }) }) diff --git a/hub/docs/build-previews.md b/hub/docs/build-previews.md index 1e1fece65..dfd111051 100644 --- a/hub/docs/build-previews.md +++ b/hub/docs/build-previews.md @@ -18,10 +18,12 @@ Pass the same base to `actions/build/screenshots` using its `base-path` input. T The path uses the numeric GitHub repository ID and the successful Build's **owning** workflow run ID. It never uses the branch head, current selected run, commit SHA, or attempt number. A later redundant run can select an existing successful Build but gets no new preview mount. Same-run retries keep the original base. Capture a downloaded package at its original compiled base, not the IDs of a later capture run. -Hub serves only one matching successful Build with `dist/index.html` in a connected repository and active branch. Missing or ambiguous ownership returns 404; duplicate ownership also produces a warning. Hub does not pick another Build or impose a new uniqueness constraint. Builds with null provider IDs and local Builds have no canonical path contract and are unsupported for private hosted preview. Their stored data remains untouched. +Hub first counts successful Builds owning the repository/run address, including retired or otherwise ineligible owners. Missing or ambiguous ownership returns 404; duplicate ownership also produces a warning. Only a sole owner with `dist/index.html` in a connected repository and active branch may serve content. Retiring one ambiguous owner cannot transfer its URL to another Build. A non-unique run-ID index supports this lookup without changing ownership constraints. Builds with null provider IDs and local Builds have no canonical path contract and are unsupported for private hosted preview. Their stored data remains untouched. Old base-`/` packages are not portable to these paths. Change the build configuration and push a **new commit** to create a new Build. A workflow rerun does not replace an immutable successful Build for the same prototype and commit. Existing packages, storage keys, Build numbers and UUIDs, review threads, and ShareLink relations remain untouched. The package does not declare its base, so Hub cannot detect an app compiled for the wrong one. +Saved screenshots use their own artifact records and bytes; serving them does not load the prototype's HTML. Eligible older Builds can therefore show their existing gallery images even when their app still needs a new fixed-base Build to render correctly. + ## Buffered preview reads Artifact reads share a 100 MiB source-byte allowance per API process across private previews, template previews, and existing public preview origins. Hub reserves each file's recorded size before reading storage and keeps that reservation until the read settles and the HTTP response finishes or disconnects. A request returns 503 without reading the file when the allowance is full. Small and empty files reserve at least 64 KiB each. Temporary template-manifest reads release their reservation before reading the selected HTML file. @@ -32,7 +34,7 @@ This allowance bounds concurrent buffered preview files, not total process memor Every private document, asset, screenshot, and bridge request requires a live Hub session and repository visibility for that exact Build. Hub checks authority again after reading stored bytes. Session expiry, repository removal, branch retirement, access revocation, or a change in template classification denies the request. Numeric path IDs are locators, not capabilities; anonymous users and share cookies cannot authorize this mount. -Resources use private revalidation rather than a fresh immutable browser cache, so the browser cannot skip the next authorization check. Screenshots and bridge responses are private and not stored. Already returned bytes cannot be recalled. +Static assets use private revalidation with an immutable-artifact ETag. A matching conditional GET or HEAD returns 304 only after live session, repository, and ownership checks, without reserving or reading the file's bytes. HTML, screenshots, and generated bridge responses do not use this asset validator; screenshots and bridges are private and not stored. Already returned bytes cannot be recalled. The prototype response keeps Build selection on `/repositories/:repositoryId/prototypes/:prototypeId?build=N`. Its preview and screenshot URLs use the owning Build's canonical path. Existing Build access URLs resolve the selected successful Build and redirect to that path, joining its logical start route, query, and fragment. Template access URLs similarly preserve their exact default-branch Build and declared screenshot paths. Template previews remain browse-only and require the existing template access rules. @@ -44,7 +46,7 @@ Private wildcard grants, cookies, authorization endpoints, and the `preview_orig The `/previews/` mount accepts only GET and HEAD and precedes the Hub SPA fallback, including when preview serving is disabled. Preview misses never return the Hub page. The canonical root without its final slash redirects with 308 and preserves its query. -Hub rejects malformed provider IDs, traversal, encoded separators, backslashes, controls, and unsafe package paths before storage access. `/` serves `dist/index.html`; a directory first tries its nested `index.html`. Missing extensionless HTML navigations may use the root SPA document. Dotted routes receive that fallback only when the saved template manifest declares them. Missing scripts and other assets return 404. Content types come from the stored path and responses disable MIME sniffing. +Hub rejects malformed provider IDs, traversal, encoded separators, backslashes, controls, and unsafe package paths before storage access. Paths are decoded once, so accepted literal-percent filenames remain usable. `/` serves `dist/index.html`; a slash-terminated directory first tries its nested `index.html`. Missing extensionless HTML navigations may use the root SPA document. Dotted routes receive that fallback only when the saved template manifest declares them. Missing scripts and other assets return 404. Screenshot capture uses the same slash-sensitive document selection. Content types come from the stored path and responses disable MIME sniffing. Hub injects only its prefixed `__replica/bridge/v1.js` script into HTML. `__replica/` is reserved for that bridge and authorized screenshots. Controls load the retained Build's own `controls.replica.json`. Review and canvas messages still validate their schema, origin, and source frame. Review anchors store logical paths relative to the Build root, compare consistently across owning-run mounts, and retain query and fragment encoding. Navigation adds the active Build prefix again. Templates and public shares do not enable review. @@ -58,6 +60,6 @@ Private responses retain CSP with `frame-ancestors 'self'`, no referrers, no MIM ## Rollout and rollback -Deploy the new Hub image through the installation's normal release process, upgrade the screenshot action, and rebuild affected prototypes with the canonical base. No database migration or wildcard configuration is needed for private GitHub previews. Keep configured wildcard infrastructure only for existing public sharing; retiring it is a separate decision. +Apply the non-unique Build run-ID index migration through normal setup, deploy the new Hub image, upgrade the screenshot action, and rebuild affected prototypes with the canonical base. The migration changes no stored Build or artifact data. No wildcard configuration is needed for private GitHub previews. Keep configured wildcard infrastructure only for existing public sharing; retiring it is a separate decision. The installer does not modify existing prototype compiler or workflow settings. Non-GitHub path mounts, public-sharing migration, package base metadata, and arbitrary post-build relocation are not included. Rollback changes the Hub image, not stored Builds or artifacts. A previously working wildcard installation also needs its retained configuration, DNS, and TLS; an installation without them returns to its former no-preview behavior. diff --git a/hub/docs/github-actions-builds.md b/hub/docs/github-actions-builds.md index a349ddfce..1c918f5d8 100644 --- a/hub/docs/github-actions-builds.md +++ b/hub/docs/github-actions-builds.md @@ -83,12 +83,7 @@ Keep publish last in its job: later steps delay the completed-job event used for The optional [build action](../../actions/build/action.yml) is still available. It runs `npm ci` and `npm run build` as a non-root user in a Node container. With `screenshots: separate`, it uploads the same dist package as the publish action and can replace the build steps and publish action above. Existing single-job workflows remain compatible: `screenshots` defaults to `inline`, which uploads one package containing the dist and screenshots, so Hub imports it only after screenshots finish. -For a fixed-base app, upgrade the action references to a reviewed revision containing `base-path` support before configuring capture. Set the app's compiler base using its supported configuration, such as `VITE_BASE`, and pass the same original base to the screenshot step: - -```yaml -with: - base-path: /previews/github/${{ github.repository_id }}/${{ github.run_id }}/ -``` +For a fixed-base app, upgrade the action references to a reviewed revision containing `base-path` support before configuring capture. Set the app's compiler base using its supported configuration, such as `VITE_BASE`, and pass `base-path: /previews/github/${{ github.repository_id }}/${{ github.run_id }}/` under `with` on the screenshot step. The same input applies to inline capture in `actions/build`; it does not configure the compiler in that action's build container. Capture mounts the downloaded `dist` at that path and joins the root and logical template routes beneath it, preserving query and fragment. The default `/` remains available for root-base or relative-output apps. The earlier pinned example above works for Starter's relative output; it must be upgraded before adding this new input. diff --git a/hub/schema/build.prisma b/hub/schema/build.prisma index 5461786bc..5be79bf05 100644 --- a/hub/schema/build.prisma +++ b/hub/schema/build.prisma @@ -42,5 +42,6 @@ model Build { @@unique([id, prototypeId]) @@unique([prototypeId, number]) @@unique([prototypeId, commitSha]) + @@index([githubWorkflowRunId]) @@map("builds") } diff --git a/hub/schema/migrations/20261220120000_build_preview_run_lookup/migration.sql b/hub/schema/migrations/20261220120000_build_preview_run_lookup/migration.sql new file mode 100644 index 000000000..d70d4df33 --- /dev/null +++ b/hub/schema/migrations/20261220120000_build_preview_run_lookup/migration.sql @@ -0,0 +1,2 @@ +-- CreateIndex +CREATE INDEX "builds_github_workflow_run_id_idx" ON "builds"("github_workflow_run_id"); diff --git a/hub/server/domains/build-preview/read-build-preview-file/index.ts b/hub/server/domains/build-preview/read-build-preview-file/index.ts index 7514cb36f..60313aef3 100644 --- a/hub/server/domains/build-preview/read-build-preview-file/index.ts +++ b/hub/server/domains/build-preview/read-build-preview-file/index.ts @@ -1,3 +1,5 @@ +import { createHash } from "node:crypto" + import { contentTypeForBuildPath } from "../../build-artifacts/content-type-for-build-path/index.ts" import { normalizeBuildArtifactPath } from "../../build-artifacts/normalize-build-artifact-path/index.ts" import { injectPreviewBridge } from "../inject-preview-bridge/index.ts" @@ -28,7 +30,6 @@ function readDeclaredRoutePathnames(bytes: Uint8Array): string[] { return [] } } - export async function readBuildPreviewFile( input: ReadBuildPreviewFileInput, dependencies: ReadBuildPreviewFileDependencies, @@ -89,6 +90,23 @@ export async function readBuildPreviewFile( } if (!artifact) return { status: "not-found" } + const contentType = contentTypeForBuildPath(path) + const html = contentType.startsWith("text/html") + const etag = + !html && path.startsWith("dist/") + ? `"${createHash("sha256") + .update(JSON.stringify([input.buildId, path, artifact.storageKey, artifact.byteLength])) + .digest("hex")}"` + : undefined + if ( + etag && + input.ifNoneMatch?.split(",").some((value) => { + const validator = value.trim() + return validator === "*" || validator.replace(/^W\//, "") === etag + }) + ) + return { status: "not-modified", etag } + if (dependencies.reserveBytes?.(artifact.byteLength) === null) { return { status: "unavailable" } } @@ -98,12 +116,11 @@ export async function readBuildPreviewFile( } if (stored.bytes.byteLength > artifact.byteLength) return { status: "unavailable" } - const contentType = contentTypeForBuildPath(path) - const html = contentType.startsWith("text/html") return { status: "ok", bytes: html ? injectPreviewBridge(stored.bytes, input.mountPath) : stored.bytes, contentType, html, + ...(etag ? { etag } : {}), } } diff --git a/hub/server/domains/build-preview/read-build-preview-file/types.ts b/hub/server/domains/build-preview/read-build-preview-file/types.ts index 127de6b48..18883b012 100644 --- a/hub/server/domains/build-preview/read-build-preview-file/types.ts +++ b/hub/server/domains/build-preview/read-build-preview-file/types.ts @@ -6,6 +6,7 @@ export interface ReadBuildPreviewFileInput { distOnly?: boolean requestPath: string mountPath?: string + ifNoneMatch?: string } export interface ReadBuildPreviewFileDependencies { @@ -20,9 +21,11 @@ export interface ReadBuildPreviewFileDependencies { export type BuildPreviewFileResult = | { status: "not-found" } | { status: "unavailable" } + | { status: "not-modified"; etag: string } | { status: "ok" bytes: Uint8Array contentType: string html: boolean + etag?: string } diff --git a/hub/server/repositories/build-artifacts/find-path-preview-targets/index.db.test.ts b/hub/server/repositories/build-artifacts/find-path-preview-targets/index.db.test.ts index 62cc958db..3d79380b5 100644 --- a/hub/server/repositories/build-artifacts/find-path-preview-targets/index.db.test.ts +++ b/hub/server/repositories/build-artifacts/find-path-preview-targets/index.db.test.ts @@ -135,6 +135,36 @@ describe("findPathPreviewTargets()", () => { } }) + it.each(["retired branch", "missing entry artifact", "Replica branch"])( + "does not retarget an ambiguous owning run after one owner becomes a %s", + async (change) => { + const repository = await createRepository() + const first = await createBuild(repository.id) + const second = await createBuild(repository.id) + const input = { + githubRepositoryId: "9007199254740993", + githubWorkflowRunId: "9007199254740995", + } + expect(await findPathPreviewTargets(prisma, input)).toHaveLength(2) + + if (change === "missing entry artifact") { + await prisma.buildArtifact.deleteMany({ where: { buildId: second.id } }) + } else { + await prisma.prototype.update({ + where: { id: second.prototypeId }, + data: change === "retired branch" ? { branchDeletedAt: new Date() } : { replica: true }, + }) + } + + const targets = await findPathPreviewTargets(prisma, input) + expect(targets).toHaveLength(2) + expect(targets.map(({ buildId }) => buildId).sort()).toEqual([first.id, second.id].sort()) + expect(await prisma.build.count({ where: { githubWorkflowRunId: 9007199254740995n } })).toBe( + 2, + ) + }, + ) + it("marks default-branch artifacts as templates and excludes workflow installation branches", async () => { const repository = await createRepository() const template = await createBuild(repository.id, { branchName: "main", runId: 201n }) diff --git a/hub/server/repositories/build-artifacts/find-path-preview-targets/index.ts b/hub/server/repositories/build-artifacts/find-path-preview-targets/index.ts index dd00a3b48..61a64b8e3 100644 --- a/hub/server/repositories/build-artifacts/find-path-preview-targets/index.ts +++ b/hub/server/repositories/build-artifacts/find-path-preview-targets/index.ts @@ -8,37 +8,46 @@ export async function findPathPreviewTargets( where: { state: "successful", githubWorkflowRunId: BigInt(input.githubWorkflowRunId), - artifacts: { some: { kind: "dist", path: "dist/index.html" } }, prototype: { - branchDeletedAt: null, - branchName: { not: "replica/install-workflow" }, repository: { githubRepositoryId: BigInt(input.githubRepositoryId), - removedAt: null, - localPath: null, }, }, }, take: 2, select: { id: true, + artifacts: { where: { kind: "dist", path: "dist/index.html" }, select: { id: true } }, prototype: { select: { replica: true, + branchDeletedAt: true, branchName: true, - repository: { select: { id: true, defaultBranch: true } }, + repository: { + select: { id: true, defaultBranch: true, removedAt: true, localPath: true }, + }, }, }, }, }) - if ( - builds.length === 1 && - builds[0]!.prototype.replica && - builds[0]!.prototype.branchName !== builds[0]!.prototype.repository.defaultBranch - ) - return [] + if (builds.length === 1) { + const { prototype, artifacts } = builds[0]! + if ( + artifacts.length === 0 || + prototype.branchDeletedAt || + prototype.branchName === "replica/install-workflow" || + prototype.repository.removedAt || + prototype.repository.localPath || + (prototype.replica && prototype.branchName !== prototype.repository.defaultBranch) + ) + return [] + } return builds.map(({ id, prototype }) => { const template = prototype.branchName === prototype.repository.defaultBranch - return { buildId: id, repository: { id: prototype.repository.id, local: false }, template } + return { + buildId: id, + repository: { id: prototype.repository.id, local: Boolean(prototype.repository.localPath) }, + template, + } }) } diff --git a/hub/server/repositories/prototype-index/find-prototype-detail/index.db.test.ts b/hub/server/repositories/prototype-index/find-prototype-detail/index.db.test.ts index 68410906d..370ee4dbc 100644 --- a/hub/server/repositories/prototype-index/find-prototype-detail/index.db.test.ts +++ b/hub/server/repositories/prototype-index/find-prototype-detail/index.db.test.ts @@ -152,6 +152,34 @@ describe("findPrototypeDetail()", () => { narrowScreenshotUrl: "/previews/github/2001/3002/__replica/screenshots/narrow.png", }) expect(detail?.controlsIdentity).toBe("controls-binding") + + await prisma.prototype.update({ + where: { id: prototypeId }, + data: { branchDeletedAt: new Date() }, + }) + const retired = await findPrototypeDetail( + prisma, + repositoryId, + prototypeId, + 42, + { page: 1, pageSize: 25 }, + null, + (mountPath, target) => (mountPath ? `${mountPath}${target}` : null), + ) + expect(retired?.selectedBuild).toMatchObject({ number: 42, state: "successful" }) + for (const build of [ + retired?.selectedBuild, + ...(retired?.prototype.builds ?? []), + ...(retired?.buildPage?.builds ?? []), + ]) { + expect(build).toMatchObject({ + number: 42, + state: "successful", + previewUrl: null, + desktopScreenshotUrl: null, + narrowScreenshotUrl: null, + }) + } }) it("bounds database results on later pages while retaining the global current Build", async () => { diff --git a/hub/server/repositories/prototype-index/find-prototype-detail/index.ts b/hub/server/repositories/prototype-index/find-prototype-detail/index.ts index 5022b51d0..176bd6de6 100644 --- a/hub/server/repositories/prototype-index/find-prototype-detail/index.ts +++ b/hub/server/repositories/prototype-index/find-prototype-detail/index.ts @@ -46,6 +46,7 @@ export async function findPrototypeDetail( description: true, startPage: true, branchName: true, + branchDeletedAt: true, author: { select: { profile: { select: { login: true, name: true, provider: true } } } }, currentBuildId: true, }, @@ -161,7 +162,9 @@ export async function findPrototypeDetail( repositoryId: prototype.repositoryId, prototypeId: prototype.id, previewUrl: - build.artifacts.some(({ path }) => path === "dist/index.html") && buildArtifactUrl + !prototype.branchDeletedAt && + build.artifacts.some(({ path }) => path === "dist/index.html") && + buildArtifactUrl ? buildArtifactUrl( createBuildPreviewPath(repository.githubRepositoryId, build.githubWorkflowRunId), "preview", @@ -169,14 +172,18 @@ export async function findPrototypeDetail( ) : null, desktopScreenshotUrl: - build.artifacts.some(({ path }) => path === "screenshots/desktop.png") && buildArtifactUrl + !prototype.branchDeletedAt && + build.artifacts.some(({ path }) => path === "screenshots/desktop.png") && + buildArtifactUrl ? buildArtifactUrl( createBuildPreviewPath(repository.githubRepositoryId, build.githubWorkflowRunId), "desktop", ) : null, narrowScreenshotUrl: - build.artifacts.some(({ path }) => path === "screenshots/narrow.png") && buildArtifactUrl + !prototype.branchDeletedAt && + build.artifacts.some(({ path }) => path === "screenshots/narrow.png") && + buildArtifactUrl ? buildArtifactUrl( createBuildPreviewPath(repository.githubRepositoryId, build.githubWorkflowRunId), "narrow", diff --git a/hub/server/repositories/prototype-index/find-repository-index/index.ts b/hub/server/repositories/prototype-index/find-repository-index/index.ts index 3305ca9b5..6e9718718 100644 --- a/hub/server/repositories/prototype-index/find-repository-index/index.ts +++ b/hub/server/repositories/prototype-index/find-repository-index/index.ts @@ -1,6 +1,7 @@ import { Prisma, type BuildState, type PrismaClient } from "../../../generated/prisma/client.ts" import { containsText } from "../contains-text/index.ts" import { reviewablePrototypeWhere } from "../reviewable-prototype-where/index.ts" +import { createBuildPreviewPath } from "../../../utils/create-build-preview-path/index.ts" import { type RepositoryScope, visibleRepositoryWhere } from "../visible-repository-where/index.ts" const pageSize = 24 @@ -20,17 +21,11 @@ export async function findRepositoryIndex( repositoryId: string, filters: RepositoryIndexFilters = { query: "", authorId: null, page: 1 }, scope: RepositoryScope = null, - buildArtifactUrl?: ( - buildId: string, - repositoryId: string, - prototypeId: string, - buildNumber: number, - target: "desktop", - ) => string, + buildArtifactUrl?: (mountPath: string | null, target: "desktop") => string | null, ) { const repository = await database.repository.findFirst({ where: { id: repositoryId, ...visibleRepositoryWhere(scope) }, - select: { id: true, nameWithOwner: true, defaultBranch: true }, + select: { id: true, nameWithOwner: true, defaultBranch: true, githubRepositoryId: true }, }) if (!repository) return null @@ -157,12 +152,19 @@ export async function findRepositoryIndex( const reviewBuilds = buildArtifactUrl && records.length > 0 ? await transaction.$queryRaw< - { prototypeId: string; id: string; number: number; hasScreenshot: boolean }[] + { + prototypeId: string + id: string + number: number + hasScreenshot: boolean + githubWorkflowRunId: bigint | null + }[] >(Prisma.sql` SELECT prototypes.id AS "prototypeId", review_build.* FROM prototypes JOIN LATERAL ( - SELECT builds.id, builds.number, (screenshot.id IS NOT NULL) AS "hasScreenshot" + SELECT builds.id, builds.number, (screenshot.id IS NOT NULL) AS "hasScreenshot", + builds.github_workflow_run_id AS "githubWorkflowRunId" FROM builds JOIN build_artifacts AS dist ON dist.build_id = builds.id AND dist.path = 'dist/index.html' AND dist.kind = 'dist' @@ -242,10 +244,10 @@ export async function findRepositoryIndex( desktopScreenshotUrl: preview.hasScreenshot && buildArtifactUrl ? buildArtifactUrl( - preview.id, - record.repositoryId, - record.id, - preview.number, + createBuildPreviewPath( + repository.githubRepositoryId, + preview.githubWorkflowRunId, + ), "desktop", ) : null, @@ -255,7 +257,11 @@ export async function findRepositoryIndex( } }) return { - repository, + repository: { + id: repository.id, + nameWithOwner: repository.nameWithOwner, + defaultBranch: repository.defaultBranch, + }, prototypes, authors: [...authors.values()], pagination: { diff --git a/hub/server/routes/api/product-index/index.db.test.ts b/hub/server/routes/api/product-index/index.db.test.ts index 43203d89f..e5a938876 100644 --- a/hub/server/routes/api/product-index/index.db.test.ts +++ b/hub/server/routes/api/product-index/index.db.test.ts @@ -198,9 +198,8 @@ describe("real product index", () => { it("pins the gallery screenshot to the newest eligible Build without returning Build history", async () => { const applicationOrigin = "http://127.0.0.1:5173" - const previewBaseOrigin = "http://preview.localhost:3001" const { id: repositoryId } = await prisma.repository.create({ - data: { nameWithOwner: "team/design", defaultBranch: "main" }, + data: { githubRepositoryId: 2001n, nameWithOwner: "team/design", defaultBranch: "main" }, }) const registeredAt = new Date("2026-10-01") const entry = { kind: "dist", path: "dist/index.html" } as const @@ -231,6 +230,7 @@ describe("real product index", () => { id: reviewBuildId, number: 2, state: "successful", + githubWorkflowRunId: 3002n, createdAt: new Date("2026-10-03"), artifacts: artifacts(entry, desktop), }, @@ -275,7 +275,7 @@ describe("real product index", () => { name: "Mona", role: "MEMBER", }) - const product = createProductRouteDependencies({ applicationOrigin, previewBaseOrigin }) + const product = createProductRouteDependencies({ applicationOrigin }) await withServer(restore, product, async (baseUrl) => { const response = await fetch(`${baseUrl}/api/repositories/${repositoryId}`, { headers: { cookie: "hub_session=member-session" }, @@ -298,12 +298,9 @@ describe("real product index", () => { const screenshotUrl = new URL(desktopScreenshotUrl ?? "") expect(screenshotUrl.origin).toBe(applicationOrigin) expect(screenshotUrl.pathname).toBe( - `/api/repositories/${repositoryId}/prototypes/${prototypeId}/builds/2/access`, - ) - expect(screenshotUrl.searchParams.get("target")).toBe("desktop") - expect([null, `http://${reviewBuildId}.preview.localhost:3001`]).toContain( - screenshotUrl.searchParams.get("preview_origin"), + "/previews/github/2001/3002/__replica/screenshots/desktop.png", ) + expect(screenshotUrl.search).toBe("") expect(index.prototypes.find(({ id }) => id === previewOnlyPrototypeId)).toMatchObject({ reviewBuild: { number: 1, desktopScreenshotUrl: null }, builds: [], diff --git a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts index 4fd8f4eca..2447bbae4 100644 --- a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts +++ b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.test.ts @@ -181,6 +181,44 @@ describe("get()", () => { }) }) + it("uses the same unavailable response for an invisible identifierless Build and an absent target", async () => { + const viewer = { + membershipId: randomUUID(), + userId: randomUUID(), + provider: "github", + sessionProvider: "github", + login: "mona", + name: "Mona", + role: "MEMBER" as const, + } + const restore = vi.fn() + await withAccessRoute(async (url, product) => { + product.findBuildPreviewTarget.mockResolvedValue({ + buildId: randomUUID(), + startPage: "/", + artifactPath: "dist/index.html", + mountPath: null, + }) + restore.mockResolvedValueOnce(viewer).mockImplementation(() => { + vi.mocked(product.isRepositoryVisible).mockResolvedValue(false) + return Promise.resolve(viewer) + }) + const headers = { cookie: "hub_session=member-session" } + const invisible = await fetch(`${url}?target=preview`, { headers, redirect: "manual" }) + expect(invisible.status).toBe(404) + expect(product.findBuildPreviewTarget).toHaveBeenCalledOnce() + + restore.mockResolvedValue(viewer) + vi.mocked(product.isRepositoryVisible).mockResolvedValue(true) + product.findBuildPreviewTarget.mockResolvedValue(null) + const absent = await fetch(`${url}?target=preview`, { headers, redirect: "manual" }) + expect(absent.status).toBe(404) + expect(await invisible.json()).toEqual(await absent.json()) + expect(invisible.headers.get("location")).toBeNull() + expect(absent.headers.get("location")).toBeNull() + }, restore) + }) + it("discards the target when session authority changes during the read", async () => { const viewer = { membershipId: randomUUID(), diff --git a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts index fd3f803d0..05b3075d8 100644 --- a/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts +++ b/hub/server/routes/api/repositories/prototypes/builds/access/get/index.ts @@ -60,7 +60,7 @@ export function get( return } const target = read.result - if (!target) { + if (!target || !(await product.isRepositoryVisible(read.current, repositoryId.data))) { response.status(404).json({ error: "Build preview not found." }) return } @@ -73,10 +73,6 @@ export function get( response.status(404).json({ error: "This Build has no supported hosted preview address." }) return } - if (!(await product.isRepositoryVisible(current, repositoryId.data))) { - response.status(404).json({ error: "Build preview not found." }) - return - } const path = query.data.target === "preview" ? (requestedRoute ?? normalizeStartPage(target.startPage) ?? "/") diff --git a/hub/server/routes/build-preview/create-preview-response-reservation/index.ts b/hub/server/routes/build-preview/create-preview-response-reservation/index.ts new file mode 100644 index 000000000..a40b9e804 --- /dev/null +++ b/hub/server/routes/build-preview/create-preview-response-reservation/index.ts @@ -0,0 +1,45 @@ +import type { Response } from "express" + +import { reserveBuildPreviewBytes } from "../../../domains/build-preview/reserve-build-preview-bytes/index.ts" + +export function createPreviewResponseReservation(response: Response) { + const reservations = new Set<() => void>() + let handlingRequest = true + let responseEnded = response.destroyed || response.writableFinished + + function releaseReservations() { + // A disconnected response can still have an uncancelled storage read in flight. + if (handlingRequest || !responseEnded) return + response.off("finish", onResponseEnd) + response.off("close", onResponseEnd) + for (const release of reservations) release() + } + + function onResponseEnd() { + responseEnded = true + releaseReservations() + } + + response.once("finish", onResponseEnd) + response.once("close", onResponseEnd) + + function reserveBytes(byteLength: number) { + if (responseEnded) return null + const reservation = reserveBuildPreviewBytes(byteLength) + if (!reservation) return null + const release = reservation + function trackedRelease() { + reservations.delete(trackedRelease) + release() + } + reservations.add(trackedRelease) + return trackedRelease + } + + function completeRequest() { + handlingRequest = false + releaseReservations() + } + + return { reserveBytes, completeRequest } +} diff --git a/hub/server/routes/build-preview/path/get/index.db.test.ts b/hub/server/routes/build-preview/path/get/index.db.test.ts index 6fefac57a..d9eda46ec 100644 --- a/hub/server/routes/build-preview/path/get/index.db.test.ts +++ b/hub/server/routes/build-preview/path/get/index.db.test.ts @@ -98,6 +98,8 @@ describe("private preview composition", () => { data: { repositoryId: repository.id, branchName: "proto/checkout", + name: "Checkout", + registeredAt: new Date(), startPage: "/checkout?stage=shipping#address", }, }) @@ -105,7 +107,9 @@ describe("private preview composition", () => { const packageFiles = new Map([ [ "dist/index.html", - new TextEncoder().encode("Saved checkout"), + new TextEncoder().encode( + 'Saved checkout', + ), ], ["dist/assets/app.css", new TextEncoder().encode("body { display: block }")], ["screenshots/desktop.png", png], @@ -119,6 +123,7 @@ describe("private preview composition", () => { state: "successful", commitSha: "a".repeat(40), githubWorkflowRunId: 3002n, + createdAt: new Date("2026-10-01"), artifacts: { create: Array.from(packageFiles, ([path, bytes]) => { const storageKey = randomUUID() @@ -137,6 +142,23 @@ describe("private preview composition", () => { where: { id: prototype.id }, data: { currentBuildId: build.id }, }) + await prisma.build.create({ + data: { + prototypeId: prototype.id, + number: 2, + state: "successful", + githubWorkflowRunId: 3003n, + createdAt: new Date("2026-10-02"), + artifacts: { + create: { + path: "dist/index.html", + kind: "dist", + storageKey: randomUUID(), + byteLength: 10, + }, + }, + }, + }) const read = vi.fn((key) => { const bytes = bytesByKey.get(key) return Promise.resolve(bytes ? { status: "ok", bytes } : { status: "not-found" }) @@ -162,8 +184,28 @@ describe("private preview composition", () => { }), ) const headers = { cookie: `hub_session=${token}`, accept: "text/html" } + const gallery = await fetch(`${origin}/api/repositories/${repository.id}`, { headers }) + expect(gallery.status).toBe(200) + const index = (await gallery.json()) as { + prototypes: { + id: string + reviewBuild: { number: number; desktopScreenshotUrl: string } + }[] + } + const card = index.prototypes.find(({ id }) => id === prototype.id) + const galleryImageUrl = `${origin}/previews/github/2001/3002/__replica/screenshots/desktop.png` + expect(card).toMatchObject({ + latestBuild: { number: 1, state: "successful" }, + reviewBuild: { number: 1, desktopScreenshotUrl: galleryImageUrl }, + builds: [], + }) + const galleryImage = await fetch(card!.reviewBuild.desktopScreenshotUrl, { headers }) + expect(galleryImage.status).toBe(200) + expect(galleryImage.headers.get("content-type")).toBe("image/png") + expect(new Uint8Array(await galleryImage.arrayBuffer())).toEqual(png) + const detail = await fetch( - `${origin}/api/repositories/${repository.id}/prototypes/${prototype.id}`, + `${origin}/api/repositories/${repository.id}/prototypes/${prototype.id}?build=1`, { headers }, ) expect(detail.status).toBe(200) diff --git a/hub/server/routes/build-preview/path/get/index.test.ts b/hub/server/routes/build-preview/path/get/index.test.ts index eecdc0e11..c400d2997 100644 --- a/hub/server/routes/build-preview/path/get/index.test.ts +++ b/hub/server/routes/build-preview/path/get/index.test.ts @@ -1,13 +1,19 @@ import { randomBytes, randomUUID } from "node:crypto" import { once } from "node:events" import { mkdir, rm, writeFile } from "node:fs/promises" -import { createServer, request as httpRequest, type IncomingHttpHeaders } from "node:http" +import { + createServer, + request as httpRequest, + type IncomingHttpHeaders, + type ServerResponse, +} from "node:http" import type { AddressInfo } from "node:net" import { join, resolve } from "node:path" import { describe, expect, it, onTestFinished, vi } from "vitest" import { createApp } from "../../../../create-app" import type { ArtifactStorage } from "../../../../domains/artifacts/create-artifact-storage/types" +import { reserveBuildPreviewBytes } from "../../../../domains/build-preview/reserve-build-preview-bytes" import { createSharePreviewSession } from "../../../../domains/public-sharing/create-share-preview-session" import { createLogger } from "../../../../integrations/pino/create-logger" import type { AuthenticationRouteDependencies } from "../../../api/auth/types" @@ -20,16 +26,25 @@ interface RouteResponse { body: Buffer } +function deferred() { + let resolve!: (value: T) => void + const promise = new Promise((settle) => { + resolve = settle + }) + return { promise, resolve } +} + async function request( origin: string, path: string, headers: Record = { cookie: "hub_session=member-session" }, method = "GET", + signal?: AbortSignal, ): Promise { return new Promise((resolve, reject) => { const url = new URL(origin) const outgoing = httpRequest( - { hostname: url.hostname, port: url.port, path, headers, method }, + { hostname: url.hostname, port: url.port, path, headers, method, signal }, (response) => { const chunks: Buffer[] = [] response.on("data", (chunk: Buffer) => chunks.push(chunk)) @@ -47,7 +62,10 @@ async function request( }) } -async function createFixture() { +async function createFixture( + observeResponse?: (response: ServerResponse, requestPath: string) => void, + options: { publicSharing?: boolean } = {}, +) { const directory = resolve(`server/routes/build-preview/path/get/.preview-test-${randomUUID()}`) const clientDirectory = join(directory, "client") await mkdir(clientDirectory, { recursive: true }) @@ -132,6 +150,7 @@ async function createFixture() { const { port } = server.address() as AddressInfo const origin = `http://127.0.0.1:${port}` preview.applicationOrigin = origin + if (options.publicSharing) preview.previewBaseOrigin = `http://preview.localhost:${port}` server.on( "request", createApp({ @@ -145,6 +164,11 @@ async function createFixture() { product, }), ) + if (observeResponse) { + server.prependListener("request", (request, response) => { + observeResponse(response, request.url?.split("?")[0] ?? "") + }) + } return { origin, mountPath, @@ -259,6 +283,21 @@ describe("get()", () => { expect(response.headers.location).toBe(`${mountPath}/?step=shipping&return=%2Fcart`) }) + it("serves literal percent filenames without decoding their bytes twice", async () => { + const { origin, mountPath, save } = await createFixture() + save("dist/assets/100%complete.bin", "literal percent bytes") + save("dist/assets/%2f.bin", "literal encoded separator bytes") + + for (const [path, expected] of [ + ["/assets/100%25complete.bin", "literal percent bytes"], + ["/assets/%252f.bin", "literal encoded separator bytes"], + ]) { + const response = await request(origin, `${mountPath}${path}`) + expect(response.status, path).toBe(200) + expect(response.body.toString(), path).toBe(expected) + } + }) + it("rejects malformed identifiers and unsafe raw paths before reading storage or the Hub shell", async () => { const { origin, mountPath, storage, findArtifact } = await createFixture() const read = vi.spyOn(storage, "read") @@ -273,7 +312,6 @@ describe("get()", () => { "/previews/github/2001/%33%30%30%32/", `${mountPath}/../private`, `${mountPath}/%2e%2e/private`, - `${mountPath}/%252e%252e/private`, `${mountPath}/assets%2fprivate`, `${mountPath}/assets%5cprivate`, `${mountPath}/assets\\private`, @@ -321,25 +359,155 @@ describe("get()", () => { expect(readAvailableShareLink).not.toHaveBeenCalled() }) - it.each(["session expiry", "repository revocation"])( - "rechecks %s on a subsequent asset request", + it.each(["session expiry", "repository revocation", "ownership ambiguity"])( + "rechecks %s before responding to a cached asset request", async (change) => { - const { origin, mountPath, save, restore, isRepositoryVisible } = await createFixture() + const { + origin, + mountPath, + save, + restore, + isRepositoryVisible, + findPathTargets, + target, + storage, + } = await createFixture() save("dist/assets/app.css", "private-asset") + const read = vi.spyOn(storage, "read") const first = await request(origin, `${mountPath}/assets/app.css`) expect(first.status).toBe(200) expect(first.body.toString()).toBe("private-asset") expect(first.headers["cache-control"]).toMatch(/\b(?:no-cache|no-store)\b/) + expect(first.headers.etag).toBeTypeOf("string") + read.mockClear() if (change === "session expiry") restore.mockResolvedValue(null) - else isRepositoryVisible.mockResolvedValue(false) - const denied = await request(origin, `${mountPath}/assets/app.css`) + else if (change === "repository revocation") isRepositoryVisible.mockResolvedValue(false) + else findPathTargets.mockResolvedValue([target, { ...target, buildId: randomUUID() }]) + const denied = await request(origin, `${mountPath}/assets/app.css`, { + cookie: "hub_session=member-session", + "if-none-match": first.headers.etag!, + }) expect(denied.status).toBe(change === "session expiry" ? 401 : 404) expect(denied.body.toString()).not.toContain("private-asset") + expect(read).not.toHaveBeenCalled() }, ) + it("revalidates immutable assets without storage or source quota and reads mismatched validators", async () => { + const { origin, mountPath, save, storage } = await createFixture() + save("dist/assets/app.css", "private-asset") + const read = vi.spyOn(storage, "read") + const first = await request(origin, `${mountPath}/assets/app.css`) + expect(first.status).toBe(200) + expect(first.headers.etag).toMatch(/^"[^"]+"$/) + const etag = first.headers.etag! + read.mockClear() + const release = reserveBuildPreviewBytes(100 * 1024 * 1024) + if (!release) throw new Error("The test could not reserve the source-byte budget.") + try { + for (const validator of [etag, `"other", W/${etag}`, "*"]) { + const cached = await request(origin, `${mountPath}/assets/app.css`, { + cookie: "hub_session=member-session", + "if-none-match": validator, + }) + expect(cached.status, validator).toBe(304) + expect(cached.headers.etag).toBe(etag) + expect(cached.headers["cache-control"]).toBe("private, no-cache") + expect(cached.body).toHaveLength(0) + } + expect(read).not.toHaveBeenCalled() + } finally { + release() + } + const changed = await request(origin, `${mountPath}/assets/app.css`, { + cookie: "hub_session=member-session", + "if-none-match": '"different-artifact"', + }) + expect(changed.status).toBe(200) + expect(changed.headers.etag).toBe(etag) + expect(changed.body.toString()).toBe("private-asset") + expect(read).toHaveBeenCalledOnce() + }) + + it("rechecks authorization after a matching artifact lookup before returning 304", async () => { + const { origin, mountPath, save, findArtifact, isRepositoryVisible, storage } = + await createFixture() + save("dist/assets/app.css", "private-asset") + const first = await request(origin, `${mountPath}/assets/app.css`) + expect(first.headers.etag).toBeTypeOf("string") + const lookup = findArtifact.getMockImplementation()! + findArtifact.mockImplementation(async (id, path) => { + const artifact = await lookup(id, path) + isRepositoryVisible.mockResolvedValue(false) + return artifact + }) + const read = vi.spyOn(storage, "read") + + const response = await request(origin, `${mountPath}/assets/app.css`, { + cookie: "hub_session=member-session", + "if-none-match": first.headers.etag!, + }) + expect(response.status).toBe(404) + expect(response.body).toHaveLength(0) + expect(read).not.toHaveBeenCalled() + }) + + it("does not reuse asset validators for HTML, bridge scripts or private screenshots", async () => { + const { origin, mountPath, save } = await createFixture() + save("dist/index.html", "Private document") + save("screenshots/desktop.png", Uint8Array.of(7, 8)) + for (const path of ["/", "/__replica/bridge/v1.js", "/__replica/screenshots/desktop.png"]) { + const response = await request(origin, `${mountPath}${path}`, { + cookie: "hub_session=member-session", + accept: "text/html", + "if-none-match": "*", + }) + expect(response.status, path).toBe(200) + expect(response.body.byteLength, path).toBeGreaterThan(0) + expect(response.headers.etag, path).toBeUndefined() + } + }) + + it("serves public-share files under previews before the private mount while retaining revocation", async () => { + const { origin, mountPath, preview, target, save, readAvailableShareLink } = + await createFixture(undefined, { publicSharing: true }) + save("dist/previews/app.js", "public preview asset") + save("dist/index.html", "Public preview SPA") + const shareSession = createSharePreviewSession( + { + buildId: target.buildId, + shareLinkId: randomUUID(), + expiresAt: new Date(Date.now() + 60_000), + }, + preview.encryptionKey, + ) + const headers = { + host: `${target.buildId}.preview.localhost:${new URL(origin).port}`, + cookie: `replica_share_preview=${encodeURIComponent(shareSession)}`, + accept: "text/html", + } + const asset = await request(origin, "/previews/app.js", headers) + const route = await request(origin, "/previews/route", headers) + expect(asset.status).toBe(200) + expect(asset.body.toString()).toBe("public preview asset") + expect(route.status).toBe(200) + expect(route.body.toString()).toContain("Public preview SPA") + + readAvailableShareLink.mockResolvedValue(null) + for (const path of ["/previews/app.js", "/previews/route"]) { + const revoked = await request(origin, path, headers) + expect(revoked.status).toBe(404) + expect(revoked.body.toString()).not.toContain("Public preview") + expect(revoked.body.toString()).not.toContain("Hub shell marker") + } + const privateResponse = await request(origin, `${mountPath}/`, { accept: "text/html" }) + expect(privateResponse.status).toBe(401) + expect(privateResponse.body.toString()).not.toContain("Hub shell marker") + expect((await request(origin, "/previews/route", { accept: "text/html" })).status).toBe(404) + }) + it("denies the bridge when the same Build becomes a template during authorization", async () => { const { origin, mountPath, preview, target, findPathTargets, findArtifact, storage } = await createFixture() @@ -489,4 +657,233 @@ describe("get()", () => { expect(response.status).toBe(404) expect(read).not.toHaveBeenCalled() }) + + it("returns unavailable before reading storage when the process-wide source budget is exhausted", async () => { + const { origin, mountPath, save, storage, findPathTargets } = await createFixture() + save("dist/assets/app.css", "private-asset") + const read = vi.spyOn(storage, "read") + const release = reserveBuildPreviewBytes(100 * 1024 * 1024) + if (!release) throw new Error("The test could not reserve the source-byte budget.") + + try { + const response = await request(origin, `${mountPath}/assets/app.css`) + + expect(findPathTargets).toHaveBeenCalledWith("2001", "3002") + expect(response.status).toBe(503) + expect(read).not.toHaveBeenCalled() + } finally { + release() + } + }) + + it("shares the minimum source reservation across private, template and public requests on different servers", async () => { + const privateRoute = await createFixture() + const otherRoute = await createFixture(undefined, { publicSharing: true }) + otherRoute.findPathTargets.mockResolvedValue([{ ...otherRoute.target, template: true }]) + privateRoute.save("dist/asset.bin", Uint8Array.of(1)) + otherRoute.save("dist/asset.bin", Uint8Array.of(7)) + const readStarted = deferred() + const stored = deferred>>() + const privateRead = vi.spyOn(privateRoute.storage, "read").mockImplementation(() => { + readStarted.resolve() + return stored.promise + }) + const otherRead = vi.spyOn(otherRoute.storage, "read") + const shareSession = createSharePreviewSession( + { + buildId: otherRoute.target.buildId, + shareLinkId: randomUUID(), + expiresAt: new Date(Date.now() + 60_000), + }, + otherRoute.preview.encryptionKey, + ) + const publicHeaders = { + host: `${otherRoute.target.buildId}.preview.localhost:${new URL(otherRoute.origin).port}`, + cookie: `replica_share_preview=${encodeURIComponent(shareSession)}`, + } + const release = reserveBuildPreviewBytes(100 * 1024 * 1024 - 64 * 1024) + if (!release) throw new Error("The test could not reserve the remaining source bytes.") + const first = request(privateRoute.origin, `${privateRoute.mountPath}/asset.bin`) + + try { + await readStarted.promise + const publicResponse = await request(otherRoute.origin, "/asset.bin", publicHeaders) + const templateResponse = await request(otherRoute.origin, `${otherRoute.mountPath}/asset.bin`) + + expect.soft(publicResponse.status).toBe(503) + expect.soft(templateResponse.status).toBe(503) + expect(otherRead).not.toHaveBeenCalled() + } finally { + stored.resolve({ status: "ok", bytes: Uint8Array.of(1) }) + await first + release() + } + + expect(privateRead).toHaveBeenCalledOnce() + expect((await request(otherRoute.origin, "/asset.bin", publicHeaders)).status).toBe(200) + expect((await request(otherRoute.origin, `${otherRoute.mountPath}/asset.bin`)).status).toBe(200) + }) + + it.each(["finish", "close"] as const)( + "holds source bytes after response.end until the canonical response emits %s", + async (completion) => { + const responsePending = deferred<{ response: ServerResponse; finish: () => void }>() + const { origin, mountPath, findArtifact, storage } = await createFixture( + (response, requestPath) => { + if (!requestPath.endsWith("/slow.bin")) return + const end = response.end.bind(response) + vi.spyOn(response, "end").mockImplementation(() => { + responsePending.resolve({ response, finish: () => end(Uint8Array.of(7)) }) + return response + }) + }, + ) + findArtifact.mockResolvedValue({ + storageKey: "asset-key", + byteLength: 100 * 1024 * 1024, + }) + const read = vi + .spyOn(storage, "read") + .mockResolvedValue({ status: "ok", bytes: Uint8Array.of(7) }) + const first = request(origin, `${mountPath}/slow.bin`).catch((error: unknown) => error) + const pending = await responsePending.promise + + try { + const blocked = await request(origin, `${mountPath}/asset.bin`) + + expect(blocked.status).toBe(503) + expect(read).toHaveBeenCalledOnce() + } finally { + const completed = once(pending.response, completion) + if (completion === "finish") pending.finish() + else pending.response.destroy() + await completed + await first + } + + expect((await request(origin, `${mountPath}/asset.bin`)).status).toBe(200) + expect(read).toHaveBeenCalledTimes(2) + }, + ) + + it.each(["storage read", "authorization recheck"] as const)( + "keeps a disconnected canonical request reserved until its pending %s settles", + async (pendingOperation) => { + const pendingStarted = deferred() + const proceed = deferred() + const disconnected = deferred() + const { origin, mountPath, findArtifact, storage, isRepositoryVisible } = await createFixture( + (response, requestPath) => { + if (requestPath.endsWith("/pending.bin")) { + response.once("close", () => disconnected.resolve()) + } + }, + ) + findArtifact.mockResolvedValue({ + storageKey: "asset-key", + byteLength: 100 * 1024 * 1024, + }) + const read = vi + .spyOn(storage, "read") + .mockResolvedValue({ status: "ok", bytes: Uint8Array.of(7) }) + if (pendingOperation === "storage read") { + read.mockImplementationOnce(async () => { + pendingStarted.resolve() + await proceed.promise + return { status: "ok", bytes: Uint8Array.of(7) } + }) + } else { + isRepositoryVisible.mockResolvedValueOnce(true).mockImplementationOnce(async () => { + pendingStarted.resolve() + await proceed.promise + return true + }) + } + const abort = new AbortController() + const first = request( + origin, + `${mountPath}/pending.bin`, + { cookie: "hub_session=member-session" }, + "GET", + abort.signal, + ).catch((error: unknown) => error) + + try { + await pendingStarted.promise + abort.abort() + await disconnected.promise + const blocked = await request(origin, `${mountPath}/asset.bin`) + + expect(blocked.status).toBe(503) + expect(read).toHaveBeenCalledOnce() + } finally { + proceed.resolve() + abort.abort() + await first + } + + expect((await request(origin, `${mountPath}/asset.bin`)).status).toBe(200) + expect(read).toHaveBeenCalledTimes(2) + }, + ) + + it.each(["not-found", "unavailable", "error"] as const)( + "releases the canonical source reservation after storage returns %s", + async (failure) => { + const { origin, mountPath, findArtifact, storage } = await createFixture() + findArtifact.mockResolvedValue({ + storageKey: "asset-key", + byteLength: 100 * 1024 * 1024, + }) + const read = vi + .spyOn(storage, "read") + .mockResolvedValue({ status: "ok", bytes: Uint8Array.of(7) }) + if (failure === "error") read.mockRejectedValueOnce(new Error("Storage read failed")) + else read.mockResolvedValueOnce({ status: failure }) + + const failed = await request(origin, `${mountPath}/asset.bin`) + const recovered = await request(origin, `${mountPath}/asset.bin`) + + expect(failed.status).toBe(failure === "not-found" ? 404 : failure === "error" ? 500 : 503) + expect(recovered.status).toBe(200) + expect(read).toHaveBeenCalledTimes(2) + }, + ) + + it("releases a temporary template manifest reservation before reserving the SPA document", async () => { + const { origin, mountPath, findArtifact, storage } = await createFixture() + const manifest = new TextEncoder().encode( + JSON.stringify({ templates: [{ path: "/release/v2.0" }] }), + ) + const html = new TextEncoder().encode("Release notes") + findArtifact.mockImplementation((_buildId, artifactPath) => + Promise.resolve( + artifactPath === "templates.json" + ? { storageKey: "manifest-key", byteLength: 100 * 1024 * 1024 } + : artifactPath === "dist/index.html" + ? { storageKey: "index-key", byteLength: html.byteLength } + : null, + ), + ) + let manifestWasReserved = false + const read = vi.spyOn(storage, "read").mockImplementation((key) => { + if (key === "manifest-key") { + const release = reserveBuildPreviewBytes(1) + manifestWasReserved = release === null + release?.() + } + return Promise.resolve({ status: "ok", bytes: key === "manifest-key" ? manifest : html }) + }) + + const response = await request(origin, `${mountPath}/release/v2.0`, { + cookie: "hub_session=member-session", + accept: "text/html", + }) + + expect(response.status).toBe(200) + expect(manifestWasReserved).toBe(true) + expect(response.body.toString()).toContain("Release notes") + expect(read).toHaveBeenNthCalledWith(1, "manifest-key") + expect(read).toHaveBeenNthCalledWith(2, "index-key") + }) }) diff --git a/hub/server/routes/build-preview/path/get/index.ts b/hub/server/routes/build-preview/path/get/index.ts index e39576997..16cc29723 100644 --- a/hub/server/routes/build-preview/path/get/index.ts +++ b/hub/server/routes/build-preview/path/get/index.ts @@ -9,6 +9,7 @@ import { readProductSession } from "../../../api/product/read-product-session/in import { canBrowseTemplates } from "../../../api/product/template-repository-access/index.ts" import type { ProductRouteDependencies } from "../../../api/product/types.ts" import type { BuildPreviewRouteDependencies } from "../../types.ts" +import { createPreviewResponseReservation } from "../../create-preview-response-reservation/index.ts" export function get( preview: BuildPreviewRouteDependencies, @@ -16,6 +17,7 @@ export function get( product: ProductRouteDependencies, ): RequestHandler { return async (request, response, next) => { + const admission = createPreviewResponseReservation(response) response.setHeader("Cache-Control", "private, no-store") response.setHeader("X-Content-Type-Options", "nosniff") response.setHeader("Referrer-Policy", "no-referrer") @@ -39,7 +41,7 @@ export function get( BigInt(match[1]!) > 9223372036854775807n || BigInt(match[2]!) > 9223372036854775807n || /%2f|%5c/i.test(path) || - /[\\%\p{Cc}\p{Cs}]/u.test(decoded) || + /[\\\p{Cc}\p{Cs}]/u.test(decoded) || decoded.split("/").some((part) => part === "." || part === "..") || request.get("service-worker")?.toLowerCase() === "script" || request.get("host") !== new URL(preview.applicationOrigin).host @@ -101,11 +103,10 @@ export function get( const review = (preview.reviewBridgeSource ?? "") .replaceAll('"__REPLICA_HUB_ORIGIN__"', JSON.stringify(preview.applicationOrigin)) .replaceAll('"__REPLICA_REVIEW_ENABLED__"', JSON.stringify(String(!target.template))) - response - .type("text/javascript") - .send( - `${review}\n${preview.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge(${JSON.stringify(preview.applicationOrigin)});`, - ) + const source = `${review}\n${preview.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge(${JSON.stringify(preview.applicationOrigin)});` + response.type("text/javascript") + response.setHeader("Content-Length", Buffer.byteLength(source)) + response.end(source) return } const screenshot = @@ -133,23 +134,34 @@ export function get( buildId: target.buildId, requestPath: path, mountPath, + ifNoneMatch: screenshot ? undefined : request.get("if-none-match"), }, - preview, + { ...preview, reserveBytes: admission.reserveBytes }, ) + if (response.destroyed) return if (!(await authorized())) { response.status(404).end() return } + if (file.status === "not-modified") { + response.setHeader("Cache-Control", "private, no-cache") + response.setHeader("ETag", file.etag) + response.status(304).end() + return + } if (file.status !== "ok") { response.status(file.status === "not-found" ? 404 : 503).end() return } response.setHeader("Cache-Control", screenshot ? "private, no-store" : "private, no-cache") response.setHeader("Content-Type", file.contentType) + if (file.etag) response.setHeader("ETag", file.etag) response.setHeader("Content-Length", file.bytes.byteLength) response.end(file.bytes) } catch (error) { next(error) + } finally { + admission.completeRequest() } } } diff --git a/hub/server/routes/build-preview/serve/get/index.test.ts b/hub/server/routes/build-preview/serve/get/index.test.ts index 12f0c416a..bbb0cffd5 100644 --- a/hub/server/routes/build-preview/serve/get/index.test.ts +++ b/hub/server/routes/build-preview/serve/get/index.test.ts @@ -235,8 +235,14 @@ describe("get()", () => { const headers = requestHeaders(buildId, origin, shareCookie) const asset = await request(origin, "/assets/app.css", headers) - const desktop = await request(origin, "/__replica/screenshots/desktop.png", headers) - const narrow = await request(origin, "/__replica/screenshots/narrow.png", headers) + const desktop = await request(origin, "/__replica/screenshots/desktop.png", { + ...headers, + "if-none-match": "*", + }) + const narrow = await request(origin, "/__replica/screenshots/narrow.png", { + ...headers, + "if-none-match": "*", + }) expect(findArtifact).toHaveBeenNthCalledWith(1, buildId, "dist/assets/app.css") expect(findArtifact).toHaveBeenNthCalledWith(2, buildId, "screenshots/desktop.png") @@ -252,6 +258,8 @@ describe("get()", () => { expect(asset.headers["cross-origin-resource-policy"]).toBe("same-origin") expect(desktop.headers["cross-origin-resource-policy"]).toBe("same-origin") expect(narrow.headers["cross-origin-resource-policy"]).toBe("same-origin") + expect(desktop.headers.etag).toBeUndefined() + expect(narrow.headers.etag).toBeUndefined() }) }) diff --git a/hub/server/routes/build-preview/serve/get/index.ts b/hub/server/routes/build-preview/serve/get/index.ts index bfa89a872..c02cab568 100644 --- a/hub/server/routes/build-preview/serve/get/index.ts +++ b/hub/server/routes/build-preview/serve/get/index.ts @@ -3,10 +3,10 @@ import type { RequestHandler } from "express" import { readBuildPreviewFile } from "../../../../domains/build-preview/read-build-preview-file/index.ts" import { readPreviewBuildId } from "../../../../domains/build-preview/read-preview-build-id/index.ts" import { readTemplateScreenshotPath } from "../../../../domains/build-preview/template-screenshot-path/index.ts" -import { reserveBuildPreviewBytes } from "../../../../domains/build-preview/reserve-build-preview-bytes/index.ts" import { readSharePreviewSession } from "../../../../domains/public-sharing/read-share-preview-session/index.ts" import { readCookie } from "../../../../integrations/express/read-cookie/index.ts" import type { BuildPreviewRouteDependencies } from "../../types.ts" +import { createPreviewResponseReservation } from "../../create-preview-response-reservation/index.ts" function setSecurityHeaders(response: Parameters[1], applicationOrigin: string) { response.setHeader( @@ -31,21 +31,7 @@ function setSecurityHeaders(response: Parameters[1], application export function get(dependencies: BuildPreviewRouteDependencies): RequestHandler { return async (request, response, next) => { - const reservations = new Set<() => void>() - let handlingRequest = true - let responseEnded = response.destroyed || response.writableFinished - function releaseReservations() { - if (handlingRequest || !responseEnded) return - response.off("finish", onResponseEnd) - response.off("close", onResponseEnd) - for (const release of reservations) release() - } - function onResponseEnd() { - responseEnded = true - releaseReservations() - } - response.once("finish", onResponseEnd) - response.once("close", onResponseEnd) + const admission = createPreviewResponseReservation(response) try { if (!dependencies.previewBaseOrigin) { next() @@ -93,18 +79,7 @@ export function get(dependencies: BuildPreviewRouteDependencies): RequestHandler }, { ...dependencies, - reserveBytes(byteLength) { - if (responseEnded) return null - const reservation = reserveBuildPreviewBytes(byteLength) - if (!reservation) return null - const release = reservation - function trackedRelease() { - reservations.delete(trackedRelease) - release() - } - reservations.add(trackedRelease) - return trackedRelease - }, + reserveBytes: admission.reserveBytes, }, ) if (response.destroyed) return @@ -127,8 +102,7 @@ export function get(dependencies: BuildPreviewRouteDependencies): RequestHandler } catch (error) { next(error) } finally { - handlingRequest = false - releaseReservations() + admission.completeRequest() } } } diff --git a/hub/server/routes/index.ts b/hub/server/routes/index.ts index 7ed56ac19..7449c18f1 100644 --- a/hub/server/routes/index.ts +++ b/hub/server/routes/index.ts @@ -94,20 +94,18 @@ export function routes(app: Express, dependencies: RouteDependencies = {}): void product, publicSharing, } = dependencies - if (preview) { - if (preview.findPathTargets && authentication && product) - app.use("/previews", handlePathPreviewGet(preview, authentication.currentSession, product)) - } - app.use("/previews", (_request, response) => { - response.setHeader("Cache-Control", "private, no-store") - response.status(404).end() - }) if (preview?.previewBaseOrigin) { if (publicSharing) { app.get("/__replica/share/authorize", handleSharePreviewAuthorizeGet(preview, publicSharing)) } app.get("/{*path}", handleBuildPreviewServeGet(preview)) } + if (preview?.findPathTargets && authentication && product) + app.use("/previews", handlePathPreviewGet(preview, authentication.currentSession, product)) + app.use("/previews", (_request, response) => { + response.setHeader("Cache-Control", "private, no-store") + response.status(404).end() + }) app.get("/api/health", handleApiHealthGet) app.get("/api/ready", (request, response) => handleApiReadyGet(request, response, { isReady, logger }), diff --git a/hub/test/database/build-preview-run-lookup-migration/index.db.test.ts b/hub/test/database/build-preview-run-lookup-migration/index.db.test.ts new file mode 100644 index 000000000..13f8ce25c --- /dev/null +++ b/hub/test/database/build-preview-run-lookup-migration/index.db.test.ts @@ -0,0 +1,152 @@ +import { execFile } from "node:child_process" +import { randomBytes, randomUUID } from "node:crypto" +import { readFile, readdir } from "node:fs/promises" +import { join } from "node:path" +import { fileURLToPath } from "node:url" +import { promisify } from "node:util" + +import pg from "pg" +import { expect, it } from "vitest" + +interface RetainedOwner { + github_repository_id: string + id: string + prototype_id: string + number: number + state: string + github_workflow_run_id: string | null + commit_sha: string | null + artifact_id: string + path: string + storage_key: string + byte_length: number +} + +it("preserves duplicate preview owners and their artifacts when upgrading the exact base", async () => { + const adminUrl = process.env.TEST_DATABASE_URL + if (!adminUrl) throw new Error("TEST_DATABASE_URL is required.") + const name = `replica_preview_lookup_upgrade_${randomBytes(8).toString("hex")}` + const admin = new pg.Client({ connectionString: adminUrl }) + await admin.connect() + let created = false + try { + await admin.query(`CREATE DATABASE ${pg.escapeIdentifier(name)}`) + created = true + const databaseUrl = new URL(adminUrl) + databaseUrl.pathname = name + const database = new pg.Client({ connectionString: databaseUrl.toString() }) + try { + await database.connect() + const hubRoot = fileURLToPath(new URL("../../../", import.meta.url)) + const migrations = join(hubRoot, "schema/migrations") + const baseMigration = "20261219120000_decision_agent_evaluations" + const base = (await readdir(migrations, { withFileTypes: true })) + .filter((entry) => entry.isDirectory() && entry.name <= baseMigration) + .map(({ name }) => name) + .sort() + expect(base.at(-1)).toBe(baseMigration) + for (const migrationName of base) { + const sql = await readFile(join(migrations, migrationName, "migration.sql"), "utf8") + if (migrationName === "20261104190000_entra_oidc_authentication") { + const statements = sql.split("\n") + await database.query(statements.slice(0, 2).join("\n")) + await database.query(statements.slice(2).join("\n")) + } else { + await database.query(sql) + } + } + + const repositoryId = randomUUID() + const prototypeIds = [randomUUID(), randomUUID()] + const buildIds = [randomUUID(), randomUUID()] + await database.query( + `INSERT INTO repositories (id, github_repository_id, name_with_owner, default_branch) + VALUES ($1, 2001, 'team/previews', 'main')`, + [repositoryId], + ) + for (const [index, prototypeId] of prototypeIds.entries()) { + await database.query( + `INSERT INTO prototypes (id, repository_id, branch_name) + VALUES ($1, $2, $3)`, + [prototypeId, repositoryId, `proto/owner-${index}`], + ) + await database.query( + `INSERT INTO builds + (id, prototype_id, number, state, github_workflow_run_id, commit_sha) + VALUES ($1, $2, 1, 'successful', 3002, $3)`, + [buildIds[index], prototypeId, "a".repeat(40)], + ) + await database.query( + `INSERT INTO build_artifacts (id, build_id, kind, path, storage_key, byte_length) + VALUES ($1, $2, 'dist', 'dist/index.html', $3, 20)`, + [randomUUID(), buildIds[index], `retained-preview-${index}`], + ) + } + async function retainedOwners() { + return ( + await database.query( + `SELECT repository.github_repository_id, build.id, build.prototype_id, + build.number, build.state, build.github_workflow_run_id, build.commit_sha, + artifact.id AS artifact_id, artifact.path, artifact.storage_key, + artifact.byte_length + FROM builds build + JOIN prototypes prototype ON prototype.id = build.prototype_id + JOIN repositories repository ON repository.id = prototype.repository_id + JOIN build_artifacts artifact ON artifact.build_id = build.id + WHERE repository.id = $1 ORDER BY build.id`, + [repositoryId], + ) + ).rows + } + const before = await retainedOwners() + expect(before).toHaveLength(2) + const run = promisify(execFile) + const prismaCli = join(hubRoot, "node_modules/prisma/build/index.js") + const options = { + cwd: hubRoot, + env: { ...process.env, DATABASE_URL: databaseUrl.toString() }, + timeout: 120_000, + } + for (const migrationName of base) { + await run( + process.execPath, + [ + prismaCli, + "migrate", + "resolve", + "--applied", + migrationName, + "--config", + "prisma7.config.ts", + ], + options, + ) + } + await run( + process.execPath, + [prismaCli, "migrate", "deploy", "--config", "prisma7.config.ts"], + options, + ) + expect(await retainedOwners()).toEqual(before) + await database.query( + `INSERT INTO builds + (id, prototype_id, number, state, github_workflow_run_id, commit_sha) + VALUES ($1, $2, 2, 'successful', 3002, $3)`, + [randomUUID(), prototypeIds[0], "b".repeat(40)], + ) + const owners = await database.query( + `SELECT id FROM builds WHERE github_workflow_run_id = 3002`, + ) + expect(owners.rows).toHaveLength(3) + expect(await retainedOwners()).toEqual(before) + } finally { + await database.end() + } + } finally { + try { + if (created) await admin.query(`DROP DATABASE ${pg.escapeIdentifier(name)} WITH (FORCE)`) + } finally { + await admin.end() + } + } +}, 120_000) From eb7d09c3934d134b80934ed533d69a80156b97f8 Mon Sep 17 00:00:00 2001 From: Will Eastler <32074613+weastler@users.noreply.github.com> Date: Sat, 21 Nov 2026 10:09:48 -0800 Subject: [PATCH 4/4] fix(hub): preserve hosted Controls serving bases Pass each hosted Build base through its bridge bootstrap and keep local smoke assertions aligned with unsupported private mounts. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../replica-prototype/assets/canvas-bridge.js | 2 +- .../build-controls/controls.js | 2 +- .../prototype-preview-bridge/controls.test.ts | 75 +++++++++++ .../prototype-preview-bridge/controls.ts | 4 +- .../prototype-preview-bridge/index.ts | 12 +- .../install-hosted-bridge/index.ts | 4 +- .../install-replica-controls-bridge/bridge.js | 2 +- hub/docs/build-previews.md | 2 +- hub/server/assets/hosted-preview-bridge.ts | 2 +- .../build-preview/path/get/index.test.ts | 116 +++++++++++++++++- .../routes/build-preview/path/get/index.ts | 2 +- .../build-preview/serve/get/index.test.ts | 14 ++- .../routes/build-preview/serve/get/index.ts | 2 +- hub/test/local-smoke/browser.js | 13 +- 14 files changed, 224 insertions(+), 28 deletions(-) diff --git a/.github/extensions/replica-prototype/assets/canvas-bridge.js b/.github/extensions/replica-prototype/assets/canvas-bridge.js index deed7e52e..3aa241ca8 100644 --- a/.github/extensions/replica-prototype/assets/canvas-bridge.js +++ b/.github/extensions/replica-prototype/assets/canvas-bridge.js @@ -1,4 +1,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=/* @__PURE__ */ ((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))((/* @__PURE__ */ o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=ee;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return I.errors=a,o===0}e.number=L;function L(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return L.errors=a,l===0}e.slider=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.choice=te;function te(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return te.errors=a,o===0}e.checkboxGroup=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.text=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return re.errors=a,l===0}e.color=ie;function ie(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ie.errors=a,o===0}e.button=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return z.errors=a,o===0}})))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` `)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=/* @__PURE__ */ new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=/* @__PURE__ */ new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=/* @__PURE__ */ new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=/* @__PURE__ */ new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=/* @__PURE__ */ new Set,p=/* @__PURE__ */ new Map,m=/* @__PURE__ */ new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e){return/^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(e)?.[0]??`/`}function A(e,t){return JSON.stringify(e)===JSON.stringify(t)}function j(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function M(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function N(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function ee(e){let t=e.binding;if(t.type===`api`){let e=N(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=M(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(/* @__PURE__ */ Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function te(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function ne(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():te(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function re(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=/* @__PURE__ */ new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=/* @__PURE__ */ Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=/* @__PURE__ */ new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return ee(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(j()).origin!==new URL(i).origin:j()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=j(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await ne(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?j():a);if(!A(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=/* @__PURE__ */ Error(`${c.message} ${L(e).message}`)}throw!l&&A(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!A(await R(()=>I(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,j());t.rejection&&!A(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=j();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function k(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!A(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&A(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` `).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>k(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return k(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await k(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function ie(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return re(JSON.parse(n))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var ae=`replica:controls`;function oe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function se(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var ce=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function le(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!ce.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function ue(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=/* @__PURE__ */ new Map,i=!1;for(let[e,a]of n){let n=ce.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??/* @__PURE__ */ new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{le(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function de(e,t){let n=new URL(e,window.location.href),r=ue(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(le(r.scopes)))n.searchParams.set(e,t);return n.toString()}function fe(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=le({...ue(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(de(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=ue(e);if(t.notice)throw Error(t.notice);s=le(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function pe(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var me={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function he(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?me.controlsActionUnavailable:``)}}function ge(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>he(e,t)))}}function _e(e){let t=``,n,r,i=``,a=!1,o=/* @__PURE__ */ new Set,s=!1,c=0,l,u,d=!1,f,p=/* @__PURE__ */ new Set,m=/* @__PURE__ */ new Set,h=``,g=fe(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,pe(se(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await ie(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(se);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:ae,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(oe(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:ge(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!oe(r.data))return;let i=r.data;if(i.type===`hello`){t=i.epoch,o.clear(),s=!1,m.clear();let e=i.fromFrameUrl&&g?.managed();g?.set(e?g.current():i.controlQuery??``),d||await w,x(`reply`,i.requestId,void 0,e?g?.current():void 0);return}if(i.type!==`command`||i.epoch!==t||o.has(i.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,i.requestId,`Reconnect controls before sending more commands.`);return}o.add(i.requestId);let c=i.command;function l(){if(a||t!==i.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(c?.operation===`url`){g.set(c.query??``),c.scope&&n?.list().some(e=>e.declaration.scope===c.scope&&e.mountedCount>0)&&(m.add(c.scope),g.refresh()),x(`reply`,i.requestId);return}if(!c||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(c.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(c.contexts)||c.contexts.length!==e.length||e.some(e=>!c.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,l)}else{let e=n.list().find(e=>e.declaration.scope===c.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(c.fingerprint!==JSON.stringify(e.declaration)||c.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(c.operation===`restore`){if(!z(c.values))throw Error(`Invalid saved controls.`);await u?.restore(e,c.values,l),m.add(e.declaration.scope),g?.refresh()}else if(c.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,l);else{let t=e.declaration.controls.find(e=>e.id===c.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),c.operation===`update`){let n={[t.id]:c.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,l)}else if(c.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===i.epoch&&(x(`reply`,i.requestId),u?.navigate())}catch(e){t===i.epoch&&x(`reply`,i.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var B=`data-replica-canvas-bridge`,ve=new TextEncoder,ye=null,V=null,H=null,U=null,be=`light-dark(#0969da, #58a6ff)`,W=null,xe=``,Se=``,G=/* @__PURE__ */ new Map;function Ce(){let e=q();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{Se=`replicaControlsBinding`in e&&e.replicaControlsBinding?Ce():``});function K(e){return e.replace(/\s+/g,` `).trim()}function we(e,t){let n=``,r=0;for(let i of e){let e=ve.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function q(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname.slice(k(window.location.pathname).length-1),search:e?`?${e}`:``,hash:window.location.hash}}function Te(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Ee(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function De(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return we(K(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function Oe(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function ke(e){if(e.id){let t=`#${Oe(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}="${Oe(n)}"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function Ae(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&De(e)!==t.accessibleName?!1:!t.selectedText||K(e.textContent||``).includes(t.selectedText)}function je(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&Ae(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&Ae(r,e)){if(n)return null;n=r}return n}function Me(){let e=document.createElement(`div`);return e.setAttribute(B,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,be),document.documentElement.append(e),e}function J(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function Ne(e,t=null){H?.remove(),H=e,U=t,H.style.pointerEvents=`none`}function Y(e,t){window.parent.postMessage(t,e)}function X(){V?.(),V=null}function Z(e,t,n){X(),Y(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Pe(e,t,n){let r=e.getBoundingClientRect(),i=ke(e);if(!r.width||!r.height||!i)return null;let a=we(K(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:q(),selector:i,accessibleName:De(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:Ee(r),viewport:Te(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Fe(e,t){X();let n=null,r=Me(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${B}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,J(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Pe(n,i.clientX,i.clientY);a?(r.style.position=$(n)?`fixed`:`absolute`,J(r,n.getBoundingClientRect()),Ne(r,n),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Z(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),V=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,H!==r&&r.remove()}}function Ie(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=/* @__PURE__ */ new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(B)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=ke(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:De(e),tagName:e.tagName.toLowerCase(),role:we(e.getAttribute(`role`)||``,64),textExcerpt:we(K(e.textContent||``),500),rect:Ee(n)}]})}function Le(e){return{schemaVersion:1,kind:`area`,route:q(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:Ee(e),viewport:Te(),elements:Ie(e)}}function Re(e,t,n=!1){X();let r=document.createElement(`div`);r.setAttribute(B,``),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let i=Me();i.style.display=`none`,document.body.append(r);let a=null,o=null,s=null,c=null;function l(e,t){r.style.pointerEvents=`none`;let n=document.elementFromPoint(e,t);return r.style.pointerEvents=``,n===document.body||n===document.documentElement?null:n}function u(n,r,a){i.style.position=a&&$(a)?`fixed`:`absolute`,J(i,r),Ne(i,a),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:n})}function d(e,t){if(!a)return;let n=Math.min(a.x,e),r=Math.min(a.y,t),o=Math.abs(e-a.x),s=Math.abs(t-a.y);i.style.display=`block`,J(i,new DOMRect(n,r,o,s))}function f(e){e.button!==0||a||(e.preventDefault(),a={x:e.clientX,y:e.clientY},s=e.pointerId,o=n?l(e.clientX,e.clientY):null,r.setPointerCapture(e.pointerId),d(e.clientX,e.clientY))}function p(e){if(a)e.pointerId===s&&(e.preventDefault(),d(e.clientX,e.clientY));else{if(!n)return;let t=l(e.clientX,e.clientY);i.style.display=t?`block`:`none`,t&&J(i,t.getBoundingClientRect())}}function m(r){if(!a||r.pointerId!==s)return;r.preventDefault();let i=Math.max(0,Math.min(window.innerWidth,r.clientX)),c=Math.max(0,Math.min(window.innerHeight,r.clientY)),l=new DOMRect(Math.min(a.x,i),Math.min(a.y,c),Math.abs(i-a.x),Math.abs(c-a.y));if(n&&Math.hypot(l.width,l.height)<8){let n=o?Pe(o,a.x,a.y):null;if(!n||!o){Z(e,t,`element-unavailable`);return}u(n,o.getBoundingClientRect(),o)}else(n?l.width<8||l.height<8:Math.hypot(l.width,l.height)<8)?Z(e,t,`area-too-small`):u(Le(l),l)}function h(r){if(!n||r.detail!==0||!(r.target instanceof Element)||r.target.hasAttribute(B))return;r.preventDefault(),r.stopImmediatePropagation();let i=r.target,a=i.getBoundingClientRect(),o=Pe(i,a.left+a.width/2,a.top+a.height/2);o?u(o,a,i):Z(e,t,`element-unavailable`)}function g(n){X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t,reason:n?`interrupted`:`escape`})}function _(r){if(n&&r.shiftKey&&r.key===`Enter`)r.preventDefault(),c={x:window.innerWidth/2,y:window.innerHeight/2},a=null,i.style.display=`block`,J(i,new DOMRect(c.x,c.y,4,4));else if(c&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(r.key)){if(r.preventDefault(),r.key===`Enter`||r.key===` `){if(!a)a={...c};else{let n=new DOMRect(Math.min(a.x,c.x),Math.min(a.y,c.y),Math.abs(a.x-c.x),Math.abs(a.y-c.y));if(n.width<8||n.height<8){Z(e,t,`area-too-small`);return}u(Le(n),n)}}else c={x:Math.max(0,Math.min(window.innerWidth,c.x+(r.key===`ArrowRight`?10:r.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(window.innerHeight,c.y+(r.key===`ArrowDown`?10:r.key===`ArrowUp`?-10:0)))},a?d(c.x,c.y):J(i,new DOMRect(c.x,c.y,4,4))}else r.key===`Escape`&&(r.preventDefault(),g())}r.addEventListener(`pointerdown`,f),r.addEventListener(`pointermove`,p),r.addEventListener(`pointerup`,m),r.addEventListener(`pointercancel`,g),r.addEventListener(`lostpointercapture`,g),n&&document.addEventListener(`click`,h,!0),document.addEventListener(`keydown`,_,!0),V=()=>{r.removeEventListener(`pointerdown`,f),r.removeEventListener(`pointermove`,p),r.removeEventListener(`pointerup`,m),r.removeEventListener(`pointercancel`,g),r.removeEventListener(`lostpointercapture`,g),n&&document.removeEventListener(`click`,h,!0),document.removeEventListener(`keydown`,_,!0),r.remove(),H!==i&&i.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function ze(e){let t=q();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=je({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:$(n)}}function Be(e=!1){if(!W||!ye)return;let t=q(),n=JSON.stringify(t);e&&=n===xe,xe=n;let r=[];for(let t of W.anchors){let n=G.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=ze(t.anchor);if(!e){G.delete(t.id);continue}G.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}Y(ye,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:W.nonce,route:t,...Se===Ce()?{replaceRoute:!0}:{},results:r})}function Ve(e){let t=e.data;if(document.querySelector(`script[src="${k(window.location.pathname)}__replica/bridge/v1.js"]`)||e.source!==window.parent||e.origin!==ye||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){Y(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,improvementSelection:!0,nonce:t.nonce,route:q(),...Se===Ce()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;be=t.accent;for(let e of document.querySelectorAll(`[${B}]`))e.style.setProperty(`--replica-selection-accent`,be);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=q(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(O(n,!0)||(De(n)||K(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Fe(e.origin,t.nonce):t.mode===`area`?Re(e.origin,t.nonce):t.mode===`improvement`&&Re(e.origin,t.nonce,!0);return}if(t.type===`replica:canvas:cancel-selection`){X(),Y(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce,reason:`command`});return}if(t.type===`replica:canvas:clear-selection`){H?.remove(),H=null,U=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors))return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});W={nonce:t.nonce,anchors:n},G.clear(),Be()}var He=Symbol.for(`replica.canvas.bridge.v1`),Ue=window;function We(e){let t=Ue[He];if(t===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof t==`function`&&t(),be=`light-dark(#0969da, #58a6ff)`,ye=e,W=null,xe=``,G.clear();let n=_e(e),r=null;function i(){r!==null&&window.cancelAnimationFrame(r),r=null,H&&U&&(H.style.position=$(U)?`fixed`:`absolute`,J(H,U.getBoundingClientRect())),Be()}function a(){r===null&&W&&(r=window.requestAnimationFrame(i))}function o(e){H&&U&&(e.target!==document&&e.target!==window||$(U))&&J(H,U.getBoundingClientRect()),r===null?Be(e.target===document||e.target===window):i()}function s(){Be()}function c(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||V||!W||t.target instanceof Element&&t.target.closest(`[role="dialog"], dialog, [role="menu"]`))return;let n=W;window.setTimeout(()=>{t.defaultPrevented||V||W!==n||Y(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,Ve),window.addEventListener(`scroll`,o,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),window.addEventListener(`keydown`,c);let l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${B}], [data-replica-controls-bridge]`)))&&a()});l.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let u=typeof ResizeObserver==`function`?new ResizeObserver(a):null;u?.observe(document.documentElement),Ue[He]=()=>{window.removeEventListener(`message`,Ve),window.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,s),window.removeEventListener(`keydown`,c),l.disconnect(),u?.disconnect(),r!==null&&window.cancelAnimationFrame(r),W=null,xe=``,G.clear(),n(),X(),H?.remove(),H=null,U=null}}function Ge(e,t=`canvas`){if(t===`canvas`){if(!/^http:\/\/127\.0\.0\.1:\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`)}else{let t=URL.parse(e);if(!t||t.origin!==e||t.pathname!==`/`||t.search||t.hash||![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid Replica Hub parent.`)}We(e)}export{Ge as installBridge}; \ No newline at end of file +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function ie(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return re(JSON.parse(n))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var ae=`replica:controls`;function oe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function se(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var ce=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function le(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!ce.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function ue(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=/* @__PURE__ */ new Map,i=!1;for(let[e,a]of n){let n=ce.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??/* @__PURE__ */ new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{le(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function de(e,t){let n=new URL(e,window.location.href),r=ue(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(le(r.scopes)))n.searchParams.set(e,t);return n.toString()}function fe(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=le({...ue(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(de(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=ue(e);if(t.notice)throw Error(t.notice);s=le(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function pe(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var me={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function he(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?me.controlsActionUnavailable:``)}}function ge(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>he(e,t)))}}function _e(e,t){let n=``,r,i,a=``,o=!1,s=/* @__PURE__ */ new Set,c=!1,l=0,u,d,f=!1,p,m=/* @__PURE__ */ new Set,h=/* @__PURE__ */ new Set,g=``,_=fe(e=>{h.clear(),S(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((r?.list()??[]).filter(e=>h.has(e.declaration.scope)).map(e=>[e.declaration.scope,pe(se(e))])),e=>{g!==e&&(g=e,S(`snapshot`,`event`))});async function v(){try{if(d=await ie(t),o){d?.dispose();return}r=d?.runtime,i=d?.subscribe(C),await d?.settled();let e=d;e&&y()&&await new Promise(t=>{function n(){clearTimeout(i),a(),p=void 0,t()}function r(){y()||n()}let i=setTimeout(n,500),a=e.subscribe(r);p=n,r()})}catch(e){u={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{f=!0}C()}function y(){return r?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function b(){let e=!!r;if(u)return{runtimeAvailable:e,scopes:[],...u};if(!r)return{runtimeAvailable:!1,status:f?`no-controls`:`missing-runtime`,scopes:[]};try{let e=r.list().filter(e=>e.mountedCount>0).map(se);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function x(){return{...b(),scopeErrors:[],reconnectRequired:c,...c?{error:`Reconnect controls before sending more commands.`}:{},...g?{error:`${g} Changes remain in memory and are not in the URL.`}:{}}}function S(t,r,i,a){if(o||!n)return;let s={protocol:ae,version:1,type:t,epoch:n,requestId:r,sequence:++l,state:x(),...i?{error:i}:{},...a===void 0?{}:{controlQuery:a}};window.parent.postMessage(oe(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function C(){for(let e of m)e();if(!f||d?.pending())return;_?.refresh();let e=JSON.stringify(x());e!==a&&(a=e,S(`snapshot`,`event`))}async function w(t){if(t.source===window.parent&&t.origin===e&&t.data&&typeof t.data==`object`&&`type`in t.data&&t.data.type===`replica:controls:status`&&`nonce`in t.data&&typeof t.data.nonce==`string`&&t.data.nonce.length<=100&&`timeoutMs`in t.data&&Number.isInteger(t.data.timeoutMs)&&typeof t.data.timeoutMs==`number`&&t.data.timeoutMs>=0&&t.data.timeoutMs<=1e4){let{nonce:n,timeoutMs:r}=t.data;function i(){return!f||d?.pending()===!0&&!x().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&r>0&&await new Promise(e=>{function t(){clearTimeout(a),m.delete(n),e()}function n(){(o||!i())&&t()}let a=setTimeout(t,r);m.add(n),n()}),o||window.parent.postMessage({type:`replica:controls:status-result`,nonce:n,value:ge(x(),i(),window.location.href)},e);return}if(t.source!==window.parent||t.origin!==e||!oe(t.data))return;let i=t.data;if(i.type===`hello`){n=i.epoch,s.clear(),c=!1,h.clear();let e=i.fromFrameUrl&&_?.managed();_?.set(e?_.current():i.controlQuery??``),f||await T,S(`reply`,i.requestId,void 0,e?_?.current():void 0);return}if(i.type!==`command`||i.epoch!==n||s.has(i.requestId))return;if(s.size>=2e3){c=!0,S(`reply`,i.requestId,`Reconnect controls before sending more commands.`);return}s.add(i.requestId);let a=i.command;function l(){if(o||n!==i.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(a?.operation===`url`){_.set(a.query??``),a.scope&&r?.list().some(e=>e.declaration.scope===a.scope&&e.mountedCount>0)&&(h.add(a.scope),_.refresh()),S(`reply`,i.requestId);return}if(!a||!r||![`ready`,`no-controls`].includes(x().status))throw Error(`Controls runtime is unavailable.`);if(a.operation===`reset-all`){if(r.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=r.list().filter(e=>e.mountedCount>0);if(!Array.isArray(a.contexts)||a.contexts.length!==e.length||e.some(e=>!a.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);h.clear(),await d?.reset(void 0,l)}else{let e=r.list().find(e=>e.declaration.scope===a.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(a.fingerprint!==JSON.stringify(e.declaration)||a.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(a.operation===`restore`){if(!z(a.values))throw Error(`Invalid saved controls.`);await d?.restore(e,a.values,l),h.add(e.declaration.scope),_?.refresh()}else if(a.operation===`reset`)h.add(e.declaration.scope),await d?.reset(e,l);else{let t=e.declaration.controls.find(e=>e.id===a.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(h.add(e.declaration.scope),a.operation===`update`){let n={[t.id]:a.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await d?.update(e,t.id,r,l)}else if(a.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}C()}n===i.epoch&&(S(`reply`,i.requestId),d?.navigate())}catch(e){n===i.epoch&&S(`reply`,i.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let T=v();function E(e){w(e)}return window.addEventListener(`message`,E),()=>{o=!0,p?.();for(let e of m)e();i?.(),d?.dispose(),window.removeEventListener(`message`,E),_?.dispose()}}var B=`data-replica-canvas-bridge`,ve=new TextEncoder,ye=null,V=null,H=null,U=null,be=`light-dark(#0969da, #58a6ff)`,W=null,xe=``,Se=``,G=/* @__PURE__ */ new Map;function Ce(){let e=q();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{Se=`replicaControlsBinding`in e&&e.replicaControlsBinding?Ce():``});function K(e){return e.replace(/\s+/g,` `).trim()}function we(e,t){let n=``,r=0;for(let i of e){let e=ve.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function q(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname.slice(k(window.location.pathname).length-1),search:e?`?${e}`:``,hash:window.location.hash}}function Te(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Ee(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function De(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return we(K(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function Oe(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function ke(e){if(e.id){let t=`#${Oe(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}="${Oe(n)}"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function Ae(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&De(e)!==t.accessibleName?!1:!t.selectedText||K(e.textContent||``).includes(t.selectedText)}function je(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&Ae(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&Ae(r,e)){if(n)return null;n=r}return n}function Me(){let e=document.createElement(`div`);return e.setAttribute(B,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,be),document.documentElement.append(e),e}function J(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function Ne(e,t=null){H?.remove(),H=e,U=t,H.style.pointerEvents=`none`}function Y(e,t){window.parent.postMessage(t,e)}function X(){V?.(),V=null}function Z(e,t,n){X(),Y(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Pe(e,t,n){let r=e.getBoundingClientRect(),i=ke(e);if(!r.width||!r.height||!i)return null;let a=we(K(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:q(),selector:i,accessibleName:De(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:Ee(r),viewport:Te(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Fe(e,t){X();let n=null,r=Me(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${B}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,J(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Pe(n,i.clientX,i.clientY);a?(r.style.position=$(n)?`fixed`:`absolute`,J(r,n.getBoundingClientRect()),Ne(r,n),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Z(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),V=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,H!==r&&r.remove()}}function Ie(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=/* @__PURE__ */ new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(B)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=ke(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:De(e),tagName:e.tagName.toLowerCase(),role:we(e.getAttribute(`role`)||``,64),textExcerpt:we(K(e.textContent||``),500),rect:Ee(n)}]})}function Le(e){return{schemaVersion:1,kind:`area`,route:q(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:Ee(e),viewport:Te(),elements:Ie(e)}}function Re(e,t,n=!1){X();let r=document.createElement(`div`);r.setAttribute(B,``),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let i=Me();i.style.display=`none`,document.body.append(r);let a=null,o=null,s=null,c=null;function l(e,t){r.style.pointerEvents=`none`;let n=document.elementFromPoint(e,t);return r.style.pointerEvents=``,n===document.body||n===document.documentElement?null:n}function u(n,r,a){i.style.position=a&&$(a)?`fixed`:`absolute`,J(i,r),Ne(i,a),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:n})}function d(e,t){if(!a)return;let n=Math.min(a.x,e),r=Math.min(a.y,t),o=Math.abs(e-a.x),s=Math.abs(t-a.y);i.style.display=`block`,J(i,new DOMRect(n,r,o,s))}function f(e){e.button!==0||a||(e.preventDefault(),a={x:e.clientX,y:e.clientY},s=e.pointerId,o=n?l(e.clientX,e.clientY):null,r.setPointerCapture(e.pointerId),d(e.clientX,e.clientY))}function p(e){if(a)e.pointerId===s&&(e.preventDefault(),d(e.clientX,e.clientY));else{if(!n)return;let t=l(e.clientX,e.clientY);i.style.display=t?`block`:`none`,t&&J(i,t.getBoundingClientRect())}}function m(r){if(!a||r.pointerId!==s)return;r.preventDefault();let i=Math.max(0,Math.min(window.innerWidth,r.clientX)),c=Math.max(0,Math.min(window.innerHeight,r.clientY)),l=new DOMRect(Math.min(a.x,i),Math.min(a.y,c),Math.abs(i-a.x),Math.abs(c-a.y));if(n&&Math.hypot(l.width,l.height)<8){let n=o?Pe(o,a.x,a.y):null;if(!n||!o){Z(e,t,`element-unavailable`);return}u(n,o.getBoundingClientRect(),o)}else(n?l.width<8||l.height<8:Math.hypot(l.width,l.height)<8)?Z(e,t,`area-too-small`):u(Le(l),l)}function h(r){if(!n||r.detail!==0||!(r.target instanceof Element)||r.target.hasAttribute(B))return;r.preventDefault(),r.stopImmediatePropagation();let i=r.target,a=i.getBoundingClientRect(),o=Pe(i,a.left+a.width/2,a.top+a.height/2);o?u(o,a,i):Z(e,t,`element-unavailable`)}function g(n){X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t,reason:n?`interrupted`:`escape`})}function _(r){if(n&&r.shiftKey&&r.key===`Enter`)r.preventDefault(),c={x:window.innerWidth/2,y:window.innerHeight/2},a=null,i.style.display=`block`,J(i,new DOMRect(c.x,c.y,4,4));else if(c&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(r.key)){if(r.preventDefault(),r.key===`Enter`||r.key===` `){if(!a)a={...c};else{let n=new DOMRect(Math.min(a.x,c.x),Math.min(a.y,c.y),Math.abs(a.x-c.x),Math.abs(a.y-c.y));if(n.width<8||n.height<8){Z(e,t,`area-too-small`);return}u(Le(n),n)}}else c={x:Math.max(0,Math.min(window.innerWidth,c.x+(r.key===`ArrowRight`?10:r.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(window.innerHeight,c.y+(r.key===`ArrowDown`?10:r.key===`ArrowUp`?-10:0)))},a?d(c.x,c.y):J(i,new DOMRect(c.x,c.y,4,4))}else r.key===`Escape`&&(r.preventDefault(),g())}r.addEventListener(`pointerdown`,f),r.addEventListener(`pointermove`,p),r.addEventListener(`pointerup`,m),r.addEventListener(`pointercancel`,g),r.addEventListener(`lostpointercapture`,g),n&&document.addEventListener(`click`,h,!0),document.addEventListener(`keydown`,_,!0),V=()=>{r.removeEventListener(`pointerdown`,f),r.removeEventListener(`pointermove`,p),r.removeEventListener(`pointerup`,m),r.removeEventListener(`pointercancel`,g),r.removeEventListener(`lostpointercapture`,g),n&&document.removeEventListener(`click`,h,!0),document.removeEventListener(`keydown`,_,!0),r.remove(),H!==i&&i.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function ze(e){let t=q();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=je({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:$(n)}}function Be(e=!1){if(!W||!ye)return;let t=q(),n=JSON.stringify(t);e&&=n===xe,xe=n;let r=[];for(let t of W.anchors){let n=G.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=ze(t.anchor);if(!e){G.delete(t.id);continue}G.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}Y(ye,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:W.nonce,route:t,...Se===Ce()?{replaceRoute:!0}:{},results:r})}function Ve(e){let t=e.data;if(document.querySelector(`script[src="${k(window.location.pathname)}__replica/bridge/v1.js"]`)||e.source!==window.parent||e.origin!==ye||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){Y(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,improvementSelection:!0,nonce:t.nonce,route:q(),...Se===Ce()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;be=t.accent;for(let e of document.querySelectorAll(`[${B}]`))e.style.setProperty(`--replica-selection-accent`,be);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=q(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(O(n,!0)||(De(n)||K(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Fe(e.origin,t.nonce):t.mode===`area`?Re(e.origin,t.nonce):t.mode===`improvement`&&Re(e.origin,t.nonce,!0);return}if(t.type===`replica:canvas:cancel-selection`){X(),Y(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce,reason:`command`});return}if(t.type===`replica:canvas:clear-selection`){H?.remove(),H=null,U=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors))return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});W={nonce:t.nonce,anchors:n},G.clear(),Be()}var He=Symbol.for(`replica.canvas.bridge.v1`),Ue=window;function We(e,t){let n=Ue[He];if(n===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof n==`function`&&n(),be=`light-dark(#0969da, #58a6ff)`,ye=e,W=null,xe=``,G.clear();let r=_e(e,t),i=null;function a(){i!==null&&window.cancelAnimationFrame(i),i=null,H&&U&&(H.style.position=$(U)?`fixed`:`absolute`,J(H,U.getBoundingClientRect())),Be()}function o(){i===null&&W&&(i=window.requestAnimationFrame(a))}function s(e){H&&U&&(e.target!==document&&e.target!==window||$(U))&&J(H,U.getBoundingClientRect()),i===null?Be(e.target===document||e.target===window):a()}function c(){Be()}function l(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||V||!W||t.target instanceof Element&&t.target.closest(`[role="dialog"], dialog, [role="menu"]`))return;let n=W;window.setTimeout(()=>{t.defaultPrevented||V||W!==n||Y(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,Ve),window.addEventListener(`scroll`,s,{capture:!0,passive:!0}),window.addEventListener(`resize`,c),window.addEventListener(`keydown`,l);let u=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${B}], [data-replica-controls-bridge]`)))&&o()});u.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let d=typeof ResizeObserver==`function`?new ResizeObserver(o):null;d?.observe(document.documentElement),Ue[He]=()=>{window.removeEventListener(`message`,Ve),window.removeEventListener(`scroll`,s,!0),window.removeEventListener(`resize`,c),window.removeEventListener(`keydown`,l),u.disconnect(),d?.disconnect(),i!==null&&window.cancelAnimationFrame(i),W=null,xe=``,G.clear(),r(),X(),H?.remove(),H=null,U=null}}function Ge(e,t=`canvas`,n){if(t===`canvas`){if(!/^http:\/\/127\.0\.0\.1:\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`)}else{let t=URL.parse(e);if(!t||t.origin!==e||t.pathname!==`/`||t.search||t.hash||![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid Replica Hub parent.`)}We(e,n)}export{Ge as installBridge}; \ No newline at end of file diff --git a/hub/.storybook/preview-fixtures/build-controls/controls.js b/hub/.storybook/preview-fixtures/build-controls/controls.js index 265f47c03..15ad2e6d7 100644 --- a/hub/.storybook/preview-fixtures/build-controls/controls.js +++ b/hub/.storybook/preview-fixtures/build-controls/controls.js @@ -1,4 +1,4 @@ (function(){var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))(o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=P;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return L.errors=a,o===0}e.number=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.slider=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return z.errors=a,l===0}e.choice=B;function B(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return B.errors=a,o===0}e.checkboxGroup=V;function V(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return V.errors=a,o===0}e.text=H;function H(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return H.errors=a,l===0}e.color=U;function U(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return U.errors=a,o===0}e.button=W;function W(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return W.errors=a,o===0}}))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` `)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e){return/^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(e)?.[0]??`/`}function A(e,t){return JSON.stringify(e)===JSON.stringify(t)}function j(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function M(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function N(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function P(e){let t=e.binding;if(t.type===`api`){let e=N(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=M(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function F(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function I(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function L(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):F(e,t.value);if(n.type===`style`)return F(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):F(e,i)}function R(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function z(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw R(e)}finally{window.clearTimeout(n)}}function B(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function V(e,t,n){let r=e.binding;if(r.type===`api`){await z(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[I(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():B(t,`value`,I(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,I(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,I(n)):i.hash=`#${I(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function H(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${R(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(I(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return P(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(j()).origin!==new URL(i).origin:j()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await z(()=>L(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=j(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await V(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?j():a);if(!A(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=R(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${R(e).message}`)}throw!l&&A(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!A(await z(()=>L(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,j());t.rejection&&!A(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,R(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=j();t.control.binding.type===`api`?await z(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function k(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!A(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&A(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` `).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=L(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>k(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return k(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await k(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function U(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return H(JSON.parse(n))}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var G=`replica:controls`;function K(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&W(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||W({[r.id]:r.value}))}catch{return!1}}function q(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var J=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function Y(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!W(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!J.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function X(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=J.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!W({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{Y(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function Z(e,t){let n=new URL(e,window.location.href),r=X(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(Y(r.scopes)))n.searchParams.set(e,t);return n.toString()}function ee(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=Y({...X(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(Z(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=X(e);if(t.notice)throw Error(t.notice);s=Y(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function te(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var ne={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function re(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?ne.controlsActionUnavailable:``)}}function ie(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>re(e,t)))}}function ae(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=ee(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,te(q(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await U(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(q);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:G,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(K(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:ie(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!K(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!W(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!W(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var Q={enabled:!0,title:`Build preview`,items:3};function $(){let e=document.querySelector(`h1`),t=document.querySelector(`p`),n=document.querySelector(`ul`);if(!e||!t||!n)throw Error(`Build controls story markup is missing.`);e.textContent=Q.title,t.hidden=!Q.enabled,n.replaceChildren(...Array.from({length:Q.items},(e,t)=>{let n=document.createElement(`li`);return n.textContent=`Item ${t+1}`,n}))}Object.assign(window,{buildPreview:{readEnabled:()=>Q.enabled,writeEnabled:e=>{Q.enabled=e,$()},readTitle:()=>Q.title,writeTitle:e=>{Q.title=e,$()},readItems:()=>Q.items,writeItems:e=>{Q.items=e,$()},add:()=>{Q.items=Math.min(8,Q.items+1),$()}}}),$(),ae(window.location.origin)})(); \ No newline at end of file +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function U(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return H(JSON.parse(n))}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var G=`replica:controls`;function K(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&W(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||W({[r.id]:r.value}))}catch{return!1}}function q(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var J=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function Y(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!W(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!J.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function X(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=J.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!W({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{Y(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function Z(e,t){let n=new URL(e,window.location.href),r=X(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(Y(r.scopes)))n.searchParams.set(e,t);return n.toString()}function ee(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=Y({...X(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(Z(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=X(e);if(t.notice)throw Error(t.notice);s=Y(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function te(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var ne={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function re(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?ne.controlsActionUnavailable:``)}}function ie(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>re(e,t)))}}function ae(e,t){let n=``,r,i,a=``,o=!1,s=new Set,c=!1,l=0,u,d,f=!1,p,m=new Set,h=new Set,g=``,_=ee(e=>{h.clear(),S(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((r?.list()??[]).filter(e=>h.has(e.declaration.scope)).map(e=>[e.declaration.scope,te(q(e))])),e=>{g!==e&&(g=e,S(`snapshot`,`event`))});async function v(){try{if(d=await U(t),o){d?.dispose();return}r=d?.runtime,i=d?.subscribe(C),await d?.settled();let e=d;e&&y()&&await new Promise(t=>{function n(){clearTimeout(i),a(),p=void 0,t()}function r(){y()||n()}let i=setTimeout(n,500),a=e.subscribe(r);p=n,r()})}catch(e){u={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{f=!0}C()}function y(){return r?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function b(){let e=!!r;if(u)return{runtimeAvailable:e,scopes:[],...u};if(!r)return{runtimeAvailable:!1,status:f?`no-controls`:`missing-runtime`,scopes:[]};try{let e=r.list().filter(e=>e.mountedCount>0).map(q);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function x(){return{...b(),scopeErrors:[],reconnectRequired:c,...c?{error:`Reconnect controls before sending more commands.`}:{},...g?{error:`${g} Changes remain in memory and are not in the URL.`}:{}}}function S(t,r,i,a){if(o||!n)return;let s={protocol:G,version:1,type:t,epoch:n,requestId:r,sequence:++l,state:x(),...i?{error:i}:{},...a===void 0?{}:{controlQuery:a}};window.parent.postMessage(K(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function C(){for(let e of m)e();if(!f||d?.pending())return;_?.refresh();let e=JSON.stringify(x());e!==a&&(a=e,S(`snapshot`,`event`))}async function w(t){if(t.source===window.parent&&t.origin===e&&t.data&&typeof t.data==`object`&&`type`in t.data&&t.data.type===`replica:controls:status`&&`nonce`in t.data&&typeof t.data.nonce==`string`&&t.data.nonce.length<=100&&`timeoutMs`in t.data&&Number.isInteger(t.data.timeoutMs)&&typeof t.data.timeoutMs==`number`&&t.data.timeoutMs>=0&&t.data.timeoutMs<=1e4){let{nonce:n,timeoutMs:r}=t.data;function i(){return!f||d?.pending()===!0&&!x().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&r>0&&await new Promise(e=>{function t(){clearTimeout(a),m.delete(n),e()}function n(){(o||!i())&&t()}let a=setTimeout(t,r);m.add(n),n()}),o||window.parent.postMessage({type:`replica:controls:status-result`,nonce:n,value:ie(x(),i(),window.location.href)},e);return}if(t.source!==window.parent||t.origin!==e||!K(t.data))return;let a=t.data;if(a.type===`hello`){n=a.epoch,s.clear(),c=!1,h.clear();let e=a.fromFrameUrl&&_?.managed();_?.set(e?_.current():a.controlQuery??``),f||await T,S(`reply`,a.requestId,void 0,e?_?.current():void 0);return}if(a.type!==`command`||a.epoch!==n||s.has(a.requestId))return;if(s.size>=2e3){c=!0,S(`reply`,a.requestId,`Reconnect controls before sending more commands.`);return}s.add(a.requestId);let l=a.command;function u(){if(o||n!==a.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){_.set(l.query??``),l.scope&&r?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(h.add(l.scope),_.refresh()),S(`reply`,a.requestId);return}if(!l||!r||![`ready`,`no-controls`].includes(x().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(r.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=r.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);h.clear(),await d?.reset(void 0,u)}else{let e=r.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!W(l.values))throw Error(`Invalid saved controls.`);await d?.restore(e,l.values,u),h.add(e.declaration.scope),_?.refresh()}else if(l.operation===`reset`)h.add(e.declaration.scope),await d?.reset(e,u);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(h.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!W(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await d?.update(e,t.id,r,u)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}C()}n===a.epoch&&(S(`reply`,a.requestId),d?.navigate())}catch(e){n===a.epoch&&S(`reply`,a.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let T=v();function E(e){w(e)}return window.addEventListener(`message`,E),()=>{o=!0,p?.();for(let e of m)e();i?.(),d?.dispose(),window.removeEventListener(`message`,E),_?.dispose()}}var Q={enabled:!0,title:`Build preview`,items:3};function $(){let e=document.querySelector(`h1`),t=document.querySelector(`p`),n=document.querySelector(`ul`);if(!e||!t||!n)throw Error(`Build controls story markup is missing.`);e.textContent=Q.title,t.hidden=!Q.enabled,n.replaceChildren(...Array.from({length:Q.items},(e,t)=>{let n=document.createElement(`li`);return n.textContent=`Item ${t+1}`,n}))}Object.assign(window,{buildPreview:{readEnabled:()=>Q.enabled,writeEnabled:e=>{Q.enabled=e,$()},readTitle:()=>Q.title,writeTitle:e=>{Q.title=e,$()},readItems:()=>Q.items,writeItems:e=>{Q.items=e,$()},add:()=>{Q.items=Math.min(8,Q.items+1),$()}}}),$(),ae(window.location.origin)})(); \ No newline at end of file diff --git a/hub/client/application/prototype-preview-bridge/controls.test.ts b/hub/client/application/prototype-preview-bridge/controls.test.ts index 37350d8b7..dff0eb2a5 100644 --- a/hub/client/application/prototype-preview-bridge/controls.test.ts +++ b/hub/client/application/prototype-preview-bridge/controls.test.ts @@ -3,6 +3,7 @@ import { beforeEach, expect, it, onTestFinished, vi } from "vitest" import { getControlsRuntime } from "@utils/prototype-controls/controls.mjs" import { installControlsBridge } from "./controls" +import { installHostedBridge } from "./install-hosted-bridge" import { controlsEnvelope } from "@utils/prototype-controls-protocol" const origin = "http://127.0.0.1:1234" @@ -95,6 +96,80 @@ it("connects ordinary local JSON bindings and stores settings in the prototype U ) }) +it.each([ + { label: "public", basePath: "/", pathname: "/previews/github/2001/3002/details" }, + { + label: "private", + basePath: "/previews/github/2001/3002/", + pathname: "/previews/github/2001/3002/checkout/cart", + }, +])( + "loads ready $label hosted Controls from the supplied Build root", + async ({ basePath, pathname }) => { + window.history.replaceState(null, "", pathname) + document.body.innerHTML = '' + const field = document.querySelector("#title")! + vi.spyOn(field, "getBoundingClientRect").mockReturnValue(new DOMRect(0, 0, 100, 30)) + vi.spyOn(document, "readyState", "get").mockReturnValue("complete") + vi.stubGlobal( + "fetch", + vi.fn((path: string) => + Promise.resolve( + path === `${basePath}controls.replica.json` + ? Response.json({ + ...declaration, + controls: [ + { + ...declaration.controls[0], + binding: { type: "field", selector: "#title" }, + }, + ], + }) + : new Response("Not found", { status: 404 }), + ), + ), + ) + const post = vi.spyOn(window.parent, "postMessage").mockImplementation(() => {}) + const installed = Symbol.for("replica.canvas.bridge.v1") + onTestFinished(() => { + const bridgeWindow = window as Window & { [installed]?: () => void } + bridgeWindow[installed]?.() + }) + + installHostedBridge(origin, basePath) + hello() + + await vi.waitFor(() => + expect(post.mock.calls.at(-1)?.[0]).toMatchObject({ + type: "reply", + state: { status: "ready", runtimeAvailable: true }, + }), + ) + expect(fetch).toHaveBeenCalledExactlyOnceWith(`${basePath}controls.replica.json`, { + credentials: "same-origin", + redirect: "error", + }) + const controller = getControlsRuntime().list()[0]! + message({ + protocol: "replica:controls", + version: 1, + epoch: "canvas-epoch", + requestId: "update", + type: "command", + command: { + operation: "update", + scope: "canvasPage", + fingerprint: JSON.stringify(controller.declaration), + revision: controller.getSnapshot().revision, + id: "title", + value: "Hosted title", + }, + }) + await vi.waitFor(() => expect(field.value).toBe("Hosted title")) + expect(window.location.pathname).toBe(pathname) + }, +) + it("rejects foreign frames, origins, epochs and stale commands without changing app state", async () => { const post = await setup() const controller = getControlsRuntime().list()[0]! diff --git a/hub/client/application/prototype-preview-bridge/controls.ts b/hub/client/application/prototype-preview-bridge/controls.ts index 38bf0359e..f716bf91a 100644 --- a/hub/client/application/prototype-preview-bridge/controls.ts +++ b/hub/client/application/prototype-preview-bridge/controls.ts @@ -13,7 +13,7 @@ import { installControlsUrl } from "@utils/install-prototype-controls-url" import { nonDefaultValues } from "@utils/prototype-controls-url/non-default-values" import { controlsStatus } from "@utils/prototype-controls-status" -export function installControlsBridge(parentOrigin: string) { +export function installControlsBridge(parentOrigin: string, basePath?: string) { let epoch = "" let runtime: ControlsRuntime | undefined let release: (() => void) | undefined @@ -51,7 +51,7 @@ export function installControlsBridge(parentOrigin: string) { ) async function load() { try { - bindings = await loadBindings() + bindings = await loadBindings(basePath) if (disposed) { bindings?.dispose() return diff --git a/hub/client/application/prototype-preview-bridge/index.ts b/hub/client/application/prototype-preview-bridge/index.ts index 177ac2083..3efdd03fa 100644 --- a/hub/client/application/prototype-preview-bridge/index.ts +++ b/hub/client/application/prototype-preview-bridge/index.ts @@ -867,7 +867,7 @@ function receiveCanvasMessage(event: MessageEvent) { const installed = Symbol.for("replica.canvas.bridge.v1") const bridgeWindow = window as Window & { [installed]?: boolean | (() => void) } -function install(origin: string) { +function install(origin: string, controlsBasePath?: string) { const previous = bridgeWindow[installed] if (previous === true) throw new Error("Remove the old source bridge before using the extension-owned bridge.") @@ -877,7 +877,7 @@ function install(origin: string) { resolvedRequest = null resolvedRoute = "" resolvedGeometry.clear() - const releaseControls = installControlsBridge(origin) + const releaseControls = installControlsBridge(origin, controlsBasePath) let geometryFrame: number | null = null function refreshGeometry() { if (geometryFrame !== null) window.cancelAnimationFrame(geometryFrame) @@ -973,7 +973,11 @@ function install(origin: string) { } } -export function installBridge(origin: string, environment: "canvas" | "hosted" = "canvas") { +export function installBridge( + origin: string, + environment: "canvas" | "hosted" = "canvas", + controlsBasePath?: string, +) { if (environment === "canvas") { if (!/^http:\/\/127\.0\.0\.1:\d+$/.test(origin)) { throw new Error("Invalid Replica canvas parent.") @@ -991,5 +995,5 @@ export function installBridge(origin: string, environment: "canvas" | "hosted" = throw new Error("Invalid Replica Hub parent.") } } - install(origin) + install(origin, controlsBasePath) } diff --git a/hub/client/application/prototype-preview-bridge/install-hosted-bridge/index.ts b/hub/client/application/prototype-preview-bridge/install-hosted-bridge/index.ts index 100a6ce37..b4d0d69af 100644 --- a/hub/client/application/prototype-preview-bridge/install-hosted-bridge/index.ts +++ b/hub/client/application/prototype-preview-bridge/install-hosted-bridge/index.ts @@ -1,5 +1,5 @@ import { installBridge } from ".." -export function installHostedBridge(origin: string) { - installBridge(origin, "hosted") +export function installHostedBridge(origin: string, basePath: string) { + installBridge(origin, "hosted", basePath) } diff --git a/hub/client/features/install-replica-controls-bridge/bridge.js b/hub/client/features/install-replica-controls-bridge/bridge.js index e1079a8aa..ed1d91c8d 100644 --- a/hub/client/features/install-replica-controls-bridge/bridge.js +++ b/hub/client/features/install-replica-controls-bridge/bridge.js @@ -1,4 +1,4 @@ (function(){var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=((n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)))(o((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=r();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t}));e.validateShape=P;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern "^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern "^[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern "^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return L.errors=a,o===0}e.number=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return R.errors=a,l===0}e.slider=z;function z(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return z.errors=a,l===0}e.choice=B;function B(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return B.errors=a,o===0}e.checkboxGroup=V;function V(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!=="default"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return V.errors=a,o===0}e.text=H;function H(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return H.errors=a,l===0}e.color=U;function U(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!=="default"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern "^#[0-9a-fA-F]{6}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return U.errors=a,o===0}e.button=W;function W(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return W.errors=a,o===0}}))(),1);function l(e){if(e&&typeof e==`object`){for(let t of Object.values(e))l(t);Object.freeze(e)}return e}function u(e){return Array.isArray(e)?`[${e.map(u).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${u(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function d(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>d(e,t));if(e.any)return e.any.some(e=>d(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:f,validateDeclaration:p}=c.default,m={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function h(e){let t=[...p.errors].filter(e=>!/^\/controls\/\d+(?:\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(m,e?.type)?m[e.type]:void 0,i=r&&c.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params}))}var g=class extends Error{constructor(e){super(`Invalid controls.replica.json:\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(` `)}`),this.name=`ControlsValidationError`,this.issues=e}};function _(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function v(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(v):[]}function y(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new g([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...v(s.when),...v(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function b(e){let t=new Set;function n(e,r=0){if(r>24)throw new g([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new g([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new g([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new g([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new g([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function x(e){b(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return C(e),S(e),e;if(!f(e))throw new g(f.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: "${e.params.additionalProperty}"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{C(e),S(e)}catch(e){throw e instanceof g?new g(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new g([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function S(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new g(t)}function C(e){if(b(e),!p(e))throw new g(h(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=_(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=_(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new g(t);return y(e),e}var w=Symbol.for(`replica.controls.injected.runtime`),T=new WeakMap;function E(){let e=globalThis[w];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>D(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});T.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[w]=n}return globalThis[w]}function D(e){C(e);let t=l(structuredClone(e)),n=u(t),r=E(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(u(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope "${t.scope}"; reload after schema changes`);return i}let a=T.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=y(t),f=new Set,p=new Map,m=new Set,h={},g=0,v=!1,b=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function w(e){let n={};for(let t of c){let r=o.get(t);n[t]=d(r.when,e)&&d(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return l({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,d(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function D(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=l({...w(D()),revision:g});function O(e){let t=w(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(u(t)!==u(n)&&(x=l({...t,revision:++g}),b=!0,!v)){v=!0;try{for(;b;){b=!1;for(let e of[...f])e();a.notify()}}finally{v=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control "${e}"`);if(!x.visible[e])throw Error(`Control "${e}" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return f.add(e),()=>f.delete(e)},update(e,t){let n=_(k(e),t);if(n)throw Error(`Control "${e}": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control "${n}"`);let i=_(e,r);if(i)throw Error(`Control "${n}": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control "${e}"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(D());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control "${e}" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for "${e}"`);if(m.has(e))throw Error(`Action "${e}" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function O(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role="button"], [role="link"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function k(e){return/^\/previews\/github\/[1-9]\d*\/[1-9]\d*\//.exec(e)?.[0]??`/`}function A(e,t){return JSON.stringify(e)===JSON.stringify(t)}function j(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function M(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function N(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API "${e}" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API "${e}" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function P(e){let t=e.binding;if(t.type===`api`){let e=N(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method "${n}" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=M(t.selector),r=O(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function F(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\(/.test(t)){let e=t.match(/\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function I(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function L(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):F(e,t.value);if(n.type===`style`)return F(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):F(e,i)}function R(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function z(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw R(e)}finally{window.clearTimeout(n)}}function B(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function V(e,t,n){let r=e.binding;if(r.type===`api`){await z(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[I(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():B(t,`value`,I(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,I(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,I(n)):i.hash=`#${I(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,"replicaControlsBinding",{value:!0}),window.dispatchEvent(a)}function H(e){x(e);let t=(e.sets??[e]).map(e=>({controller:D(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=E().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!O(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${R(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(I(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return P(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(j()).origin!==new URL(i).origin:j()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function v(e,t,n,r){let i=await z(()=>L(t.control,n));g(e,t,n,r);let a=_(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function b(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=j(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await V(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await v(e,t,o,s?j():a);if(!A(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=R(s),l=!1;if(o)try{let n=await v(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${R(e).message}`)}throw!l&&A(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function S(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await b(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!A(await z(()=>L(n,r)),n.default))await b(e,t,n.default);else{let n=await v(e,t,r,j());t.rejection&&!A(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,R(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=j();t.control.binding.type===`api`?await z(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>S(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function k(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of y(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!A(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await b(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&A(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(` `).slice(0,1e3))}let M=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=L(t.control,t.object),r=_(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:E(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>k(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?_(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return k(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await k(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(` -`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function U(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return H(JSON.parse(n))}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var G=`replica:controls`;function K(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&W(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||W({[r.id]:r.value}))}catch{return!1}}function q(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var J=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function Y(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!W(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!J.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function X(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=J.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!W({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{Y(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function Z(e,t){let n=new URL(e,window.location.href),r=X(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(Y(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Q(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=Y({...X(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(Z(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=X(e);if(t.notice)throw Error(t.notice);s=Y(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function $(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var ee={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function te(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?ee.controlsActionUnavailable:``)}}function ne(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>te(e,t)))}}function re(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=Q(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,$(q(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await U(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(q);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:G,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(K(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:ne(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!K(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!W(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!W(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}re(`__REPLICA_CONTROLS_PARENT_ORIGIN__`)})(); \ No newline at end of file +`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(M);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function U(e=k(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\s*<(?:!doctype html|html)/i.test(n)))return H(JSON.parse(n))}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var G=`replica:controls`;function K(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&W(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||W({[r.id]:r.value}))}catch{return!1}}function q(e){return C(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var J=/^rc\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function Y(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!W(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!J.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function X(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=J.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!W({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{Y(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function Z(e,t){let n=new URL(e,window.location.href),r=X(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(Y(r.scopes)))n.searchParams.set(e,t);return n.toString()}function Q(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=Y({...X(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(Z(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=X(e);if(t.notice)throw Error(t.notice);s=Y(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function $(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var ee={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope "${e}" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function te(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?ee.controlsActionUnavailable:``)}}function ne(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>te(e,t)))}}function re(e,t){let n=``,r,i,a=``,o=!1,s=new Set,c=!1,l=0,u,d,f=!1,p,m=new Set,h=new Set,g=``,_=Q(e=>{h.clear(),S(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((r?.list()??[]).filter(e=>h.has(e.declaration.scope)).map(e=>[e.declaration.scope,$(q(e))])),e=>{g!==e&&(g=e,S(`snapshot`,`event`))});async function v(){try{if(d=await U(t),o){d?.dispose();return}r=d?.runtime,i=d?.subscribe(C),await d?.settled();let e=d;e&&y()&&await new Promise(t=>{function n(){clearTimeout(i),a(),p=void 0,t()}function r(){y()||n()}let i=setTimeout(n,500),a=e.subscribe(r);p=n,r()})}catch(e){u={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{f=!0}C()}function y(){return r?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function b(){let e=!!r;if(u)return{runtimeAvailable:e,scopes:[],...u};if(!r)return{runtimeAvailable:!1,status:f?`no-controls`:`missing-runtime`,scopes:[]};try{let e=r.list().filter(e=>e.mountedCount>0).map(q);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function x(){return{...b(),scopeErrors:[],reconnectRequired:c,...c?{error:`Reconnect controls before sending more commands.`}:{},...g?{error:`${g} Changes remain in memory and are not in the URL.`}:{}}}function S(t,r,i,a){if(o||!n)return;let s={protocol:G,version:1,type:t,epoch:n,requestId:r,sequence:++l,state:x(),...i?{error:i}:{},...a===void 0?{}:{controlQuery:a}};window.parent.postMessage(K(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function C(){for(let e of m)e();if(!f||d?.pending())return;_?.refresh();let e=JSON.stringify(x());e!==a&&(a=e,S(`snapshot`,`event`))}async function w(t){if(t.source===window.parent&&t.origin===e&&t.data&&typeof t.data==`object`&&`type`in t.data&&t.data.type===`replica:controls:status`&&`nonce`in t.data&&typeof t.data.nonce==`string`&&t.data.nonce.length<=100&&`timeoutMs`in t.data&&Number.isInteger(t.data.timeoutMs)&&typeof t.data.timeoutMs==`number`&&t.data.timeoutMs>=0&&t.data.timeoutMs<=1e4){let{nonce:n,timeoutMs:r}=t.data;function i(){return!f||d?.pending()===!0&&!x().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&r>0&&await new Promise(e=>{function t(){clearTimeout(a),m.delete(n),e()}function n(){(o||!i())&&t()}let a=setTimeout(t,r);m.add(n),n()}),o||window.parent.postMessage({type:`replica:controls:status-result`,nonce:n,value:ne(x(),i(),window.location.href)},e);return}if(t.source!==window.parent||t.origin!==e||!K(t.data))return;let a=t.data;if(a.type===`hello`){n=a.epoch,s.clear(),c=!1,h.clear();let e=a.fromFrameUrl&&_?.managed();_?.set(e?_.current():a.controlQuery??``),f||await T,S(`reply`,a.requestId,void 0,e?_?.current():void 0);return}if(a.type!==`command`||a.epoch!==n||s.has(a.requestId))return;if(s.size>=2e3){c=!0,S(`reply`,a.requestId,`Reconnect controls before sending more commands.`);return}s.add(a.requestId);let l=a.command;function u(){if(o||n!==a.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){_.set(l.query??``),l.scope&&r?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(h.add(l.scope),_.refresh()),S(`reply`,a.requestId);return}if(!l||!r||![`ready`,`no-controls`].includes(x().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(r.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=r.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);h.clear(),await d?.reset(void 0,u)}else{let e=r.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!W(l.values))throw Error(`Invalid saved controls.`);await d?.restore(e,l.values,u),h.add(e.declaration.scope),_?.refresh()}else if(l.operation===`reset`)h.add(e.declaration.scope),await d?.reset(e,u);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(h.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!W(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await d?.update(e,t.id,r,u)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}C()}n===a.epoch&&(S(`reply`,a.requestId),d?.navigate())}catch(e){n===a.epoch&&S(`reply`,a.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let T=v();function E(e){w(e)}return window.addEventListener(`message`,E),()=>{o=!0,p?.();for(let e of m)e();i?.(),d?.dispose(),window.removeEventListener(`message`,E),_?.dispose()}}re(`__REPLICA_CONTROLS_PARENT_ORIGIN__`)})(); \ No newline at end of file diff --git a/hub/docs/build-previews.md b/hub/docs/build-previews.md index dfd111051..7bd20284b 100644 --- a/hub/docs/build-previews.md +++ b/hub/docs/build-previews.md @@ -48,7 +48,7 @@ The `/previews/` mount accepts only GET and HEAD and precedes the Hub SPA fallba Hub rejects malformed provider IDs, traversal, encoded separators, backslashes, controls, and unsafe package paths before storage access. Paths are decoded once, so accepted literal-percent filenames remain usable. `/` serves `dist/index.html`; a slash-terminated directory first tries its nested `index.html`. Missing extensionless HTML navigations may use the root SPA document. Dotted routes receive that fallback only when the saved template manifest declares them. Missing scripts and other assets return 404. Screenshot capture uses the same slash-sensitive document selection. Content types come from the stored path and responses disable MIME sniffing. -Hub injects only its prefixed `__replica/bridge/v1.js` script into HTML. `__replica/` is reserved for that bridge and authorized screenshots. Controls load the retained Build's own `controls.replica.json`. Review and canvas messages still validate their schema, origin, and source frame. Review anchors store logical paths relative to the Build root, compare consistently across owning-run mounts, and retain query and fragment encoding. Navigation adds the active Build prefix again. Templates and public shares do not enable review. +Hub injects only its prefixed `__replica/bridge/v1.js` script into HTML. `__replica/` is reserved for that bridge and authorized screenshots. The hosted bridge passes Controls the Build's serving base: the canonical prefix for private previews and `/` for public shares. Controls load that Build's own `controls.replica.json`, independent of the app's current route. Review and canvas messages still validate their schema, origin, and source frame. Review anchors store logical paths relative to the Build root, compare consistently across owning-run mounts, and retain query and fragment encoding. Navigation adds the active Build prefix again. Templates and public shares do not enable review. ## Trusted-publisher boundary diff --git a/hub/server/assets/hosted-preview-bridge.ts b/hub/server/assets/hosted-preview-bridge.ts index 103c59230..8c578cb1b 100644 --- a/hub/server/assets/hosted-preview-bridge.ts +++ b/hub/server/assets/hosted-preview-bridge.ts @@ -1,2 +1,2 @@ // prettier-ignore -export const hostedPreviewBridgeSource = "var ReplicaHostedPreviewBridge=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;lt[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=((e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)))(s((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});var t=r();t.code=`require(\"ajv/dist/runtime/equal\").default`,e.default=t}));e.validateShape=ee;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern \"^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern \"^[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==\"default\"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern \"^#[0-9a-fA-F]{6}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return F.errors=a,o===0}e.number=I;function I(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return I.errors=a,l===0}e.slider=L;function L(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return L.errors=a,l===0}e.choice=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return R.errors=a,o===0}e.checkboxGroup=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==\"default\"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.text=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return re.errors=a,l===0}e.color=ie;function ie(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern \"^#[0-9a-fA-F]{6}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ie.errors=a,o===0}e.button=ae;function ae(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ae.errors=a,o===0}}))(),1);function u(e){if(e&&typeof e==`object`){for(let t of Object.values(e))u(t);Object.freeze(e)}return e}function d(e){return Array.isArray(e)?`[${e.map(d).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${d(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function f(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>f(e,t));if(e.any)return e.any.some(e=>f(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:p,validateDeclaration:m}=l.default,h={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function g(e){let t=[...m.errors].filter(e=>!/^\\/controls\\/\\d+(?:\\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(h,e?.type)?h[e.type]:void 0,i=r&&l.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: \"${e.params.additionalProperty}\"`:e.message,keyword:e.keyword,params:e.params}))}var _=class extends Error{constructor(e){super(`Invalid controls.replica.json:\\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(`\n`)}`),this.name=`ControlsValidationError`,this.issues=e}};function v(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function y(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(y):[]}function b(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new _([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...y(s.when),...y(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function x(e){let t=new Set;function n(e,r=0){if(r>24)throw new _([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new _([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new _([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new _([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new _([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function S(e){x(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return w(e),C(e),e;if(!p(e))throw new _(p.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: \"${e.params.additionalProperty}\"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{w(e),C(e)}catch(e){throw e instanceof _?new _(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new _([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function C(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new _(t)}function w(e){if(x(e),!m(e))throw new _(g(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=v(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=v(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new _(t);return b(e),e}var T=Symbol.for(`replica.controls.injected.runtime`),E=new WeakMap;function D(){let e=globalThis[T];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>O(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});E.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[T]=n}return globalThis[T]}function O(e){w(e);let t=u(structuredClone(e)),n=d(t),r=D(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(d(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope \"${t.scope}\"; reload after schema changes`);return i}let a=E.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=b(t),l=new Set,p=new Map,m=new Set,h={},g=0,_=!1,y=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function C(e){let n={};for(let t of c){let r=o.get(t);n[t]=f(r.when,e)&&f(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return u({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,f(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function T(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=u({...C(T()),revision:g});function O(e){let t=C(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(d(t)!==d(n)&&(x=u({...t,revision:++g}),y=!0,!_)){_=!0;try{for(;y;){y=!1;for(let e of[...l])e();a.notify()}}finally{_=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control \"${e}\"`);if(!x.visible[e])throw Error(`Control \"${e}\" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return l.add(e),()=>l.delete(e)},update(e,t){let n=v(k(e),t);if(n)throw Error(`Control \"${e}\": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control \"${n}\"`);let i=v(e,r);if(i)throw Error(`Control \"${n}\": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control \"${e}\"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(T());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control \"${e}\" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for \"${e}\"`);if(m.has(e))throw Error(`Action \"${e}\" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function k(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role=\"button\"], [role=\"link\"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function A(e){return/^\\/previews\\/github\\/[1-9]\\d*\\/[1-9]\\d*\\//.exec(e)?.[0]??`/`}function j(e,t){return JSON.stringify(e)===JSON.stringify(t)}function M(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function N(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function ee(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API \"${e}\" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API \"${e}\" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function te(e){let t=e.binding;if(t.type===`api`){let e=ee(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method \"${n}\" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=N(t.selector),r=k(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\\(/.test(t)){let e=t.match(/\\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function ne(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function re(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():ne(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,\"replicaControlsBinding\",{value:!0}),window.dispatchEvent(a)}function ie(e){S(e);let t=(e.sets??[e]).map(e=>({controller:O(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=D().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!k(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return te(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(M()).origin!==new URL(i).origin:M()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function _(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=v(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function y(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=M(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await re(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await _(e,t,o,s?M():a);if(!j(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await _(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${L(e).message}`)}throw!l&&j(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function x(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await y(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!j(await R(()=>I(n,r)),n.default))await y(e,t,n.default);else{let n=await _(e,t,r,M());t.rejection&&!j(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=M();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>x(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function E(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of b(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!j(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await y(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&j(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(`\n`).slice(0,1e3))}let A=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=v(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:D(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>E(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?v(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return E(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await E(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(`\n`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(A);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function ae(e=A(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\\s*<(?:!doctype html|html)/i.test(n)))return ie(JSON.parse(n))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var oe=`replica:controls`;function se(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function ce(e){return w(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var le=/^rc\\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function ue(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!le.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function de(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=le.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{ue(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function fe(e,t){let n=new URL(e,window.location.href),r=de(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(ue(r.scopes)))n.searchParams.set(e,t);return n.toString()}function pe(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=ue({...de(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(fe(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=de(e);if(t.notice)throw Error(t.notice);s=ue(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function me(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var he={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope \"${e}\" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ge(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?he.controlsActionUnavailable:``)}}function _e(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>ge(e,t)))}}function ve(e){let t=``,n,r,i=``,a=!1,o=new Set,s=!1,c=0,l,u,d=!1,f,p=new Set,m=new Set,h=``,g=pe(e=>{m.clear(),x(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((n?.list()??[]).filter(e=>m.has(e.declaration.scope)).map(e=>[e.declaration.scope,me(ce(e))])),e=>{h!==e&&(h=e,x(`snapshot`,`event`))});async function _(){try{if(u=await ae(),a){u?.dispose();return}n=u?.runtime,r=u?.subscribe(S),await u?.settled();let e=u;e&&v()&&await new Promise(t=>{function n(){clearTimeout(i),a(),f=void 0,t()}function r(){v()||n()}let i=setTimeout(n,500),a=e.subscribe(r);f=n,r()})}catch(e){l={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{d=!0}S()}function v(){return n?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function y(){let e=!!n;if(l)return{runtimeAvailable:e,scopes:[],...l};if(!n)return{runtimeAvailable:!1,status:d?`no-controls`:`missing-runtime`,scopes:[]};try{let e=n.list().filter(e=>e.mountedCount>0).map(ce);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function b(){return{...y(),scopeErrors:[],reconnectRequired:s,...s?{error:`Reconnect controls before sending more commands.`}:{},...h?{error:`${h} Changes remain in memory and are not in the URL.`}:{}}}function x(n,r,i,o){if(a||!t)return;let s={protocol:oe,version:1,type:n,epoch:t,requestId:r,sequence:++c,state:b(),...i?{error:i}:{},...o===void 0?{}:{controlQuery:o}};window.parent.postMessage(se(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function S(){for(let e of p)e();if(!d||u?.pending())return;g?.refresh();let e=JSON.stringify(b());e!==i&&(i=e,x(`snapshot`,`event`))}async function C(r){if(r.source===window.parent&&r.origin===e&&r.data&&typeof r.data==`object`&&`type`in r.data&&r.data.type===`replica:controls:status`&&`nonce`in r.data&&typeof r.data.nonce==`string`&&r.data.nonce.length<=100&&`timeoutMs`in r.data&&Number.isInteger(r.data.timeoutMs)&&typeof r.data.timeoutMs==`number`&&r.data.timeoutMs>=0&&r.data.timeoutMs<=1e4){let{nonce:t,timeoutMs:n}=r.data;function i(){return!d||u?.pending()===!0&&!b().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&n>0&&await new Promise(e=>{function t(){clearTimeout(o),p.delete(r),e()}function r(){(a||!i())&&t()}let o=setTimeout(t,n);p.add(r),r()}),a||window.parent.postMessage({type:`replica:controls:status-result`,nonce:t,value:_e(b(),i(),window.location.href)},e);return}if(r.source!==window.parent||r.origin!==e||!se(r.data))return;let c=r.data;if(c.type===`hello`){t=c.epoch,o.clear(),s=!1,m.clear();let e=c.fromFrameUrl&&g?.managed();g?.set(e?g.current():c.controlQuery??``),d||await w,x(`reply`,c.requestId,void 0,e?g?.current():void 0);return}if(c.type!==`command`||c.epoch!==t||o.has(c.requestId))return;if(o.size>=2e3){s=!0,x(`reply`,c.requestId,`Reconnect controls before sending more commands.`);return}o.add(c.requestId);let l=c.command;function f(){if(a||t!==c.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){g.set(l.query??``),l.scope&&n?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(m.add(l.scope),g.refresh()),x(`reply`,c.requestId);return}if(!l||!n||![`ready`,`no-controls`].includes(b().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(n.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=n.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);m.clear(),await u?.reset(void 0,f)}else{let e=n.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!z(l.values))throw Error(`Invalid saved controls.`);await u?.restore(e,l.values,f),m.add(e.declaration.scope),g?.refresh()}else if(l.operation===`reset`)m.add(e.declaration.scope),await u?.reset(e,f);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(m.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await u?.update(e,t.id,r,f)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}S()}t===c.epoch&&(x(`reply`,c.requestId),u?.navigate())}catch(e){t===c.epoch&&x(`reply`,c.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let w=_();function T(e){C(e)}return window.addEventListener(`message`,T),()=>{a=!0,f?.();for(let e of p)e();r?.(),u?.dispose(),window.removeEventListener(`message`,T),g?.dispose()}}var B=`data-replica-canvas-bridge`,ye=new TextEncoder,be=null,V=null,H=null,U=null,xe=`light-dark(#0969da, #58a6ff)`,W=null,Se=``,Ce=``,G=new Map;function we(){let e=q();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{Ce=`replicaControlsBinding`in e&&e.replicaControlsBinding?we():``});function K(e){return e.replace(/\\s+/g,` `).trim()}function Te(e,t){let n=``,r=0;for(let i of e){let e=ye.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function q(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname.slice(A(window.location.pathname).length-1),search:e?`?${e}`:``,hash:window.location.hash}}function Ee(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function De(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function Oe(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return Te(K(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function ke(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\\\${e}`)}function Ae(e){if(e.id){let t=`#${ke(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}=\"${ke(n)}\"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function je(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&Oe(e)!==t.accessibleName?!1:!t.selectedText||K(e.textContent||``).includes(t.selectedText)}function Me(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&je(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&je(r,e)){if(n)return null;n=r}return n}function Ne(){let e=document.createElement(`div`);return e.setAttribute(B,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,xe),document.documentElement.append(e),e}function J(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function Pe(e,t=null){H?.remove(),H=e,U=t,H.style.pointerEvents=`none`}function Y(e,t){window.parent.postMessage(t,e)}function X(){V?.(),V=null}function Z(e,t,n){X(),Y(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Fe(e,t,n){let r=e.getBoundingClientRect(),i=Ae(e);if(!r.width||!r.height||!i)return null;let a=Te(K(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:q(),selector:i,accessibleName:Oe(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:De(r),viewport:Ee(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Ie(e,t){X();let n=null,r=Ne(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${B}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,J(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Fe(n,i.clientX,i.clientY);a?(r.style.position=$(n)?`fixed`:`absolute`,J(r,n.getBoundingClientRect()),Pe(r,n),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Z(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),V=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,H!==r&&r.remove()}}function Le(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(B)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=Ae(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:Oe(e),tagName:e.tagName.toLowerCase(),role:Te(e.getAttribute(`role`)||``,64),textExcerpt:Te(K(e.textContent||``),500),rect:De(n)}]})}function Re(e){return{schemaVersion:1,kind:`area`,route:q(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:De(e),viewport:Ee(),elements:Le(e)}}function ze(e,t,n=!1){X();let r=document.createElement(`div`);r.setAttribute(B,``),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let i=Ne();i.style.display=`none`,document.body.append(r);let a=null,o=null,s=null,c=null;function l(e,t){r.style.pointerEvents=`none`;let n=document.elementFromPoint(e,t);return r.style.pointerEvents=``,n===document.body||n===document.documentElement?null:n}function u(n,r,a){i.style.position=a&&$(a)?`fixed`:`absolute`,J(i,r),Pe(i,a),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:n})}function d(e,t){if(!a)return;let n=Math.min(a.x,e),r=Math.min(a.y,t),o=Math.abs(e-a.x),s=Math.abs(t-a.y);i.style.display=`block`,J(i,new DOMRect(n,r,o,s))}function f(e){e.button!==0||a||(e.preventDefault(),a={x:e.clientX,y:e.clientY},s=e.pointerId,o=n?l(e.clientX,e.clientY):null,r.setPointerCapture(e.pointerId),d(e.clientX,e.clientY))}function p(e){if(a)e.pointerId===s&&(e.preventDefault(),d(e.clientX,e.clientY));else{if(!n)return;let t=l(e.clientX,e.clientY);i.style.display=t?`block`:`none`,t&&J(i,t.getBoundingClientRect())}}function m(r){if(!a||r.pointerId!==s)return;r.preventDefault();let i=Math.max(0,Math.min(window.innerWidth,r.clientX)),c=Math.max(0,Math.min(window.innerHeight,r.clientY)),l=new DOMRect(Math.min(a.x,i),Math.min(a.y,c),Math.abs(i-a.x),Math.abs(c-a.y));if(n&&Math.hypot(l.width,l.height)<8){let n=o?Fe(o,a.x,a.y):null;if(!n||!o){Z(e,t,`element-unavailable`);return}u(n,o.getBoundingClientRect(),o)}else(n?l.width<8||l.height<8:Math.hypot(l.width,l.height)<8)?Z(e,t,`area-too-small`):u(Re(l),l)}function h(r){if(!n||r.detail!==0||!(r.target instanceof Element)||r.target.hasAttribute(B))return;r.preventDefault(),r.stopImmediatePropagation();let i=r.target,a=i.getBoundingClientRect(),o=Fe(i,a.left+a.width/2,a.top+a.height/2);o?u(o,a,i):Z(e,t,`element-unavailable`)}function g(n){X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t,reason:n?`interrupted`:`escape`})}function _(r){if(n&&r.shiftKey&&r.key===`Enter`)r.preventDefault(),c={x:window.innerWidth/2,y:window.innerHeight/2},a=null,i.style.display=`block`,J(i,new DOMRect(c.x,c.y,4,4));else if(c&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(r.key)){if(r.preventDefault(),r.key===`Enter`||r.key===` `){if(!a)a={...c};else{let n=new DOMRect(Math.min(a.x,c.x),Math.min(a.y,c.y),Math.abs(a.x-c.x),Math.abs(a.y-c.y));if(n.width<8||n.height<8){Z(e,t,`area-too-small`);return}u(Re(n),n)}}else c={x:Math.max(0,Math.min(window.innerWidth,c.x+(r.key===`ArrowRight`?10:r.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(window.innerHeight,c.y+(r.key===`ArrowDown`?10:r.key===`ArrowUp`?-10:0)))},a?d(c.x,c.y):J(i,new DOMRect(c.x,c.y,4,4))}else r.key===`Escape`&&(r.preventDefault(),g())}r.addEventListener(`pointerdown`,f),r.addEventListener(`pointermove`,p),r.addEventListener(`pointerup`,m),r.addEventListener(`pointercancel`,g),r.addEventListener(`lostpointercapture`,g),n&&document.addEventListener(`click`,h,!0),document.addEventListener(`keydown`,_,!0),V=()=>{r.removeEventListener(`pointerdown`,f),r.removeEventListener(`pointermove`,p),r.removeEventListener(`pointerup`,m),r.removeEventListener(`pointercancel`,g),r.removeEventListener(`lostpointercapture`,g),n&&document.removeEventListener(`click`,h,!0),document.removeEventListener(`keydown`,_,!0),r.remove(),H!==i&&i.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function Be(e){let t=q();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=Me({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:$(n)}}function Ve(e=!1){if(!W||!be)return;let t=q(),n=JSON.stringify(t);e&&=n===Se,Se=n;let r=[];for(let t of W.anchors){let n=G.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=Be(t.anchor);if(!e){G.delete(t.id);continue}G.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}Y(be,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:W.nonce,route:t,...Ce===we()?{replaceRoute:!0}:{},results:r})}function He(e){let t=e.data;if(document.querySelector(`script[src=\"${A(window.location.pathname)}__replica/bridge/v1.js\"]`)||e.source!==window.parent||e.origin!==be||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){Y(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,improvementSelection:!0,nonce:t.nonce,route:q(),...Ce===we()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;xe=t.accent;for(let e of document.querySelectorAll(`[${B}]`))e.style.setProperty(`--replica-selection-accent`,xe);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=q(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(k(n,!0)||(Oe(n)||K(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Ie(e.origin,t.nonce):t.mode===`area`?ze(e.origin,t.nonce):t.mode===`improvement`&&ze(e.origin,t.nonce,!0);return}if(t.type===`replica:canvas:cancel-selection`){X(),Y(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce,reason:`command`});return}if(t.type===`replica:canvas:clear-selection`){H?.remove(),H=null,U=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors))return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});W={nonce:t.nonce,anchors:n},G.clear(),Ve()}var Ue=Symbol.for(`replica.canvas.bridge.v1`),We=window;function Ge(e){let t=We[Ue];if(t===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof t==`function`&&t(),xe=`light-dark(#0969da, #58a6ff)`,be=e,W=null,Se=``,G.clear();let n=ve(e),r=null;function i(){r!==null&&window.cancelAnimationFrame(r),r=null,H&&U&&(H.style.position=$(U)?`fixed`:`absolute`,J(H,U.getBoundingClientRect())),Ve()}function a(){r===null&&W&&(r=window.requestAnimationFrame(i))}function o(e){H&&U&&(e.target!==document&&e.target!==window||$(U))&&J(H,U.getBoundingClientRect()),r===null?Ve(e.target===document||e.target===window):i()}function s(){Ve()}function c(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||V||!W||t.target instanceof Element&&t.target.closest(`[role=\"dialog\"], dialog, [role=\"menu\"]`))return;let n=W;window.setTimeout(()=>{t.defaultPrevented||V||W!==n||Y(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,He),window.addEventListener(`scroll`,o,{capture:!0,passive:!0}),window.addEventListener(`resize`,s),window.addEventListener(`keydown`,c);let l=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${B}], [data-replica-controls-bridge]`)))&&a()});l.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let u=typeof ResizeObserver==`function`?new ResizeObserver(a):null;u?.observe(document.documentElement),We[Ue]=()=>{window.removeEventListener(`message`,He),window.removeEventListener(`scroll`,o,!0),window.removeEventListener(`resize`,s),window.removeEventListener(`keydown`,c),l.disconnect(),u?.disconnect(),r!==null&&window.cancelAnimationFrame(r),W=null,Se=``,G.clear(),n(),X(),H?.remove(),H=null,U=null}}function Ke(e,t=`canvas`){if(t===`canvas`){if(!/^http:\\/\\/127\\.0\\.0\\.1:\\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`)}else{let t=URL.parse(e);if(!t||t.origin!==e||t.pathname!==`/`||t.search||t.hash||![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid Replica Hub parent.`)}Ge(e)}function qe(e){Ke(e,`hosted`)}return e.installHostedBridge=qe,e})({});" +export const hostedPreviewBridgeSource = "var ReplicaHostedPreviewBridge=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;lt[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=((e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)))(s((e=>{var t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r=55296&&i<=56319&&r{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),i=t((e=>{Object.defineProperty(e,\"__esModule\",{value:!0});var t=r();t.code=`require(\"ajv/dist/runtime/equal\").default`,e.default=t}));e.validateShape=ee;var a={type:`object`,additionalProperties:!1,required:[`version`,`scope`,`controls`],properties:{$schema:{type:`string`},version:{const:1},scope:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},role:{enum:[`shared`,`page`]},container:{$ref:`#/$defs/selector`},panel:{type:`object`,additionalProperties:!1,required:[`width`],properties:{width:{type:`integer`,minimum:160,maximum:4096}}},groups:{type:`array`,maxItems:100,items:{type:`object`,additionalProperties:!1,required:[`id`,`label`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},when:{$ref:`#/$defs/condition`}}}},controls:{type:`array`,maxItems:500,items:{oneOf:[{$ref:`#/$defs/boolean`},{$ref:`#/$defs/number`},{$ref:`#/$defs/slider`},{$ref:`#/$defs/choice`},{$ref:`#/$defs/checkboxGroup`},{$ref:`#/$defs/text`},{$ref:`#/$defs/color`},{$ref:`#/$defs/button`}]}}}},o=Object.prototype.hasOwnProperty,s=n().default,c=RegExp(`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`,`u`),l={type:[`string`,`number`,`boolean`]},u=i().default,d={validate:f};function f(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0,s=o,p=!1,m=null,h=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.equals===void 0){let e={instancePath:t,schemaPath:`#/oneOf/0/required`,keyword:`required`,params:{missingProperty:`equals`},message:`must have required property 'equals'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`equals`){let e={instancePath:t,schemaPath:`#/oneOf/0/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.equals!==void 0){let n=e.equals;if(typeof n!=`string`&&!(typeof n==`number`&&isFinite(n))&&typeof n!=`boolean`){let e={instancePath:t+`/equals`,schemaPath:`#/$defs/scalar/type`,keyword:`type`,params:{type:l.type},message:`must be string,number,boolean`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=h===o;g&&(p=!0,m=0);let _=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.in===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`in`},message:`must have required property 'in'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`in`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.in!==void 0){let n=e.in;if(Array.isArray(n)){if(n.length>20){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/maxItems`,keyword:`maxItems`,params:{limit:20},message:`must NOT have more than 20 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r1){outer0:for(;r--;)for(i=r;i--;)if(u(n[r],n[i])){let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[e]:a.push(e),o++;break outer0}}}else{let e={instancePath:t+`/in`,schemaPath:`#/oneOf/1/properties/in/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=_===o;if(g&&p)p=!1,m=[m,1];else{g&&(p=!0,m=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.control===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`control`},message:`must have required property 'control'`};a===null?a=[e]:a.push(e),o++}if(e.includes===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`includes`},message:`must have required property 'includes'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`control`&&n!==`includes`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.control!==void 0){let n=e.control;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/control`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.includes!==void 0&&typeof e.includes!=`string`){let e={instancePath:t+`/includes`,schemaPath:`#/oneOf/2/properties/includes/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var g=n===o;if(g&&p)p=!1,m=[m,2];else{g&&(p=!0,m=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.all===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`all`},message:`must have required property 'all'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`all`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.all!==void 0){let n=e.all;if(Array.isArray(n)){if(n.length>10){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/all`,schemaPath:`#/oneOf/3/properties/all/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r10){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/maxItems`,keyword:`maxItems`,params:{limit:10},message:`must NOT have more than 10 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/any`,schemaPath:`#/oneOf/4/properties/any/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/0/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=d===o;f&&(l=!0,u=0);let v=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.selector===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`selector`},message:`must have required property 'selector'`};a===null?a=[e]:a.push(e),o++}if(e.property===void 0){let e={instancePath:t,schemaPath:`#/oneOf/1/required`,keyword:`required`,params:{missingProperty:`property`},message:`must have required property 'property'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`selector`&&n!==`property`){let e={instancePath:t,schemaPath:`#/oneOf/1/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`style`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/1/properties/type/const`,keyword:`const`,params:{allowedValue:`style`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.selector!==void 0){let n=e.selector;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/selector`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.property!==void 0){let n=e.property;if(typeof n==`string`){if(s(n)>100){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/maxLength`,keyword:`maxLength`,params:{limit:100},message:`must NOT have more than 100 characters`};a===null?a=[e]:a.push(e),o++}if(!m.test(n)){let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/pattern`,keyword:`pattern`,params:{pattern:`^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$`},message:`must match pattern \"^(--[a-zA-Z0-9_-]+|[a-z][a-z-]*)$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/property`,schemaPath:`#/oneOf/1/properties/property/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/1/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=v===o;if(f&&l)l=!1,u=[u,1];else{f&&(l=!0,u=1);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.key===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`key`},message:`must have required property 'key'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/2/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`key`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/2/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`query`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/2/properties/type/const`,keyword:`const`,params:{allowedValue:`query`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.key!==void 0){let n=e.key;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/key`,schemaPath:`#/oneOf/2/properties/key/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/2/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[2].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/2/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,2];else{f&&(l=!0,u=2);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.mode===void 0){let e={instancePath:t,schemaPath:`#/oneOf/3/required`,keyword:`required`,params:{missingProperty:`mode`},message:`must have required property 'mode'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`mode`){let e={instancePath:t,schemaPath:`#/oneOf/3/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`hash`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/3/properties/type/const`,keyword:`const`,params:{allowedValue:`hash`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.mode!==void 0){let n=e.mode;if(n!==`in-place`&&n!==`navigate`){let e={instancePath:t+`/mode`,schemaPath:`#/oneOf/3/properties/mode/enum`,keyword:`enum`,params:{allowedValues:p.oneOf[3].properties.mode.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}}else{let e={instancePath:t,schemaPath:`#/oneOf/3/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;if(f&&l)l=!1,u=[u,3];else{f&&(l=!0,u=3);let n=o;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.type===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.object===void 0){let e={instancePath:t,schemaPath:`#/oneOf/4/required`,keyword:`required`,params:{missingProperty:`object`},message:`must have required property 'object'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`type`&&n!==`object`&&n!==`read`&&n!==`write`&&n!==`action`&&n!==`subscribe`&&n!==`pollMs`){let e={instancePath:t,schemaPath:`#/oneOf/4/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.type!==void 0&&e.type!==`api`){let e={instancePath:t+`/type`,schemaPath:`#/oneOf/4/properties/type/const`,keyword:`const`,params:{allowedValue:`api`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.object!==void 0){let n=e.object;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(!h.test(n)){let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$`},message:`must match pattern \"^[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/object`,schemaPath:`#/oneOf/4/properties/object/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.read!==void 0){let n=e.read;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/read`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.write!==void 0){let n=e.write;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/write`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.action!==void 0){let n=e.action;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/action`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.subscribe!==void 0){let n=e.subscribe;if(typeof n==`string`){if(s(n)>64){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/maxLength`,keyword:`maxLength`,params:{limit:64},message:`must NOT have more than 64 characters`};a===null?a=[e]:a.push(e),o++}if(!g.test(n)){let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/pattern`,keyword:`pattern`,params:{pattern:`^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$`},message:`must match pattern \"^(?!constructor$|prototype$|__proto__$)[a-zA-Z_$][a-zA-Z0-9_$]*$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/subscribe`,schemaPath:`#/$defs/method/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.pollMs!==void 0){let n=e.pollMs;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),o++}if(typeof n==`number`&&isFinite(n)){if(n>6e4||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:6e4},message:`must be <= 60000`};a===null?a=[e]:a.push(e),o++}if(n<100||isNaN(n)){let e={instancePath:t+`/pollMs`,schemaPath:`#/oneOf/4/properties/pollMs/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:100},message:`must be >= 100`};a===null?a=[e]:a.push(e),o++}}}}else{let e={instancePath:t,schemaPath:`#/oneOf/4/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}var f=n===o;f&&l?(l=!1,u=[u,4]):f&&(l=!0,u=4)}}}if(l)o=c,a!==null&&(c?a.length=c:a=null);else{let e={instancePath:t,schemaPath:`#/oneOf`,keyword:`oneOf`,params:{passingSchemas:u},message:`must match exactly one schema in oneOf`};a===null?a=[e]:a.push(e),o++}return _.errors=a,o===0}function v(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return v.errors=a,o===0}var y={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`number`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function b(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return b.errors=a,l===0}var x={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`min`,`max`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{const:`slider`},default:{type:`number`},binding:{$ref:`#/$defs/binding`},min:{type:`number`},max:{type:`number`},step:{type:`number`,exclusiveMinimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function S(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return S.errors=a,l===0}var C={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`,`options`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`select`,`radio`,`segmented`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},options:{$ref:`#/$defs/options`},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function w(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return w.errors=a,o===0}function T(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==\"default\"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return T.errors=a,o===0}var E={type:`object`,additionalProperties:!1,required:[`id`,`label`,`type`,`default`],properties:{id:{$ref:`#/$defs/id`},label:{$ref:`#/$defs/label`},type:{enum:[`text`,`textarea`]},default:{type:`string`},binding:{$ref:`#/$defs/binding`},minLength:{type:`integer`,minimum:0},maxLength:{type:`integer`,minimum:0},group:{$ref:`#/$defs/id`},when:{$ref:`#/$defs/condition`}}};function D(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return D.errors=a,l===0}var O=RegExp(`^#[0-9a-fA-F]{6}$`,`u`);function k(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern \"^#[0-9a-fA-F]{6}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return k.errors=a,o===0}function A(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return A.errors=a,o===0}function j(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let l=null,u=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.version===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`version`},message:`must have required property 'version'`};l===null?l=[e]:l.push(e),u++}if(e.scope===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`scope`},message:`must have required property 'scope'`};l===null?l=[e]:l.push(e),u++}if(e.controls===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`controls`},message:`must have required property 'controls'`};l===null?l=[e]:l.push(e),u++}for(let n in e)if(!o.call(a.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};l===null?l=[e]:l.push(e),u++}if(e.$schema!==void 0&&typeof e.$schema!=`string`){let e={instancePath:t+`/$schema`,schemaPath:`#/properties/%24schema/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}if(e.version!==void 0&&e.version!==1){let e={instancePath:t+`/version`,schemaPath:`#/properties/version/const`,keyword:`const`,params:{allowedValue:1},message:`must be equal to constant`};l===null?l=[e]:l.push(e),u++}if(e.scope!==void 0){let n=e.scope;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/scope`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.role!==void 0){let n=e.role;if(n!==`shared`&&n!==`page`){let e={instancePath:t+`/role`,schemaPath:`#/properties/role/enum`,keyword:`enum`,params:{allowedValues:a.properties.role.enum},message:`must be equal to one of the allowed values`};l===null?l=[e]:l.push(e),u++}}if(e.container!==void 0){let n=e.container;if(typeof n==`string`){if(s(n)>512){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/maxLength`,keyword:`maxLength`,params:{limit:512},message:`must NOT have more than 512 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/container`,schemaPath:`#/$defs/selector/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}if(e.panel!==void 0){let n=e.panel;if(n&&typeof n==`object`&&!Array.isArray(n)){if(n.width===void 0){let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/required`,keyword:`required`,params:{missingProperty:`width`},message:`must have required property 'width'`};l===null?l=[e]:l.push(e),u++}for(let e in n)if(e!==`width`){let n={instancePath:t+`/panel`,schemaPath:`#/properties/panel/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:e},message:`must NOT have additional properties`};l===null?l=[n]:l.push(n),u++}if(n.width!==void 0){let e=n.width;if(typeof e!=`number`||e%1||isNaN(e)||!isFinite(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};l===null?l=[e]:l.push(e),u++}if(typeof e==`number`&&isFinite(e)){if(e>4096||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/maximum`,keyword:`maximum`,params:{comparison:`<=`,limit:4096},message:`must be <= 4096`};l===null?l=[e]:l.push(e),u++}if(e<160||isNaN(e)){let e={instancePath:t+`/panel/width`,schemaPath:`#/properties/panel/properties/width/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:160},message:`must be >= 160`};l===null?l=[e]:l.push(e),u++}}}}else{let e={instancePath:t+`/panel`,schemaPath:`#/properties/panel/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}if(e.groups!==void 0){let n=e.groups;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};l===null?l=[e]:l.push(e),u++}if(s(n)<1){let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};l===null?l=[e]:l.push(e),u++}}else{let e={instancePath:t+`/groups/`+r+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};l===null?l=[e]:l.push(e),u++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/groups/`+r+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(l=l===null?f.errors:l.concat(f.errors),u=l.length))}else{let e={instancePath:t+`/groups/`+r,schemaPath:`#/properties/groups/items/type`,keyword:`type`,params:{type:`object`},message:`must be object`};l===null?l=[e]:l.push(e),u++}}}else{let e={instancePath:t+`/groups`,schemaPath:`#/properties/groups/type`,keyword:`type`,params:{type:`array`},message:`must be array`};l===null?l=[e]:l.push(e),u++}}if(e.controls!==void 0){let n=e.controls;if(Array.isArray(n)){if(n.length>500){let e={instancePath:t+`/controls`,schemaPath:`#/properties/controls/maxItems`,keyword:`maxItems`,params:{limit:500},message:`must NOT have more than 500 items`};l===null?l=[e]:l.push(e),u++}let e=n.length;for(let r=0;r100){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/sets`,schemaPath:`#/properties/sets/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`boolean`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`boolean`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0&&typeof e.default!=`boolean`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`boolean`},message:`must be boolean`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return F.errors=a,o===0}e.number=I;function I(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(y.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`number`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`number`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return I.errors=a,l===0}e.slider=L;function L(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}if(e.min===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`min`},message:`must have required property 'min'`};a===null?a=[e]:a.push(e),l++}if(e.max===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`max`},message:`must have required property 'max'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(x.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0&&e.type!==`slider`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`slider`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),l++}if(e.default!==void 0){let n=e.default;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.min!==void 0){let n=e.min;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/min`,schemaPath:`#/properties/min/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.max!==void 0){let n=e.max;if(!(typeof n==`number`&&isFinite(n))){let e={instancePath:t+`/max`,schemaPath:`#/properties/max/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.step!==void 0){let n=e.step;if(typeof n==`number`&&isFinite(n)){if(n<=0||isNaN(n)){let e={instancePath:t+`/step`,schemaPath:`#/properties/step/exclusiveMinimum`,keyword:`exclusiveMinimum`,params:{comparison:`>`,limit:0},message:`must be > 0`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/step`,schemaPath:`#/properties/step/type`,keyword:`type`,params:{type:`number`},message:`must be number`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return L.errors=a,l===0}e.choice=R;function R(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0){let n=e.type;if(n!==`select`&&n!==`radio`&&n!==`segmented`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:C.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),o++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return R.errors=a,o===0}e.checkboxGroup=ne;function ne(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}if(e.options===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`options`},message:`must have required property 'options'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==\"default\"&&n!==`options`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`checkboxGroup`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`checkboxGroup`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.default!==void 0){let n=e.default;if(Array.isArray(n)){let e=n.length;for(let r=0;r1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/default`,schemaPath:`#/properties/default/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.options!==void 0){let n=e.options;if(Array.isArray(n)){if(n.length>100){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/maxItems`,keyword:`maxItems`,params:{limit:100},message:`must NOT have more than 100 items`};a===null?a=[e]:a.push(e),o++}if(n.length<1){let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/minItems`,keyword:`minItems`,params:{limit:1},message:`must NOT have fewer than 1 items`};a===null?a=[e]:a.push(e),o++}let e=n.length;for(let r=0;r200){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(e)<1){let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/options/`+r,schemaPath:`#/$defs/options/items/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}let r=n.length,i;if(r>1){let e={};for(;r--;){let s=n[r];if(typeof s==`string`){if(typeof e[s]==`number`){i=e[s];let n={instancePath:t+`/options`,schemaPath:`#/$defs/options/uniqueItems`,keyword:`uniqueItems`,params:{i:r,j:i},message:`must NOT have duplicate items (items ## `+i+` and `+r+` are identical)`};a===null?a=[n]:a.push(n),o++;break}e[s]=r}}}}else{let e={instancePath:t+`/options`,schemaPath:`#/$defs/options/type`,keyword:`type`,params:{type:`array`},message:`must be array`};a===null?a=[e]:a.push(e),o++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ne.errors=a,o===0}e.text=re;function re(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,l=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),l++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),l++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),l++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),l++}for(let n in e)if(!o.call(E.properties,n)){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),l++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),l++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}if(e.type!==void 0){let n=e.type;if(n!==`text`&&n!==`textarea`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/enum`,keyword:`enum`,params:{allowedValues:E.properties.type.enum},message:`must be equal to one of the allowed values`};a===null?a=[e]:a.push(e),l++}}if(e.default!==void 0&&typeof e.default!=`string`){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),l=a.length)),e.minLength!==void 0){let n=e.minLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/minLength`,schemaPath:`#/properties/minLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.maxLength!==void 0){let n=e.maxLength;if(typeof n!=`number`||n%1||isNaN(n)||!isFinite(n)){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/type`,keyword:`type`,params:{type:`integer`},message:`must be integer`};a===null?a=[e]:a.push(e),l++}if(typeof n==`number`&&isFinite(n)&&(n<0||isNaN(n))){let e={instancePath:t+`/maxLength`,schemaPath:`#/properties/maxLength/minimum`,keyword:`minimum`,params:{comparison:`>=`,limit:0},message:`must be >= 0`};a===null?a=[e]:a.push(e),l++}}if(e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),l++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),l++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),l=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),l++}return re.errors=a,l===0}e.color=ie;function ie(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}if(e.default===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`default`},message:`must have required property 'default'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==\"default\"&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`color`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`color`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.default!==void 0){let n=e.default;if(typeof n==`string`){if(!O.test(n)){let e={instancePath:t+`/default`,schemaPath:`#/properties/default/pattern`,keyword:`pattern`,params:{pattern:`^#[0-9a-fA-F]{6}$`},message:`must match pattern \"^#[0-9a-fA-F]{6}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/default`,schemaPath:`#/properties/default/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ie.errors=a,o===0}e.button=ae;function ae(e,{instancePath:t=``,parentData:n,parentDataProperty:r,rootData:i=e}={}){let a=null,o=0;if(e&&typeof e==`object`&&!Array.isArray(e)){if(e.id===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`id`},message:`must have required property 'id'`};a===null?a=[e]:a.push(e),o++}if(e.label===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`label`},message:`must have required property 'label'`};a===null?a=[e]:a.push(e),o++}if(e.type===void 0){let e={instancePath:t,schemaPath:`#/required`,keyword:`required`,params:{missingProperty:`type`},message:`must have required property 'type'`};a===null?a=[e]:a.push(e),o++}for(let n in e)if(n!==`id`&&n!==`label`&&n!==`type`&&n!==`binding`&&n!==`group`&&n!==`when`){let e={instancePath:t,schemaPath:`#/additionalProperties`,keyword:`additionalProperties`,params:{additionalProperty:n},message:`must NOT have additional properties`};a===null?a=[e]:a.push(e),o++}if(e.id!==void 0){let n=e.id;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/id`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.label!==void 0){let n=e.label;if(typeof n==`string`){if(s(n)>200){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/maxLength`,keyword:`maxLength`,params:{limit:200},message:`must NOT have more than 200 characters`};a===null?a=[e]:a.push(e),o++}if(s(n)<1){let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/minLength`,keyword:`minLength`,params:{limit:1},message:`must NOT have fewer than 1 characters`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/label`,schemaPath:`#/$defs/label/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}if(e.type!==void 0&&e.type!==`button`){let e={instancePath:t+`/type`,schemaPath:`#/properties/type/const`,keyword:`const`,params:{allowedValue:`button`},message:`must be equal to constant`};a===null?a=[e]:a.push(e),o++}if(e.binding!==void 0&&(_(e.binding,{instancePath:t+`/binding`,parentData:e,parentDataProperty:`binding`,rootData:i})||(a=a===null?_.errors:a.concat(_.errors),o=a.length)),e.group!==void 0){let n=e.group;if(typeof n==`string`){if(!c.test(n)){let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/pattern`,keyword:`pattern`,params:{pattern:`^[a-zA-Z][a-zA-Z0-9_-]{0,63}$`},message:`must match pattern \"^[a-zA-Z][a-zA-Z0-9_-]{0,63}$\"`};a===null?a=[e]:a.push(e),o++}}else{let e={instancePath:t+`/group`,schemaPath:`#/$defs/id/type`,keyword:`type`,params:{type:`string`},message:`must be string`};a===null?a=[e]:a.push(e),o++}}e.when!==void 0&&(f(e.when,{instancePath:t+`/when`,parentData:e,parentDataProperty:`when`,rootData:i})||(a=a===null?f.errors:a.concat(f.errors),o=a.length))}else{let e={instancePath:t,schemaPath:`#/type`,keyword:`type`,params:{type:`object`},message:`must be object`};a===null?a=[e]:a.push(e),o++}return ae.errors=a,o===0}}))(),1);function u(e){if(e&&typeof e==`object`){for(let t of Object.values(e))u(t);Object.freeze(e)}return e}function d(e){return Array.isArray(e)?`[${e.map(d).join(`,`)}]`:e&&typeof e==`object`?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${d(e[t])}`).join(`,`)}}`:JSON.stringify(e)}function f(e,t){if(!e)return!0;if(e.all)return e.all.every(e=>f(e,t));if(e.any)return e.any.some(e=>f(e,t));let n=t[e.control];return`equals`in e?n===e.equals:`in`in e?e.in.includes(n):Array.isArray(n)&&n.includes(e.includes)}var{validateDocumentShape:p,validateDeclaration:m}=l.default,h={boolean:`boolean`,number:`number`,slider:`slider`,select:`choice`,radio:`choice`,segmented:`choice`,checkboxGroup:`checkboxGroup`,text:`text`,textarea:`text`,color:`color`,button:`button`};function g(e){let t=[...m.errors].filter(e=>!/^\\/controls\\/\\d+(?:\\/|$)/.test(e.instancePath)).map(e=>({...e}));return Array.isArray(e?.controls)&&e.controls.forEach((e,n)=>{let r=Object.hasOwn(h,e?.type)?h[e.type]:void 0,i=r&&l.default[r];i?i(e)||t.push(...i.errors.map(e=>({...e,instancePath:`/controls/${n}${e.instancePath}`}))):t.push({instancePath:`/controls/${n}/type`,message:`must name a supported control type`})}),t.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: \"${e.params.additionalProperty}\"`:e.message,keyword:e.keyword,params:e.params}))}var _=class extends Error{constructor(e){super(`Invalid controls.replica.json:\\n${e.map(e=>` ${e.path||`/`}: ${e.message}`).join(`\n`)}`),this.name=`ControlsValidationError`,this.issues=e}};function v(e,t){switch(e.type){case`boolean`:return typeof t==`boolean`?null:`must be a boolean`;case`number`:case`slider`:{if(typeof t!=`number`||!Number.isFinite(t))return`must be a finite number`;if(e.min!==void 0&&t= min`;if(e.max!==void 0&&t>e.max)return`must be <= max`;let n=(t-e.min)/(e.step??1);return!Number.isFinite(n)||Math.abs(n-Math.round(n))>1e-8?`must align with step (anchored at min)`:null}case`select`:case`radio`:case`segmented`:return e.options.includes(t)?null:`must be a declared option`;case`checkboxGroup`:return Array.isArray(t)&&new Set(t).size===t.length&&t.every(t=>e.options.includes(t))?null:`must be unique declared options`;case`text`:case`textarea`:return typeof t==`string`?e.minLength!==void 0&&[...t].lengthe.maxLength?`longer than maxLength`:null:`must be a string`;case`color`:return typeof t==`string`&&/^#[0-9a-fA-F]{6}$/.test(t)?null:`must be a six-digit hex color`;default:return`button controls have no value`}}function y(e){return e?e.control?[e.control]:(e.all??e.any).flatMap(y):[]}function b(e){let t=new Map((e.groups??[]).map(e=>[e.id,e])),n=new Map(e.controls.map(e=>[e.id,e])),r=new Set,i=new Set,a=[];function o(e){if(r.has(e))return;if(i.has(e))throw new _([{path:`/controls/${e}/when`,message:`conditional dependency cycle (including groups)`}]);i.add(e);let s=n.get(e);for(let e of[...y(s.when),...y(t.get(s.group)?.when)])o(e);i.delete(e),r.add(e),a.push(e)}for(let e of n.keys())o(e);return a}function x(e){let t=new Set;function n(e,r=0){if(r>24)throw new _([{path:`/`,message:`document nesting exceeds 24`}]);if(typeof e==`number`&&!Number.isFinite(e))throw new _([{path:`/`,message:`numbers must be finite`}]);if(![`string`,`number`,`boolean`,`object`].includes(typeof e))throw new _([{path:`/`,message:`must contain only JSON values`}]);if(e&&typeof e==`object`){if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new _([{path:`/`,message:`must contain only JSON objects`}]);if(t.has(e))throw new _([{path:`/`,message:`must be an acyclic JSON document`}]);t.add(e);for(let t of Object.values(e))n(t,r+1);t.delete(e)}}n(e)}function S(e){x(e);let t=e&&typeof e==`object`&&Object.hasOwn(e,`sets`)?e.sets:[e];if(!e||typeof e!=`object`||!Object.hasOwn(e,`sets`))return w(e),C(e),e;if(!p(e))throw new _(p.errors.map(e=>({path:e.instancePath,message:e.keyword===`additionalProperties`?`${e.message}: \"${e.params.additionalProperty}\"`:e.message,keyword:e.keyword,params:e.params})));let n=new Set;return t.forEach((e,t)=>{try{w(e),C(e)}catch(e){throw e instanceof _?new _(e.issues.map(e=>({...e,path:`/sets/${t}${e.path}`}))):e}if(n.has(e.scope))throw new _([{path:`/sets/${t}/scope`,message:`duplicate scope ${e.scope}`}]);n.add(e.scope)}),e}function C(e){let t=[];for(let[n,r]of e.controls.entries()){let e=r.binding,i=`/controls/${n}/binding`;e?((r.type===`button`&&![`button`,`api`].includes(e.type)||r.type!==`button`&&e.type===`button`)&&t.push({path:i,message:`binding does not match the control type`}),e.type===`query`&&(e.key===`rc`||e.key.startsWith(`rc.`))&&t.push({path:i,message:`rc and rc.* are reserved for control settings`}),e.type===`api`&&(([`window`,`globalThis`,`self`,`parent`,`top`,`document`,`location`,`history`,`navigator`].includes(e.object.split(`.`)[0])||[e.read,e.write,e.action,e.subscribe].some(e=>[`eval`,`Function`].includes(e)))&&t.push({path:i,message:`API bindings must name an app-owned object and ordinary methods`}),e.object.split(`.`).some(e=>[`constructor`,`prototype`,`__proto__`].includes(e))&&t.push({path:i,message:`API object must name the app's own exposed object`}),r.type===`button`?(!e.action||e.read||e.write||e.subscribe||e.pollMs)&&t.push({path:i,message:`API buttons require only object and action`}):(!e.read||!e.write||e.action||!!e.subscribe==!!e.pollMs)&&t.push({path:i,message:`API values require read, write, and either subscribe or pollMs`}))):t.push({path:i,message:`each control requires a binding`})}if(t.length)throw new _(t)}function w(e){if(x(e),!m(e))throw new _(g(e));let t=[];function n(e,n){t.push({path:e,message:n})}let r=new Set,i=new Map((e.groups??[]).map(e=>[e.id,e])),a=new Map(e.controls.map(e=>[e.id,e]));for(let[t,i]of[[`groups`,e.groups??[]],[`controls`,e.controls]])i.forEach((e,i)=>{r.has(e.id)&&n(`/${t}/${i}/id`,`duplicate ID ${e.id}`),r.add(e.id)});function o(e,t,r=0){if(!e)return;if(r>4){n(t,`conditions support at most five levels`);return}if(e.all||e.any){let n=e.all?`all`:`any`;e[n].forEach((e,i)=>o(e,`${t}/${n}/${i}`,r+1));return}let i=a.get(e.control);if(!i||i.type===`button`)n(t,`condition must reference a value control`);else if(`includes`in e)(i.type!==`checkboxGroup`||!i.options.includes(e.includes))&&n(t,`includes requires a declared checkboxGroup option`);else if(i.type===`checkboxGroup`)n(t,`checkboxGroup conditions must use includes`);else for(let r of`in`in e?e.in:[e.equals]){let e=v(i,r);e&&n(t,`invalid condition for ${i.id}: ${e}`)}}if(e.controls.forEach((e,t)=>{let r=`/controls/${t}`;if(e.group&&!i.has(e.group)&&n(`${r}/group`,`unknown group`),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&n(r,`min must not exceed max`),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&n(r,`minLength must not exceed maxLength`),e.type===`segmented`&&e.options.length>3&&n(`${r}/options`,`segmented supports at most three options`),e.type!==`button`){let t=v(e,e.default);t&&n(`${r}/default`,t)}o(e.when,`${r}/when`)}),(e.groups??[]).forEach((e,t)=>o(e.when,`/groups/${t}/when`)),t.length)throw new _(t);return b(e),e}var T=Symbol.for(`replica.controls.injected.runtime`),E=new WeakMap;function D(){let e=globalThis[T];if(e&&e.version!==2)throw Error(`Replica controls runtime version mismatch; reload the page`);if(!e){let e=new Map,t=new Set,n=Object.freeze({version:2,create:e=>O(e),list:()=>Object.freeze([...e.values()].map(e=>e.controller)),subscribe(e){return t.add(e),()=>t.delete(e)}});E.set(n,{scopes:e,notify:()=>{for(let e of[...t])e()}}),globalThis[T]=n}return globalThis[T]}function O(e){w(e);let t=u(structuredClone(e)),n=d(t),r=D(),i=r.list().find(e=>e.declaration.scope===t.scope);if(i){if(d(i.declaration)!==n)throw Error(`Conflicting controls declaration for scope \"${t.scope}\"; reload after schema changes`);return i}let a=E.get(r);if(!a)return r.create(e);let o=new Map(t.controls.map(e=>[e.id,e])),s=new Map((t.groups??[]).map(e=>[e.id,e])),c=b(t),l=new Set,p=new Map,m=new Set,h={},g=0,_=!1,y=!1,x;function S(e){for(let t of[...p.values()].reverse()){let n=t();if(Object.hasOwn(n,e)&&typeof n[e]==`function`)return n}}function C(e){let n={};for(let t of c){let r=o.get(t);n[t]=f(r.when,e)&&f(s.get(r.group)?.when,e),!n[t]&&r.type!==`button`&&(e[t]=structuredClone(r.default))}return u({values:e,visible:n,groups:Object.fromEntries([...s].map(([t,n])=>[t,f(n.when,e)])),actions:Object.fromEntries(t.controls.filter(e=>e.type===`button`).map(e=>[e.id,{available:!!S(e.id)&&!h[e.id]?.error,busy:m.has(e.id)}])),...Object.keys(h).length?{bindings:structuredClone(h)}:{}})}function T(){return Object.fromEntries(t.controls.filter(e=>e.type!==`button`).map(e=>[e.id,structuredClone(e.default)]))}x=u({...C(T()),revision:g});function O(e){let t=C(e),n={values:x.values,visible:x.visible,groups:x.groups,actions:x.actions,...x.bindings?{bindings:x.bindings}:{}};if(d(t)!==d(n)&&(x=u({...t,revision:++g}),y=!0,!_)){_=!0;try{for(;y;){y=!1;for(let e of[...l])e();a.notify()}}finally{_=!1}}}function k(e){let t=o.get(e);if(!t)throw Error(`Unknown control \"${e}\"`);if(!x.visible[e])throw Error(`Control \"${e}\" is hidden`);return t}let A=Object.freeze({declaration:t,getSnapshot:()=>x,subscribe(e){return l.add(e),()=>l.delete(e)},update(e,t){let n=v(k(e),t);if(n)throw Error(`Control \"${e}\": ${n}`);O({...x.values,[e]:structuredClone(t)})},restore(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Controls restore requires an object`);let t={...x.values};for(let[n,r]of Object.entries(e)){let e=o.get(n);if(!e)throw Error(`Unknown control \"${n}\"`);let i=v(e,r);if(i)throw Error(`Control \"${n}\": ${i}`);t[n]=structuredClone(r)}O(t)},refreshActions(){O({...x.values})},bindingStatus(e,t,n=!1,r=!t){if(!o.has(e))throw Error(`Unknown control \"${e}\"`);h[e]={error:t.slice(0,500),busy:n,available:r},O({...x.values})},reset(e){if(e===void 0)return O(T());let t=k(e);if(t.type===`button`)throw Error(`Buttons cannot be reset`);O({...x.values,[e]:structuredClone(t.default)})},async action(e){if(k(e).type!==`button`)throw Error(`Control \"${e}\" is not a button`);let t=S(e);if(!t)throw Error(`No mounted action handler for \"${e}\"`);if(m.has(e))throw Error(`Action \"${e}\" is busy`);m.add(e),O({...x.values});try{return await t[e]()}finally{m.delete(e),O({...x.values})}},mount(e=()=>({})){let t=Symbol();p.set(t,e);try{O({...x.values}),a.notify()}catch(e){throw p.delete(t),O({...x.values}),a.notify(),e}let n=!0;return()=>{n&&(n=!1,p.delete(t),O({...x.values}),a.notify())}},get mountedCount(){return p.size}});return a.scopes.set(t.scope,Object.freeze({canonical:n,controller:A})),a.notify(),A}function k(e,t=!1){if(!(e instanceof HTMLElement)||!e.isConnected)return`The binding target is missing or stale.`;let n=e.getBoundingClientRect();for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t);if(t.hasAttribute(`hidden`)||t.hasAttribute(`inert`)||t.getAttribute(`aria-hidden`)===`true`||t.getAttribute(`aria-disabled`)===`true`||e.visibility===`hidden`||e.visibility===`collapse`||e.display===`none`||Number(e.opacity||1)===0)return`The binding target is hidden or disabled.`}if(e.hasAttribute(`data-replica-canvas-bridge`)||e.matches(`:disabled`)||!n.width||!n.height)return`The binding target is hidden or disabled.`;if(!t)return``;let r=document.elementFromPoint(n.left+n.width/2,n.top+n.height/2);if(!r||r!==e&&!e.contains(r))return`The binding target is blocked by another element.`;let i=e.closest(`button, input, select, textarea, [role=\"button\"], [role=\"link\"], a`),a=e.closest(`form`)||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement?e.form:null);if(i!==e||a)return`The binding target is not a safe standalone control.`;let o=e.closest(`a`);if(o){let e=o.getAttribute(`href`),t;try{t=new URL(e||``,window.location.href)}catch{return`The binding target has an invalid link URL.`}if(!e||![`http:`,`https:`].includes(t.protocol)||t.origin!==window.location.origin||t.username||t.password||o.hasAttribute(`download`)||o.hasAttribute(`target`)&&o.getAttribute(`target`)!==`_self`)return`The binding target leaves the prototype or downloads a file.`}return``}function A(e){return/^\\/previews\\/github\\/[1-9]\\d*\\/[1-9]\\d*\\//.exec(e)?.[0]??`/`}function j(e,t){return JSON.stringify(e)===JSON.stringify(t)}function M(){let e=new URL(window.location.href);for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);return e.href}function N(e){let t=document.querySelectorAll(e);if(t.length!==1)throw Error(t.length?`The binding target is ambiguous.`:`The binding target is missing.`);return t[0]}function ee(e){let t=window;for(let n of e.split(`.`)){if(!t||!Object.hasOwn(t,n))throw Error(`The app API \"${e}\" is unavailable.`);t=t[n]}if(!t||typeof t!=`object`&&typeof t!=`function`)throw Error(`The app API \"${e}\" is not an object.`);if([window,window.document,window.location,window.history,window.navigator].includes(t))throw Error(`API bindings must use an app-owned object, not a browser API.`);return t}function te(e){let t=e.binding;if(t.type===`api`){let e=ee(t.object);for(let n of[t.read,t.write,t.action,t.subscribe].filter(Boolean))if(!Object.hasOwn(e,n)||typeof e[n]!=`function`)throw Error(`The app API method \"${n}\" is unavailable.`);return e}if(t.type===`query`||t.type===`hash`)return window;let n=N(t.selector),r=k(n,t.type===`button`);if(r)throw Error(r);if(t.type===`field`){if(!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)||n instanceof HTMLInputElement&&[`button`,`submit`,`reset`,`image`,`file`,`password`,`hidden`].includes(n.type))throw Error(`The binding requires a supported native form field.`);if(e.type===`boolean`&&!(n instanceof HTMLInputElement&&n.type===`checkbox`))throw Error(`A boolean field binding requires a checkbox.`);if(e.type===`checkboxGroup`&&!(n instanceof HTMLSelectElement&&n.multiple))throw Error(`A checkboxGroup field binding requires a multiple select.`);if(n.readOnly)throw Error(`The binding target is read-only.`)}if(t.type===`style`&&e.type===`checkboxGroup`)throw Error(`Style bindings require a scalar control.`);return n}function P(e,t){if(e.type===`boolean`)return t===`true`||t!==`false`&&t;if(e.type===`number`||e.type===`slider`)return t.trim()===``?NaN:Number(t);if(e.type===`checkboxGroup`)return JSON.parse(t);if(e.type===`color`&&/^rgb\\(/.test(t)){let e=t.match(/\\d+/g);if(e?.length===3)return`#${e.map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`}return t}function F(e){return Array.isArray(e)?JSON.stringify(e):String(e)}function I(e,t){let n=e.binding;if(n.type===`api`)return t[n.read]();if(n.type===`field`)return e.type===`boolean`?t.checked:e.type===`checkboxGroup`?[...t.selectedOptions].map(e=>e.value):P(e,t.value);if(n.type===`style`)return P(e,window.getComputedStyle(t).getPropertyValue(n.property).trim());let r=new URL(window.location.href),i=n.type===`query`?r.searchParams.get(n.key):decodeURIComponent(r.hash.slice(1));return i===null?structuredClone(e.default):P(e,i)}function L(e){let t=typeof e==`string`?e:e?.message;return Error(typeof t==`string`&&t?t:`The app binding failed without an error message.`)}async function R(e,t=5e3){let n;try{return await Promise.race([Promise.resolve().then(e),new Promise((e,r)=>{n=window.setTimeout(()=>r(Error(`The app API timed out. Its outcome is unknown.`)),t)})])}catch(e){throw L(e)}finally{window.clearTimeout(n)}}function ne(e,t,n){let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,t).set.call(e,n)}async function re(e,t,n){let r=e.binding;if(r.type===`api`){await R(()=>t[r.write](structuredClone(n)));return}if(r.type===`field`){if(t instanceof HTMLSelectElement)for(let e of Array.isArray(n)?n:[F(n)]){let n=[...t.options].filter(t=>t.value===e);if(n.length!==1||n[0].disabled||n[0].closest(`optgroup[disabled], [hidden], [inert]`))throw Error(`The native option is missing, ambiguous, hidden or disabled.`)}if(e.type===`checkboxGroup`)for(let e of t.options)e.selected=n.includes(e.value);else e.type===`boolean`?t.checked!==n&&t.click():ne(t,`value`,F(n));t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));return}if(r.type===`style`){t.style.setProperty(r.property,F(n));return}let i=new URL(window.location.href);if(r.type===`query`?i.searchParams.set(r.key,F(n)):i.hash=`#${F(n).replace(/%/g,`%25`)}`,i.href===window.location.href)return;if(i.origin!==window.location.origin)throw Error(`URL bindings cannot leave the prototype.`);if(r.mode===`navigate`)return i;window.history.replaceState(window.history.state,``,i);let a=new Event(r.type===`hash`?`hashchange`:`popstate`);Object.defineProperty(a,\"replicaControlsBinding\",{value:!0}),window.dispatchEvent(a)}function ie(e){S(e);let t=(e.sets??[e]).map(e=>({controller:O(e),release:void 0,records:new Map(e.controls.map(e=>[e.id,{control:e,object:void 0,cleanup:void 0,initialized:!1,lastRead:0,reading:!1}]))})),n=!1,r=0,i=Promise.resolve(),a=Promise.resolve(),o=!1,s=!1,c,l=new Set,u=``;function d(){let e=JSON.stringify(t.map(({controller:e})=>[e.declaration.scope,e.mountedCount,e.getSnapshot().revision]));if(e!==u){u=e;for(let e of l)e()}}let f=D().subscribe(()=>{!s&&!r&&d()});function p(e){if(!e.controller.declaration.container)return!0;let t=document.querySelectorAll(e.controller.declaration.container);if(t.length>1)throw Error(`The page container is ambiguous.`);return t.length===1&&!k(t[0])}function m(e,t){let n=t.cleanup;t.cleanup=void 0,t.object=void 0,t.initialized=!1;try{n?.()}catch(n){let r=Error(`API cleanup failed: ${L(n).message}`);return e.controller.bindingStatus(t.control.id,r.message),r}}function h(e){let n=e.binding;if(n.type===`query`||n.type===`hash`){let e=new Set;for(let r of t){let t;try{t=p(r)}catch{continue}if(t)for(let t of r.records.values()){let i=t.control.binding;i.type===n.type&&(n.type===`hash`||i.key===n.key)&&e.add(F(r.controller.getSnapshot().values[t.control.id]))}}if(e.size>1)throw Error(`This URL setting has conflicting active Controls bindings.`)}return te(e)}function g(e,t,r,i){let a=t.control.binding.type===`api`?new URL(M()).origin!==new URL(i).origin:M()!==i;if(n||!p(e)||a||h(t.control)!==r)throw Error(`The binding target or prototype route changed. The outcome is unknown.`)}async function _(e,t,n,r){let i=await R(()=>I(t.control,n));g(e,t,n,r);let a=v(t.control,i);if(a)throw Error(`The app value ${a}.`);return e.controller.restore({[t.control.id]:i}),t.lastRead=Date.now(),i}async function y(e,t,n){let{control:r}=t,i=e.controller.getSnapshot().values[r.id],a=M(),o;e.controller.bindingStatus(r.id,``,!0);try{o=h(r);let i=await re(r,o,n);if(i){let t=new URL(c?.href??window.location.href);return r.binding.type===`query`?t.searchParams.set(r.binding.key,i.searchParams.get(r.binding.key)):t.hash=i.hash,c=t,e.controller.restore({[r.id]:n}),e.controller.bindingStatus(r.id,``),n}await new Promise(e=>{let t=window.setTimeout(()=>{window.cancelAnimationFrame(n),e()},100),n=window.requestAnimationFrame(()=>{window.clearTimeout(t),e()})});let s=[`query`,`hash`].includes(r.binding.type),l=await _(e,t,o,s?M():a);if(!j(l,n))throw t.rejection=`The app rejected or adjusted this value. Its actual value is shown.`,t.rejectedValue=l,Error(`The app rejected or adjusted this value. Its actual value is shown.`);return t.rejection=``,e.controller.bindingStatus(r.id,``),l}catch(s){let c=L(s),l=!1;if(o)try{let n=await _(e,t,o,a);t.rejection=c.message,t.rejectedValue=n,l=!0}catch(e){c=Error(`${c.message} ${L(e).message}`)}throw!l&&j(e.controller.getSnapshot().values[r.id],n)&&e.controller.restore({[r.id]:i}),e.controller.bindingStatus(r.id,c.message,!1,l),c}}async function x(e,t){let{control:n}=t;if(!t.reading){t.reading=!0;try{let r=h(n);if(t.object!==r){let i=m(e,t);if(i)throw i;if(t.object=r,n.binding.type===`api`&&n.binding.subscribe){let e=r[n.binding.subscribe](()=>{t.lastRead=0,C()});if(typeof e!=`function`)throw Error(`The API notification method must return a cleanup function.`);t.cleanup=e}}if(n.type===`button`){e.controller.bindingStatus(n.id,t.rejection||``,!1,!0);return}if(!t.initialized)t.initialized=!0,await y(e,t,e.controller.getSnapshot().values[n.id]);else{let i=n.binding.type===`api`?n.binding.pollMs:250;if(t.lastRead===0||i&&Date.now()-t.lastRead>=i){if(!e.controller.getSnapshot().visible[n.id]&&!j(await R(()=>I(n,r)),n.default))await y(e,t,n.default);else{let n=await _(e,t,r,M());t.rejection&&!j(n,t.rejectedValue)&&(t.rejection=``)}e.controller.bindingStatus(n.id,t.rejection||``,!1,!0)}}}catch(t){e.controller.bindingStatus(n.id,L(t).message)}finally{t.reading=!1}}}function C(){return o||(o=!0,a=a.then(async()=>{if(!(n||r)){s=!0;try{await Promise.all(t.map(async e=>{let t,n=!1;try{t=p(e)}catch(r){t=!0,n=!0;for(let t of e.records.values())e.controller.bindingStatus(t.control.id,`Invalid page container: ${r.message}`)}if(t){if(!e.release){let t=Object.fromEntries([...e.records.values()].filter(e=>e.control.type===`button`).map(t=>[t.control.id,async()=>{let n=h(t.control),r=M();t.control.binding.type===`api`?await R(()=>n[t.control.binding.action](),3e4):n.click(),g(e,t,n,r)}]));e.release=e.controller.mount(()=>t)}n||await Promise.all([...e.records.values()].map(t=>x(e,t)))}else{e.release?.(),e.release=void 0;for(let t of e.records.values())m(e,t)}}))}finally{s=!1,d()}}}).finally(()=>{o=!1})),a}function w(e,t){let n=i.then(async()=>{await a,t?.(),c=void 0,r++;try{return await e()}catch(e){throw c=void 0,e}finally{r--,d()}});return i=n.catch(()=>{}),n}function T(e){let n=t.find(t=>t.controller===e);if(!n)throw Error(`Unknown controls set.`);return n}async function E(e,t,n){let r=T(e),i=e.getSnapshot();n?.(),e.restore(t);let a=[];for(let o of b(e.declaration)){n?.();let s=r.records.get(o);if(s.control.type===`button`)continue;let c=e.getSnapshot().values[o];if(Object.hasOwn(t,o)||!j(c,i.values[o])||[`query`,`hash`].includes(s.control.binding.type)&&s.control.binding.mode===`navigate`)try{await y(r,s,c)}catch(t){e.getSnapshot().bindings[o]?.available!==!0&&j(e.getSnapshot().values[o],c)&&e.restore({[o]:i.values[o]}),a.push(`${s.control.label}: ${t.message}`)}}if(n?.(),a.length)throw Error(a.join(`\n`).slice(0,1e3))}let A=window.setInterval(()=>{C()},250);function N(e){for(let n of t)for(let t of n.records.values())if(t.control.binding.type!==`api`&&t.control.type!==`button`){if(e.type===`input`||e.type===`change`){if(e.target!==t.object)continue;try{let e=I(t.control,t.object),r=v(t.control,e);if(r)throw Error(`The app value ${r}.`);n.controller.restore({[t.control.id]:e})}catch(e){n.controller.bindingStatus(t.control.id,e.message)}}t.lastRead=0}C()}for(let e of[`input`,`change`,`popstate`,`hashchange`])window.addEventListener(e,N);return C(),{runtime:D(),pending:()=>r>0||s,subscribe(e){return l.add(e),()=>l.delete(e)},settled:()=>a,restore:(e,t,n)=>w(()=>E(e,t,n),n),update:(e,t,n,r)=>w(()=>{let i=e.declaration.controls.find(e=>e.id===t),a=i?v(i,n):`Unknown control.`;if(a)throw Error(a);if(!e.getSnapshot().visible[t])throw Error(`This control is hidden.`);return E(e,{[t]:n},r)},r),takeNavigation(){if(!c)return;let e=c;c=void 0;for(let t of[...e.searchParams.keys()])(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.delete(t);for(let[t,n]of new URL(window.location.href).searchParams)(t===`rc`||t.startsWith(`rc.`))&&e.searchParams.append(t,n);return e.href},navigate(){let e=this.takeNavigation();e&&window.location.assign(e)},reset:(e,n)=>w(async()=>{let r=e?[T(e)]:t,i=[];for(let e of r){let t=Object.fromEntries(e.controller.declaration.controls.filter(e=>e.type!==`button`).map(e=>[e.id,e.default]));if(!e.release)e.controller.reset();else try{await E(e.controller,t,n)}catch(e){i.push(e.message)}}if(i.length)throw Error(i.join(`\n`).slice(0,1e3))},n),dispose(){n=!0,f(),window.clearInterval(A);for(let e of[`input`,`change`,`popstate`,`hashchange`])window.removeEventListener(e,N);for(let e of t){e.release?.();for(let t of e.records.values())m(e,t)}}}}async function ae(e=A(window.location.pathname)){let t=await fetch(`${e}controls.replica.json`,{credentials:`same-origin`,redirect:`error`});if(t.status===404||t.status===410)return;if(!t.ok)throw Error(`controls.replica.json returned HTTP ${t.status}.`);let n=``,r=t.body?.getReader();if(r){let e=new TextDecoder,t=0;for(;;){let{done:i,value:a}=await r.read();if(i)break;if(t+=a.byteLength,t>256e3)throw await r.cancel(),Error(`controls.replica.json exceeds the 256,000-byte limit.`);n+=e.decode(a,{stream:!0})}n+=e.decode()}else n=await t.text();if(new TextEncoder().encode(n).length>256e3)throw Error(`controls.replica.json exceeds the 256,000-byte limit.`);if(!(t.headers.get(`content-type`)?.startsWith(`text/html`)&&/^\\s*<(?:!doctype html|html)/i.test(n)))return ie(JSON.parse(n))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.entries(e).every(([e,t])=>/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e)&&(typeof t==`string`||typeof t==`boolean`||typeof t==`number`&&Number.isFinite(t)||Array.isArray(t)&&t.length<=100&&t.every(e=>typeof e==`string`)))}var oe=`replica:controls`;function se(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;try{let n=JSON.stringify(e);if(!(typeof n==`string`&&new Blob([n]).size<=512e3&&Object.keys(e).every(e=>[`protocol`,`version`,`epoch`,`requestId`,`type`,`sequence`,`state`,`error`,`command`,`controlQuery`,`fromFrameUrl`].includes(e))&&(t.error===void 0||typeof t.error==`string`&&t.error.length<=1e3)&&(t.controlQuery===void 0||[`hello`,`snapshot`,`reply`].includes(t.type)&&typeof t.controlQuery==`string`&&new Blob([t.controlQuery]).size<=8192)&&(t.fromFrameUrl===void 0||t.type===`hello`&&typeof t.fromFrameUrl==`boolean`)&&t.protocol===`replica:controls`&&t.version===1&&typeof t.epoch==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.epoch)&&typeof t.requestId==`string`&&/^[a-zA-Z0-9-]{1,100}$/.test(t.requestId)&&[`hello`,`snapshot`,`command`,`reply`].includes(t.type)))return!1;if(t.type!==`command`)return t.command===void 0;let r=t.command;if(!r||typeof r!=`object`||Array.isArray(r))return!1;if(r.operation===`url`)return Object.keys(r).every(e=>[`operation`,`query`,`scope`].includes(e))&&(r.scope===void 0||typeof r.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope))&&typeof r.query==`string`&&new Blob([r.query]).size<=8192&&[...new URLSearchParams(r.query).keys()].every(e=>/^rc\\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e));if(r.operation===`reset-all`)return Object.keys(r).every(e=>[`operation`,`contexts`].includes(e))&&Array.isArray(r.contexts)&&r.contexts.length<=100&&new Set(r.contexts.map(e=>e?.scope)).size===r.contexts.length&&r.contexts.every(e=>typeof e==`object`&&!!e&&Object.keys(e).length===3&&typeof e.scope==`string`&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(e.scope)&&typeof e.fingerprint==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0);let i=[`operation`,`scope`,`fingerprint`,`revision`];return typeof r.scope!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.scope)||typeof r.fingerprint!=`string`||!Number.isSafeInteger(r.revision)||r.revision===void 0||r.revision<0?!1:r.operation===`restore`?Object.keys(r).every(e=>[...i,`values`].includes(e))&&z(r.values):r.operation===`reset`?Object.keys(r).every(e=>i.includes(e)):r.operation!==`action`&&r.operation!==`update`||typeof r.id!=`string`||!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(r.id)?!1:Object.keys(r).every(e=>[...i,`id`,...r.operation===`update`?[`value`]:[]].includes(e))&&(r.operation===`action`||z({[r.id]:r.value}))}catch{return!1}}function ce(e){return w(e.declaration),JSON.parse(JSON.stringify({declaration:e.declaration,fingerprint:JSON.stringify(e.declaration),snapshot:e.getSnapshot()}))}var le=/^rc\\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\\.([a-zA-Z][a-zA-Z0-9_-]{0,63})$/;function ue(e){let t=new URLSearchParams;for(let n of Object.keys(e).sort()){let r=e[n];if(!z(r))throw Error(`Invalid control settings.`);for(let e of Object.keys(r).sort()){let i=`rc.${n}.${e}`;if(!le.test(i))throw Error(`Invalid control settings identifier.`);t.set(i,JSON.stringify(r[e]))}}let n=t.toString();if(new Blob([n]).size>8192)throw Error(`Control settings exceed the 8 KB URL limit. Reduce the settings before sharing.`);return n}function de(e){let t=new URLSearchParams(e),n=[...t].filter(([e])=>e.startsWith(`rc.`));if(new Blob([new URLSearchParams(n).toString()]).size>8192)return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`};let r=new Map,i=!1;for(let[e,a]of n){let n=le.exec(e);if(!n||t.getAll(e).length!==1){i=!0;continue}let o=n[1],s=n[2],c;try{c=JSON.parse(a)}catch{c=a}if(!z({[s]:c})){i=!0;continue}let l=r.get(o)??new Map;l.set(s,c),r.set(o,l)}let a=Object.fromEntries([...r].map(([e,t])=>[e,Object.fromEntries(t)]));try{ue(a)}catch{return{scopes:{},notice:`Control settings in this URL exceed 8 KB. Defaults were used.`}}return{scopes:a,notice:i?`Some URL control settings were invalid. Defaults were used instead.`:``}}function fe(e,t){let n=new URL(e,window.location.href),r=de(t);if(r.notice)throw Error(r.notice);for(let e of[...n.searchParams.keys()])e.startsWith(`rc.`)&&n.searchParams.delete(e);for(let[e,t]of new URLSearchParams(ue(r.scopes)))n.searchParams.set(e,t);return n.toString()}function pe(e,t,n){let r=window.history.pushState.bind(window.history),i=window.history.replaceState.bind(window.history),a=!1,o=document.readyState===`complete`||(performance.getEntriesByType?.(`navigation`)??[]).some(e=>`domContentLoadedEventStart`in e&&typeof e.domContentLoadedEventStart==`number`&&e.domContentLoadedEventStart>0),s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString();function c(){try{let e=ue({...de(s).scopes,...t()});return n(``),e}catch(e){return n(e instanceof Error?e.message:`Controls could not be saved in the URL.`),s}}function l(e){if(!a||!o)return new URL(String(e??window.location.href),window.location.href).toString();let t=new URL(fe(String(e??window.location.href),c()));return t.searchParams.set(`rc`,`1`),t.toString()}function u(e,t,n){r(e,t,l(n))}function d(e,t,n){i(e,t,l(n))}window.history.pushState=u,window.history.replaceState=d;function f(t){`replicaControlsBinding`in t&&t.replicaControlsBinding===!0||(s=new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString(),e(s))}function p(e){if(!a||!o||e.defaultPrevented||!(e.target instanceof Element))return;let t=e.target.closest(`a[href]`);if(!(t instanceof HTMLAnchorElement)||t.hasAttribute(`download`)||t.target&&t.target!==`_self`)return;let n=new URL(t.href);n.origin===window.location.origin&&(t.href=l(n))}window.addEventListener(`popstate`,f),window.addEventListener(`click`,p,!0);function m(){if(!a||!o)return;s=c();let e=l(window.location.href);e!==window.location.href&&i(window.history.state,``,e)}function h(){o=!0,m()}return document.addEventListener(`DOMContentLoaded`,h,{once:!0}),{set(e){let t=de(e);if(t.notice)throw Error(t.notice);s=ue(t.scopes),a=!0,m()},refresh:m,current(){return new URLSearchParams([...new URLSearchParams(window.location.search)].filter(([e])=>e.startsWith(`rc.`))).toString()},managed(){return new URLSearchParams(window.location.search).get(`rc`)===`1`},dispose(){window.history.pushState===u&&(window.history.pushState=r),window.history.replaceState===d&&(window.history.replaceState=i),window.removeEventListener(`popstate`,f),window.removeEventListener(`click`,p,!0),document.removeEventListener(`DOMContentLoaded`,h)}}}function me(e){return Object.fromEntries(e.declaration.controls.filter(t=>t.type!==`button`&&e.snapshot.visible[t.id]&&JSON.stringify(e.snapshot.values[t.id])!==JSON.stringify(t.default)).map(t=>[t.id,e.snapshot.values[t.id]]))}var he={improvementNotesLoading:`Loading improvement notes...`,localCommentsSaved:`Comments stay on this device until a Build with matching content is published and the canvas syncs them to Hub.`,commentPreparationFailed:`Hub could not prepare this comment.`,commentRefreshFailed:e=>`The comment was saved, but Hub could not be refreshed: ${e}`,commentLiveUpdatesPaused:`Live updates paused; checking every 30 seconds.`,mentionSuggestions:`Mention suggestions`,mentionSuggestionsError:`Mention suggestions are unavailable. Try again.`,mentionSuggestionsLoading:`Loading people...`,mentionSuggestionsEmpty:`No matching people. You can type a GitHub login to check it when sending.`,mentionLimit:`Each message can mention at most 10 distinct people.`,controls:`Controls`,controlsMove:`Move controls`,controlsMoveHint:`Drag to move. Use arrow keys, or Shift and arrow keys for smaller steps.`,controlsCollapse:`Collapse controls`,controlsExpand:`Expand controls`,controlsCollapseGroup:e=>`Collapse ${e}`,controlsExpandGroup:e=>`Expand ${e}`,controlsDescription:`Settings stay in this prototype's URL. The app may paint before Controls apply declared defaults.`,controlsConnecting:`Connecting controls...`,controlsEmpty:`No active controls. This prototype may have no declaration or this route may not mount controls.`,controlsLearnMore:`Learn more`,controlsMissingRuntime:`No supported controls runtime found.`,controlsLocalMissingRuntime:`Local controls couldn't connect.`,controlsLocalConnectionFailed:`The preview has not responded to controls. Retry the connection or ask Copilot to diagnose the cause.`,controlsLocalStorageFailed:`Controls could not be saved in the prototype URL. Changes remain in memory.`,controlsDiagnose:`Diagnose with Copilot`,controlsFix:`Fix with Copilot`,controlsDiagnostics:`Technical details`,controlsUnavailable:e=>`${e} is unavailable`,controlsNotApplied:e=>`${e} could not be applied`,controlsDiagnosisRequested:`Requested in chat`,controlsDiagnosisFailed:`Could not request a diagnosis. Try again.`,controlsUnsupportedRuntime:`This controls runtime version is unsupported. Upgrade only after an approved release.`,controlsInvalid:`The Controls definitions are invalid. Fix controls.replica.json and reload.`,controlsScopeError:(e,t)=>`Controls scope \"${e}\" did not connect. ${t}`,controlsRetry:`Retry connection`,controlsRetryStorage:`Retry saving`,controlsResetAll:`Reset all controls`,controlsRegion:`Prototype controls`,controlsActionBusy:` - Working...`,controlsActionUnavailable:`No mounted action handler.`,controlsValueNotApplied:`This value was not applied.`,browserNavigation:`Prototype navigation`,browserBack:`Back`,browserForward:`Forward`,browserReload:`Reload preview`,browserAddress:`Prototype address`,browserAddressInvalid:`Enter a valid URL or route.`,browserAddressOrigin:`The address must stay on this prototype's origin.`,browserOpenTab:`Open preview in browser`,browserAppearance:`Preview appearance`,browserLight:`Light appearance`,browserDark:`Dark appearance`,commentingUnavailable:`Commenting needs attention`,commentingDescription:`The canvas could not connect to the preview's commenting bridge.`,closeCommentingDialog:`Close commenting dialog`,commentingFix:`Fix with Copilot`,commentingFixRequested:`Requested in chat`,commentingDismiss:`Dismiss`,commentingMissing:`The preview has not responded through its local proxy. Check that the selected server is running, then reopen the canvas. Script or framing policies, certificate errors, and origin-dependent apps can prevent connection. A Vite plugin or server restart is not required to connect.`,commentingIncompatible:`The preview responded with an incompatible commenting protocol. Update the installed Replica extension and reopen the canvas, or use Fix with Copilot to check the preview connection.`,connectToHub:`Connect to the Hub`,closeConnectionDialog:`Close connection dialog`,connectionDescription:`Connecting to the hub lets you share the prototype with others and enables commenting.`,connectionBeforePublishing:`Connect to the hub before publishing this prototype.`,connectionRepositoryRequired:`Open a repository with a GitHub origin before connecting.`,connectionHubRequired:`Enter and save a Hub URL before connecting.`,connectionOpeningBrowser:`Opening browser...`,connectionApproval:`Browser approval`,connectionWaiting:`Make sure your browser shows the same code`,connectionApprovalExpired:`The approval expired or was declined. Connect again to retry.`,connectionBrowserFailed:e=>`Could not open your browser. Open or copy the approval link below. ${e}`,hubUrl:`Hub URL`,editHubUrl:`Edit Hub URL`,saveHub:`Save Hub`,disconnectFailed:(e,t)=>`Could not disconnect from ${e}: ${t} The previous connection may still be active. Save another Hub URL to switch this canvas locally, or retry Disconnect Hub.`,resetHubUrl:`Reset to repository Hub URL`,resetHubUnavailable:`No repository Hub URL is available. Enter a URL manually or retry reset.`,hubHttpsHint:`Remote Hubs require HTTPS`,copyApprovalLink:`Copy Hub approval link`,approvalLinkCopied:`Approval link copied`,approvalCopyFailed:`Could not copy the link. Copy the Connect to the hub link manually.`,invalidResponse:`The extension returned an invalid response.`,startPage:`Start page`,prototypeFrameTitle:e=>`${e} prototype`,startPageOrigin:`Hub returned a start page outside the prototype.`,hubStatusUnavailable:e=>`Hub status unavailable: ${e}`,hubBuildImported:`Hub imported this Build.`,hubBuildMissing:`Hub has not imported a successful registered Build.`,hubPublicationUnavailable:`Connect to Hub to verify publication.`,editDetails:`Edit details`,startPageHint:`Paste a prototype URL or route. Leave blank to start at /.`,requestFailed:`The request failed.`,statusUnavailable:`Publish status unavailable.`,publishRequestPending:`Waiting for the current commit to run through the publish workflow.`,waitingForHubImport:`The workflow completed. Waiting for Hub to import this Build.`,workingTreeChanged:`Uncommitted changes`,workingTreeClean:`Working tree clean`,buildDetails:`Build details`,latestBuild:`Latest Build`,buildTitle:e=>`Build #${e}`,buildCommit:`Commit`,unknownCommitAuthor:`Unknown`,showBuildHistory:`Show build history`,closeBuildDetails:`Close build details`,branch:`Branch`,sessionId:`Session ID`,comparison:`Branch comparison`,comparisonNeedsRefresh:`Branch comparison unavailable until Git stats refresh.`,upToDate:`Up to date`,commitsBehind:e=>`${e} ${e===1?`commit`:`commits`} behind`,copyBranch:`Copy branch`,copySessionId:`Copy session ID`,branchCopied:`Branch copied`,sessionIdCopied:`Session ID copied`,buildDetailsCopyFailed:e=>`${e} could not be copied. Select it and copy it manually.`,unavailable:`Unavailable`,publishLabels:{succeeded:`Awaiting Hub`,failed:`Retry`,in_progress:`Publishing`,not_published:`Publish`,published:`Published`,requested:`Requested`,unavailable:`Publish`}};function ge(e,t){let n=e.snapshot.bindings?.[t.id],r=e.snapshot.actions[t.id];return{scope:e.declaration.scope,id:t.id,visible:e.snapshot.visible[t.id]===!0,available:(t.type!==`button`||r?.available===!0)&&(!n?.error||n.available===!0),busy:n?.busy===!0||r?.busy===!0,error:n?.error||(t.type===`button`&&!r?.available?he.controlsActionUnavailable:``)}}function _e(e,t,n){return{status:t?`pending`:e.status,url:n,error:t?``:e.error??``,controls:t?[]:e.scopes.flatMap(e=>e.declaration.controls.map(t=>ge(e,t)))}}function ve(e,t){let n=``,r,i,a=``,o=!1,s=new Set,c=!1,l=0,u,d,f=!1,p,m=new Set,h=new Set,g=``,_=pe(e=>{h.clear(),S(`snapshot`,`event`,void 0,e)},()=>Object.fromEntries((r?.list()??[]).filter(e=>h.has(e.declaration.scope)).map(e=>[e.declaration.scope,me(ce(e))])),e=>{g!==e&&(g=e,S(`snapshot`,`event`))});async function v(){try{if(d=await ae(t),o){d?.dispose();return}r=d?.runtime,i=d?.subscribe(C),await d?.settled();let e=d;e&&y()&&await new Promise(t=>{function n(){clearTimeout(i),a(),p=void 0,t()}function r(){y()||n()}let i=setTimeout(n,500),a=e.subscribe(r);p=n,r()})}catch(e){u={status:`invalid-config`,error:e instanceof Error?e.message.slice(0,1e3):`Controls definitions could not be read.`}}finally{f=!0}C()}function y(){return r?.list().some(e=>Object.values(e.getSnapshot().bindings??{}).some(e=>e.error))}function b(){let e=!!r;if(u)return{runtimeAvailable:e,scopes:[],...u};if(!r)return{runtimeAvailable:!1,status:f?`no-controls`:`missing-runtime`,scopes:[]};try{let e=r.list().filter(e=>e.mountedCount>0).map(ce);return e.length>100?{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Too many active controls scopes.`}:{runtimeAvailable:!0,status:e.length?`ready`:`no-controls`,scopes:e}}catch{return{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`The Controls definitions are invalid.`}}}function x(){return{...b(),scopeErrors:[],reconnectRequired:c,...c?{error:`Reconnect controls before sending more commands.`}:{},...g?{error:`${g} Changes remain in memory and are not in the URL.`}:{}}}function S(t,r,i,a){if(o||!n)return;let s={protocol:oe,version:1,type:t,epoch:n,requestId:r,sequence:++l,state:x(),...i?{error:i}:{},...a===void 0?{}:{controlQuery:a}};window.parent.postMessage(se(s)?s:{...s,state:{runtimeAvailable:!0,status:`invalid-config`,scopes:[],error:`Controls exceed the transport size limit.`},error:`Controls exceed the transport size limit.`},e)}function C(){for(let e of m)e();if(!f||d?.pending())return;_?.refresh();let e=JSON.stringify(x());e!==a&&(a=e,S(`snapshot`,`event`))}async function w(t){if(t.source===window.parent&&t.origin===e&&t.data&&typeof t.data==`object`&&`type`in t.data&&t.data.type===`replica:controls:status`&&`nonce`in t.data&&typeof t.data.nonce==`string`&&t.data.nonce.length<=100&&`timeoutMs`in t.data&&Number.isInteger(t.data.timeoutMs)&&typeof t.data.timeoutMs==`number`&&t.data.timeoutMs>=0&&t.data.timeoutMs<=1e4){let{nonce:n,timeoutMs:r}=t.data;function i(){return!f||d?.pending()===!0&&!x().scopes.some(({snapshot:e})=>[...Object.values(e.actions),...Object.values(e.bindings??{})].some(e=>e.busy))}i()&&r>0&&await new Promise(e=>{function t(){clearTimeout(a),m.delete(n),e()}function n(){(o||!i())&&t()}let a=setTimeout(t,r);m.add(n),n()}),o||window.parent.postMessage({type:`replica:controls:status-result`,nonce:n,value:_e(x(),i(),window.location.href)},e);return}if(t.source!==window.parent||t.origin!==e||!se(t.data))return;let a=t.data;if(a.type===`hello`){n=a.epoch,s.clear(),c=!1,h.clear();let e=a.fromFrameUrl&&_?.managed();_?.set(e?_.current():a.controlQuery??``),f||await T,S(`reply`,a.requestId,void 0,e?_?.current():void 0);return}if(a.type!==`command`||a.epoch!==n||s.has(a.requestId))return;if(s.size>=2e3){c=!0,S(`reply`,a.requestId,`Reconnect controls before sending more commands.`);return}s.add(a.requestId);let l=a.command;function u(){if(o||n!==a.epoch)throw Error(`The preview reconnected. The command outcome is unknown.`)}try{if(l?.operation===`url`){_.set(l.query??``),l.scope&&r?.list().some(e=>e.declaration.scope===l.scope&&e.mountedCount>0)&&(h.add(l.scope),_.refresh()),S(`reply`,a.requestId);return}if(!l||!r||![`ready`,`no-controls`].includes(x().status))throw Error(`Controls runtime is unavailable.`);if(l.operation===`reset-all`){if(r.list().some(e=>Object.values(e.getSnapshot().actions).some(e=>e.busy)))throw Error(`Wait for pending actions before resetting controls.`);let e=r.list().filter(e=>e.mountedCount>0);if(!Array.isArray(l.contexts)||l.contexts.length!==e.length||e.some(e=>!l.contexts?.some(t=>t.scope===e.declaration.scope&&t.fingerprint===JSON.stringify(e.declaration)&&t.revision===e.getSnapshot().revision)))throw Error(`Controls changed. The stale reset was not applied.`);h.clear(),await d?.reset(void 0,u)}else{let e=r.list().find(e=>e.declaration.scope===l.scope&&e.mountedCount>0);if(!e)throw Error(`This controls scope is no longer active.`);if(l.fingerprint!==JSON.stringify(e.declaration)||l.revision!==e.getSnapshot().revision)throw Error(`Controls changed. The stale command was not applied.`);if(l.operation===`restore`){if(!z(l.values))throw Error(`Invalid saved controls.`);await d?.restore(e,l.values,u),h.add(e.declaration.scope),_?.refresh()}else if(l.operation===`reset`)h.add(e.declaration.scope),await d?.reset(e,u);else{let t=e.declaration.controls.find(e=>e.id===l.id);if(!t||!e.getSnapshot().visible[t.id])throw Error(`This control is unknown or hidden.`);if(h.add(e.declaration.scope),l.operation===`update`){let n={[t.id]:l.value};if(!z(n))throw Error(`Invalid control value.`);let r=n[t.id];if(r===void 0)throw Error(`Missing control value.`);await d?.update(e,t.id,r,u)}else if(l.operation===`action`)await e.action(t.id);else throw Error(`Unknown controls command.`)}C()}n===a.epoch&&(S(`reply`,a.requestId),d?.navigate())}catch(e){n===a.epoch&&S(`reply`,a.requestId,e instanceof Error?e.message.slice(0,300):`The controls command failed.`)}}let T=v();function E(e){w(e)}return window.addEventListener(`message`,E),()=>{o=!0,p?.();for(let e of m)e();i?.(),d?.dispose(),window.removeEventListener(`message`,E),_?.dispose()}}var B=`data-replica-canvas-bridge`,ye=new TextEncoder,be=null,V=null,H=null,U=null,xe=`light-dark(#0969da, #58a6ff)`,W=null,Se=``,Ce=``,G=new Map;function we(){let e=q();return e.pathname+e.search+e.hash}for(let e of[`popstate`,`hashchange`])window.addEventListener(e,e=>{Ce=`replicaControlsBinding`in e&&e.replicaControlsBinding?we():``});function K(e){return e.replace(/\\s+/g,` `).trim()}function Te(e,t){let n=``,r=0;for(let i of e){let e=ye.encode(i).length;if(r+e>t)break;n+=i,r+=e}return n}function q(){let e=window.location.search.slice(1).split(`&`).filter(e=>{let t=new URLSearchParams(e).keys().next().value;return t!==`rc`&&!t?.startsWith(`rc.`)}).join(`&`);return{pathname:window.location.pathname.slice(A(window.location.pathname).length-1),search:e?`?${e}`:``,hash:window.location.hash}}function Ee(){return{width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function De(e){return{x:e.left+window.scrollX,y:e.top+window.scrollY,width:e.width,height:e.height}}function Oe(e){let t=e.getAttribute(`aria-labelledby`),n=t?t.split(/\\s+/).map(e=>document.getElementById(e)?.textContent||``).join(` `):``,r=`labels`in e&&e.labels?Array.from(e.labels).map(e=>e.textContent||``).join(` `):``;return Te(K(e.getAttribute(`aria-label`)||n||r||e.getAttribute(`alt`)||e.getAttribute(`title`)||``),1e3)}function ke(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\\\${e}`)}function Ae(e){if(e.id){let t=`#${ke(e.id)}`;if(document.querySelectorAll(t).length===1)return t}for(let t of[`data-testid`,`data-test-id`]){let n=e.getAttribute(t);if(!n)continue;let r=`[${t}=\"${ke(n)}\"]`;if(document.querySelectorAll(r).length===1)return r}let t=[],n=e;for(;n&&n!==document.documentElement;){let e=n.tagName.toLowerCase(),r=n.parentElement?Array.from(n.parentElement.children).filter(e=>e.tagName===n?.tagName):[],i=r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e;t.unshift(i);let a=t.join(` > `);if(document.querySelectorAll(a).length===1)return a;n=n.parentElement}return t.join(` > `)}function je(e,t){return e.tagName.toLowerCase()!==t.tagName||t.accessibleName&&Oe(e)!==t.accessibleName?!1:!t.selectedText||K(e.textContent||``).includes(t.selectedText)}function Me(e){let t=null;try{t=document.querySelector(e.selector)}catch{}if(t&&je(t,e))return t;if(!e.accessibleName&&!e.selectedText)return null;let n=null;for(let r of document.getElementsByTagName(e.tagName))if(r!==t&&je(r,e)){if(n)return null;n=r}return n}function Ne(){let e=document.createElement(`div`);return e.setAttribute(B,``),Object.assign(e.style,{position:`fixed`,colorScheme:`light dark`,zIndex:`2147483647`,pointerEvents:`none`,border:`2px solid var(--replica-selection-accent)`,borderRadius:`4px`,background:`color-mix(in srgb, var(--replica-selection-accent) 12%, transparent)`,boxSizing:`border-box`}),e.style.setProperty(`--replica-selection-accent`,xe),document.documentElement.append(e),e}function J(e,t){let n=e.style.position===`absolute`,r=`left`in t?t.left:t.x-window.scrollX,i=`top`in t?t.top:t.y-window.scrollY;Object.assign(e.style,{left:`${r+(n?window.scrollX:0)}px`,top:`${i+(n?window.scrollY:0)}px`,width:`${t.width}px`,height:`${t.height}px`})}function Pe(e,t=null){H?.remove(),H=e,U=t,H.style.pointerEvents=`none`}function Y(e,t){window.parent.postMessage(t,e)}function X(){V?.(),V=null}function Z(e,t,n){X(),Y(e,{type:`replica:canvas:selection-failed`,nonce:t,reason:n})}function Fe(e,t,n){let r=e.getBoundingClientRect(),i=Ae(e);if(!r.width||!r.height||!i)return null;let a=Te(K(window.getSelection()?.toString()||``),2e3);return{schemaVersion:1,kind:`element`,route:q(),selector:i,accessibleName:Oe(e),tagName:e.tagName.toLowerCase(),selectedText:e.contains(window.getSelection()?.anchorNode||null)?a:``,rect:De(r),viewport:Ee(),elementOffset:{x:Math.min(1,Math.max(0,(t-r.left)/r.width)),y:Math.min(1,Math.max(0,(n-r.top)/r.height))}}}function Ie(e,t){X();let n=null,r=Ne(),i=document.documentElement.style.cursor;document.documentElement.style.cursor=`crosshair`;function a(e){let t=e.target instanceof Element?e.target.closest(`:not([${B}])`):null;!t||t===document.documentElement||t===document.body?(n=null,r.style.display=`none`):(n=t,r.style.display=`block`,J(r,t.getBoundingClientRect()))}function o(i){if(!n)return;i.preventDefault(),i.stopImmediatePropagation();let a=Fe(n,i.clientX,i.clientY);a?(r.style.position=$(n)?`fixed`:`absolute`,J(r,n.getBoundingClientRect()),Pe(r,n),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:a})):(r.remove(),Z(e,t,`element-unavailable`))}function s(n){n.key===`Escape`&&(n.preventDefault(),X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t}))}document.addEventListener(`pointermove`,a,!0),document.addEventListener(`click`,o,!0),document.addEventListener(`keydown`,s,!0),V=()=>{document.removeEventListener(`pointermove`,a,!0),document.removeEventListener(`click`,o,!0),document.removeEventListener(`keydown`,s,!0),document.documentElement.style.cursor=i,H!==r&&r.remove()}}function Le(e){let t=[[e.left+e.width/2,e.top+e.height/2],[e.left+1,e.top+1],[e.right-1,e.top+1],[e.right-1,e.bottom-1],[e.left+1,e.bottom-1]],n=new Set;for(let[e,r]of t){for(let t of document.elementsFromPoint(e,r))if(t.hasAttribute(B)||n.add(t),n.size>=8)break;if(n.size>=8)break}return Array.from(n).flatMap(e=>{let t=Ae(e),n=e.getBoundingClientRect();return!t||!n.width||!n.height?[]:[{selector:t,accessibleName:Oe(e),tagName:e.tagName.toLowerCase(),role:Te(e.getAttribute(`role`)||``,64),textExcerpt:Te(K(e.textContent||``),500),rect:De(n)}]})}function Re(e){return{schemaVersion:1,kind:`area`,route:q(),path:[{x:0,y:0},{x:1,y:0},{x:1,y:1},{x:0,y:1},{x:0,y:0}],rect:De(e),viewport:Ee(),elements:Le(e)}}function ze(e,t,n=!1){X();let r=document.createElement(`div`);r.setAttribute(B,``),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,cursor:`crosshair`,touchAction:`none`});let i=Ne();i.style.display=`none`,document.body.append(r);let a=null,o=null,s=null,c=null;function l(e,t){r.style.pointerEvents=`none`;let n=document.elementFromPoint(e,t);return r.style.pointerEvents=``,n===document.body||n===document.documentElement?null:n}function u(n,r,a){i.style.position=a&&$(a)?`fixed`:`absolute`,J(i,r),Pe(i,a),X(),Y(e,{type:`replica:canvas:selected`,nonce:t,anchor:n})}function d(e,t){if(!a)return;let n=Math.min(a.x,e),r=Math.min(a.y,t),o=Math.abs(e-a.x),s=Math.abs(t-a.y);i.style.display=`block`,J(i,new DOMRect(n,r,o,s))}function f(e){e.button!==0||a||(e.preventDefault(),a={x:e.clientX,y:e.clientY},s=e.pointerId,o=n?l(e.clientX,e.clientY):null,r.setPointerCapture(e.pointerId),d(e.clientX,e.clientY))}function p(e){if(a)e.pointerId===s&&(e.preventDefault(),d(e.clientX,e.clientY));else{if(!n)return;let t=l(e.clientX,e.clientY);i.style.display=t?`block`:`none`,t&&J(i,t.getBoundingClientRect())}}function m(r){if(!a||r.pointerId!==s)return;r.preventDefault();let i=Math.max(0,Math.min(window.innerWidth,r.clientX)),c=Math.max(0,Math.min(window.innerHeight,r.clientY)),l=new DOMRect(Math.min(a.x,i),Math.min(a.y,c),Math.abs(i-a.x),Math.abs(c-a.y));if(n&&Math.hypot(l.width,l.height)<8){let n=o?Fe(o,a.x,a.y):null;if(!n||!o){Z(e,t,`element-unavailable`);return}u(n,o.getBoundingClientRect(),o)}else(n?l.width<8||l.height<8:Math.hypot(l.width,l.height)<8)?Z(e,t,`area-too-small`):u(Re(l),l)}function h(r){if(!n||r.detail!==0||!(r.target instanceof Element)||r.target.hasAttribute(B))return;r.preventDefault(),r.stopImmediatePropagation();let i=r.target,a=i.getBoundingClientRect(),o=Fe(i,a.left+a.width/2,a.top+a.height/2);o?u(o,a,i):Z(e,t,`element-unavailable`)}function g(n){X(),Y(e,{type:`replica:canvas:selection-cancelled`,nonce:t,reason:n?`interrupted`:`escape`})}function _(r){if(n&&r.shiftKey&&r.key===`Enter`)r.preventDefault(),c={x:window.innerWidth/2,y:window.innerHeight/2},a=null,i.style.display=`block`,J(i,new DOMRect(c.x,c.y,4,4));else if(c&&[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(r.key)){if(r.preventDefault(),r.key===`Enter`||r.key===` `){if(!a)a={...c};else{let n=new DOMRect(Math.min(a.x,c.x),Math.min(a.y,c.y),Math.abs(a.x-c.x),Math.abs(a.y-c.y));if(n.width<8||n.height<8){Z(e,t,`area-too-small`);return}u(Re(n),n)}}else c={x:Math.max(0,Math.min(window.innerWidth,c.x+(r.key===`ArrowRight`?10:r.key===`ArrowLeft`?-10:0))),y:Math.max(0,Math.min(window.innerHeight,c.y+(r.key===`ArrowDown`?10:r.key===`ArrowUp`?-10:0)))},a?d(c.x,c.y):J(i,new DOMRect(c.x,c.y,4,4))}else r.key===`Escape`&&(r.preventDefault(),g())}r.addEventListener(`pointerdown`,f),r.addEventListener(`pointermove`,p),r.addEventListener(`pointerup`,m),r.addEventListener(`pointercancel`,g),r.addEventListener(`lostpointercapture`,g),n&&document.addEventListener(`click`,h,!0),document.addEventListener(`keydown`,_,!0),V=()=>{r.removeEventListener(`pointerdown`,f),r.removeEventListener(`pointermove`,p),r.removeEventListener(`pointerup`,m),r.removeEventListener(`pointercancel`,g),r.removeEventListener(`lostpointercapture`,g),n&&document.removeEventListener(`click`,h,!0),document.removeEventListener(`keydown`,_,!0),r.remove(),H!==i&&i.remove()}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){for(let t=e;t;t=t.parentElement){let e=window.getComputedStyle(t).position;if(e===`fixed`||e===`sticky`)return!0}return!1}function Be(e){let t=q();if(!Q(e)||!Q(e.route)||e.route.pathname!==t.pathname||e.route.search!==t.search||e.route.hash!==t.hash)return null;if(e.kind===`area`){if(!Q(e.rect)||typeof e.rect.x!=`number`||typeof e.rect.y!=`number`||typeof e.rect.width!=`number`||typeof e.rect.height!=`number`||!Object.values(e.rect).every(Number.isFinite))return null;let t={x:e.rect.x-window.scrollX,y:e.rect.y-window.scrollY,width:e.rect.width,height:e.rect.height};return{x:t.x+t.width,y:t.y,rect:t,viewportAnchored:!1}}if(e.kind!==`element`||typeof e.selector!=`string`||typeof e.accessibleName!=`string`||typeof e.tagName!=`string`||e.selectedText!==void 0&&typeof e.selectedText!=`string`||!Q(e.elementOffset)||typeof e.elementOffset.x!=`number`||typeof e.elementOffset.y!=`number`||!Number.isFinite(e.elementOffset.x)||!Number.isFinite(e.elementOffset.y))return null;let n=Me({selector:e.selector,accessibleName:e.accessibleName,tagName:e.tagName,selectedText:e.selectedText});if(!n)return null;let r=n.getBoundingClientRect();return!r.width||!r.height?null:{x:r.left+r.width*e.elementOffset.x,y:r.top+r.height*e.elementOffset.y,viewportAnchored:$(n)}}function Ve(e=!1){if(!W||!be)return;let t=q(),n=JSON.stringify(t);e&&=n===Se,Se=n;let r=[];for(let t of W.anchors){let n=G.get(t.id),i;if(e&&n&&!n.viewportAnchored){let e=n.scrollX-window.scrollX,t=n.scrollY-window.scrollY;i={x:n.x+e,y:n.y+t,...n.rect?{rect:{...n.rect,x:n.rect.x+e,y:n.rect.y+t}}:{}}}else{let e=Be(t.anchor);if(!e){G.delete(t.id);continue}G.set(t.id,{...e,scrollX:window.scrollX,scrollY:window.scrollY}),i={x:e.x,y:e.y,...`rect`in e?{rect:e.rect}:{}}}r.push({id:t.id,...i})}Y(be,{type:`replica:canvas:resolved`,protocolVersion:1,nonce:W.nonce,route:t,...Ce===we()?{replaceRoute:!0}:{},results:r})}function He(e){let t=e.data;if(document.querySelector(`script[src=\"${A(window.location.pathname)}__replica/bridge/v1.js\"]`)||e.source!==window.parent||e.origin!==be||!Q(t)||typeof t.nonce!=`string`||t.nonce.length>100)return;if(t.type===`replica:canvas:request-ready`){Y(e.origin,{type:`replica:canvas:ready`,protocolVersion:1,improvementSelection:!0,nonce:t.nonce,route:q(),...Ce===we()?{replaceRoute:!0}:{}});return}if(t.type===`replica:canvas:theme`){if(typeof t.accent!=`string`||t.accent.length>200||!CSS.supports(`color`,t.accent))return;xe=t.accent;for(let e of document.querySelectorAll(`[${B}]`))e.style.setProperty(`--replica-selection-accent`,xe);return}if(t.type===`replica:canvas:click`){let{selector:n,expectedLabel:r,route:i}=t,a=q(),o=`The click target is unavailable or ambiguous.`,s=null;if(typeof n==`string`&&n.length>0&&n.length<=512&&typeof r==`string`&&r.length>0&&r.length<=200&&Q(i)&&typeof i.pathname==`string`&&i.pathname===a.pathname&&i.search===a.search&&i.hash===a.hash)try{let e=document.querySelectorAll(n);e.length===1&&(s=e.item(0))}catch{o=`The click selector is invalid.`}else o=`The prototype route changed or the click input is invalid.`;if(s){let n=s;if(k(n,!0)||(Oe(n)||K(n.textContent||``).slice(0,200))!==r)o=`The target is hidden, blocked, disabled, unsafe, or its accessible name changed.`;else{n.click(),Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!0});return}}Y(e.origin,{type:`replica:canvas:click-result`,nonce:t.nonce,clicked:!1,error:o});return}if(t.type===`replica:canvas:select`){t.mode===`element`?Ie(e.origin,t.nonce):t.mode===`area`?ze(e.origin,t.nonce):t.mode===`improvement`&&ze(e.origin,t.nonce,!0);return}if(t.type===`replica:canvas:cancel-selection`){X(),Y(e.origin,{type:`replica:canvas:selection-cancelled`,nonce:t.nonce,reason:`command`});return}if(t.type===`replica:canvas:clear-selection`){H?.remove(),H=null,U=null;return}if(t.type!==`replica:canvas:resolve`||!Array.isArray(t.anchors))return;let n=[],r=t.anchors;for(let e of r)Q(e)&&typeof e.id==`number`&&Number.isSafeInteger(e.id)&&n.push({id:e.id,anchor:e.anchor});W={nonce:t.nonce,anchors:n},G.clear(),Ve()}var Ue=Symbol.for(`replica.canvas.bridge.v1`),We=window;function Ge(e,t){let n=We[Ue];if(n===!0)throw Error(`Remove the old source bridge before using the extension-owned bridge.`);typeof n==`function`&&n(),xe=`light-dark(#0969da, #58a6ff)`,be=e,W=null,Se=``,G.clear();let r=ve(e,t),i=null;function a(){i!==null&&window.cancelAnimationFrame(i),i=null,H&&U&&(H.style.position=$(U)?`fixed`:`absolute`,J(H,U.getBoundingClientRect())),Ve()}function o(){i===null&&W&&(i=window.requestAnimationFrame(a))}function s(e){H&&U&&(e.target!==document&&e.target!==window||$(U))&&J(H,U.getBoundingClientRect()),i===null?Ve(e.target===document||e.target===window):a()}function c(){Ve()}function l(t){if(t.key!==`Escape`||t.defaultPrevented||t.isComposing||V||!W||t.target instanceof Element&&t.target.closest(`[role=\"dialog\"], dialog, [role=\"menu\"]`))return;let n=W;window.setTimeout(()=>{t.defaultPrevented||V||W!==n||Y(e,{type:`replica:canvas:conversation-dismiss-requested`,nonce:n.nonce})},0)}window.addEventListener(`message`,He),window.addEventListener(`scroll`,s,{capture:!0,passive:!0}),window.addEventListener(`resize`,c),window.addEventListener(`keydown`,l);let u=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${B}], [data-replica-controls-bridge]`)))&&o()});u.observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let d=typeof ResizeObserver==`function`?new ResizeObserver(o):null;d?.observe(document.documentElement),We[Ue]=()=>{window.removeEventListener(`message`,He),window.removeEventListener(`scroll`,s,!0),window.removeEventListener(`resize`,c),window.removeEventListener(`keydown`,l),u.disconnect(),d?.disconnect(),i!==null&&window.cancelAnimationFrame(i),W=null,Se=``,G.clear(),r(),X(),H?.remove(),H=null,U=null}}function Ke(e,t=`canvas`,n){if(t===`canvas`){if(!/^http:\\/\\/127\\.0\\.0\\.1:\\d+$/.test(e))throw Error(`Invalid Replica canvas parent.`)}else{let t=URL.parse(e);if(!t||t.origin!==e||t.pathname!==`/`||t.search||t.hash||![`http:`,`https:`].includes(t.protocol))throw Error(`Invalid Replica Hub parent.`)}Ge(e,n)}function qe(e,t){Ke(e,`hosted`,t)}return e.installHostedBridge=qe,e})({});" diff --git a/hub/server/routes/build-preview/path/get/index.test.ts b/hub/server/routes/build-preview/path/get/index.test.ts index c400d2997..f94e27371 100644 --- a/hub/server/routes/build-preview/path/get/index.test.ts +++ b/hub/server/routes/build-preview/path/get/index.test.ts @@ -9,8 +9,11 @@ import { } from "node:http" import type { AddressInfo } from "node:net" import { join, resolve } from "node:path" +import { runInNewContext } from "node:vm" +import { JSDOM } from "jsdom" import { describe, expect, it, onTestFinished, vi } from "vitest" +import { hostedPreviewBridgeSource } from "../../../../assets/hosted-preview-bridge" import { createApp } from "../../../../create-app" import type { ArtifactStorage } from "../../../../domains/artifacts/create-artifact-storage/types" import { reserveBuildPreviewBytes } from "../../../../domains/build-preview/reserve-build-preview-bytes" @@ -508,6 +511,112 @@ describe("get()", () => { expect((await request(origin, "/previews/route", { accept: "text/html" })).status).toBe(404) }) + it.each(["public", "private"])( + "boots ready Controls from the %s Build root on a canonical-looking deep route", + async (delivery) => { + const { origin, mountPath, preview, target, save, findPathTargets } = await createFixture( + undefined, + { publicSharing: true }, + ) + preview.bridgeSource = hostedPreviewBridgeSource + save("dist/index.html", "Prototype details") + save( + "dist/controls.replica.json", + JSON.stringify({ + version: 1, + scope: "hostedPage", + controls: [ + { + id: "title", + label: "Title", + type: "text", + default: "Build title", + binding: { type: "query", key: "title", mode: "in-place" }, + }, + ], + }), + ) + const share = createSharePreviewSession( + { + buildId: target.buildId, + shareLinkId: randomUUID(), + expiresAt: new Date(Date.now() + 60_000), + }, + preview.encryptionKey, + ) + const headers: Record = + delivery === "public" + ? { + host: `${target.buildId}.preview.localhost:${new URL(origin).port}`, + cookie: `replica_share_preview=${encodeURIComponent(share)}`, + accept: "text/html", + } + : { cookie: "hub_session=member-session", accept: "text/html" } + const pathname = `${mountPath}/details` + const page = await request(origin, pathname, headers) + expect(page.status).toBe(200) + expect(page.body.toString()).toContain("Prototype details") + const dom = new JSDOM(page.body.toString(), { + url: `${origin}${pathname}`, + runScripts: "outside-only", + pretendToBeVisual: true, + }) + onTestFinished(() => dom.window.close()) + const frame = dom.window + frame.TextEncoder = TextEncoder + frame.TextDecoder = TextDecoder + frame.structuredClone = (value: T): T => frame.JSON.parse(frame.JSON.stringify(value)) as T + const readControls = vi.fn(async (path: string) => { + const response = await request(origin, path, headers) + return new Response(new Uint8Array(response.body), { + status: response.status, + headers: { "content-type": String(response.headers["content-type"]) }, + }) + }) + frame.fetch = readControls + const post = vi.spyOn(frame.parent, "postMessage").mockImplementation(() => {}) + const script = frame.document.querySelector("script[src]")! + const bootstrap = await request(origin, script.getAttribute("src")!, headers) + expect(bootstrap.status).toBe(200) + + frame.eval(bootstrap.body.toString()) + frame.dispatchEvent( + new frame.MessageEvent("message", { + source: frame.parent, + origin, + data: { + protocol: "replica:controls", + version: 1, + epoch: "hosted-epoch", + requestId: "hello", + type: "hello", + }, + }), + ) + + await vi.waitFor(() => + expect(post.mock.calls.at(-1)?.[0]).toMatchObject({ + type: "reply", + state: { + status: "ready", + runtimeAvailable: true, + scopes: [ + { + declaration: { scope: "hostedPage" }, + snapshot: { values: { title: "Build title" } }, + }, + ], + }, + }), + ) + expect(readControls).toHaveBeenCalledExactlyOnceWith( + `${delivery === "public" ? "/" : `${mountPath}/`}controls.replica.json`, + { credentials: "same-origin", redirect: "error" }, + ) + if (delivery === "public") expect(findPathTargets).not.toHaveBeenCalled() + }, + ) + it("denies the bridge when the same Build becomes a template during authorization", async () => { const { origin, mountPath, preview, target, findPathTargets, findArtifact, storage } = await createFixture() @@ -572,7 +681,10 @@ describe("get()", () => { ) it("serves the hosted bridge for an encoded reserved path instead of a stored shadow", async () => { - const { origin, mountPath, save, findArtifact, storage } = await createFixture() + const { origin, mountPath, preview, save, findArtifact, storage } = await createFixture() + preview.bridgeSource = + "globalThis.ReplicaHostedPreviewBridge={installHostedBridge:globalThis.installHostedBridge}" + const installHostedBridge = vi.fn() save("dist/__replica/bridge/v1.js", "globalThis.shadowedBridge = true") const read = vi.spyOn(storage, "read") @@ -582,6 +694,8 @@ describe("get()", () => { expect(canonical.status).toBe(200) expect(encoded.status).toBe(200) expect(encoded.body).toEqual(canonical.body) + runInNewContext(canonical.body.toString(), { installHostedBridge }) + expect(installHostedBridge).toHaveBeenCalledExactlyOnceWith(origin, `${mountPath}/`) expect(findArtifact).not.toHaveBeenCalled() expect(read).not.toHaveBeenCalled() }) diff --git a/hub/server/routes/build-preview/path/get/index.ts b/hub/server/routes/build-preview/path/get/index.ts index 16cc29723..35f8cba52 100644 --- a/hub/server/routes/build-preview/path/get/index.ts +++ b/hub/server/routes/build-preview/path/get/index.ts @@ -103,7 +103,7 @@ export function get( const review = (preview.reviewBridgeSource ?? "") .replaceAll('"__REPLICA_HUB_ORIGIN__"', JSON.stringify(preview.applicationOrigin)) .replaceAll('"__REPLICA_REVIEW_ENABLED__"', JSON.stringify(String(!target.template))) - const source = `${review}\n${preview.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge(${JSON.stringify(preview.applicationOrigin)});` + const source = `${review}\n${preview.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge(${JSON.stringify(preview.applicationOrigin)},${JSON.stringify(mountPath)});` response.type("text/javascript") response.setHeader("Content-Length", Buffer.byteLength(source)) response.end(source) diff --git a/hub/server/routes/build-preview/serve/get/index.test.ts b/hub/server/routes/build-preview/serve/get/index.test.ts index bbb0cffd5..c6e8dc0d8 100644 --- a/hub/server/routes/build-preview/serve/get/index.test.ts +++ b/hub/server/routes/build-preview/serve/get/index.test.ts @@ -6,6 +6,7 @@ import { createServer, request as httpRequest, type IncomingHttpHeaders } from " import type { AddressInfo } from "node:net" import path from "node:path" import { Readable } from "node:stream" +import { runInNewContext } from "node:vm" import express, { type ErrorRequestHandler } from "express" import { describe, expect, it, onTestFinished, vi, type Mock } from "vitest" @@ -389,6 +390,9 @@ describe("get()", () => { it("disables review behavior in the public preview bridge", async () => { await withServeRoute( async ({ origin, buildId, shareCookie, dependencies, findArtifact, read }) => { + dependencies.bridgeSource = + "globalThis.ReplicaHostedPreviewBridge={installHostedBridge:globalThis.installHostedBridge}" + const installHostedBridge = vi.fn() const response = await request( origin, "/__replica/bridge/v1.js", @@ -398,9 +402,13 @@ describe("get()", () => { expect(response.status).toBe(200) expect(response.headers["content-type"]).toMatch(/^text\/javascript/) expect(response.headers["cache-control"]).toBe("private, no-store") - expect(response.body.toString()).toBe( - `globalThis.reviewBridge={origin:"https://hub.example.com",enabled:"false" !== "false"};\n${dependencies.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge("https://hub.example.com");`, - ) + const context = { installHostedBridge, reviewBridge: undefined } + runInNewContext(response.body.toString(), context) + expect(context.reviewBridge).toEqual({ + origin: "https://hub.example.com", + enabled: false, + }) + expect(installHostedBridge).toHaveBeenCalledExactlyOnceWith("https://hub.example.com", "/") expect(findArtifact).not.toHaveBeenCalled() expect(read).not.toHaveBeenCalled() }, diff --git a/hub/server/routes/build-preview/serve/get/index.ts b/hub/server/routes/build-preview/serve/get/index.ts index c02cab568..45081340c 100644 --- a/hub/server/routes/build-preview/serve/get/index.ts +++ b/hub/server/routes/build-preview/serve/get/index.ts @@ -64,7 +64,7 @@ export function get(dependencies: BuildPreviewRouteDependencies): RequestHandler const reviewSource = (dependencies.reviewBridgeSource ?? "") .replaceAll('"__REPLICA_HUB_ORIGIN__"', JSON.stringify(dependencies.applicationOrigin)) .replaceAll('"__REPLICA_REVIEW_ENABLED__"', JSON.stringify("false")) - const source = `${reviewSource}\n${dependencies.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge(${JSON.stringify(dependencies.applicationOrigin)});` + const source = `${reviewSource}\n${dependencies.bridgeSource};ReplicaHostedPreviewBridge.installHostedBridge(${JSON.stringify(dependencies.applicationOrigin)},"/");` response.setHeader("Cache-Control", "private, no-store") response.type("text/javascript").send(source) return diff --git a/hub/test/local-smoke/browser.js b/hub/test/local-smoke/browser.js index 47cd23758..3ac1c3b04 100644 --- a/hub/test/local-smoke/browser.js +++ b/hub/test/local-smoke/browser.js @@ -30,15 +30,10 @@ Object(async (page) => { const welcome = prototypes.getByRole("link", { name: "Welcome", exact: true }) const noBuild = prototypes.getByRole("link", { name: "No Build", exact: true }) await welcome.waitFor() - const screenshot = prototypes.getByRole("img", { name: "Welcome, Build 1", exact: true }) - await screenshot.scrollIntoViewIfNeeded() - const screenshotLoaded = await screenshot.evaluate(async (image) => { - await image.decode() - return image.naturalWidth === 1 && image.naturalHeight === 1 - }) - if (!screenshotLoaded) { - throw new Error("The gallery did not display the saved Welcome screenshot.") - } + const welcomeCard = prototypes.locator(".prototype-card").filter({ has: welcome }) + await welcomeCard.locator(".prototype-card__fallback").waitFor() + if (await welcomeCard.locator(".prototype-card__preview img").count()) + throw new Error("The local Welcome Build has no supported private screenshot URL.") const galleryNames = await prototypes.getByRole("link").allTextContents() await admin.getByRole("link", { name: "Edit prototype listings", exact: true }).click()